diff options
author | John Wiegley <johnw@newartisans.com> | 2008-07-19 21:36:34 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-07-19 21:36:34 -0400 |
commit | d568319495a0695582797de0be4b85e1e06e73b2 (patch) | |
tree | cda7e94b2da52b32006c6a83b335d72ff2ccc165 /derive.cc | |
parent | 150abce0dbd11863e4a8309fd306a4c2667501f8 (diff) | |
parent | 2aeee0bb64b56959ebcf86165c0b31630e0f92ac (diff) | |
download | fork-ledger-d568319495a0695582797de0be4b85e1e06e73b2.tar.gz fork-ledger-d568319495a0695582797de0be4b85e1e06e73b2.tar.bz2 fork-ledger-d568319495a0695582797de0be4b85e1e06e73b2.zip |
Merged in bug fixes from master (done for 2.6.1b)
Diffstat (limited to 'derive.cc')
-rw-r--r-- | derive.cc | 31 |
1 files changed, 23 insertions, 8 deletions
@@ -112,6 +112,8 @@ entry_t * derive_new_entry(journal_t& journal, } } else { + account_t * draw_acct = NULL; + while (i != end) { string& re_pat(*i++); account_t * acct = NULL; @@ -135,11 +137,6 @@ entry_t * derive_new_entry(journal_t& journal, } found: - if (! acct) - acct = journal.find_account_re(re_pat); - if (! acct) - acct = journal.find_account(re_pat); - transaction_t * xact; if (i == end) { if (amt) @@ -147,7 +144,22 @@ entry_t * derive_new_entry(journal_t& journal, else xact = new transaction_t(acct); } else { - xact = new transaction_t(acct, amount_t(*i++)); + amount_t amount(*i++); + + strings_list::iterator x = i; + if (i != end && ++x == end) { + draw_acct = journal.find_account_re(*i); + if (! draw_acct) + draw_acct = journal.find_account(*i); + i++; + } + + if (! acct) + acct = journal.find_account_re(re_pat); + if (! acct) + acct = journal.find_account(re_pat); + + xact = new transaction_t(acct, amount); if (! xact->amount.commodity()) { if (amt) xact->amount.set_commodity(amt->commodity()); @@ -158,8 +170,11 @@ entry_t * derive_new_entry(journal_t& journal, added->add_transaction(xact); } - assert(matching->transactions.back()->account); - if (account_t * draw_acct = matching->transactions.back()->account) + if (! draw_acct) { + assert(matching->transactions.back()->account); + draw_acct = matching->transactions.back()->account; + } + if (draw_acct) added->add_transaction(new transaction_t(draw_acct)); } |