diff options
-rw-r--r-- | src/report.cc | 8 | ||||
-rw-r--r-- | src/report.h | 18 | ||||
-rw-r--r-- | src/session.cc | 15 | ||||
-rw-r--r-- | src/session.h | 7 | ||||
-rw-r--r-- | test/regress/647D5DB9.test | 17 |
5 files changed, 39 insertions, 26 deletions
diff --git a/src/report.cc b/src/report.cc index de67708b..fde3365b 100644 --- a/src/report.cc +++ b/src/report.cc @@ -753,6 +753,8 @@ expr_t::ptr_op_t report_t::lookup(const string& name) return MAKE_FUNCTOR(report_t::fn_display_amount); else if (is_eq(p, "display_total")) return MAKE_FUNCTOR(report_t::fn_display_total); + else if (is_eq(p, "date")) + return MAKE_FUNCTOR(report_t::fn_today); break; case 'f': @@ -789,6 +791,10 @@ expr_t::ptr_op_t report_t::lookup(const string& name) case 'n': if (is_eq(p, "null")) return WRAP_FUNCTOR(fn_null); +#if 0 + else if (is_eq(p, "now")) + return MAKE_FUNCTOR(report_t::fn_now); +#endif break; case 'o': @@ -868,6 +874,8 @@ expr_t::ptr_op_t report_t::lookup(const string& name) return MAKE_FUNCTOR(report_t::fn_truncated); else if (is_eq(p, "total_expr")) return MAKE_FUNCTOR(report_t::fn_total_expr); + else if (is_eq(p, "today")) + return MAKE_FUNCTOR(report_t::fn_today); break; case 'u': diff --git a/src/report.h b/src/report.h index a1c93c39..d48b5a78 100644 --- a/src/report.h +++ b/src/report.h @@ -119,10 +119,12 @@ public: #define BUDGET_BUDGETED 0x01 #define BUDGET_UNBUDGETED 0x02 + date_t terminus; uint_least8_t budget_flags; explicit report_t(session_t& _session) - : session(_session), budget_flags(BUDGET_NO_BUDGET) {} + : session(_session), terminus(CURRENT_DATE()), + budget_flags(BUDGET_NO_BUDGET) {} virtual ~report_t() { output_stream.close(); @@ -154,6 +156,15 @@ public: value_t fn_format_date(call_scope_t& scope); value_t fn_ansify_if(call_scope_t& scope); +#if 0 + value_t fn_now(call_scope_t&) { + return CURRENT_TIME(); + } +#endif + value_t fn_today(call_scope_t&) { + return terminus; + } + value_t fn_options(call_scope_t&) { return value_t(static_cast<scope_t *>(this)); } @@ -476,9 +487,8 @@ public: string predicate = "date<[" + to_iso_extended_string(*interval.start) + "]"; parent->HANDLER(limit_).on(string("--end"), predicate); -#if 0 - terminus = interval.begin; -#endif + + parent->terminus = *interval.start; }); OPTION(report_t, equity); diff --git a/src/session.cc b/src/session.cc index 7727c467..2ae09e21 100644 --- a/src/session.cc +++ b/src/session.cc @@ -245,27 +245,12 @@ expr_t::ptr_op_t session_t::lookup(const string& name) { const char * p = name.c_str(); switch (*p) { - case 'd': - if (is_eq(p, "date")) - return MAKE_FUNCTOR(session_t::fn_today); - break; - - case 'n': - if (is_eq(p, "now")) - return MAKE_FUNCTOR(session_t::fn_now); - break; - case 'o': if (WANT_OPT()) { p += OPT_PREFIX_LEN; if (option_t<session_t> * handler = lookup_option(p)) return MAKE_OPT_HANDLER(session_t, handler); } break; - - case 't': - if (is_eq(p, "today")) - return MAKE_FUNCTOR(session_t::fn_today); - break; } // Check if they are trying to access an option's setting or value. diff --git a/src/session.h b/src/session.h index 10e5b758..679fe679 100644 --- a/src/session.h +++ b/src/session.h @@ -101,13 +101,6 @@ public: clean_accounts(); } - value_t fn_now(call_scope_t&) { - return CURRENT_TIME(); - } - value_t fn_today(call_scope_t&) { - return CURRENT_DATE(); - } - void report_options(std::ostream& out) { HANDLER(account_).report(out); diff --git a/test/regress/647D5DB9.test b/test/regress/647D5DB9.test new file mode 100644 index 00000000..3f187b36 --- /dev/null +++ b/test/regress/647D5DB9.test @@ -0,0 +1,17 @@ +bal --end 2008/12/31 -JV bal Equities +<<< +2008/01/01 * Purchase Apple shares + Equities 1000 AAPL @ $2 + Cash + +2008/06/30 * Sell some Apple shares + Equities -500 AAPL @ $2.5 + Cash + +P 2008/10/01 02:18:02 AAPL $3 +P 2009/01/31 02:18:02 AAPL $4 +P 3000/01/01 02:18:02 APPL $100 +>>>1 +2008-12-31 1500 +>>>2 +=== 0 |