From 82e43fe125a9b2158976fe5a3afccfa85d7a7574 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sun, 20 Jun 2010 18:54:21 -0400 Subject: If fixated price commodities are mixed, show them For example, if a Ledger file contains transactions with the use of both EUR and EUR {=PRICE}, then regular reports will always show the {=PRICE}, disabling the by-name commodity merging that takes place. In brief, fixated and non-fixated commodities are now non-mergable. If a file contains all of one, or all of the other, they will still be merged, since these separate usages do not conflict the way that fixated and non-fixated together do. --- src/pool.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/pool.cc') diff --git a/src/pool.cc b/src/pool.cc index df20d179..20b585dd 100644 --- a/src/pool.cc +++ b/src/pool.cc @@ -172,12 +172,21 @@ commodity_pool_t::create(commodity_t& comm, const string& mapping_key) { assert(comm); + assert(! comm.has_annotation()); assert(details); assert(! mapping_key.empty()); std::auto_ptr commodity (new annotated_commodity_t(&comm, details)); + comm.add_flags(COMMODITY_SAW_ANNOTATED); + if (details.price) { + if (details.has_flags(ANNOTATION_PRICE_FIXATED)) + comm.add_flags(COMMODITY_SAW_ANN_PRICE_FIXATED); + else + comm.add_flags(COMMODITY_SAW_ANN_PRICE_FLOAT); + } + commodity->qualified_symbol = comm.symbol(); assert(! commodity->qualified_symbol->empty()); @@ -282,6 +291,9 @@ commodity_pool_t::exchange(const amount_t& amount, moment->date() : optional(), tag); annotation.add_flags(ANNOTATION_PRICE_CALCULATED); + if (current_annotation && + current_annotation->has_flags(ANNOTATION_PRICE_FIXATED)) + annotation.add_flags(ANNOTATION_PRICE_FIXATED); if (moment) annotation.add_flags(ANNOTATION_DATE_CALCULATED); if (tag) -- cgit v1.2.3