(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.
This commit is contained in:
John Wiegley 2006-02-20 00:04:04 +00:00
parent 3df316446e
commit 945d315eba

View file

@ -72,13 +72,15 @@ bool entry_base_t::remove_transaction(transaction_t * xact)
return true; return true;
} }
value_t entry_balance;
bool entry_base_t::finalize() bool entry_base_t::finalize()
{ {
// Scan through and compute the total balance for the entry. This // Scan through and compute the total balance for the entry. This
// is used for auto-calculating the value of entries with no cost, // is used for auto-calculating the value of entries with no cost,
// and the per-unit price of unpriced commodities. // and the per-unit price of unpriced commodities.
value_t balance; value_t& balance = entry_balance;
bool no_amounts = true; bool no_amounts = true;
for (transactions_list::const_iterator x = transactions.begin(); for (transactions_list::const_iterator x = transactions.begin();
@ -453,8 +455,7 @@ bool journal_t::add_entry(entry_t * entry)
{ {
entry->journal = this; entry->journal = this;
if (! entry->finalize() || if (! run_hooks(entry_finalize_hooks, *entry) || ! entry->finalize()) {
! run_hooks(entry_finalize_hooks, *entry)) {
entry->journal = NULL; entry->journal = NULL;
return false; return false;
} }