diff options
author | John Wiegley <johnw@newartisans.com> | 2010-06-22 20:56:35 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2010-06-22 20:56:35 -0400 |
commit | 266dee564fe19fccb03e0d3df1c933674868431d (patch) | |
tree | daf24d96086f4846b578d959a6ca4e372b428382 /src/xact.cc | |
parent | 1f3dba77565b976a61eca73084e51518acee1736 (diff) | |
download | fork-ledger-266dee564fe19fccb03e0d3df1c933674868431d.tar.gz fork-ledger-266dee564fe19fccb03e0d3df1c933674868431d.tar.bz2 fork-ledger-266dee564fe19fccb03e0d3df1c933674868431d.zip |
Price annotation no longer inject an implied cost
Consider the following transaction:
2010-06-22 Sample
Assets:Brokerage 10 AAPL {$30}
Assets:Brokerage
Previously, this would have been equivalent to:
2010-06-22 Sample
Assets:Brokerage 10 AAPL @ $30
Assets:Brokerage
However, this is not always what the user expects to happen. When @ is
not being used, the transaction should reflect a mere transfer of
commodities. This is now how it works, and thus the above transaction
is now equivalent to the following instead:
2010-06-22 Sample
Assets:Brokerage 10 AAPL {$30}
Assets:Brokerage -10 AAPL {$30}
Diffstat (limited to 'src/xact.cc')
-rw-r--r-- | src/xact.cc | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/src/xact.cc b/src/xact.cc index c60cffcd..35d61edd 100644 --- a/src/xact.cc +++ b/src/xact.cc @@ -124,27 +124,13 @@ bool xact_base_t::finalize() amount_t& p(post->cost ? *post->cost : post->amount); if (! p.is_null()) { DEBUG("xact.finalize", "post must balance = " << p.reduced()); - if (! post->cost && post->amount.has_annotation() && - post->amount.annotation().price) { - // If the amount has no cost, but is annotated with a per-unit - // price, use the price times the amount as the cost - post->cost = (*post->amount.annotation().price * - post->amount).unrounded(); - DEBUG("xact.finalize", - "annotation price = " << *post->amount.annotation().price); - DEBUG("xact.finalize", "amount = " << post->amount); - DEBUG("xact.finalize", "priced cost = " << *post->cost); - post->add_flags(POST_COST_CALCULATED); - add_or_set_value(balance, post->cost->rounded().reduced()); - } else { - // 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. - add_or_set_value(balance, p.keep_precision() ? - p.rounded().reduced() : p.reduced()); - } + // 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. + add_or_set_value(balance, p.keep_precision() ? + p.rounded().reduced() : p.reduced()); } else if (null_post) { throw_(std::logic_error, |