From 5aef1add426ca00daee5af38b27c52d7e49e3491 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Mon, 28 Jul 2008 02:16:58 -0400 Subject: Merged over fix to #205 from v2.6.1b, which deals with small commodity rounding. --- amount.cc | 3 ++- entry.cc | 16 +++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/amount.cc b/amount.cc index d96913d3..1749013e 100644 --- a/amount.cc +++ b/amount.cc @@ -703,7 +703,8 @@ bool amount_t::is_zero() const throw_(amount_error, "Cannot determine if an uninitialized amount is zero"); if (has_commodity()) { - if (quantity->prec <= commodity().precision()) + if (quantity->prec <= commodity().precision() || + quantity->has_flags(BIGINT_KEEP_PREC)) return is_realzero(); else return round(commodity().precision()).sign() == 0; diff --git a/entry.cc b/entry.cc index 2feaa761..81dfc7df 100644 --- a/entry.cc +++ b/entry.cc @@ -311,14 +311,16 @@ bool entry_base_t::finalize() // (item-position-end-line (entry-position entry)) // (format-value balance :width 20))) - if (! balance.is_null() && ! balance.is_zero()) { - error * err = - new balance_error("Entry does not balance", - new entry_context(*this, "While balancing entry:")); + if (! balance.is_null()) { balance.round(); - err->context.push_front - (new value_context(balance, "Unbalanced remainder is:")); - throw err; + if (! balance.is_zero()) { + error * err = + new balance_error("Entry does not balance", + new entry_context(*this, "While balancing entry:")); + err->context.push_front + (new value_context(balance, "Unbalanced remainder is:")); + throw err; + } } return true; -- cgit v1.2.3