diff options
-rw-r--r-- | src/report.h | 4 | ||||
-rw-r--r-- | src/session.cc | 5 | ||||
-rw-r--r-- | src/session.h | 4 | ||||
-rw-r--r-- | test/baseline/opt-current.test | 17 |
4 files changed, 29 insertions, 1 deletions
diff --git a/src/report.h b/src/report.h index 5bd98360..991d60ba 100644 --- a/src/report.h +++ b/src/report.h @@ -297,7 +297,9 @@ public: "%(quoted(join(note)))\n"); }); - OPTION(report_t, current); // -c + OPTION_(report_t, current, DO() { // -c + parent->HANDLER(limit_).on("date<=today"); + }); OPTION_(report_t, daily, DO() { parent->HANDLER(period_).on("daily"); diff --git a/src/session.cc b/src/session.cc index 7a3ecf19..8e505c22 100644 --- a/src/session.cc +++ b/src/session.cc @@ -241,6 +241,11 @@ expr_t::ptr_op_t session_t::lookup(const string& name) return MAKE_OPT_HANDLER(session_t, handler); } break; + + case 't': + if (is_eq(p, "today")) + return MAKE_FUNCTOR(session_t::fn_today); + break; } return symbol_scope_t::lookup(name); diff --git a/src/session.h b/src/session.h index d2320bb7..cb71c61b 100644 --- a/src/session.h +++ b/src/session.h @@ -98,6 +98,10 @@ public: clean_accounts(); } + value_t fn_today(call_scope_t&) { + return CURRENT_DATE(); + } + option_t<session_t> * lookup_option(const char * p); virtual expr_t::ptr_op_t lookup(const string& name); diff --git a/test/baseline/opt-current.test b/test/baseline/opt-current.test new file mode 100644 index 00000000..a0450ea2 --- /dev/null +++ b/test/baseline/opt-current.test @@ -0,0 +1,17 @@ +bal --current +<<< +2007/02/02 RD VMMXX + Assets:Investments:Vanguard:VMMXX 0.350 VMMXX @ $1.00 + Income:Dividends:Vanguard:VMMXX $-0.35 + +2700/02/02 RD VMMXX + Assets:Investments:Vanguard:VMMXX 0.350 VMMXX @ $1.00 + Income:Dividends:Vanguard:VMMXX $-0.35 +>>>1 + 0.350 VMMXX Assets:Investments:Vanguard:VMMXX + $-0.35 Income:Dividends:Vanguard:VMMXX +-------------------- + $-0.35 + 0.350 VMMXX +>>>2 +=== 0 |