From 6ac79137f74a9257c0079f14cf3ef49e8da6375a Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 5 Mar 2009 23:53:07 -0400 Subject: Don't compute running total for balance reports --- src/filters.cc | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'src/filters.cc') diff --git a/src/filters.cc b/src/filters.cc index b66bafae..2895bf7f 100644 --- a/src/filters.cc +++ b/src/filters.cc @@ -194,33 +194,33 @@ void calc_posts::operator()(post_t& post) if (last_post) { assert(last_post->has_xdata()); - add_or_set_value(xdata.total, last_post->xdata().total); + if (! account_wise) + xdata.total = last_post->xdata().total; xdata.count = last_post->xdata().count + 1; } else { xdata.count = 1; } - value_t amount; - post.add_to_value(amount, amount_expr); + post.add_to_value(xdata.visited_value, amount_expr); + xdata.add_flags(POST_EXT_VISITED); - add_or_set_value(xdata.total, amount); - - if (calc_totals) { - account_t * acct = post.reported_account(); + account_t * acct = post.reported_account(); + acct->xdata().add_flags(ACCOUNT_EXT_VISITED); + if (! account_wise) { + add_or_set_value(xdata.total, xdata.visited_value); + } else { account_t::xdata_t * acct_xdata = &acct->xdata(); - add_or_set_value(acct_xdata->self_details.total, amount); + add_or_set_value(acct_xdata->self_details.total, xdata.visited_value); acct_xdata->self_details.posts_count++; acct_xdata->self_details.posts_virtuals_count++; - acct_xdata->add_flags(ACCOUNT_EXT_VISITED); - while (true) { - add_or_set_value(acct_xdata->family_details.total, amount); - acct_xdata->family_details.posts_count++; + add_or_set_value(acct_xdata->family_details.total, xdata.visited_value); + acct_xdata->family_details.posts_count++; if (post.has_flags(POST_VIRTUAL)) acct_xdata->family_details.posts_virtuals_count++; @@ -259,7 +259,8 @@ namespace { // If the account for this post is all virtual, then report the post as // such. This allows subtotal reports to show "(Account)" for accounts // that contain only virtual posts. - if (account && account->has_xdata()) { + if (account && account->has_xdata() && + account->xdata().has_flags(ACCOUNT_EXT_AUTO_VIRTUALIZE)) { if (! account->xdata().has_flags(ACCOUNT_EXT_HAS_NON_VIRTUALS)) { post.add_flags(POST_VIRTUAL); if (! account->xdata().has_flags(ACCOUNT_EXT_HAS_UNB_VIRTUALS)) @@ -567,6 +568,8 @@ void subtotal_posts::operator()(post_t& post) // such, so that `handle_value' can show "(Account)" for accounts // that contain only virtual posts. + post.reported_account()->xdata().add_flags(ACCOUNT_EXT_AUTO_VIRTUALIZE); + if (! post.has_flags(POST_VIRTUAL)) post.reported_account()->xdata().add_flags(ACCOUNT_EXT_HAS_NON_VIRTUALS); else if (! post.has_flags(POST_MUST_BALANCE)) -- cgit v1.2.3