summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/account.h7
-rw-r--r--src/filters.cc29
-rw-r--r--src/filters.h6
3 files changed, 23 insertions, 19 deletions
diff --git a/src/account.h b/src/account.h
index d0516e78..dd7ac3d6 100644
--- a/src/account.h
+++ b/src/account.h
@@ -123,9 +123,10 @@ class account_t : public scope_t
#define ACCOUNT_EXT_SORT_CALC 0x01
#define ACCOUNT_EXT_HAS_NON_VIRTUALS 0x02
#define ACCOUNT_EXT_HAS_UNB_VIRTUALS 0x04
-#define ACCOUNT_EXT_VISITED 0x08
-#define ACCOUNT_EXT_MATCHING 0x10
-#define ACCOUNT_EXT_DISPLAYED 0x20
+#define ACCOUNT_EXT_AUTO_VIRTUALIZE 0x08
+#define ACCOUNT_EXT_VISITED 0x10
+#define ACCOUNT_EXT_MATCHING 0x20
+#define ACCOUNT_EXT_DISPLAYED 0x40
struct details_t
{
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))
diff --git a/src/filters.h b/src/filters.h
index eb93e50a..69dd9ac7 100644
--- a/src/filters.h
+++ b/src/filters.h
@@ -342,16 +342,16 @@ class calc_posts : public item_handler<post_t>
{
post_t * last_post;
expr_t& amount_expr;
- bool calc_totals;
+ bool account_wise;
calc_posts();
public:
calc_posts(post_handler_ptr handler,
expr_t& _amount_expr,
- bool _calc_totals = false)
+ bool _account_wise = false)
: item_handler<post_t>(handler), last_post(NULL),
- amount_expr(_amount_expr), calc_totals(_calc_totals) {
+ amount_expr(_amount_expr), account_wise(_account_wise) {
TRACE_CTOR(calc_posts, "post_handler_ptr, expr_t&, bool");
}
virtual ~calc_posts() {