fix: balance: Show all empty accounts in flat balance reports. (#1688)
Previously we only showed empty leaves.
This commit is contained in:
parent
4cb631c0f2
commit
50f73b7434
@ -410,12 +410,17 @@ displayedAccounts ReportSpec{_rsQuery=query,_rsReportOpts=ropts} valuedaccts
|
|||||||
-- Accounts interesting for their own sake
|
-- Accounts interesting for their own sake
|
||||||
isInteresting name amts =
|
isInteresting name amts =
|
||||||
d <= depth -- Throw out anything too deep
|
d <= depth -- Throw out anything too deep
|
||||||
&& ((empty_ ropts && all (null . asubs) amts) -- Keep all leaves when using empty_
|
&& ( (empty_ ropts && keepWhenEmpty amts) -- Keep empty accounts when called with --empty
|
||||||
|| not (isZeroRow balance amts)) -- Throw out anything with zero balance
|
|| not (isZeroRow balance amts) -- Keep everything with a non-zero balance in the row
|
||||||
|
)
|
||||||
where
|
where
|
||||||
d = accountNameLevel name
|
d = accountNameLevel name
|
||||||
balance | ALTree <- accountlistmode_ ropts, d == depth = maybeStripPrices . aibalance
|
keepWhenEmpty = case accountlistmode_ ropts of
|
||||||
| otherwise = maybeStripPrices . aebalance
|
ALFlat -> const True -- Keep all empty accounts in flat mode
|
||||||
|
ALTree -> all (null . asubs) -- Keep only empty leaves in tree mode
|
||||||
|
balance = maybeStripPrices . case accountlistmode_ ropts of
|
||||||
|
ALTree | d == depth -> aibalance
|
||||||
|
_ -> aebalance
|
||||||
where maybeStripPrices = if show_costs_ ropts then id else mixedAmountStripPrices
|
where maybeStripPrices = if show_costs_ ropts then id else mixedAmountStripPrices
|
||||||
|
|
||||||
-- Accounts interesting because they are a fork for interesting subaccounts
|
-- Accounts interesting because they are a fork for interesting subaccounts
|
||||||
|
|||||||
@ -21,7 +21,7 @@ $ hledger -f - balance
|
|||||||
(a:b) 1
|
(a:b) 1
|
||||||
|
|
||||||
# 2. An uninteresting parent account (with same balance as its single subaccount) is elided by default, like ledger
|
# 2. An uninteresting parent account (with same balance as its single subaccount) is elided by default, like ledger
|
||||||
$ hledger -f - balance --no-total
|
$ hledger -f - balance --no-total --tree
|
||||||
>
|
>
|
||||||
1 a:b
|
1 a:b
|
||||||
>=0
|
>=0
|
||||||
@ -98,3 +98,19 @@ Balance changes in 2020:
|
|||||||
a || 1
|
a || 1
|
||||||
aa || 0
|
aa || 0
|
||||||
aaa || 0
|
aaa || 0
|
||||||
|
|
||||||
|
# 11. In flat mode, display all zero-balance accounts, including non-leaves
|
||||||
|
$ hledger -f - balance --flat --no-total --empty
|
||||||
|
1 a
|
||||||
|
0 a:aa
|
||||||
|
0 a:aa:aaa
|
||||||
|
|
||||||
|
# 12. Same as 11 for multiperiod
|
||||||
|
$ hledger -f - balance --flat --no-total -Y --empty
|
||||||
|
Balance changes in 2020:
|
||||||
|
|
||||||
|
|| 2020
|
||||||
|
==========++======
|
||||||
|
a || 1
|
||||||
|
a:aa || 0
|
||||||
|
a:aa:aaa || 0
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user