summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-02-09 00:57:56 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-02-09 00:57:56 -0400
commit391300aea29a755e20a60774be662e4ebd361b66 (patch)
treec493107dd2ac3c2d3c6a90fe5149b591b106e537
parent90bba2a808fef9179c81d59eeb8b03a52e223de4 (diff)
downloadfork-ledger-391300aea29a755e20a60774be662e4ebd361b66.tar.gz
fork-ledger-391300aea29a755e20a60774be662e4ebd361b66.tar.bz2
fork-ledger-391300aea29a755e20a60774be662e4ebd361b66.zip
Had to step back from a change that was breaking regular reports.
-rw-r--r--src/chain.cc4
-rw-r--r--src/filters.cc9
-rw-r--r--src/report.h5
3 files changed, 15 insertions, 3 deletions
diff --git a/src/chain.cc b/src/chain.cc
index 4c33b4de..c953366a 100644
--- a/src/chain.cc
+++ b/src/chain.cc
@@ -61,7 +61,9 @@ xact_handler_ptr chain_xact_handlers(report_t& report,
// determine, for example, whether filtered xacts are included or excluded
// from the running total.
assert(report.HANDLED(amount_));
- handler.reset(new calc_xacts(handler, report.HANDLER(amount_).expr));
+ 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'.
diff --git a/src/filters.cc b/src/filters.cc
index 4f49718b..a88f21e8 100644
--- a/src/filters.cc
+++ b/src/filters.cc
@@ -191,8 +191,15 @@ void calc_xacts::operator()(xact_t& xact)
add_or_set_value(xdata.total, last_xact->xdata().total);
if (! xdata.has_flags(XACT_EXT_NO_TOTAL)) {
+#if 0
bind_scope_t bound_scope(*amount_expr.get_context(), xact);
- xdata.total += amount_expr.calc();
+ if (xdata.total.is_null())
+ xdata.total = amount_expr.calc();
+ else
+ xdata.total += amount_expr.calc();
+#else
+ xact.add_to_value(xdata.total);
+#endif
}
item_handler<xact_t>::operator()(xact);
diff --git a/src/report.h b/src/report.h
index ce1ab9dd..5e198e22 100644
--- a/src/report.h
+++ b/src/report.h
@@ -186,10 +186,10 @@ public:
expr_t expr;
CTOR(report_t, amount_) {
expr = "amount";
+ on("amount");
}
DO_(args) {
expr = args[0].to_string();
- expr.set_context(parent);
});
OPTION(report_t, amount_data); // -j
@@ -246,6 +246,7 @@ public:
expr_t expr;
CTOR(report_t, display_amount_) {
expr = "amount_expr";
+ on("amount_expr");
}
DO_(args) {
expr = args[0].to_string();
@@ -256,6 +257,7 @@ public:
expr_t expr;
CTOR(report_t, display_total_) {
expr = "total_expr";
+ on("total_expr");
}
DO_(args) {
expr = args[0].to_string();
@@ -367,6 +369,7 @@ public:
expr_t expr;
CTOR(report_t, total_) {
expr = "total";
+ on("total");
}
DO_(args) {
expr = args[0].to_string();