summaryrefslogtreecommitdiff
path: root/src/pool.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2010-06-20 18:54:21 -0400
committerJohn Wiegley <johnw@newartisans.com>2010-06-20 20:29:53 -0400
commit82e43fe125a9b2158976fe5a3afccfa85d7a7574 (patch)
tree48d6b91a60e2a0d1f8f1f9ceb644c51568e35bb7 /src/pool.cc
parent6420390d36ee2f5fe074c48eb030b32fe63d6af5 (diff)
downloadfork-ledger-82e43fe125a9b2158976fe5a3afccfa85d7a7574.tar.gz
fork-ledger-82e43fe125a9b2158976fe5a3afccfa85d7a7574.tar.bz2
fork-ledger-82e43fe125a9b2158976fe5a3afccfa85d7a7574.zip
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.
Diffstat (limited to 'src/pool.cc')
-rw-r--r--src/pool.cc12
1 files changed, 12 insertions, 0 deletions
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_t> 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<date_t>(), 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)