summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-02-14 05:55:09 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-02-14 05:55:09 -0400
commit50f434a5e341e69edadae2929b53414b2d4de9f2 (patch)
tree6511236db109e2cca07d48503a67360d79795280
parentee5e0600aaa63859b9452d981ea9dd29b581b216 (diff)
downloadfork-ledger-50f434a5e341e69edadae2929b53414b2d4de9f2.tar.gz
fork-ledger-50f434a5e341e69edadae2929b53414b2d4de9f2.tar.bz2
fork-ledger-50f434a5e341e69edadae2929b53414b2d4de9f2.zip
Generate null transactions for empty periods
For example, if one uses -M to generate a monthly report for an entire year, and there are no transaction in the month of February, ordinarily Ledger would report nothing for that month, even if -E were used. Now "null transactions" are generated for periods without any activity, in order to make certain reports -- such as running monthly averages -- more accurate. For example, instead of -MA being just a monthly running average of months with activity, it is now a true average among all months during the reported period.
-rw-r--r--src/filters.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/filters.cc b/src/filters.cc
index d5c8f177..ca6397a8 100644
--- a/src/filters.cc
+++ b/src/filters.cc
@@ -488,7 +488,23 @@ void interval_xacts::operator()(xact_t& xact)
while (date >= (temp = interval.increment(quant))) {
if (quant == temp)
break;
+ interval.begin = quant;
quant = temp;
+
+ // Generate a null transaction, so the intervening periods can be seen
+ // when -E is used, or if the calculated amount ends up being non-zero
+ account_t empty_account(NULL, "<Empty>");
+ entry_t null_entry;
+ null_entry.add_flags(ITEM_TEMP);
+ null_entry._date = quant;
+ xact_t null_xact(&empty_account);
+ null_xact.add_flags(ITEM_TEMP);
+ null_xact.amount = 0L;
+ null_entry.add_xact(&null_xact);
+
+ last_xact = &null_xact;
+ subtotal_xacts::operator()(null_xact);
+ report_subtotal(quant);
}
start = interval.begin = quant;
}