imp: balance: Allow --related flag for balance reports. (#1469)
This commit is contained in:
parent
38e311211d
commit
f345fd0b78
@ -306,6 +306,7 @@ balancemode = hledgerCommandMode
|
||||
++ flattreeflags True ++
|
||||
[flagReq ["drop"] (\s opts -> Right $ setopt "drop" s opts) "N" "omit N leading account name parts (in flat mode)"
|
||||
,flagNone ["average","A"] (setboolopt "average") "show a row average column (in multicolumn reports)"
|
||||
,flagNone ["related","r"] (setboolopt "related") "show postings' siblings instead"
|
||||
,flagNone ["row-total","T"] (setboolopt "row-total") "show a row total column (in multicolumn reports)"
|
||||
,flagNone ["no-total","N"] (setboolopt "no-total") "omit the final total row"
|
||||
,flagNone ["no-elide"] (setboolopt "no-elide") "don't squash boring parent accounts (in tree mode); don't show only 2 commodities per amount"
|
||||
|
||||
@ -73,6 +73,9 @@ This command supports the
|
||||
with output formats `txt`, `csv`, `json`, and (multi-period reports only:) `html`.
|
||||
In `txt` output in a colour-supporting terminal, negative amounts are shown in red.
|
||||
|
||||
The `--related`/`-r` flag shows the balance of the *other* postings in the
|
||||
transactions of the postings which would normally be shown.
|
||||
|
||||
### Simple balance report
|
||||
|
||||
With no arguments, `balance` shows a list of all accounts and their
|
||||
|
||||
@ -1,17 +0,0 @@
|
||||
# 1. related postings will only display each posting once
|
||||
<
|
||||
P 2021-01-01 A 10 B
|
||||
|
||||
2021-01-01
|
||||
(a) 1 A
|
||||
(a) 2 A
|
||||
(b) 3 A
|
||||
|
||||
$ hledger -f- register a --related
|
||||
2021-01-01 (b) 3 A 3 A
|
||||
>=
|
||||
|
||||
# 2. related postings will display valued postings when requested
|
||||
$ hledger -f- register a --related -V
|
||||
2021-01-01 (b) 30 B 30 B
|
||||
>=
|
||||
37
hledger/test/related.test
Normal file
37
hledger/test/related.test
Normal file
@ -0,0 +1,37 @@
|
||||
# 1. With --related, balance will display related accounts
|
||||
$ hledger -f sample.journal bal --related checking -N
|
||||
$1 assets:bank:saving
|
||||
$-1 income:gifts
|
||||
$-1 income:salary
|
||||
$1 liabilities:debts
|
||||
>=
|
||||
|
||||
# 2. Also works for multi-period reports
|
||||
$ hledger -f sample.journal bal --related checking -NY
|
||||
Balance changes in 2008:
|
||||
|
||||
|| 2008
|
||||
====================++======
|
||||
assets:bank:saving || $1
|
||||
income:gifts || $-1
|
||||
income:salary || $-1
|
||||
liabilities:debts || $1
|
||||
>=
|
||||
|
||||
# 3. for register, related postings will only display each posting once
|
||||
<
|
||||
P 2021-01-01 A 10 B
|
||||
|
||||
2021-01-01
|
||||
(a) 1 A
|
||||
(a) 2 A
|
||||
(b) 3 A
|
||||
|
||||
$ hledger -f- register a --related
|
||||
2021-01-01 (b) 3 A 3 A
|
||||
>=
|
||||
|
||||
# 4. related postings will display valued postings when requested
|
||||
$ hledger -f- register a --related -V
|
||||
2021-01-01 (b) 30 B 30 B
|
||||
>=
|
||||
Loading…
Reference in New Issue
Block a user