summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-01-31 05:44:02 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-01-31 05:44:02 -0400
commit6b5d006575b185dc248f4dfa788fa791b84a6854 (patch)
tree179038d573b52c20a61e5ee95dff642b293b93fe /src
parent6b81bb80057ef1391fe7f6d1d2e134f8289331d0 (diff)
downloadfork-ledger-6b5d006575b185dc248f4dfa788fa791b84a6854.tar.gz
fork-ledger-6b5d006575b185dc248f4dfa788fa791b84a6854.tar.bz2
fork-ledger-6b5d006575b185dc248f4dfa788fa791b84a6854.zip
Fixed some entry balancing problems relating to the new rational code.
Diffstat (limited to 'src')
-rw-r--r--src/entry.cc9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/entry.cc b/src/entry.cc
index d1aa1234..e3f60f75 100644
--- a/src/entry.cc
+++ b/src/entry.cc
@@ -106,14 +106,12 @@ bool entry_base_t::finalize()
DEBUG("entry.finalize", "xact must balance = " << p);
if (! p.is_null()) {
if (p.keep_precision()) {
- amount_t temp(p);
// If the amount was a cost, it very likely has the "keep_precision"
// flag set, meaning commodity display precision is ignored when
// displaying the amount. We never want this set for the balance,
// so we must clear the flag in a temporary to avoid it propagating
// into the balance.
- temp.set_keep_precision(false);
- add_or_set_value(balance, temp);
+ add_or_set_value(balance, p.rounded());
} else {
add_or_set_value(balance, p);
}
@@ -218,7 +216,8 @@ bool entry_base_t::finalize()
commodity_t::exchange(xact->amount, *xact->cost);
if (xact->amount.is_annotated())
- add_or_set_value(balance, breakdown.basis_cost - breakdown.final_cost);
+ add_or_set_value(balance, (breakdown.basis_cost -
+ breakdown.final_cost).rounded());
else
xact->amount = breakdown.amount;
}
@@ -231,7 +230,7 @@ bool entry_base_t::finalize()
add_error_context(entry_context(*this));
#endif
add_error_context("Unbalanced remainder is: ");
- add_error_context(value_context(balance.unrounded()));
+ add_error_context(value_context(balance));
throw_(balance_error, "Entry does not balance");
}