From 37a1989ca0b47308acee386f0976cb2da57eeedd Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Mon, 9 Feb 2009 15:07:28 -0400 Subject: Added a new --collapse-if-zero option. --- src/filters.cc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/filters.cc') 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::operator()(*last_xact); - } else { + } + else if (only_collapse_if_zero && ! subtotal.is_zero()) { + foreach (xact_t * xact, component_xacts) + item_handler::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; } -- cgit v1.2.3