diff options
author | johannes@debussy <johannes@debussy> | 2013-11-05 14:56:13 +0100 |
---|---|---|
committer | johannes@debussy <johannes@debussy> | 2013-11-05 14:56:13 +0100 |
commit | 71f1adad647d5ec4f2e69970543758d7f49f1340 (patch) | |
tree | 0dfe887b2bc7b6406755852059ea9c7a7c463c3a /src/filters.cc | |
parent | 973659d9a1f8679ab67144660915cad015ea633a (diff) | |
download | fork-ledger-71f1adad647d5ec4f2e69970543758d7f49f1340.tar.gz fork-ledger-71f1adad647d5ec4f2e69970543758d7f49f1340.tar.bz2 fork-ledger-71f1adad647d5ec4f2e69970543758d7f49f1340.zip |
first try for implementing --depth for register
Diffstat (limited to 'src/filters.cc')
-rw-r--r-- | src/filters.cc | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/src/filters.cc b/src/filters.cc index fadd5b5a..02f0e79b 100644 --- a/src/filters.cc +++ b/src/filters.cc @@ -449,13 +449,16 @@ void collapse_posts::report_subtotal() DEBUG("filters.collapse", "earliest date = " << earliest_date); DEBUG("filters.collapse", "latest date = " << latest_date); - handle_value(/* value= */ subtotal, - /* account= */ totals_account, - /* xact= */ &xact, - /* temps= */ temps, - /* handler= */ handler, - /* date= */ latest_date, - /* act_date_p= */ false); + foreach (post_t * post, component_posts) { + handle_value(/* value= */ subtotal, + /* account= */ find_totals_account(post->account), + /* xact= */ &xact, + /* temps= */ temps, + /* handler= */ handler, + /* date= */ latest_date, + /* act_date_p= */ false); + } + } component_posts.clear(); @@ -466,6 +469,21 @@ void collapse_posts::report_subtotal() count = 0; } +account_t* collapse_posts::find_totals_account(account_t* account) +{ + unsigned short depth=2; + if(account->depth==depth) + { + string name=account->fullname(); + account_t*& acc = totals_accounts[name]; + if(acc==NULL) + acc= &temps.create_account(name); + return acc; + } + //recurse + return find_totals_account(account->parent); +} + void collapse_posts::operator()(post_t& post) { // If we've reached a new xact, report on the subtotal |