summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-02-15 22:55:29 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-02-15 22:57:23 -0400
commit14ffc2b31a38a7fdd25bd93fe21d17132b16062a (patch)
tree5188fc520c8bf3af25c7b6a266fb485dd0e0e2fb /src
parente32129b25cbea725208bb4212edb6caf1cf9bbf3 (diff)
downloadfork-ledger-14ffc2b31a38a7fdd25bd93fe21d17132b16062a.tar.gz
fork-ledger-14ffc2b31a38a7fdd25bd93fe21d17132b16062a.tar.bz2
fork-ledger-14ffc2b31a38a7fdd25bd93fe21d17132b16062a.zip
Don't apply all filters for account-wise reports
This creates its own problems; instead, only most are used.
Diffstat (limited to 'src')
-rw-r--r--src/chain.cc70
-rw-r--r--src/chain.h6
-rw-r--r--src/report.cc2
3 files changed, 43 insertions, 35 deletions
diff --git a/src/chain.cc b/src/chain.cc
index c8cbf673..62aac7b0 100644
--- a/src/chain.cc
+++ b/src/chain.cc
@@ -36,31 +36,35 @@
namespace ledger {
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);
- // 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_));
expr_t& expr(report.HANDLER(amount_).expr);
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
// `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()));
}
- // 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)));
+ if (! only_preliminaries) {
+ // 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.
diff --git a/src/chain.h b/src/chain.h
index f976ea3c..b064c4ed 100644
--- a/src/chain.h
+++ b/src/chain.h
@@ -88,8 +88,10 @@ 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);
+xact_handler_ptr
+chain_xact_handlers(report_t& report,
+ xact_handler_ptr base_handler,
+ bool only_preliminaries = false);
} // namespace ledger
diff --git a/src/report.cc b/src/report.cc
index 49623eda..343f0110 100644
--- a/src/report.cc
+++ b/src/report.cc
@@ -114,7 +114,7 @@ void report_t::sum_all_accounts()
journal_xacts_iterator walker(*session.journal.get());
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);
expr.mark_uncompiled(); // recompile, throw away xact_t bindings