summaryrefslogtreecommitdiff
path: root/journal.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2006-02-20 00:04:04 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 02:41:24 -0400
commit21722ae48442b1ed2a6f398b36b23ffb48cd2901 (patch)
tree1092959b2522b98bc2223050322eb2667bd97048 /journal.cc
parent7154896d20abfb8583344bb2cad3cde473919b2e (diff)
downloadfork-ledger-21722ae48442b1ed2a6f398b36b23ffb48cd2901.tar.gz
fork-ledger-21722ae48442b1ed2a6f398b36b23ffb48cd2901.tar.bz2
fork-ledger-21722ae48442b1ed2a6f398b36b23ffb48cd2901.zip
(add_entry): Run `entry_finalize_hooks' before finalizing an entry.
This allows automated entries to add their transactions to the current matching entry before that entry's balance is checked.
Diffstat (limited to 'journal.cc')
-rw-r--r--journal.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/journal.cc b/journal.cc
index 6e0f9f1d..9e073388 100644
--- a/journal.cc
+++ b/journal.cc
@@ -72,13 +72,15 @@ bool entry_base_t::remove_transaction(transaction_t * xact)
return true;
}
+value_t entry_balance;
+
bool entry_base_t::finalize()
{
// Scan through and compute the total balance for the entry. This
// is used for auto-calculating the value of entries with no cost,
// and the per-unit price of unpriced commodities.
- value_t balance;
+ value_t& balance = entry_balance;
bool no_amounts = true;
for (transactions_list::const_iterator x = transactions.begin();
@@ -453,8 +455,7 @@ bool journal_t::add_entry(entry_t * entry)
{
entry->journal = this;
- if (! entry->finalize() ||
- ! run_hooks(entry_finalize_hooks, *entry)) {
+ if (! run_hooks(entry_finalize_hooks, *entry) || ! entry->finalize()) {
entry->journal = NULL;
return false;
}