summaryrefslogtreecommitdiff
path: root/src/pool.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2012-03-16 00:59:32 -0500
committerJohn Wiegley <johnw@newartisans.com>2012-03-16 01:00:20 -0500
commita49e33a8ce91e07ebcbbb99bd8f01108d578dcc0 (patch)
treeaf6d0756d1229566d9d70698c736b058212dcb1c /src/pool.cc
parent61e369b04b7d4a0240844de3a5d5346a729b937c (diff)
downloadfork-ledger-a49e33a8ce91e07ebcbbb99bd8f01108d578dcc0.tar.gz
fork-ledger-a49e33a8ce91e07ebcbbb99bd8f01108d578dcc0.tar.bz2
fork-ledger-a49e33a8ce91e07ebcbbb99bd8f01108d578dcc0.zip
Don't add price exchanges for a commodity itself
Fixes #703
Diffstat (limited to 'src/pool.cc')
-rw-r--r--src/pool.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/pool.cc b/src/pool.cc
index d5494352..5813c0f6 100644
--- a/src/pool.cc
+++ b/src/pool.cc
@@ -277,8 +277,10 @@ commodity_pool_t::exchange(const amount_t& amount,
if (! per_unit_cost.is_realzero() &&
(current_annotation == NULL ||
! (current_annotation->price &&
- current_annotation->has_flags(ANNOTATION_PRICE_FIXATED))))
+ current_annotation->has_flags(ANNOTATION_PRICE_FIXATED))) &&
+ commodity.referent() != per_unit_cost.commodity().referent()) {
exchange(commodity, per_unit_cost, moment ? *moment : CURRENT_TIME());
+ }
cost_breakdown_t breakdown;
breakdown.final_cost = ! is_per_unit ? cost : cost * amount.abs();