diff options
author | John Wiegley <johnw@newartisans.com> | 2015-08-04 14:23:44 -0700 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2015-08-04 14:23:44 -0700 |
commit | fbba9adc16c515632a5009d2ec88c9fcab532676 (patch) | |
tree | ba1175218f653b46fae7b978ae5d5dd4b91edf65 /src/filters.cc | |
parent | 00e4cdb008a21ded16efdac80a6249cfc316f71d (diff) | |
parent | 658029d39f8594c7f3bf75fb8f7ca9fb2081b473 (diff) | |
download | ledger-fbba9adc16c515632a5009d2ec88c9fcab532676.tar.gz ledger-fbba9adc16c515632a5009d2ec88c9fcab532676.tar.bz2 ledger-fbba9adc16c515632a5009d2ec88c9fcab532676.zip |
Merge pull request #216 from johannesgerer/master
--depth for register
Diffstat (limited to 'src/filters.cc')
-rw-r--r-- | src/filters.cc | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/src/filters.cc b/src/filters.cc index 2f97a0e5..fd30c966 100644 --- a/src/filters.cc +++ b/src/filters.cc @@ -448,16 +448,20 @@ void collapse_posts::report_subtotal() DEBUG("filters.collapse", "Pseudo-xact date = " << *xact._date); DEBUG("filters.collapse", "earliest date = " << earliest_date); DEBUG("filters.collapse", "latest date = " << latest_date); + + foreach (totals_map::value_type& pat, totals) { + handle_value(/* value= */ pat.second, + /* account= */ &temps.create_account(pat.first), + /* xact= */ &xact, + /* temps= */ temps, + /* handler= */ handler, + /* date= */ latest_date, + /* act_date_p= */ false); + } - handle_value(/* value= */ subtotal, - /* account= */ totals_account, - /* xact= */ &xact, - /* temps= */ temps, - /* handler= */ handler, - /* date= */ latest_date, - /* act_date_p= */ false); } + totals.clear(); component_posts.clear(); last_xact = NULL; @@ -466,6 +470,20 @@ void collapse_posts::report_subtotal() count = 0; } +value_t& collapse_posts::find_totals(account_t* account) +{ + unsigned short depth=3; + + if(depth==0) + return totals[_("<Total>")]; + + if(account->depth==depth) + return totals[account->fullname()]; + + //else recurse + return find_totals(account->parent); +} + void collapse_posts::operator()(post_t& post) { // If we've reached a new xact, report on the subtotal @@ -475,6 +493,7 @@ void collapse_posts::operator()(post_t& post) report_subtotal(); post.add_to_value(subtotal, amount_expr); + post.add_to_value(find_totals(post.account), amount_expr); component_posts.push_back(&post); |