diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/amount.cc | 4 | ||||
-rw-r--r-- | src/commodity.cc | 11 | ||||
-rw-r--r-- | src/commodity.h | 5 |
3 files changed, 17 insertions, 3 deletions
diff --git a/src/amount.cc b/src/amount.cc index cc568bb1..f6b3edfb 100644 --- a/src/amount.cc +++ b/src/amount.cc @@ -546,6 +546,10 @@ amount_t::value(const bool primary_only, if (in_terms_of && commodity() == *in_terms_of) { return *this; } + else if (is_annotated() && annotation().price && + annotation().has_flags(ANNOTATION_PRICE_FIXATED)) { + return (*annotation().price * number()).rounded(); + } else if (optional<price_point_t> point = commodity().find_price(in_terms_of, moment)) { return (point->price * number()).rounded(); diff --git a/src/commodity.cc b/src/commodity.cc index 1c849624..08252cf4 100644 --- a/src/commodity.cc +++ b/src/commodity.cc @@ -638,6 +638,12 @@ void annotation_t::parse(std::istream& in) throw_(amount_error, _("Commodity specifies more than one price")); in.get(c); + c = peek_next_nonws(in); + if (c == '=') { + in.get(c); + add_flags(ANNOTATION_PRICE_FIXATED); + } + READ_INTO(in, buf, 255, c, c != '}'); if (c == '}') in.get(c); @@ -761,7 +767,10 @@ void annotated_commodity_t::write_annotations(std::ostream& out) const void annotation_t::print(std::ostream& out, bool keep_base) const { if (price) - out << " {" << (keep_base ? *price : price->unreduced()).rounded() << '}'; + out << " {" + << (has_flags(ANNOTATION_PRICE_FIXATED) ? "=" : "") + << (keep_base ? *price : price->unreduced()).rounded() + << '}'; if (date) out << " [" << format_date(*date, string("%Y/%m/%d")) << ']'; diff --git a/src/commodity.h b/src/commodity.h index 310a0a89..c152dfc7 100644 --- a/src/commodity.h +++ b/src/commodity.h @@ -363,8 +363,9 @@ struct annotation_t : public supports_flags<>, public equality_comparable<annotation_t> { #define ANNOTATION_PRICE_CALCULATED 0x01 -#define ANNOTATION_DATE_CALCULATED 0x02 -#define ANNOTATION_TAG_CALCULATED 0x04 +#define ANNOTATION_PRICE_FIXATED 0x02 +#define ANNOTATION_DATE_CALCULATED 0x04 +#define ANNOTATION_TAG_CALCULATED 0x08 optional<amount_t> price; optional<date_t> date; |