summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/output.cc29
-rw-r--r--src/output.h4
-rw-r--r--test/baseline/opt-basis.test2
-rw-r--r--test/baseline/opt-cost.test2
-rw-r--r--test/baseline/opt-depth.test10
-rw-r--r--test/baseline/opt-depth_flat.test8
-rw-r--r--test/baseline/opt-empty_bal.test2
-rw-r--r--test/baseline/opt-empty_bal_flat.test2
-rw-r--r--test/baseline/opt-flat.test2
-rw-r--r--test/regress/55831A79.test2
10 files changed, 49 insertions, 14 deletions
diff --git a/src/output.cc b/src/output.cc
index 76d811a3..63d8c919 100644
--- a/src/output.cc
+++ b/src/output.cc
@@ -136,14 +136,22 @@ format_accounts::format_accounts(report_t& _report,
}
}
-void format_accounts::post_account(account_t& account)
+std::size_t format_accounts::post_account(account_t& account)
{
if (account.xdata().has_flags(ACCOUNT_EXT_TO_DISPLAY)) {
+ if (account.parent &&
+ account.parent->xdata().has_flags(ACCOUNT_EXT_TO_DISPLAY) &&
+ ! account.parent->xdata().has_flags(ACCOUNT_EXT_DISPLAYED))
+ post_account(*account.parent);
+
account.xdata().add_flags(ACCOUNT_EXT_DISPLAYED);
bind_scope_t bound_scope(report, account);
account_line_format.format(report.output_stream, bound_scope);
+
+ return 1;
}
+ return 0;
}
std::pair<std::size_t, std::size_t>
@@ -167,9 +175,11 @@ format_accounts::mark_accounts(account_t& account, const bool flat)
" it has " << to_display << " children to display");
#endif
- if (account.has_flags(ACCOUNT_EXT_VISITED) || (! flat && visited > 0)) {
+ if (account.parent &&
+ (account.has_flags(ACCOUNT_EXT_VISITED) || (! flat && visited > 0))) {
bind_scope_t bound_scope(report, account);
- if (disp_pred(bound_scope) && (flat || to_display != 1)) {
+ if ((! flat && to_display > 1) ||
+ (disp_pred(bound_scope) && (flat || to_display != 1))) {
account.xdata().add_flags(ACCOUNT_EXT_TO_DISPLAY);
DEBUG("account.display", "Marking account as TO_DISPLAY");
to_display = 1;
@@ -192,17 +202,12 @@ void format_accounts::flush()
mark_accounts(*report.session.master, report.HANDLED(flat));
- std::size_t top_displayed = 0;
+ std::size_t displayed = 0;
- foreach (account_t * account, posted_accounts) {
- post_account(*account);
-
- if (account->has_flags(ACCOUNT_EXT_DISPLAYED))
- top_displayed++;
- }
+ foreach (account_t * account, posted_accounts)
+ displayed += post_account(*account);
- if (! report.HANDLED(no_total) && top_displayed > 1 &&
- report.session.master->family_total()) {
+ if (! report.HANDLED(no_total) && displayed > 1) {
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/output.h b/src/output.h
index 00f7d38d..a35d81cd 100644
--- a/src/output.h
+++ b/src/output.h
@@ -109,8 +109,8 @@ public:
std::pair<std::size_t, std::size_t>
mark_accounts(account_t& account, const bool flat);
- virtual void post_account(account_t& account);
- virtual void flush();
+ virtual std::size_t post_account(account_t& account);
+ virtual void flush();
virtual void operator()(account_t& account);
};
diff --git a/test/baseline/opt-basis.test b/test/baseline/opt-basis.test
index f1b1242d..8270be88 100644
--- a/test/baseline/opt-basis.test
+++ b/test/baseline/opt-basis.test
@@ -6,5 +6,7 @@ bal --basis
>>>1
$0.35 Assets:Investments:Vanguard:VMMXX
$-0.35 Income:Dividends:Vanguard:VMMXX
+--------------------
+ 0
>>>2
=== 0
diff --git a/test/baseline/opt-cost.test b/test/baseline/opt-cost.test
index edf17428..b84646d8 100644
--- a/test/baseline/opt-cost.test
+++ b/test/baseline/opt-cost.test
@@ -6,5 +6,7 @@ bal --cost
>>>1
$0.35 Assets:Investments:Vanguard:VMMXX
$-0.35 Income:Dividends:Vanguard:VMMXX
+--------------------
+ 0
>>>2
=== 0
diff --git a/test/baseline/opt-depth.test b/test/baseline/opt-depth.test
index e8dc2e1d..4b378fac 100644
--- a/test/baseline/opt-depth.test
+++ b/test/baseline/opt-depth.test
@@ -23,6 +23,8 @@ bal --depth 1
$-10.00 Assets
$40.00 Expenses
$-30.00 Income
+--------------------
+ 0
>>>2
=== 0
bal --depth 2
@@ -32,6 +34,8 @@ bal --depth 2
$10.00 Books
$30.00 One
$-30.00 Income:One
+--------------------
+ 0
>>>2
=== 0
bal --depth 3
@@ -45,6 +49,8 @@ bal --depth 3
$-30.00 Income:One
$-10.00 Books
$-20.00 Two
+--------------------
+ 0
>>>2
=== 0
bal --depth 4
@@ -62,6 +68,8 @@ bal --depth 4
$-20.00 Two
$-10.00 Books
$-10.00 Three
+--------------------
+ 0
>>>2
=== 0
bal --depth 5
@@ -79,5 +87,7 @@ bal --depth 5
$-20.00 Two
$-10.00 Books
$-10.00 Three:Books
+--------------------
+ 0
>>>2
=== 0
diff --git a/test/baseline/opt-depth_flat.test b/test/baseline/opt-depth_flat.test
index c43c1c26..85f29423 100644
--- a/test/baseline/opt-depth_flat.test
+++ b/test/baseline/opt-depth_flat.test
@@ -26,6 +26,8 @@ bal --depth 2 --flat
>>>1
$-10.00 Assets:Cash
$10.00 Expenses:Books
+--------------------
+ 0
>>>2
=== 0
bal --depth 3 --flat
@@ -34,6 +36,8 @@ bal --depth 3 --flat
$10.00 Expenses:Books
$10.00 Expenses:One:Books
$-10.00 Income:One:Books
+--------------------
+ 0
>>>2
=== 0
bal --depth 4 --flat
@@ -44,6 +48,8 @@ bal --depth 4 --flat
$10.00 Expenses:One:Two:Books
$-10.00 Income:One:Books
$-10.00 Income:One:Two:Books
+--------------------
+ 0
>>>2
=== 0
bal --depth 5 --flat
@@ -56,5 +62,7 @@ bal --depth 5 --flat
$-10.00 Income:One:Books
$-10.00 Income:One:Two:Books
$-10.00 Income:One:Two:Three:Books
+--------------------
+ 0
>>>2
=== 0
diff --git a/test/baseline/opt-empty_bal.test b/test/baseline/opt-empty_bal.test
index 1f44f0db..f8e7560b 100644
--- a/test/baseline/opt-empty_bal.test
+++ b/test/baseline/opt-empty_bal.test
@@ -35,5 +35,7 @@ bal --empty
$-20.00 Two
$-10.00 Books
$-10.00 Three:Books
+--------------------
+ 0
>>>2
=== 0
diff --git a/test/baseline/opt-empty_bal_flat.test b/test/baseline/opt-empty_bal_flat.test
index 8293530f..338c0bf8 100644
--- a/test/baseline/opt-empty_bal_flat.test
+++ b/test/baseline/opt-empty_bal_flat.test
@@ -29,5 +29,7 @@ bal --empty --flat
$-10.00 Income:One:Books
$-10.00 Income:One:Two:Books
$-10.00 Income:One:Two:Three:Books
+--------------------
+ 0
>>>2
=== 0
diff --git a/test/baseline/opt-flat.test b/test/baseline/opt-flat.test
index ddf37d2e..6064e833 100644
--- a/test/baseline/opt-flat.test
+++ b/test/baseline/opt-flat.test
@@ -28,5 +28,7 @@ bal --flat
$-10.00 Income:One:Books
$-10.00 Income:One:Two:Books
$-10.00 Income:One:Two:Three:Books
+--------------------
+ 0
>>>2
=== 0
diff --git a/test/regress/55831A79.test b/test/regress/55831A79.test
index 9ceb7782..3f4a6348 100644
--- a/test/regress/55831A79.test
+++ b/test/regress/55831A79.test
@@ -20,5 +20,7 @@ bal discover
0 liabilities:credit cards:discover 4462
$-39.00 fee
$-64.76 interest
+--------------------
+ 0
>>>2
=== 0