summaryrefslogtreecommitdiff
path: root/src/filters.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-02-15 20:59:13 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-02-15 20:59:13 -0400
commitbfa6a643a1317515e10cca2170463f941e6d0f10 (patch)
treeefb252f89017778e84b0960be979528ad1a8a3ae /src/filters.cc
parent78e57ac4cfe60147051f0a04e82c19174a86f899 (diff)
downloadfork-ledger-bfa6a643a1317515e10cca2170463f941e6d0f10.tar.gz
fork-ledger-bfa6a643a1317515e10cca2170463f941e6d0f10.tar.bz2
fork-ledger-bfa6a643a1317515e10cca2170463f941e6d0f10.zip
Improved handling of --empty option
For example, in period reports null transactions are only generated for empty periods if --empty is used. Otherwise, the presence of such transactions can get confusing.
Diffstat (limited to 'src/filters.cc')
-rw-r--r--src/filters.cc48
1 files changed, 24 insertions, 24 deletions
diff --git a/src/filters.cc b/src/filters.cc
index fc924065..118e8c5e 100644
--- a/src/filters.cc
+++ b/src/filters.cc
@@ -476,28 +476,29 @@ void interval_xacts::operator()(xact_t& xact)
(is_valid(interval.end) && date >= interval.end))
return;
- if (interval) {
- if (! started) {
- if (! is_valid(interval.begin))
- interval.set_start(date);
- start = interval.begin;
- started = true;
- }
+ if (! started) {
+ if (! is_valid(interval.begin))
+ interval.set_start(date);
+ start = interval.begin;
+ started = true;
+ }
- date_t quant = interval.increment(interval.begin);
- if (date >= quant) {
- if (last_xact)
- report_subtotal(quant);
+ date_t quant = interval.increment(interval.begin);
+ if (date >= quant) {
+ if (last_xact)
+ report_subtotal(quant);
- date_t temp;
- while (date >= (temp = interval.increment(quant))) {
- if (quant == temp)
- break;
- interval.begin = quant;
- quant = temp;
+ date_t temp;
+ 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
+ if (generate_empty_xacts) {
+ // 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
entry_temps.push_back(entry_t());
entry_t& null_entry = entry_temps.back();
null_entry.add_flags(ITEM_TEMP);
@@ -511,16 +512,15 @@ void interval_xacts::operator()(xact_t& xact)
last_xact = &null_xact;
subtotal_xacts::operator()(null_xact);
+
report_subtotal(quant);
}
- start = interval.begin = quant;
}
-
- subtotal_xacts::operator()(xact);
- } else {
- item_handler<xact_t>::operator()(xact);
+ start = interval.begin = quant;
}
+ subtotal_xacts::operator()(xact);
+
last_xact = &xact;
}