summaryrefslogtreecommitdiff
path: root/src/filters.cc
diff options
context:
space:
mode:
authorPeter Pickford <git@netremedies.ca>2016-03-04 19:26:19 -0800
committerPeter Pickford <git@netremedies.ca>2016-03-09 16:00:10 -0800
commit97ec24544e783abd9edecdc13e8deba99baee47b (patch)
tree3c6248c62cae462a72d47ed1dcb510177db4ad78 /src/filters.cc
parent6770d00dba467d55921c3676a339cac8b221f214 (diff)
downloadfork-ledger-97ec24544e783abd9edecdc13e8deba99baee47b.tar.gz
fork-ledger-97ec24544e783abd9edecdc13e8deba99baee47b.tar.bz2
fork-ledger-97ec24544e783abd9edecdc13e8deba99baee47b.zip
Periods should be initialized from from/since clause rather than earliest transaction date
Bug 1159 Use interval start date (period from/since) to initialize first period. This allows the offset of a period start to be specified -p 'every 12 months from 2000-04-01' will have periods yyyy-04-01 to yyyy-03-31 .... If no from/since is specified for the period the first transaction date reported is used to initialize the period as before. added test case regress/1159.test
Diffstat (limited to 'src/filters.cc')
-rw-r--r--src/filters.cc10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/filters.cc b/src/filters.cc
index 1d7832ca..8aa1218b 100644
--- a/src/filters.cc
+++ b/src/filters.cc
@@ -982,10 +982,12 @@ void interval_posts::flush()
std::stable_sort(all_posts.begin(), all_posts.end(),
sort_posts_by_date());
- // Determine the beginning interval by using the earliest post
- if (all_posts.size() > 0 && all_posts.front() &&
- ! interval.find_period(all_posts.front()->date()))
- throw_(std::logic_error, _("Failed to find period for interval report"));
+ // only if the interval has no start use the earliest post
+ if (!(interval.begin() && interval.find_period(*interval.begin())))
+ // Determine the beginning interval by using the earliest post
+ if (all_posts.size() > 0 && all_posts.front()
+ && !interval.find_period(all_posts.front()->date()))
+ throw_(std::logic_error, _("Failed to find period for interval report"));
// Walk the interval forward reporting all posts within each one
// before moving on, until we reach the end of all_posts