diff options
Diffstat (limited to 'src/balance.cc')
-rw-r--r-- | src/balance.cc | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/balance.cc b/src/balance.cc index 864926cf..274f860a 100644 --- a/src/balance.cc +++ b/src/balance.cc @@ -33,6 +33,7 @@ #include "balance.h" #include "commodity.h" +#include "pool.h" #include "unistring.h" // for justify() namespace ledger { @@ -202,6 +203,16 @@ balance_t::value(const bool primary_only, return resolved ? temp : optional<balance_t>(); } +balance_t balance_t::price() const +{ + balance_t temp; + + foreach (const amounts_map::value_type& pair, amounts) + temp += pair.second.price(); + + return temp; +} + optional<amount_t> balance_t::commodity_amount(const optional<const commodity_t&>& commodity) const { @@ -243,7 +254,8 @@ balance_t::strip_annotations(const keep_details_t& what_to_keep) const void balance_t::print(std::ostream& out, const int first_width, const int latter_width, - const bool right_justify) const + const bool right_justify, + const bool colorize) const { bool first = true; int lwidth = latter_width; @@ -272,7 +284,8 @@ void balance_t::print(std::ostream& out, std::ostringstream buf; buf << *amount; - justify(out, buf.str(), width, right_justify); + justify(out, buf.str(), width, right_justify, + colorize && amount->sign() < 0); } if (first) { |