If a posting's price has an annotation tag, save it
This commit is contained in:
parent
470730c92d
commit
6420390d36
1 changed files with 30 additions and 22 deletions
14
src/xact.cc
14
src/xact.cc
|
|
@ -281,8 +281,8 @@ bool xact_base_t::finalize()
|
||||||
(post->amount, *post->cost, false,
|
(post->amount, *post->cost, false,
|
||||||
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() && post->amount.annotation().price) {
|
||||||
breakdown.basis_cost.commodity() == breakdown.final_cost.commodity()) {
|
if (breakdown.basis_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) {
|
||||||
DEBUG("xact.finalize", "gain_loss = " << gain_loss);
|
DEBUG("xact.finalize", "gain_loss = " << gain_loss);
|
||||||
gain_loss.in_place_round();
|
gain_loss.in_place_round();
|
||||||
|
|
@ -306,9 +306,17 @@ bool xact_base_t::finalize()
|
||||||
add_post(p);
|
add_post(p);
|
||||||
DEBUG("xact.finalize", "added gain_loss, balance = " << balance);
|
DEBUG("xact.finalize", "added gain_loss, balance = " << balance);
|
||||||
} else {
|
} else {
|
||||||
DEBUG("xact.finalize", "gain_loss would have display as zero");
|
DEBUG("xact.finalize", "gain_loss would have displayed as zero");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (post->amount.has_annotation()) {
|
||||||
|
if (breakdown.amount.has_annotation())
|
||||||
|
breakdown.amount.annotation().tag = post->amount.annotation().tag;
|
||||||
|
else
|
||||||
|
breakdown.amount.annotate
|
||||||
|
(annotation_t(none, none, post->amount.annotation().tag));
|
||||||
|
}
|
||||||
post->amount = breakdown.amount;
|
post->amount = breakdown.amount;
|
||||||
DEBUG("xact.finalize", "added breakdown, balance = " << balance);
|
DEBUG("xact.finalize", "added breakdown, balance = " << balance);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue