summaryrefslogtreecommitdiff
path: root/src/balance.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-01-19 22:30:46 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-01-19 22:30:46 -0400
commitc6303ab9efdb414a1809ec3413264037b31f092e (patch)
treea8fc8e2b66caaa2a7b176e553330a4742a2a11ff /src/balance.cc
parent7cc64c04a56b30b4c04fe4cf7d3399dcf58c4971 (diff)
downloadfork-ledger-c6303ab9efdb414a1809ec3413264037b31f092e.tar.gz
fork-ledger-c6303ab9efdb414a1809ec3413264037b31f092e.tar.bz2
fork-ledger-c6303ab9efdb414a1809ec3413264037b31f092e.zip
Fixed the market valuation function for balances.
Diffstat (limited to 'src/balance.cc')
-rw-r--r--src/balance.cc16
1 files changed, 9 insertions, 7 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;
}