From 135d997293a9d6bdb1176edfb729293c233f97e2 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sun, 20 Jun 2010 16:48:36 -0400 Subject: If a periodic posting terminates, stop forecasting with it --- src/filters.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/filters.cc') diff --git a/src/filters.cc b/src/filters.cc index 1a0ecd50..2323aed9 100644 --- a/src/filters.cc +++ b/src/filters.cc @@ -1316,10 +1316,10 @@ void forecast_posts::flush() // If the next date in the series for this periodic posting is more than 5 // years beyond the last valid post we generated, drop it from further // consideration. - date_t next = *(*least).first.next; - assert(next > begin); + optional next((*least).first.next); - if (static_cast((next - last).days()) > + if (! next || + static_cast((*next - last).days()) > static_cast(365U) * forecast_years) { DEBUG("filters.forecast", "Forecast transaction exceeds " << forecast_years @@ -1328,7 +1328,8 @@ void forecast_posts::flush() continue; } - begin = next; + assert(*next > begin); + begin = *next; // `post' refers to the posting defined in the period transaction. We // make a copy of it within a temporary transaction with the payee -- cgit v1.2.3