diff options
author | John Wiegley <johnw@newartisans.com> | 2009-02-15 20:45:09 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-02-15 20:45:09 -0400 |
commit | 5d4ac679201fd45f7a780ca1b7920682db69d62e (patch) | |
tree | 781c09e574ae64982d05b1f4597a4fb99bf2b461 /src | |
parent | cb6b6e8b67f5c4abbfc0f8c2b538815ebc841c73 (diff) | |
download | fork-ledger-5d4ac679201fd45f7a780ca1b7920682db69d62e.tar.gz fork-ledger-5d4ac679201fd45f7a780ca1b7920682db69d62e.tar.bz2 fork-ledger-5d4ac679201fd45f7a780ca1b7920682db69d62e.zip |
chain_xact_handlers now always operators the same
Previously, account-wise reports used a subset of the total number of
transaction filters, but this could cause confusing results, and made
some reports immpossible (such as account-wise monthly averages).
Diffstat (limited to 'src')
-rw-r--r-- | src/chain.cc | 156 | ||||
-rw-r--r-- | src/chain.h | 7 | ||||
-rw-r--r-- | src/report.cc | 6 |
3 files changed, 81 insertions, 88 deletions
diff --git a/src/chain.cc b/src/chain.cc index b1749909..84f56761 100644 --- a/src/chain.cc +++ b/src/chain.cc @@ -36,89 +36,85 @@ namespace ledger { xact_handler_ptr chain_xact_handlers(report_t& report, - xact_handler_ptr base_handler, - const bool handle_individual_xacts) + xact_handler_ptr base_handler) { xact_handler_ptr handler(base_handler); - // format_xacts write each xact received to the output stream. - if (handle_individual_xacts) { - // truncate_entries cuts off a certain number of _entries_ from being - // displayed. It does not affect calculation. - if (report.HANDLED(head_) || report.HANDLED(tail_)) - handler.reset(new truncate_entries(handler, - report.HANDLER(head_).value.to_long(), - report.HANDLER(tail_).value.to_long())); - - // filter_xacts will only pass through xacts matching the - // `display_predicate'. - if (report.HANDLED(display_)) - handler.reset(new filter_xacts - (handler, item_predicate<xact_t>(report.HANDLER(display_).str(), - report.what_to_keep()))); - - // calc_xacts computes the running total. When this appears will - // determine, for example, whether filtered xacts are included or excluded - // from the running total. - assert(report.HANDLED(amount_)); - expr_t& expr(report.HANDLER(amount_).expr); - expr.set_context(&report); - handler.reset(new calc_xacts(handler, expr)); - - // filter_xacts will only pass through xacts matching the - // `secondary_predicate'. - if (report.HANDLED(only_)) - handler.reset(new filter_xacts - (handler, item_predicate<xact_t> - (report.HANDLER(only_).str(), report.what_to_keep()))); - - // sort_xacts will sort all the xacts it sees, based on the `sort_order' - // value expression. - if (report.HANDLED(sort_)) { - if (report.HANDLED(sort_entries_)) - handler.reset(new sort_entries(handler, report.HANDLER(sort_).str())); - else - handler.reset(new sort_xacts(handler, report.HANDLER(sort_).str())); - } - - // changed_value_xacts adds virtual xacts to the list to account for - // changes in market value of commodities, which otherwise would affect - // the running total unpredictably. - if (report.HANDLED(revalued)) - handler.reset(new changed_value_xacts(handler, - report.HANDLER(total_).expr, - report.HANDLED(revalued_only))); - - // collapse_xacts causes entries with multiple xacts to appear as entries - // with a subtotaled xact for each commodity used. - if (report.HANDLED(collapse)) - handler.reset(new collapse_xacts(handler, expr, - report.HANDLED(collapse_if_zero))); - - // subtotal_xacts combines all the xacts it receives into one subtotal - // entry, which has one xact for each commodity in each account. - // - // period_xacts is like subtotal_xacts, but it subtotals according to time - // periods rather than totalling everything. - // - // dow_xacts is like period_xacts, except that it reports all the xacts - // that fall on each subsequent day of the week. - if (report.HANDLED(subtotal)) - handler.reset(new subtotal_xacts(handler, expr)); - - if (report.HANDLED(dow)) - handler.reset(new dow_xacts(handler, expr)); - else if (report.HANDLED(by_payee)) - handler.reset(new by_payee_xacts(handler, expr)); - - // interval_xacts groups xacts together based on a time period, such as - // weekly or monthly. - if (report.HANDLED(period_)) { - handler.reset(new interval_xacts(handler, expr, - report.HANDLER(period_).str(), - report.session.master.get())); - handler.reset(new sort_xacts(handler, "date")); - } + // truncate_entries cuts off a certain number of _entries_ from being + // displayed. It does not affect calculation. + if (report.HANDLED(head_) || report.HANDLED(tail_)) + handler.reset(new truncate_entries(handler, + report.HANDLER(head_).value.to_long(), + report.HANDLER(tail_).value.to_long())); + + // filter_xacts will only pass through xacts matching the + // `display_predicate'. + if (report.HANDLED(display_)) + handler.reset(new filter_xacts + (handler, item_predicate<xact_t>(report.HANDLER(display_).str(), + report.what_to_keep()))); + + // calc_xacts computes the running total. When this appears will + // determine, for example, whether filtered xacts are included or excluded + // from the running total. + assert(report.HANDLED(amount_)); + expr_t& expr(report.HANDLER(amount_).expr); + expr.set_context(&report); + handler.reset(new calc_xacts(handler, expr)); + + // filter_xacts will only pass through xacts matching the + // `secondary_predicate'. + if (report.HANDLED(only_)) + handler.reset(new filter_xacts + (handler, item_predicate<xact_t> + (report.HANDLER(only_).str(), report.what_to_keep()))); + + // sort_xacts will sort all the xacts it sees, based on the `sort_order' + // value expression. + if (report.HANDLED(sort_)) { + if (report.HANDLED(sort_entries_)) + handler.reset(new sort_entries(handler, report.HANDLER(sort_).str())); + else + handler.reset(new sort_xacts(handler, report.HANDLER(sort_).str())); + } + + // changed_value_xacts adds virtual xacts to the list to account for + // changes in market value of commodities, which otherwise would affect + // the running total unpredictably. + if (report.HANDLED(revalued)) + handler.reset(new changed_value_xacts(handler, + report.HANDLER(total_).expr, + report.HANDLED(revalued_only))); + + // collapse_xacts causes entries with multiple xacts to appear as entries + // with a subtotaled xact for each commodity used. + if (report.HANDLED(collapse)) + handler.reset(new collapse_xacts(handler, expr, + report.HANDLED(collapse_if_zero))); + + // subtotal_xacts combines all the xacts it receives into one subtotal + // entry, which has one xact for each commodity in each account. + // + // period_xacts is like subtotal_xacts, but it subtotals according to time + // periods rather than totalling everything. + // + // dow_xacts is like period_xacts, except that it reports all the xacts + // that fall on each subsequent day of the week. + if (report.HANDLED(subtotal)) + handler.reset(new subtotal_xacts(handler, expr)); + + if (report.HANDLED(dow)) + handler.reset(new dow_xacts(handler, expr)); + else if (report.HANDLED(by_payee)) + handler.reset(new by_payee_xacts(handler, expr)); + + // interval_xacts groups xacts together based on a time period, such as + // weekly or monthly. + if (report.HANDLED(period_)) { + handler.reset(new interval_xacts(handler, expr, + report.HANDLER(period_).str(), + report.session.master.get())); + handler.reset(new sort_xacts(handler, "date")); } // invert_xacts inverts the value of the xacts it receives. diff --git a/src/chain.h b/src/chain.h index c6de088f..f976ea3c 100644 --- a/src/chain.h +++ b/src/chain.h @@ -88,11 +88,8 @@ typedef shared_ptr<item_handler<xact_t> > xact_handler_ptr; typedef shared_ptr<item_handler<account_t> > acct_handler_ptr; class report_t; - -xact_handler_ptr -chain_xact_handlers(report_t& report, - xact_handler_ptr base_handler, - const bool handle_individual_xacts = true); +xact_handler_ptr chain_xact_handlers(report_t& report, + xact_handler_ptr base_handler); } // namespace ledger diff --git a/src/report.cc b/src/report.cc index 933ff306..2f60a6ba 100644 --- a/src/report.cc +++ b/src/report.cc @@ -113,9 +113,9 @@ void report_t::sum_all_accounts() expr.set_context(this); journal_xacts_iterator walker(*session.journal.get()); - pass_down_xacts - (chain_xact_handlers(*this, xact_handler_ptr(new set_account_value(expr)), - false), walker); + pass_down_xacts(chain_xact_handlers + (*this, xact_handler_ptr(new set_account_value(expr))), + walker); expr.mark_uncompiled(); // recompile, throw away xact_t bindings session.master->calculate_sums(expr); |