From 9f81c798ee0854cab038714670123bff6676a5d5 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 8 Mar 2012 01:08:08 -0600 Subject: fn_market can now accept a commodity name for arg 0 --- src/report.cc | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src') 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(1) : optional()); 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(2)) - result = args[0].exchange_commodities(args.get(2), - /* add_prices= */ false, moment); + result = arg0.exchange_commodities(args.get(2), + /* add_prices= */ false, moment); else - result = args[0].value(moment); + result = arg0.value(moment); if (! result.is_null()) return result; -- cgit v1.2.3