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.
This commit is contained in:
parent
ee5e0600aa
commit
50f434a5e3
1 changed files with 16 additions and 0 deletions
|
|
@ -488,7 +488,23 @@ void interval_xacts::operator()(xact_t& xact)
|
||||||
while (date >= (temp = interval.increment(quant))) {
|
while (date >= (temp = interval.increment(quant))) {
|
||||||
if (quant == temp)
|
if (quant == temp)
|
||||||
break;
|
break;
|
||||||
|
interval.begin = quant;
|
||||||
quant = temp;
|
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;
|
start = interval.begin = quant;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue