summaryrefslogtreecommitdiff
path: root/journal.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2007-04-19 20:31:46 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 03:38:28 -0400
commit0a6b5726ec3bf402a953ea8a03b98ecbf4b90b0c (patch)
tree0a2c2aca7100d045f491b03f0a5bda92378d3ef9 /journal.cc
parent176b3044e355398a0c31e0c42a3cd7b8a2e3f3e5 (diff)
downloadfork-ledger-0a6b5726ec3bf402a953ea8a03b98ecbf4b90b0c.tar.gz
fork-ledger-0a6b5726ec3bf402a953ea8a03b98ecbf4b90b0c.tar.bz2
fork-ledger-0a6b5726ec3bf402a953ea8a03b98ecbf4b90b0c.zip
Made the amount/balance/value interface a bit more rational; added
back a useless version of the register command (just to prove the command sequence); and added smart XML semantics to the XPath implementation so that nodes can be coerced to values.
Diffstat (limited to 'journal.cc')
-rw-r--r--journal.cc16
1 files changed, 7 insertions, 9 deletions
diff --git a/journal.cc b/journal.cc
index 0b9f3909..1bf31dd6 100644
--- a/journal.cc
+++ b/journal.cc
@@ -124,7 +124,7 @@ bool entry_base_t::finalize()
ann_comm(static_cast<annotated_commodity_t&>
((*x)->amount.commodity()));
if (ann_comm.price)
- balance += ann_comm.price * (*x)->amount - *((*x)->cost);
+ balance += ann_comm.price * (*x)->amount.number() - *((*x)->cost);
}
} else {
saw_null = true;
@@ -165,7 +165,7 @@ bool entry_base_t::finalize()
other_bal++;
amount_t per_unit_cost =
- amount_t((*other_bal).second / (*this_bal).second).unround();
+ amount_t((*other_bal).second / (*this_bal).second.number()).unround();
for (; x != transactions.end(); x++) {
if ((*x)->cost || ((*x)->flags & TRANSACTION_VIRTUAL) ||
@@ -180,11 +180,11 @@ bool entry_base_t::finalize()
if ((*x)->amount.commodity() &&
! (*x)->amount.commodity().annotated)
(*x)->amount.annotate_commodity
- (abs(per_unit_cost),
+ (per_unit_cost.abs(),
entry ? entry->actual_date() : ptime(),
entry ? entry->code : "");
- (*x)->cost = new amount_t(- (per_unit_cost * (*x)->amount));
+ (*x)->cost = new amount_t(- (per_unit_cost * (*x)->amount.number()));
balance += *(*x)->cost;
}
}
@@ -228,8 +228,7 @@ bool entry_base_t::finalize()
for (amounts_map::const_iterator i = bal->amounts.begin();
i != bal->amounts.end();
i++) {
- amount_t amt = (*i).second;
- amt.negate();
+ amount_t amt = (*i).second.negate();
if (first) {
(*x)->amount = amt;
@@ -248,8 +247,7 @@ bool entry_base_t::finalize()
// fall through...
case value_t::AMOUNT:
- (*x)->amount = *((amount_t *) balance.data);
- (*x)->amount.negate();
+ (*x)->amount = ((amount_t *) balance.data)->negate();
(*x)->flags |= TRANSACTION_CALCULATED;
balance += (*x)->amount;
@@ -552,7 +550,7 @@ bool journal_t::add_entry(entry_t * entry)
i++)
if ((*i)->cost && (*i)->amount)
(*i)->amount.commodity().add_price(entry->date(),
- *(*i)->cost / (*i)->amount);
+ *(*i)->cost / (*i)->amount.number());
return true;
}