diff options
-rw-r--r-- | src/filters.cc | 9 | ||||
-rw-r--r-- | src/filters.h | 4 | ||||
-rw-r--r-- | src/report.h | 37 |
3 files changed, 37 insertions, 13 deletions
diff --git a/src/filters.cc b/src/filters.cc index bc365fac..d5c8f177 100644 --- a/src/filters.cc +++ b/src/filters.cc @@ -403,7 +403,7 @@ void subtotal_xacts::report_subtotal(const char * spec_fmt) out_date << format_date(finish, string(fmt)); } else { - out_date << format_date(finish); + out_date << format_date(finish, std::string("- ") + output_date_format); } entry_temps.push_back(entry_t()); @@ -455,11 +455,8 @@ void interval_xacts::report_subtotal(const date_t& date) { assert(last_xact); - start = interval.begin; - if (is_valid(date)) - finish = date - gregorian::days(1); - else - finish = last_xact->date(); + start = interval.begin; + finish = date - gregorian::days(1); subtotal_xacts::report_subtotal(); diff --git a/src/filters.h b/src/filters.h index e4378b5f..d5db3b6c 100644 --- a/src/filters.h +++ b/src/filters.h @@ -591,11 +591,11 @@ public: TRACE_DTOR(interval_xacts); } - void report_subtotal(const date_t& moment = date_t()); + void report_subtotal(const date_t& moment); virtual void flush() { if (last_xact) - report_subtotal(); + report_subtotal(last_xact->date()); subtotal_xacts::flush(); } virtual void operator()(xact_t& xact); diff --git a/src/report.h b/src/report.h index 467fc121..c94cbb91 100644 --- a/src/report.h +++ b/src/report.h @@ -148,6 +148,13 @@ public: return true; } + void prefix_to_period(const string& str) { + if (! HANDLED(period_)) + HANDLER(period_).on(str); + else + HANDLER(period_).on(str + " " + HANDLER(period_).str()); + } + void append_predicate(const string& str) { if (HANDLED(limit_)) HANDLER(limit_).on(string("(") + HANDLER(limit_).str() + ")&" + str); @@ -258,7 +265,12 @@ public: OPTION(report_t, cost); OPTION(report_t, csv_format_); OPTION(report_t, current); // -c - OPTION(report_t, daily); + + OPTION_(report_t, daily, DO() { + // This will turn on HANDLER(period_) + parent->prefix_to_period("daily"); + }); + OPTION(report_t, date_format_); // -y OPTION(report_t, deviation); // -D @@ -329,7 +341,10 @@ public: parent->HANDLER(display_total_).on("market_value(total_expr)"); }); - OPTION(report_t, monthly); // -M + OPTION_(report_t, monthly, DO() { // -M + // This will turn on HANDLER(period_) + parent->prefix_to_period("monthly"); + }); OPTION_(report_t, only_, DO_(args) { // -d parent->append_secondary_predicate(args[0].to_string()); @@ -366,7 +381,11 @@ public: parent->HANDLER(total_).on("total"); }); - OPTION(report_t, quarterly); + OPTION_(report_t, quarterly, DO() { + // This will turn on HANDLER(period_) + parent->prefix_to_period("quarterly"); + }); + OPTION(report_t, real); // -R OPTION(report_t, register_format_); OPTION(report_t, related); // -r @@ -417,10 +436,18 @@ public: parent->append_predicate("uncleared|pending"); }); - OPTION(report_t, weekly); // -W + OPTION_(report_t, weekly, DO() { // -W + // This will turn on HANDLER(period_) + parent->prefix_to_period("weekly"); + }); + OPTION(report_t, wide); // -w OPTION(report_t, wide_register_format_); - OPTION(report_t, yearly); // -Y + + OPTION_(report_t, yearly, DO() { // -Y + // This will turn on HANDLER(period_) + parent->prefix_to_period("yearly"); + }); }; // jww (2009-02-10): These should perhaps live elsewhere |