diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/chain.cc | 6 | ||||
-rw-r--r-- | src/filters.cc | 6 | ||||
-rw-r--r-- | src/filters.h | 13 | ||||
-rw-r--r-- | src/report.cc | 1 | ||||
-rw-r--r-- | src/report.h | 2 |
5 files changed, 20 insertions, 8 deletions
diff --git a/src/chain.cc b/src/chain.cc index d7d1460b..db52269c 100644 --- a/src/chain.cc +++ b/src/chain.cc @@ -209,7 +209,11 @@ post_handler_ptr chain_post_handlers(report_t& report, = new forecast_posts(handler, item_predicate(report.HANDLER(forecast_while_).str(), report.what_to_keep()), - report); + report, + report.HANDLED(forecast_years_) ? + static_cast<std::size_t> + (report.HANDLER(forecast_years_).value.to_long()) : + 5UL); forecast_handler->add_period_xacts(report.session.journal->period_xacts); handler.reset(forecast_handler); diff --git a/src/filters.cc b/src/filters.cc index 814cf276..fe8761a5 100644 --- a/src/filters.cc +++ b/src/filters.cc @@ -871,9 +871,11 @@ void forecast_posts::flush() date_t next = *(*least).first.next; assert(next > begin); - if ((next - last).days() > 365 * 5) { + if (static_cast<std::size_t>((next - last).days()) > + static_cast<std::size_t>(365U) * forecast_years) { DEBUG("filters.forecast", - "Forecast transaction exceeds 5 years beyond today"); + "Forecast transaction exceeds " << forecast_years + << " years beyond today"); pending_posts.erase(least); continue; } diff --git a/src/filters.h b/src/filters.h index 3eb5da8d..7c1f169c 100644 --- a/src/filters.h +++ b/src/filters.h @@ -764,16 +764,19 @@ public: */ class forecast_posts : public generate_posts { - item_predicate pred; - scope_t& context; + item_predicate pred; + scope_t& context; + const std::size_t forecast_years; public: forecast_posts(post_handler_ptr handler, const item_predicate& predicate, - scope_t& _context) - : generate_posts(handler), pred(predicate), context(_context) { + scope_t& _context, + const std::size_t _forecast_years) + : generate_posts(handler), pred(predicate), context(_context), + forecast_years(_forecast_years) { TRACE_CTOR(forecast_posts, - "post_handler_ptr, const item_predicate&, scope_t&"); + "post_handler_ptr, item_predicate, scope_t&, std::size_t"); } virtual ~forecast_posts() throw() { TRACE_DTOR(forecast_posts); diff --git a/src/report.cc b/src/report.cc index bc0680d1..7d74952c 100644 --- a/src/report.cc +++ b/src/report.cc @@ -559,6 +559,7 @@ option_t<report_t> * report_t::lookup_option(const char * p) case 'f': OPT(flat); else OPT_ALT(forecast_while_, forecast_); + else OPT(forecast_years_); else OPT(format_); else OPT(force_color); else OPT(force_pager); diff --git a/src/report.h b/src/report.h index 4d028e33..c1ad1997 100644 --- a/src/report.h +++ b/src/report.h @@ -240,6 +240,7 @@ public: HANDLER(force_color).report(out); HANDLER(force_pager).report(out); HANDLER(forecast_while_).report(out); + HANDLER(forecast_years_).report(out); HANDLER(format_).report(out); HANDLER(gain).report(out); HANDLER(head_).report(out); @@ -544,6 +545,7 @@ public: OPTION(report_t, force_color); OPTION(report_t, force_pager); OPTION(report_t, forecast_while_); + OPTION(report_t, forecast_years_); OPTION(report_t, format_); // -F OPTION_(report_t, gain, DO() { // -G |