diff options
author | John Wiegley <johnw@newartisans.com> | 2012-03-08 00:54:19 -0600 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2012-03-08 00:54:19 -0600 |
commit | 17a84642fbb4684d5a8415371003f12ccb760d99 (patch) | |
tree | ab1ddc19d533b1c1a97621a567c862d79495343e /src/commodity.cc | |
parent | c86bff270712bcf5aaf296d2f867a856be8b6ff9 (diff) | |
download | fork-ledger-17a84642fbb4684d5a8415371003f12ccb760d99.tar.gz fork-ledger-17a84642fbb4684d5a8415371003f12ccb760d99.tar.bz2 fork-ledger-17a84642fbb4684d5a8415371003f12ccb760d99.zip |
Corrected calculation of market valuation expressions
Diffstat (limited to 'src/commodity.cc')
-rw-r--r-- | src/commodity.cc | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/commodity.cc b/src/commodity.cc index 0543c973..24d54695 100644 --- a/src/commodity.cc +++ b/src/commodity.cc @@ -97,14 +97,20 @@ commodity_t::find_price_from_expr(expr_t& expr, DEBUG("commodity.price.find", ""); } #endif - call_scope_t call_args(*scope_t::default_scope); + value_t result(expr.calc(*scope_t::default_scope)); - call_args.push_back(string_value(base_symbol())); - call_args.push_back(moment); - if (commodity) - call_args.push_back(string_value(commodity->symbol())); + if (is_expr(result)) { + value_t call_args; + + call_args.push_back(string_value(base_symbol())); + call_args.push_back(moment); + if (commodity) + call_args.push_back(string_value(commodity->symbol())); + + result = as_expr(result)->call(call_args, *scope_t::default_scope); + } - return price_point_t(moment, expr.calc(call_args).to_amount()); + return price_point_t(moment, result.to_amount()); } optional<price_point_t> |