summaryrefslogtreecommitdiff
path: root/journal.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2004-08-29 04:31:59 -0400
committerJohn Wiegley <johnw@newartisans.com>2004-08-29 04:31:59 -0400
commit2d62f7b633bdaa39c650bb67425514cf1e66a4dd (patch)
treeffe42356e5e83f2cbc2cce74a8566ea1ac738e8b /journal.cc
parent032afa5657bd600476cde256b6d7db84fde7d038 (diff)
downloadfork-ledger-2d62f7b633bdaa39c650bb67425514cf1e66a4dd.tar.gz
fork-ledger-2d62f7b633bdaa39c650bb67425514cf1e66a4dd.tar.bz2
fork-ledger-2d62f7b633bdaa39c650bb67425514cf1e66a4dd.zip
redid the way amount_t::commodity is handled; no more direct access
Diffstat (limited to 'journal.cc')
-rw-r--r--journal.cc19
1 files changed, 8 insertions, 11 deletions
diff --git a/journal.cc b/journal.cc
index 30d258f1..2d8cc4bb 100644
--- a/journal.cc
+++ b/journal.cc
@@ -246,12 +246,9 @@ bool journal_t::add_entry(entry_t * entry)
i != entry->transactions.end();
i++) {
(*i)->account->add_transaction(*i);
-
- if ((*i)->cost) {
- assert((*i)->cost->commodity);
- (*i)->amount.commodity->add_price(entry->date,
- *(*i)->cost / (*i)->amount);
- }
+ if ((*i)->cost)
+ (*i)->amount.commodity().add_price(entry->date,
+ *(*i)->cost / (*i)->amount);
}
return true;
@@ -330,8 +327,8 @@ entry_t * journal_t::derive_entry(strings_list::iterator i,
first = xact = new transaction_t(m_xact->account, amt);
added->add_transaction(xact);
- if (xact->amount.commodity->symbol.empty())
- xact->amount.commodity = m_xact->amount.commodity;
+ if (xact->amount.commodity().symbol.empty())
+ xact->amount.set_commodity(m_xact->amount.commodity());
m_xact = matching->transactions.back();
@@ -355,7 +352,7 @@ entry_t * journal_t::derive_entry(strings_list::iterator i,
x++) {
if (acct_regex.match((*x)->account->fullname())) {
acct = (*x)->account;
- cmdty = (*x)->amount.commodity;
+ cmdty = &(*x)->amount.commodity();
break;
}
}
@@ -379,8 +376,8 @@ entry_t * journal_t::derive_entry(strings_list::iterator i,
transaction_t * xact = new transaction_t(acct, amt);
added->add_transaction(xact);
- if (! xact->amount.commodity)
- xact->amount.commodity = cmdty;
+ if (! xact->amount.commodity())
+ xact->amount.set_commodity(*cmdty);
}
if (i != end && std::string(*i++) == "-from" && i != end) {