Fixed minor rounding issue with priced commodities
This commit is contained in:
parent
659741ac47
commit
158b9c92fd
1 changed files with 6 additions and 4 deletions
10
src/xact.cc
10
src/xact.cc
|
|
@ -275,11 +275,11 @@ bool xact_base_t::finalize()
|
||||||
datetime_t(date(), time_duration(0, 0, 0, 0)));
|
datetime_t(date(), time_duration(0, 0, 0, 0)));
|
||||||
|
|
||||||
if (post->amount.has_annotation() &&
|
if (post->amount.has_annotation() &&
|
||||||
breakdown.basis_cost.commodity() ==
|
breakdown.basis_cost.commodity() == breakdown.final_cost.commodity()) {
|
||||||
breakdown.final_cost.commodity()) {
|
if (amount_t gain_loss = breakdown.basis_cost - breakdown.final_cost) {
|
||||||
if (amount_t gain_loss = (breakdown.basis_cost -
|
|
||||||
breakdown.final_cost).rounded()) {
|
|
||||||
DEBUG("xact.finalize", "gain_loss = " << gain_loss);
|
DEBUG("xact.finalize", "gain_loss = " << gain_loss);
|
||||||
|
gain_loss.in_place_round();
|
||||||
|
DEBUG("xact.finalize", "gain_loss rounds to = " << gain_loss);
|
||||||
|
|
||||||
add_or_set_value(balance, gain_loss.reduced());
|
add_or_set_value(balance, gain_loss.reduced());
|
||||||
|
|
||||||
|
|
@ -293,6 +293,8 @@ bool xact_base_t::finalize()
|
||||||
p->set_state(post->state());
|
p->set_state(post->state());
|
||||||
add_post(p);
|
add_post(p);
|
||||||
DEBUG("xact.finalize", "added gain_loss, balance = " << balance);
|
DEBUG("xact.finalize", "added gain_loss, balance = " << balance);
|
||||||
|
} else {
|
||||||
|
DEBUG("xact.finalize", "gain_loss would have display as zero");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
post->amount = breakdown.amount;
|
post->amount = breakdown.amount;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue