summaryrefslogtreecommitdiff
path: root/src/amount.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/amount.cc')
-rw-r--r--src/amount.cc12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/amount.cc b/src/amount.cc
index d1aa1655..46eb5531 100644
--- a/src/amount.cc
+++ b/src/amount.cc
@@ -1065,10 +1065,6 @@ bool amount_t::parse(std::istream& in, const parse_flags_t& flags)
if (! commodity_)
commodity_ = commodity_pool_t::current_pool->create(symbol);
assert(commodity_);
-
- if (details)
- commodity_ =
- commodity_pool_t::current_pool->find_or_create(*commodity_, details);
}
// Quickly scan through and verify the correctness of the amount's use of
@@ -1204,6 +1200,14 @@ bool amount_t::parse(std::istream& in, const parse_flags_t& flags)
if (! flags.has_flags(PARSE_NO_REDUCE))
in_place_reduce(); // will not throw an exception
+ if (commodity_ && details) {
+ if (details.has_flags(ANNOTATION_PRICE_NOT_PER_UNIT)) {
+ assert(details.price);
+ *details.price /= this->abs();
+ }
+ set_commodity(*commodity_pool_t::current_pool->find_or_create(*commodity_, details));
+ }
+
VERIFY(valid());
return true;