From a49e33a8ce91e07ebcbbb99bd8f01108d578dcc0 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Fri, 16 Mar 2012 00:59:32 -0500 Subject: [PATCH] Don't add price exchanges for a commodity itself Fixes #703 --- 95350193.test | 6 ++++++ src/pool.cc | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 95350193.test diff --git a/95350193.test b/95350193.test new file mode 100644 index 00000000..dadb39cf --- /dev/null +++ b/95350193.test @@ -0,0 +1,6 @@ +2011-11-08 * Test + Assets:Voucher:Amazon 137.87 GBP (48H5) + Assets:Cash -137.87 GBP + +test pricedb +end test 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();