diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/filters.cc | 7 | ||||
-rw-r--r-- | src/xact.cc | 7 | ||||
-rw-r--r-- | src/xact.h | 5 |
3 files changed, 17 insertions, 2 deletions
diff --git a/src/filters.cc b/src/filters.cc index f97e58d0..8d8589e4 100644 --- a/src/filters.cc +++ b/src/filters.cc @@ -186,8 +186,13 @@ void calc_xacts::operator()(xact_t& xact) try { xact_t::xdata_t& xdata(xact.xdata()); - if (last_xact && last_xact->has_xdata()) + if (last_xact) { + assert(last_xact->has_xdata()); add_or_set_value(xdata.total, last_xact->xdata().total); + xdata.count = last_xact->xdata().count + 1; + } else { + xdata.count = 1; + } xact.add_to_value(xdata.total, amount_expr); diff --git a/src/xact.cc b/src/xact.cc index 0e287962..b2337329 100644 --- a/src/xact.cc +++ b/src/xact.cc @@ -182,6 +182,11 @@ namespace { return xact.amount; } + value_t get_count(xact_t& xact) { + assert(xact.xdata_); + return xact.xdata_->count; + } + value_t get_account(call_scope_t& scope) { xact_t& xact(find_scope<xact_t>(scope)); @@ -231,6 +236,8 @@ expr_t::ptr_op_t xact_t::lookup(const string& name) return WRAP_FUNCTOR(get_wrapper<&get_code>); else if (name == "cost") return WRAP_FUNCTOR(get_wrapper<&get_cost>); + else if (name == "count") + return WRAP_FUNCTOR(get_wrapper<&get_count>); else if (name == "calculated") return WRAP_FUNCTOR(get_wrapper<&get_is_calculated>); break; @@ -140,6 +140,7 @@ public: #define XACT_EXT_MATCHES 0x80 value_t total; + std::size_t count; value_t value; date_t date; account_t * account; @@ -147,12 +148,14 @@ public: std::list<sort_value_t> sort_values; - xdata_t() : supports_flags<>(), account(NULL), ptr(NULL) { + xdata_t() + : supports_flags<>(), count(0), account(NULL), ptr(NULL) { TRACE_CTOR(xact_t::xdata_t, ""); } xdata_t(const xdata_t& other) : supports_flags<>(other.flags()), total(other.total), + count(other.count), value(other.value), date(other.date), account(other.account), |