diff options
author | John Wiegley <johnw@newartisans.com> | 2010-06-20 16:48:36 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2010-06-20 17:08:27 -0400 |
commit | 135d997293a9d6bdb1176edfb729293c233f97e2 (patch) | |
tree | f32e31484dbfc38d2c286184cc37ab892878d4be /src/filters.cc | |
parent | 6770380b6da5061857e0a15539f1b85669d24e62 (diff) | |
download | fork-ledger-135d997293a9d6bdb1176edfb729293c233f97e2.tar.gz fork-ledger-135d997293a9d6bdb1176edfb729293c233f97e2.tar.bz2 fork-ledger-135d997293a9d6bdb1176edfb729293c233f97e2.zip |
If a periodic posting terminates, stop forecasting with it
Diffstat (limited to 'src/filters.cc')
-rw-r--r-- | src/filters.cc | 9 |
1 files changed, 5 insertions, 4 deletions
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<date_t> next((*least).first.next); - if (static_cast<std::size_t>((next - last).days()) > + if (! next || + static_cast<std::size_t>((*next - last).days()) > static_cast<std::size_t>(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 |