Don't apply all filters for account-wise reports
This creates its own problems; instead, only most are used.
This commit is contained in:
parent
e32129b25c
commit
14ffc2b31a
3 changed files with 42 additions and 34 deletions
68
src/chain.cc
68
src/chain.cc
|
|
@ -36,31 +36,35 @@
|
||||||
namespace ledger {
|
namespace ledger {
|
||||||
|
|
||||||
xact_handler_ptr chain_xact_handlers(report_t& report,
|
xact_handler_ptr chain_xact_handlers(report_t& report,
|
||||||
xact_handler_ptr base_handler)
|
xact_handler_ptr base_handler,
|
||||||
|
bool only_preliminaries)
|
||||||
{
|
{
|
||||||
xact_handler_ptr handler(base_handler);
|
xact_handler_ptr handler(base_handler);
|
||||||
|
|
||||||
// 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(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_));
|
assert(report.HANDLED(amount_));
|
||||||
expr_t& expr(report.HANDLER(amount_).expr);
|
expr_t& expr(report.HANDLER(amount_).expr);
|
||||||
expr.set_context(&report);
|
expr.set_context(&report);
|
||||||
handler.reset(new calc_xacts(handler, expr));
|
|
||||||
|
if (! only_preliminaries) {
|
||||||
|
// 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(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.
|
||||||
|
handler.reset(new calc_xacts(handler, expr));
|
||||||
|
}
|
||||||
|
|
||||||
// filter_xacts will only pass through xacts matching the
|
// filter_xacts will only pass through xacts matching the
|
||||||
// `secondary_predicate'.
|
// `secondary_predicate'.
|
||||||
|
|
@ -78,19 +82,21 @@ xact_handler_ptr chain_xact_handlers(report_t& report,
|
||||||
handler.reset(new sort_xacts(handler, report.HANDLER(sort_).str()));
|
handler.reset(new sort_xacts(handler, report.HANDLER(sort_).str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// changed_value_xacts adds virtual xacts to the list to account for
|
if (! only_preliminaries) {
|
||||||
// changes in market value of commodities, which otherwise would affect
|
// changed_value_xacts adds virtual xacts to the list to account for
|
||||||
// the running total unpredictably.
|
// changes in market value of commodities, which otherwise would affect
|
||||||
if (report.HANDLED(revalued))
|
// the running total unpredictably.
|
||||||
handler.reset(new changed_value_xacts(handler,
|
if (report.HANDLED(revalued))
|
||||||
report.HANDLER(total_).expr,
|
handler.reset(new changed_value_xacts(handler,
|
||||||
report.HANDLED(revalued_only)));
|
report.HANDLER(total_).expr,
|
||||||
|
report.HANDLED(revalued_only)));
|
||||||
|
|
||||||
// collapse_xacts causes entries with multiple xacts to appear as entries
|
// collapse_xacts causes entries with multiple xacts to appear as entries
|
||||||
// with a subtotaled xact for each commodity used.
|
// with a subtotaled xact for each commodity used.
|
||||||
if (report.HANDLED(collapse))
|
if (report.HANDLED(collapse))
|
||||||
handler.reset(new collapse_xacts(handler, expr,
|
handler.reset(new collapse_xacts(handler, expr,
|
||||||
report.HANDLED(collapse_if_zero)));
|
report.HANDLED(collapse_if_zero)));
|
||||||
|
}
|
||||||
|
|
||||||
// subtotal_xacts combines all the xacts it receives into one subtotal
|
// subtotal_xacts combines all the xacts it receives into one subtotal
|
||||||
// entry, which has one xact for each commodity in each account.
|
// entry, which has one xact for each commodity in each account.
|
||||||
|
|
|
||||||
|
|
@ -88,8 +88,10 @@ typedef shared_ptr<item_handler<xact_t> > xact_handler_ptr;
|
||||||
typedef shared_ptr<item_handler<account_t> > acct_handler_ptr;
|
typedef shared_ptr<item_handler<account_t> > acct_handler_ptr;
|
||||||
|
|
||||||
class report_t;
|
class report_t;
|
||||||
xact_handler_ptr chain_xact_handlers(report_t& report,
|
xact_handler_ptr
|
||||||
xact_handler_ptr base_handler);
|
chain_xact_handlers(report_t& report,
|
||||||
|
xact_handler_ptr base_handler,
|
||||||
|
bool only_preliminaries = false);
|
||||||
|
|
||||||
} // namespace ledger
|
} // namespace ledger
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ void report_t::sum_all_accounts()
|
||||||
|
|
||||||
journal_xacts_iterator walker(*session.journal.get());
|
journal_xacts_iterator walker(*session.journal.get());
|
||||||
pass_down_xacts(chain_xact_handlers
|
pass_down_xacts(chain_xact_handlers
|
||||||
(*this, xact_handler_ptr(new set_account_value(expr))),
|
(*this, xact_handler_ptr(new set_account_value(expr)), true),
|
||||||
walker);
|
walker);
|
||||||
|
|
||||||
expr.mark_uncompiled(); // recompile, throw away xact_t bindings
|
expr.mark_uncompiled(); // recompile, throw away xact_t bindings
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue