diff options
-rw-r--r-- | src/chain.cc | 3 | ||||
-rw-r--r-- | src/filters.cc | 6 | ||||
-rw-r--r-- | src/filters.h | 9 | ||||
-rw-r--r-- | src/report.h | 1 |
4 files changed, 13 insertions, 6 deletions
diff --git a/src/chain.cc b/src/chain.cc index 964e3aea..4c33b4de 100644 --- a/src/chain.cc +++ b/src/chain.cc @@ -60,7 +60,8 @@ xact_handler_ptr chain_xact_handlers(report_t& report, // 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)); + assert(report.HANDLED(amount_)); + handler.reset(new calc_xacts(handler, report.HANDLER(amount_).expr)); // filter_xacts will only pass through xacts matching the // `secondary_predicate'. diff --git a/src/filters.cc b/src/filters.cc index b19c36f1..4f49718b 100644 --- a/src/filters.cc +++ b/src/filters.cc @@ -190,8 +190,10 @@ void calc_xacts::operator()(xact_t& xact) if (last_xact && last_xact->has_xdata()) add_or_set_value(xdata.total, last_xact->xdata().total); - if (! xdata.has_flags(XACT_EXT_NO_TOTAL)) - xact.add_to_value(xdata.total); + if (! xdata.has_flags(XACT_EXT_NO_TOTAL)) { + bind_scope_t bound_scope(*amount_expr.get_context(), xact); + xdata.total += amount_expr.calc(); + } item_handler<xact_t>::operator()(xact); diff --git a/src/filters.h b/src/filters.h index 97584b0a..06698a22 100644 --- a/src/filters.h +++ b/src/filters.h @@ -327,13 +327,16 @@ public: class calc_xacts : public item_handler<xact_t> { xact_t * last_xact; + expr_t& amount_expr; calc_xacts(); public: - calc_xacts(xact_handler_ptr handler) - : item_handler<xact_t>(handler), last_xact(NULL) { - TRACE_CTOR(calc_xacts, "xact_handler_ptr"); + calc_xacts(xact_handler_ptr handler, + expr_t& _amount_expr) + : item_handler<xact_t>(handler), + last_xact(NULL), amount_expr(_amount_expr) { + TRACE_CTOR(calc_xacts, "xact_handler_ptr, expr_t&"); } virtual ~calc_xacts() { TRACE_DTOR(calc_xacts); diff --git a/src/report.h b/src/report.h index 418ac0e2..ce1ab9dd 100644 --- a/src/report.h +++ b/src/report.h @@ -189,6 +189,7 @@ public: } DO_(args) { expr = args[0].to_string(); + expr.set_context(parent); }); OPTION(report_t, amount_data); // -j |