diff options
author | John Wiegley <johnw@newartisans.com> | 2010-06-07 08:23:22 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2010-06-07 08:32:14 -0400 |
commit | c85cf0d810846e6ffc2a45b7283adacc202db30f (patch) | |
tree | b444a914c8551951556a15794a94810d38b62414 /src/annotate.cc | |
parent | a4d4f9979486eb82c05bd032e1452c2fd400249f (diff) | |
download | fork-ledger-c85cf0d810846e6ffc2a45b7283adacc202db30f.tar.gz fork-ledger-c85cf0d810846e6ffc2a45b7283adacc202db30f.tar.bz2 fork-ledger-c85cf0d810846e6ffc2a45b7283adacc202db30f.zip |
Fixed the way prices and costs are print'd
Diffstat (limited to 'src/annotate.cc')
-rw-r--r-- | src/annotate.cc | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/src/annotate.cc b/src/annotate.cc index feb3b3ca..e1e64ac2 100644 --- a/src/annotate.cc +++ b/src/annotate.cc @@ -66,15 +66,6 @@ void annotation_t::parse(std::istream& in) temp.parse(buf, PARSE_NO_MIGRATE); DEBUG("commodity.annotations", "Parsed annotation price: " << temp); - - // Since this price will maintain its own precision, make sure - // it is at least as large as the base commodity, since the user - // may have only specified {$1} or something similar. - - if (temp.has_commodity() && - temp.precision() > temp.commodity().precision()) - temp = temp.rounded(); // no need to retain individual precision - price = temp; } else if (c == '[') { @@ -118,18 +109,22 @@ void annotation_t::parse(std::istream& in) #endif } -void annotation_t::print(std::ostream& out, bool keep_base) const +void annotation_t::print(std::ostream& out, bool keep_base, + bool no_computed_annotations) const { - if (price) + if (price && + (! no_computed_annotations || ! has_flags(ANNOTATION_PRICE_CALCULATED))) out << " {" << (has_flags(ANNOTATION_PRICE_FIXATED) ? "=" : "") - << (keep_base ? *price : price->unreduced()).rounded() + << (keep_base ? *price : price->unreduced()) << '}'; - if (date) + if (date && + (! no_computed_annotations || ! has_flags(ANNOTATION_DATE_CALCULATED))) out << " [" << format_date(*date, FMT_WRITTEN) << ']'; - if (tag) + if (tag && + (! no_computed_annotations || ! has_flags(ANNOTATION_TAG_CALCULATED))) out << " (" << *tag << ')'; } @@ -197,9 +192,10 @@ annotated_commodity_t::strip_annotations(const keep_details_t& what_to_keep) return *new_comm; } -void annotated_commodity_t::write_annotations(std::ostream& out) const +void annotated_commodity_t::write_annotations + (std::ostream& out, bool no_computed_annotations) const { - details.print(out, pool().keep_base); + details.print(out, pool().keep_base, no_computed_annotations); } } // namespace ledger |