summaryrefslogtreecommitdiff
path: root/journal.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2006-03-04 17:13:45 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 02:41:29 -0400
commit7acc1306d985fb532ee429121fac0e1692285503 (patch)
tree6ff877c57daf4fdeb048147dad6f17811cdeca41 /journal.cc
parent11498f48070a9e96826afb316c684fed8c59397b (diff)
downloadfork-ledger-7acc1306d985fb532ee429121fac0e1692285503.tar.gz
fork-ledger-7acc1306d985fb532ee429121fac0e1692285503.tar.bz2
fork-ledger-7acc1306d985fb532ee429121fac0e1692285503.zip
*** empty log message ***
Diffstat (limited to 'journal.cc')
-rw-r--r--journal.cc8
1 files changed, 5 insertions, 3 deletions
diff --git a/journal.cc b/journal.cc
index 4e03ae1a..7c1aeac5 100644
--- a/journal.cc
+++ b/journal.cc
@@ -18,7 +18,6 @@ transaction_t::~transaction_t()
DEBUG_PRINT("ledger.memory.dtors", "dtor transaction_t");
if (cost) delete cost;
if (amount_expr) amount_expr->release();
- if (cost_expr) cost_expr->release();
}
std::time_t transaction_t::actual_date() const
@@ -130,8 +129,8 @@ bool entry_base_t::finalize()
nxact->flags |= TRANSACTION_CALCULATED;
}
- // If one transaction of a two-line transaction is of a different
- // commodity than the others, and it has no per-unit price,
+ // If the first transaction of a two-transaction entry is of a
+ // different commodity than the other, and it has no per-unit price,
// determine its price by dividing the unit count into the value of
// the balance. This is done for the last eligible commodity.
@@ -158,6 +157,9 @@ bool entry_base_t::finalize()
balance -= (*x)->amount;
entry_t * entry = dynamic_cast<entry_t *>(this);
+ if ((*x)->amount.commodity().annotated)
+ throw error("Cannot self-balance an annotated commodity");
+
(*x)->amount.annotate_commodity(abs(per_unit_cost),
entry ? entry->actual_date() : 0,
entry ? entry->code : "");