− let directives = [Directive::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!(-010000.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!(9000.00),
− commodity: Commodity::try_from("EUR").unwrap(),
− }),
− cost: None,
− price: None,
− },
− Posting {
− flag: None,
− account: Account::try_from("Expenses:Banking:Fees").unwrap(),
− amount: None,
− cost: None,
− price: None,
− },
− ],
− })];
+ let directives = [Directive::from(
+ Transaction::on(date!(2022 - 03 - 07)).tap_mut(|transaction| {
+ let commodity = Commodity::try_from("EUR").unwrap();
+ transaction
+ .build_posting(Account::try_from("Assets:Checking").unwrap(), |posting| {
+ posting.set_amount(Amount::new(dec!(-10000.00), commodity));
+ })
+ .build_posting(Account::try_from("Assets:Wallet").unwrap(), |posting| {
+ posting.set_amount(Amount::new(dec!(9000.00), commodity));
+ })
+ .build_posting(Account::try_from("Expenses:Banking:Fees").unwrap(), |_| {});
+ }),
+ )];