diff options
author | John Wiegley <johnw@newartisans.com> | 2012-03-08 01:08:08 -0600 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2012-03-08 01:08:08 -0600 |
commit | 9f81c798ee0854cab038714670123bff6676a5d5 (patch) | |
tree | 614106e54bf13001e364ba3b68c5b5c75d4a34e0 /src | |
parent | 113fb0ee6a520dccdcd18a634f7ee73acd8ee488 (diff) | |
download | fork-ledger-9f81c798ee0854cab038714670123bff6676a5d5.tar.gz fork-ledger-9f81c798ee0854cab038714670123bff6676a5d5.tar.bz2 fork-ledger-9f81c798ee0854cab038714670123bff6676a5d5.zip |
fn_market can now accept a commodity name for arg 0
Diffstat (limited to 'src')
-rw-r--r-- | src/report.cc | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/report.cc b/src/report.cc index 26e6da0c..02fd7c18 100644 --- a/src/report.cc +++ b/src/report.cc @@ -517,11 +517,21 @@ value_t report_t::fn_market(call_scope_t& args) args.get<datetime_t>(1) : optional<datetime_t>()); value_t result; + value_t arg0 = args[0]; + + if (arg0.is_string()) { + amount_t tmp(1L); + commodity_t * commodity = + commodity_pool_t::current_pool->find_or_create(arg0.as_string()); + tmp.set_commodity(*commodity); + arg0 = tmp; + } + if (args.has<string>(2)) - result = args[0].exchange_commodities(args.get<string>(2), - /* add_prices= */ false, moment); + result = arg0.exchange_commodities(args.get<string>(2), + /* add_prices= */ false, moment); else - result = args[0].value(moment); + result = arg0.value(moment); if (! result.is_null()) return result; |