use beancount_pretty_printer::PrettyPrinter;
use beancount_types::Account;
use beancount_types::Amount;
use beancount_types::Commodity;
use beancount_types::Posting;
use beancount_types::Transaction;
use beancount_types::TransactionFlag::Complete;
use rust_decimal_macros::dec;
#[test]
fn pretty_printed_transaction() {
    let mut buffer = Vec::with_capacity(1_024);
    let mut printer = PrettyPrinter::<_, 2, 2, 100>::unbuffered(&mut buffer);
    printer
        .print_transaction(&Transaction {
            date: time::macros::date!(2022 - 03 - 07),
            flag: Complete,
            payee: None,
            narration: None,
            postings: vec![
                Posting {
                    flag: None,
                    account: Account::try_from("Assets:Checking").unwrap(),
                    amount: Some(Amount {
                        amount: dec!(-100.00),
                        commodity: Commodity::try_from("EUR").unwrap(),
                    }),
                    cost: None,
                    price: None,
                },
                Posting {
                    flag: None,
                    account: Account::try_from("Assets:Wallet").unwrap(),
                    amount: Some(Amount {
                        amount: dec!(100.00),
                        commodity: Commodity::try_from("EUR").unwrap(),
                    }),
                    cost: None,
                    price: None,
                },
            ],
        })
        .unwrap();
    let formatted = String::from_utf8(buffer).unwrap();
    insta::assert_display_snapshot!(formatted)
}