diff options
author | John Wiegley <johnw@newartisans.com> | 2012-03-10 02:27:33 -0600 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2012-03-10 02:27:33 -0600 |
commit | 080c1d9a2d0f3013a4d26879a3e98cfa62ef3e48 (patch) | |
tree | b95c15c1dc13925bcc4b3c11d98c06c50bba1bcc /src/amount.cc | |
parent | 50f202c4e8faecf7398fb21ba5b31768ec46c826 (diff) | |
download | fork-ledger-080c1d9a2d0f3013a4d26879a3e98cfa62ef3e48.tar.gz fork-ledger-080c1d9a2d0f3013a4d26879a3e98cfa62ef3e48.tar.bz2 fork-ledger-080c1d9a2d0f3013a4d26879a3e98cfa62ef3e48.zip |
Added syntactic sugar for lot pricing: {{$500.00}}
Diffstat (limited to 'src/amount.cc')
-rw-r--r-- | src/amount.cc | 12 |
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; |