summaryrefslogtreecommitdiff
path: root/src/filters.cc
diff options
context:
space:
mode:
authorjohannes@debussy <johannes@debussy>2013-11-05 11:57:00 +0100
committerJohn Wiegley <johnw@newartisans.com>2020-07-21 14:50:01 -0700
commit5e10e0c94aa764e3933e19bd40b7cd35ff6d37f0 (patch)
tree1d3d22c3073d063226ca42d1014dccdb6b6f2044 /src/filters.cc
parent315d428f6a3b1965b10d2477cccc71f85548490c (diff)
downloadfork-ledger-5e10e0c94aa764e3933e19bd40b7cd35ff6d37f0.tar.gz
fork-ledger-5e10e0c94aa764e3933e19bd40b7cd35ff6d37f0.tar.bz2
fork-ledger-5e10e0c94aa764e3933e19bd40b7cd35ff6d37f0.zip
first try for implementing --depth for register
Diffstat (limited to 'src/filters.cc')
-rw-r--r--src/filters.cc33
1 files changed, 26 insertions, 7 deletions
diff --git a/src/filters.cc b/src/filters.cc
index 0bf89283..6b91aab4 100644
--- a/src/filters.cc
+++ b/src/filters.cc
@@ -449,15 +449,19 @@ 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 (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);
+ }
+
}
+ 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);