diff options
author | John Wiegley <johnw@newartisans.com> | 2009-02-15 19:24:17 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-02-15 19:24:17 -0400 |
commit | dfee8bc691cb4e5caad0c8855a35b982ff6c8a85 (patch) | |
tree | 1ca0c1ec96e1ce4cf1aa2434eaf1c0ea37545367 /src/account.cc | |
parent | c1fd59666e4197c7cfc332fc87e72196c1f51c4c (diff) | |
download | fork-ledger-dfee8bc691cb4e5caad0c8855a35b982ff6c8a85.tar.gz fork-ledger-dfee8bc691cb4e5caad0c8855a35b982ff6c8a85.tar.bz2 fork-ledger-dfee8bc691cb4e5caad0c8855a35b982ff6c8a85.zip |
Added 'count' and 'subcount' props for accounts
Diffstat (limited to 'src/account.cc')
-rw-r--r-- | src/account.cc | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/account.cc b/src/account.cc index 104d0cee..38a3eae8 100644 --- a/src/account.cc +++ b/src/account.cc @@ -161,6 +161,16 @@ namespace { return account.xdata_->total; } + value_t get_count(account_t& account) { + assert(account.xdata_); + return account.xdata_->total_count; + } + + value_t get_subcount(account_t& account) { + assert(account.xdata_); + return account.xdata_->count; + } + value_t get_amount(account_t& account) { assert(account.xdata_); return account.xdata_->value; @@ -196,6 +206,11 @@ expr_t::ptr_op_t account_t::lookup(const string& name) return WRAP_FUNCTOR(get_wrapper<&get_amount>); break; + case 'c': + if (name == "count") + return WRAP_FUNCTOR(get_wrapper<&get_count>); + break; + case 'd': if (name == "depth") return WRAP_FUNCTOR(get_wrapper<&get_depth>); @@ -208,6 +223,11 @@ expr_t::ptr_op_t account_t::lookup(const string& name) return WRAP_FUNCTOR(get_wrapper<&get_partial_name>); break; + case 's': + if (name == "subcount") + return WRAP_FUNCTOR(get_wrapper<&get_subcount>); + break; + case 't': if (name == "total") return WRAP_FUNCTOR(get_wrapper<&get_total>); @@ -249,7 +269,7 @@ void account_t::calculate_sums(expr_t& amount_expr) xdata_t& child_xd((*pair.second).xdata()); if (! child_xd.total.is_null()) { add_or_set_value(xd.total, child_xd.total); - xd.total_count += child_xd.total_count + child_xd.count; + xd.total_count += child_xd.total_count; } else { assert(child_xd.total_count == 0); assert(child_xd.count == 0); |