diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/balance.cc | 16 | ||||
-rw-r--r-- | src/balance.h | 3 |
2 files changed, 11 insertions, 8 deletions
diff --git a/src/balance.cc b/src/balance.cc index 085d32b1..571f09c3 100644 --- a/src/balance.cc +++ b/src/balance.cc @@ -158,17 +158,19 @@ balance_t& balance_t::operator/=(const amount_t& amt) } optional<balance_t> -balance_t::value(const optional<datetime_t>& moment) const +balance_t::value(const optional<datetime_t>& moment, + const optional<commodity_t&>& in_terms_of) const { optional<balance_t> temp; - foreach (const amounts_map::value_type& pair, amounts) - if (optional<amount_t> val = pair.second.value(moment)) { - if (! temp) - temp = balance_t(); + foreach (const amounts_map::value_type& pair, amounts) { + if (! temp) + temp = balance_t(); + if (optional<amount_t> val = pair.second.value(moment, in_terms_of)) *temp += *val; - } - + else + *temp += pair.second; + } return temp; } diff --git a/src/balance.h b/src/balance.h index d00fadb1..0122e5a3 100644 --- a/src/balance.h +++ b/src/balance.h @@ -377,7 +377,8 @@ public: return *this = temp; } - optional<balance_t> value(const optional<datetime_t>& moment = none) const; + optional<balance_t> value(const optional<datetime_t>& moment = none, + const optional<commodity_t&>& in_terms_of = none) const; /** * Truth tests. An balance may be truth test in two ways: |