diff options
author | John Wiegley <johnw@newartisans.com> | 2009-02-24 03:40:57 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-02-24 03:40:57 -0400 |
commit | 79c74782783f789c067d3ba1fb1461c436b07828 (patch) | |
tree | a2a2fc8f7888c0c973edf0d2d1d6c42ef5f96056 /src/commodity.cc | |
parent | eb364f4183d2549540c92d3e58246fad4f45dda2 (diff) | |
download | fork-ledger-79c74782783f789c067d3ba1fb1461c436b07828.tar.gz fork-ledger-79c74782783f789c067d3ba1fb1461c436b07828.tar.bz2 fork-ledger-79c74782783f789c067d3ba1fb1461c436b07828.zip |
Fixes to the way annotated prices are displayed
Diffstat (limited to 'src/commodity.cc')
-rw-r--r-- | src/commodity.cc | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/commodity.cc b/src/commodity.cc index c65ad0a4..1721697c 100644 --- a/src/commodity.cc +++ b/src/commodity.cc @@ -737,17 +737,21 @@ 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 annotation_t& info) +void annotated_commodity_t::write_annotations(std::ostream& out) const { - if (info.price) - out << " {" << *info.price << '}'; + details.print(out, parent().keep_base); +} + +void annotation_t::print(std::ostream& out, bool keep_base) const +{ + if (price) + out << " {" << (keep_base ? *price : price->unreduced()).rounded() << '}'; - if (info.date) - out << " [" << format_date(*info.date, string("%Y/%m/%d")) << ']'; + if (date) + out << " [" << format_date(*date, string("%Y/%m/%d")) << ']'; - if (info.tag) - out << " (" << *info.tag << ')'; + if (tag) + out << " (" << *tag << ')'; } bool compare_amount_commodities::operator()(const amount_t * left, @@ -817,7 +821,8 @@ bool compare_amount_commodities::operator()(const amount_t * left, } } -commodity_pool_t::commodity_pool_t() : default_commodity(NULL) +commodity_pool_t::commodity_pool_t() + : default_commodity(NULL), keep_base(false) { TRACE_CTOR(commodity_pool_t, ""); null_commodity = create(""); @@ -894,7 +899,7 @@ namespace { std::ostringstream name; comm.print(name); - annotated_commodity_t::write_annotations(name, details); + details.print(name, comm.parent().keep_base); DEBUG("amounts.commodities", "make_qualified_name for " << comm.qualified_symbol << std::endl << details); |