summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2012-02-28 01:37:29 -0600
committerJohn Wiegley <johnw@newartisans.com>2012-02-28 01:37:29 -0600
commit887f429ae40934c145e03b03cc452e6af4457c0f (patch)
treec021ea1b6b67b0d866d67d114a7ce68ffdb00532
parentd3d13329d98b2b26378813a91ad0d4e49045a426 (diff)
downloadfork-ledger-887f429ae40934c145e03b03cc452e6af4457c0f.tar.gz
fork-ledger-887f429ae40934c145e03b03cc452e6af4457c0f.tar.bz2
fork-ledger-887f429ae40934c145e03b03cc452e6af4457c0f.zip
Added debug code for debugging interval reports
-rw-r--r--src/filters.cc22
-rw-r--r--src/filters.h31
-rw-r--r--src/times.cc11
3 files changed, 56 insertions, 8 deletions
diff --git a/src/filters.cc b/src/filters.cc
index f57f37e7..fbef1cd8 100644
--- a/src/filters.cc
+++ b/src/filters.cc
@@ -916,11 +916,24 @@ void interval_posts::report_subtotal(const date_interval_t& ival)
void interval_posts::operator()(post_t& post)
{
- if (! interval.find_period(post.date()))
+ DEBUG("filters.interval", "Considering post with amount " << post.amount);
+#if defined(DEBUG_ON)
+ DEBUG("filters.interval", "interval is:");
+ debug_interval(interval);
+#endif
+ if (! interval.find_period(post.date())) {
+ DEBUG("filters.interval", "Post does not fall within period");
return;
+ }
if (interval.duration) {
- if (last_interval && interval != last_interval) {
+ DEBUG("filters.interval", "There is an interval duration");
+ if (interval != last_interval) {
+#if defined(DEBUG_ON)
+ DEBUG("filters.interval", "interval != last_interval, so reporting");
+ DEBUG("filters.interval", "last_interval is:");
+ debug_interval(last_interval);
+#endif
report_subtotal(last_interval);
if (generate_empty_posts) {
@@ -942,13 +955,14 @@ void interval_posts::operator()(post_t& post)
}
assert(last_interval <= interval);
} else {
+ DEBUG("filters.interval", "Setting last_interval = interval");
last_interval = interval;
}
- } else {
- last_interval = interval;
}
+ DEBUG("filters.interval", "Calling subtotal_posts::operator()");
subtotal_posts::operator()(post);
} else {
+ DEBUG("filters.interval", "There is no interval duration");
item_handler<post_t>::operator()(post);
}
diff --git a/src/filters.h b/src/filters.h
index d207d842..2e51c91c 100644
--- a/src/filters.h
+++ b/src/filters.h
@@ -728,21 +728,44 @@ public:
empty_account = &temps.create_account(_("<None>"));
}
- void report_subtotal(const date_interval_t& interval);
+ void report_subtotal(const date_interval_t& ival);
+
+#if defined(DEBUG_ON)
+ void debug_interval(const date_interval_t& ival) {
+ if (ival.start)
+ DEBUG("filters.interval", "start = " << *ival.start);
+ else
+ DEBUG("filters.interval", "no start");
+
+ if (ival.finish)
+ DEBUG("filters.interval", "finish = " << *ival.finish);
+ else
+ DEBUG("filters.interval", "no finish");
+ }
+#endif
virtual void flush() {
if (last_post && interval.duration) {
- if (last_interval && interval != last_interval)
+ DEBUG("filters.interval", "There is a last_post and an interval.duration");
+ if (interval != last_interval) {
+#if defined(DEBUG_ON)
+ DEBUG("filters.interval", "interval != last_interval, so reporting");
+ DEBUG("filters.interval", "interval is:");
+ debug_interval(interval);
+ DEBUG("filters.interval", "last_interval is:");
+ debug_interval(last_interval);
+#endif
report_subtotal(last_interval);
+ }
subtotal_posts::flush();
}
}
virtual void operator()(post_t& post);
virtual void clear() {
- interval = start_interval;
+ interval = start_interval;
last_interval = date_interval_t();
- last_post = NULL;
+ last_post = NULL;
subtotal_posts::clear();
create_accounts();
diff --git a/src/times.cc b/src/times.cc
index 0384edf6..dd10a508 100644
--- a/src/times.cc
+++ b/src/times.cc
@@ -1397,8 +1397,17 @@ bool date_interval_t::find_period(const date_t& date)
DEBUG("times.interval", "date = " << date);
DEBUG("times.interval", "scan = " << scan);
DEBUG("times.interval", "end_of_scan = " << end_of_scan);
+#if defined(DEBUG_ON)
+ if (finish)
+ DEBUG("times.interval", "finish = " << *finish);
+ else
+ DEBUG("times.interval", "finish is not set");
+#endif
while (date >= scan && (! finish || scan < *finish)) {
+ DEBUG("times.interval", "date = " << date);
+ DEBUG("times.interval", "end_of_scan = " << end_of_scan);
+
if (date < end_of_scan) {
start = scan;
end_of_duration = end_of_scan;
@@ -1416,6 +1425,8 @@ bool date_interval_t::find_period(const date_t& date)
end_of_scan = duration->add(scan);
}
+ DEBUG("times.interval", "false: failed scan");
+
return false;
}