Merged over fix to #205 from v2.6.1b, which deals with small commodity
rounding.
This commit is contained in:
parent
1bb29cdbb7
commit
5aef1add42
2 changed files with 11 additions and 8 deletions
|
|
@ -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;
|
||||
|
|
|
|||
16
entry.cc
16
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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue