diff options
author | John Wiegley <johnw@newartisans.com> | 2009-02-17 05:22:59 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-02-17 05:22:59 -0400 |
commit | e1c37aeee857d5da11881addfa7ec63981b44d94 (patch) | |
tree | 064a1837ee190266e6935c76ad1e992d2b2a2e7b /src/chain.cc | |
parent | 6afd2b39cf4be54c86a69a64b741396e14b5607a (diff) | |
download | fork-ledger-e1c37aeee857d5da11881addfa7ec63981b44d94.tar.gz fork-ledger-e1c37aeee857d5da11881addfa7ec63981b44d94.tar.bz2 fork-ledger-e1c37aeee857d5da11881addfa7ec63981b44d94.zip |
Improved the --collapse filter
It now takes the --display and --only predicates into account, so that
it never appears to be collapsing single transactions.
There are cases where there are multiple transactions, but the display
or only predicate filters them out, so that if collapse didn't consider
this, the user would wonder why a single transaction was being collapsed
-- since they'd never see that collapse saw more than two.
Diffstat (limited to 'src/chain.cc')
-rw-r--r-- | src/chain.cc | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/chain.cc b/src/chain.cc index 1d24aafb..c5891f3a 100644 --- a/src/chain.cc +++ b/src/chain.cc @@ -40,6 +40,8 @@ xact_handler_ptr chain_xact_handlers(report_t& report, bool only_preliminaries) { xact_handler_ptr handler(base_handler); + item_predicate display_predicate; + item_predicate only_predicate; assert(report.HANDLED(amount_)); expr_t& expr(report.HANDLER(amount_).expr); @@ -58,11 +60,11 @@ xact_handler_ptr chain_xact_handlers(report_t& report, // filter_xacts will only pass through xacts matching the // `display_predicate'. - if (report.HANDLED(display_)) - handler.reset(new filter_xacts - (handler, item_predicate(report.HANDLER(display_).str(), - report.what_to_keep()), - report)); + if (report.HANDLED(display_)) { + display_predicate = item_predicate(report.HANDLER(display_).str(), + report.what_to_keep()); + handler.reset(new filter_xacts(handler, display_predicate, report)); + } // calc_xacts computes the running total. When this appears will // determine, for example, whether filtered xacts are included or excluded @@ -72,11 +74,11 @@ xact_handler_ptr chain_xact_handlers(report_t& report, // filter_xacts will only pass through xacts matching the // `secondary_predicate'. - if (report.HANDLED(only_)) - handler.reset(new filter_xacts - (handler, item_predicate(report.HANDLER(only_).str(), - report.what_to_keep()), - report)); + if (report.HANDLED(only_)) { + only_predicate = item_predicate(report.HANDLER(only_).str(), + report.what_to_keep()); + handler.reset(new filter_xacts(handler, only_predicate, report)); + } // sort_xacts will sort all the xacts it sees, based on the `sort_order' // value expression. @@ -100,6 +102,7 @@ xact_handler_ptr chain_xact_handlers(report_t& report, // with a subtotaled xact for each commodity used. if (report.HANDLED(collapse)) handler.reset(new collapse_xacts(handler, expr, + display_predicate, only_predicate, report.HANDLED(collapse_if_zero))); } |