Don't allow the "keep precision" flag to propagate into the balance amount.
This commit is contained in:
parent
165300ea84
commit
3dbdeb2917
1 changed files with 12 additions and 1 deletions
13
src/entry.cc
13
src/entry.cc
|
|
@ -105,7 +105,18 @@ bool entry_base_t::finalize()
|
|||
amount_t& p(xact->cost ? *xact->cost : xact->amount);
|
||||
DEBUG("entry.finalize", "xact must balance = " << p);
|
||||
if (! p.is_null()) {
|
||||
add_or_set_value(balance, p);
|
||||
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);
|
||||
} else {
|
||||
add_or_set_value(balance, p);
|
||||
}
|
||||
} else {
|
||||
if (null_xact)
|
||||
throw_(std::logic_error,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue