diff options
author | John Wiegley <johnw@newartisans.com> | 2009-01-19 22:28:00 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-01-19 22:28:00 -0400 |
commit | e9a5a9bd7753e69fb60849076083c26c06cce6a4 (patch) | |
tree | f1a77e80c5f45140a998a7ea25dde4a23edc5e1e /src/report.cc | |
parent | 83648af19fd702127e8af98d20938c21c4ad9e0e (diff) | |
download | fork-ledger-e9a5a9bd7753e69fb60849076083c26c06cce6a4.tar.gz fork-ledger-e9a5a9bd7753e69fb60849076083c26c06cce6a4.tar.bz2 fork-ledger-e9a5a9bd7753e69fb60849076083c26c06cce6a4.zip |
Added back the -V (market value) option.
Diffstat (limited to 'src/report.cc')
-rw-r--r-- | src/report.cc | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/report.cc b/src/report.cc index ce414446..c258dce4 100644 --- a/src/report.cc +++ b/src/report.cc @@ -277,6 +277,26 @@ value_t report_t::get_display_total(call_scope_t& scope) return display_total.calc(scope); } +value_t report_t::f_market_value(call_scope_t& args) +{ + var_t<datetime_t> date(args, 1); + var_t<string> in_terms_of(args, 2); + + commodity_t * commodity = NULL; + if (in_terms_of) + commodity = amount_t::current_pool->find_or_create(*in_terms_of); + + DEBUG("report.market", "getting market value of: " << args[0]); + + value_t result = + args[0].value(date ? optional<datetime_t>(*date) : optional<datetime_t>(), + commodity ? optional<commodity_t&>(*commodity) : + optional<commodity_t&>()); + + DEBUG("report.market", "result is: " << result); + return result; +} + namespace { value_t print_balance(call_scope_t& args) { @@ -484,6 +504,11 @@ expr_t::ptr_op_t report_t::lookup(const string& name) return MAKE_FUNCTOR(report_t::get_display_total); break; + case 'm': + if (std::strcmp(p, "market_value") == 0) + return MAKE_FUNCTOR(report_t::f_market_value); + break; + case 'o': if (std::strncmp(p, "opt_", 4) == 0) { p = p + 4; @@ -560,6 +585,8 @@ expr_t::ptr_op_t report_t::lookup(const string& name) case 'm': if (std::strcmp(p, "monthly") == 0) return MAKE_FUNCTOR(report_t::option_monthly); + else if (std::strcmp(p, "market") == 0) + return MAKE_FUNCTOR(report_t::option_market); break; case 'n': @@ -676,6 +703,11 @@ expr_t::ptr_op_t report_t::lookup(const string& name) return MAKE_FUNCTOR(report_t::option_uncleared); break; + case 'V': + if (! *(p + 1)) + return MAKE_FUNCTOR(report_t::option_market); + break; + case 'W': if (! *(p + 1)) return MAKE_FUNCTOR(report_t::option_weekly); |