summaryrefslogtreecommitdiff
path: root/src/filters.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-02-09 15:07:28 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-02-09 15:07:28 -0400
commit37a1989ca0b47308acee386f0976cb2da57eeedd (patch)
tree30ca37b88df705e979a722133bcf093a125da502 /src/filters.cc
parent11dc80b6184f7a48400a76ee226ef1c9be819145 (diff)
downloadfork-ledger-37a1989ca0b47308acee386f0976cb2da57eeedd.tar.gz
fork-ledger-37a1989ca0b47308acee386f0976cb2da57eeedd.tar.bz2
fork-ledger-37a1989ca0b47308acee386f0976cb2da57eeedd.zip
Added a new --collapse-if-zero option.
Diffstat (limited to 'src/filters.cc')
-rw-r--r--src/filters.cc14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/filters.cc b/src/filters.cc
index b33bd29b..8877812a 100644
--- a/src/filters.cc
+++ b/src/filters.cc
@@ -284,7 +284,16 @@ void collapse_xacts::report_subtotal()
if (count == 1) {
item_handler<xact_t>::operator()(*last_xact);
- } else {
+ }
+ else if (only_collapse_if_zero && ! subtotal.is_zero()) {
+ foreach (xact_t * xact, component_xacts)
+ item_handler<xact_t>::operator()(*xact);
+ component_xacts.clear();
+ }
+ else {
+ if (only_collapse_if_zero)
+ component_xacts.clear();
+
entry_temps.push_back(entry_t());
entry_t& entry = entry_temps.back();
entry.payee = last_entry->payee;
@@ -311,6 +320,9 @@ void collapse_xacts::operator()(xact_t& xact)
xact.add_to_value(subtotal, amount_expr);
count++;
+ if (only_collapse_if_zero)
+ component_xacts.push_back(&xact);
+
last_entry = xact.entry;
last_xact = &xact;
}