From 21722ae48442b1ed2a6f398b36b23ffb48cd2901 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Mon, 20 Feb 2006 00:04:04 +0000 Subject: (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. --- journal.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'journal.cc') 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; } -- cgit v1.2.3