diff options
author | John Wiegley <johnw@newartisans.com> | 2005-01-14 23:20:24 +0000 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-04-13 02:40:49 -0400 |
commit | cb15e764eb1ba9064ef2c1f750735d47696d3fd0 (patch) | |
tree | b9084afc04f7e4386cef3882ba303f04520f99df /derive.cc | |
parent | d142018bcdab7351e96dd64a6fc52af71ab2c69c (diff) | |
download | fork-ledger-cb15e764eb1ba9064ef2c1f750735d47696d3fd0.tar.gz fork-ledger-cb15e764eb1ba9064ef2c1f750735d47696d3fd0.tar.bz2 fork-ledger-cb15e764eb1ba9064ef2c1f750735d47696d3fd0.zip |
(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 <SYMBOL>" in the ledger file).
Diffstat (limited to 'derive.cc')
-rw-r--r-- | derive.cc | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -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); } |