From 2ef1934bb0dbcd08dfe8d4dc68bfd1509c8f51ce Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Fri, 26 Jun 2009 17:09:34 +0100 Subject: Restored --price option, added baseline test This option reports only in terms of the annotated price of the commodities involved, otherwise it reports the amounts themselves. It can be used in conjunction with other reports, as it applies to the displayed amounts, not the actual amounts being calculated. --- src/amount.cc | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/amount.cc') diff --git a/src/amount.cc b/src/amount.cc index 0b798686..2434f110 100644 --- a/src/amount.cc +++ b/src/amount.cc @@ -576,6 +576,17 @@ amount_t::value(const bool primary_only, return none; } +amount_t amount_t::price() const +{ + if (is_annotated() && annotation().price) { + amount_t temp(*annotation().price); + temp *= *this; + DEBUG("amount.price", "Returning price of " << *this << " = " << temp); + return temp; + } + return *this; +} + int amount_t::sign() const { @@ -784,8 +795,9 @@ bool amount_t::is_annotated() const throw_(amount_error, _("Cannot determine if an uninitialized amount's commodity is annotated")); - assert(! commodity().annotated || as_annotated_commodity(commodity()).details); - return commodity().annotated; + assert(! has_commodity() || ! commodity().annotated || + as_annotated_commodity(commodity()).details); + return has_commodity() && commodity().annotated; } annotation_t& amount_t::annotation() -- cgit v1.2.3