summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/account.cc12
-rw-r--r--src/account.h29
-rw-r--r--src/filters.cc18
-rw-r--r--src/output.cc6
-rw-r--r--src/post.cc4
-rw-r--r--src/textual.cc9
-rw-r--r--src/xact.cc6
7 files changed, 49 insertions, 35 deletions
diff --git a/src/account.cc b/src/account.cc
index 3e39045f..56555d61 100644
--- a/src/account.cc
+++ b/src/account.cc
@@ -167,32 +167,32 @@ namespace {
}
value_t get_total(account_t& account) {
- if (! account.xdata_ || account.xdata_->total.is_null())
+ if (! account.xdata_ || account.xdata_->family_details.total.is_null())
return 0L;
else
- return account.xdata_->total;
+ return account.xdata_->family_details.total;
}
value_t get_count(account_t& account) {
if (account.xdata_)
- return long(account.xdata_->total_count);
+ return long(account.xdata_->family_details.posts_count);
else
return 0L;
}
value_t get_subcount(account_t& account) {
if (account.xdata_)
- return long(account.xdata_->count);
+ return long(account.xdata_->self_details.posts_count);
else
return 0L;
}
value_t get_amount(account_t& account) {
if (! account.xdata_ ||
- account.xdata_->value.is_null())
+ account.xdata_->self_details.total.is_null())
return 0L;
else
- return account.xdata_->value;
+ return account.xdata_->self_details.total;
}
value_t get_depth(account_t& account) {
diff --git a/src/account.h b/src/account.h
index 79c989bc..bc635829 100644
--- a/src/account.h
+++ b/src/account.h
@@ -128,26 +128,31 @@ class account_t : public scope_t
#define ACCOUNT_EXT_MATCHING 0x10
#define ACCOUNT_EXT_DISPLAYED 0x20
- value_t value;
- value_t total;
- std::size_t count; // posts counted toward amount
- std::size_t total_count; // posts counted toward total
- std::size_t virtuals;
- std::size_t total_virtuals;
+ struct details_t
+ {
+ value_t total;
+
+ std::size_t posts_count;
+ std::size_t posts_virtuals_count;
+
+ details_t()
+ : posts_count(0),
+ posts_virtuals_count(0) {}
+ };
+
+ details_t self_details;
+ details_t family_details;
std::list<sort_value_t> sort_values;
- xdata_t() : supports_flags<>(), count(0), total_count(0), virtuals(0)
+ xdata_t() : supports_flags<>()
{
TRACE_CTOR(account_t::xdata_t, "");
}
xdata_t(const xdata_t& other)
: supports_flags<>(other.flags()),
- value(other.value),
- total(other.total),
- count(other.count),
- total_count(other.total_count),
- virtuals(other.virtuals),
+ self_details(other.self_details),
+ family_details(other.family_details),
sort_values(other.sort_values)
{
TRACE_CTOR(account_t::xdata_t, "copy");
diff --git a/src/filters.cc b/src/filters.cc
index bdcd1b67..36219b0d 100644
--- a/src/filters.cc
+++ b/src/filters.cc
@@ -200,25 +200,29 @@ void calc_posts::operator()(post_t& post)
xdata.count = 1;
}
- post.add_to_value(xdata.total, amount_expr);
+ value_t amount;
+ post.add_to_value(amount, amount_expr);
+
+ add_or_set_value(xdata.total, amount);
if (calc_totals) {
account_t * acct = post.reported_account();
account_t::xdata_t * acct_xdata = &acct->xdata();
- post.add_to_value(acct_xdata->value, amount_expr);
+ add_or_set_value(acct_xdata->self_details.total, amount);
+
+ acct_xdata->self_details.posts_count++;
+ acct_xdata->self_details.posts_virtuals_count++;
- acct_xdata->count++;
- acct_xdata->virtuals++;
acct_xdata->add_flags(ACCOUNT_EXT_VISITED);
while (true) {
- post.add_to_value(acct_xdata->total, amount_expr);
+ add_or_set_value(acct_xdata->family_details.total, amount);
+ acct_xdata->family_details.posts_count++;
- acct_xdata->total_count++;
if (post.has_flags(POST_VIRTUAL))
- acct_xdata->total_virtuals++;
+ acct_xdata->family_details.posts_virtuals_count++;
acct = acct->parent;
if (acct)
diff --git a/src/output.cc b/src/output.cc
index e14c75dc..b559f253 100644
--- a/src/output.cc
+++ b/src/output.cc
@@ -290,8 +290,10 @@ void format_accounts::flush()
if (report.session.master->has_xdata()) {
account_t::xdata_t& xdata(report.session.master->xdata());
- if (! report.HANDLED(no_total) && top_displayed > 1 && xdata.total) {
- xdata.value = xdata.total;
+ if (! report.HANDLED(no_total) && top_displayed > 1 &&
+ xdata.family_details.total) {
+ xdata.self_details.total = xdata.family_details.total;
+
bind_scope_t bound_scope(report, *report.session.master);
separator_format.format(out, bound_scope);
total_line_format.format(out, bound_scope);
diff --git a/src/post.cc b/src/post.cc
index 79add9b9..92fe84d1 100644
--- a/src/post.cc
+++ b/src/post.cc
@@ -232,10 +232,10 @@ namespace {
DEBUG("post.account_amount", "Found account: " << account->fullname());
- if (account->xdata().value.is_null())
+ if (account->xdata().self_details.total.is_null())
return 0L;
else
- return account->xdata().value.simplified();
+ return account->xdata().self_details.total.simplified();
}
value_t get_account_depth(post_t& post) {
diff --git a/src/textual.cc b/src/textual.cc
index 901c5759..20dbda96 100644
--- a/src/textual.cc
+++ b/src/textual.cc
@@ -1013,20 +1013,21 @@ post_t * instance_t::parse_post(char * line,
amount_t& amt(*post->assigned_amount);
DEBUG("post.assign", "line " << linenum << ": "
- "account balance = " << xdata.value);
+ "account balance = " << xdata.self_details.total);
DEBUG("post.assign", "line " << linenum << ": "
"post amount = " << amt);
amount_t diff;
- switch (xdata.value.type()) {
+ switch (xdata.self_details.total.type()) {
case value_t::AMOUNT:
- diff = amt - xdata.value.as_amount();
+ diff = amt - xdata.self_details.total.as_amount();
break;
case value_t::BALANCE:
if (optional<amount_t> comm_bal =
- xdata.value.as_balance().commodity_amount(amt.commodity()))
+ xdata.self_details.total.as_balance()
+ .commodity_amount(amt.commodity()))
diff = amt - *comm_bal;
else
diff = amt;
diff --git a/src/xact.cc b/src/xact.cc
index 0e5914d1..8b834f53 100644
--- a/src/xact.cc
+++ b/src/xact.cc
@@ -317,11 +317,13 @@ bool xact_base_t::finalize()
post->amount.in_place_reduce();
- add_or_set_value(post->account->xdata().value, post->amount);
+ add_or_set_value(post->account->xdata().self_details.total,
+ post->amount);
DEBUG("xact.finalize.totals",
"Total for " << post->account->fullname() << " + "
- << post->amount << ": " << post->account->xdata().value);
+ << post->amount << ": "
+ << post->account->xdata().self_details.total);
} else {
some_null = true;
}