From cb15e764eb1ba9064ef2c1f750735d47696d3fd0 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Fri, 14 Jan 2005 23:20:24 +0000 Subject: (derive_new_entry): Simplified some code. (derive_new_entry): If no commodity was specified for an amount, and none was figured out from previous transactions, then use the default commodity (which is specified using "D " in the ledger file). --- derive.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'derive.cc') diff --git a/derive.cc b/derive.cc index 26569041..abec5f32 100644 --- a/derive.cc +++ b/derive.cc @@ -44,7 +44,7 @@ entry_t * derive_new_entry(journal_t& journal, first = xact = new transaction_t(m_xact->account, amount_t(*i++)); added->add_transaction(xact); - if (xact->amount.commodity().symbol.empty()) + if (! xact->amount.commodity()) xact->amount.set_commodity(m_xact->amount.commodity()); m_xact = matching->transactions.back(); @@ -91,8 +91,12 @@ entry_t * derive_new_entry(journal_t& journal, } transaction_t * xact = new transaction_t(acct, amount_t(*i++)); - if (cmdty && ! xact->amount.commodity()) - xact->amount.set_commodity(*cmdty); + if (! xact->amount.commodity()) { + if (cmdty) + xact->amount.set_commodity(*cmdty); + else if (commodity_t::default_commodity) + xact->amount.set_commodity(*commodity_t::default_commodity); + } added->add_transaction(xact); } -- cgit v1.2.3