From fb4fed00ba3dede4c649e21ce64cf29a8244c8bd Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sat, 11 Oct 2003 23:21:14 +0000 Subject: c --- ledger.cc | 45 ++++++--------------------------------------- 1 file changed, 6 insertions(+), 39 deletions(-) (limited to 'ledger.cc') diff --git a/ledger.cc b/ledger.cc index 1a6e0ae0..37623f5c 100644 --- a/ledger.cc +++ b/ledger.cc @@ -220,10 +220,10 @@ bool entry::finalize(bool do_compute) // transactions and create new virtual transactions for all that // apply. - for (book::virtual_map_iterator m = main_ledger->virtual_mapping.begin(); - m != main_ledger->virtual_mapping.end(); + for (book::virtual_map_iterator m = ledger->virtual_mapping.begin(); + m != ledger->virtual_mapping.end(); m++) { - std::list xacts; + std::list new_xacts; for (std::list::iterator x = xacts.begin(); x != xacts.end(); @@ -248,40 +248,7 @@ bool entry::finalize(bool do_compute) t->is_virtual = (*i)->is_virtual; t->must_balance = (*i)->must_balance; - // If there is already a virtual transaction for the - // account under consideration, and it's `must_balance' - // flag matches, then simply add this amount to that - // transaction. - - bool added = false; - - for (std::list::iterator y = xacts.begin(); - y != xacts.end(); - y++) { - if ((*y)->is_virtual && (*y)->acct == t->acct && - (*y)->must_balance == t->must_balance) { - (*y)->cost->credit(t->cost); - delete t; - added = true; - break; - } - } - - if (! added) - for (std::list::iterator y = xacts.begin(); - y != xacts.end(); - y++) { - if ((*y)->is_virtual && (*y)->acct == t->acct && - (*y)->must_balance == t->must_balance) { - (*y)->cost->credit(t->cost); - delete t; - added = true; - break; - } - } - - if (! added) - xacts.push_back(t); + new_xacts.push_back(t); } } @@ -290,8 +257,8 @@ bool entry::finalize(bool do_compute) // iteration above is screwed up if we try adding new // transactions during the traversal. - for (std::list::iterator x = xacts.begin(); - x != xacts.end(); + for (std::list::iterator x = new_xacts.begin(); + x != new_xacts.end(); x++) { xacts.push_back(*x); -- cgit v1.2.3