Fixed the market valuation function for balances.
This commit is contained in:
parent
7cc64c04a5
commit
c6303ab9ef
2 changed files with 11 additions and 8 deletions
|
|
@ -158,17 +158,19 @@ balance_t& balance_t::operator/=(const amount_t& amt)
|
||||||
}
|
}
|
||||||
|
|
||||||
optional<balance_t>
|
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;
|
optional<balance_t> temp;
|
||||||
|
|
||||||
foreach (const amounts_map::value_type& pair, amounts)
|
foreach (const amounts_map::value_type& pair, amounts) {
|
||||||
if (optional<amount_t> val = pair.second.value(moment)) {
|
|
||||||
if (! temp)
|
if (! temp)
|
||||||
temp = balance_t();
|
temp = balance_t();
|
||||||
|
if (optional<amount_t> val = pair.second.value(moment, in_terms_of))
|
||||||
*temp += *val;
|
*temp += *val;
|
||||||
|
else
|
||||||
|
*temp += pair.second;
|
||||||
}
|
}
|
||||||
|
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -377,7 +377,8 @@ public:
|
||||||
return *this = temp;
|
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:
|
* Truth tests. An balance may be truth test in two ways:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue