summaryrefslogtreecommitdiff
path: root/src/balance.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-02-23 01:51:23 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-02-23 01:51:23 -0400
commit9f53efbf5f8e49b9c4dbe8c3ff595e99903b3aab (patch)
treeacf41ff447a8d2adac68c51f40f0a50e846133c8 /src/balance.cc
parentde6de07bac1337b0dd87b41c853369dc8432c2af (diff)
downloadfork-ledger-9f53efbf5f8e49b9c4dbe8c3ff595e99903b3aab.tar.gz
fork-ledger-9f53efbf5f8e49b9c4dbe8c3ff595e99903b3aab.tar.bz2
fork-ledger-9f53efbf5f8e49b9c4dbe8c3ff595e99903b3aab.zip
Many fixes to both --market and --exchange
Diffstat (limited to 'src/balance.cc')
-rw-r--r--src/balance.cc17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/balance.cc b/src/balance.cc
index 70e83362..39392aa3 100644
--- a/src/balance.cc
+++ b/src/balance.cc
@@ -163,18 +163,19 @@ balance_t::value(const bool primary_only,
const optional<datetime_t>& moment,
const optional<commodity_t&>& in_terms_of) const
{
- optional<balance_t> temp;
+ balance_t temp;
+ bool resolved = false;
foreach (const amounts_map::value_type& pair, amounts) {
- if (! temp)
- temp = balance_t();
if (optional<amount_t> val = pair.second.value(primary_only, moment,
- in_terms_of))
- *temp += *val;
- else
- *temp += pair.second;
+ in_terms_of)) {
+ temp += *val;
+ resolved = true;
+ } else {
+ temp += pair.second;
+ }
}
- return temp;
+ return resolved ? temp : optional<balance_t>();
}
optional<amount_t>