lib, cli: merge --show-unbudgeted into --empty
This commit is contained in:
parent
8d03adc5ad
commit
f2aaaf3310
@ -64,12 +64,13 @@ type BudgetReportRow = PeriodicReportRow BudgetCell
|
|||||||
-- actual balance changes from the regular transactions,
|
-- actual balance changes from the regular transactions,
|
||||||
-- and compare these to get a 'BudgetReport'.
|
-- and compare these to get a 'BudgetReport'.
|
||||||
-- Unbudgeted accounts may be hidden or renamed (see budgetRollup).
|
-- Unbudgeted accounts may be hidden or renamed (see budgetRollup).
|
||||||
budgetReport :: ReportOpts -> Bool -> Bool -> DateSpan -> Day -> Journal -> BudgetReport
|
budgetReport :: ReportOpts -> Bool -> DateSpan -> Day -> Journal -> BudgetReport
|
||||||
budgetReport ropts' assrt showunbudgeted reportspan d j =
|
budgetReport ropts' assrt reportspan d j =
|
||||||
let
|
let
|
||||||
-- Budget report demands ALTree mode to ensure subaccounts and subaccount budgets are properly handled
|
-- Budget report demands ALTree mode to ensure subaccounts and subaccount budgets are properly handled
|
||||||
-- and that reports with and without --show-unbudgeted make sense when compared side by side
|
-- and that reports with and without --empty make sense when compared side by side
|
||||||
ropts = ropts' { accountlistmode_ = ALTree }
|
ropts = ropts' { accountlistmode_ = ALTree }
|
||||||
|
showunbudgeted = empty_ ropts
|
||||||
q = queryFromOpts d ropts
|
q = queryFromOpts d ropts
|
||||||
budgetedaccts =
|
budgetedaccts =
|
||||||
dbg2 "budgetedacctsinperiod" $
|
dbg2 "budgetedacctsinperiod" $
|
||||||
@ -162,7 +163,7 @@ budgetJournal assrt _ropts reportspan j =
|
|||||||
--
|
--
|
||||||
-- 2. subaccounts with no budget goal are merged with their closest parent account
|
-- 2. subaccounts with no budget goal are merged with their closest parent account
|
||||||
-- with a budget goal, so that only budgeted accounts are shown.
|
-- with a budget goal, so that only budgeted accounts are shown.
|
||||||
-- This can be disabled by --show-unbudgeted.
|
-- This can be disabled by --empty.
|
||||||
--
|
--
|
||||||
budgetRollUp :: [AccountName] -> Bool -> Journal -> Journal
|
budgetRollUp :: [AccountName] -> Bool -> Journal -> Journal
|
||||||
budgetRollUp budgetedaccts showunbudgeted j = j { jtxns = remapTxn <$> jtxns j }
|
budgetRollUp budgetedaccts showunbudgeted j = j { jtxns = remapTxn <$> jtxns j }
|
||||||
|
|||||||
@ -289,7 +289,6 @@ balancemode = (defCommandMode $ ["balance"] ++ aliases) { -- also accept but don
|
|||||||
,flagNone ["pretty-tables"] (\opts -> setboolopt "pretty-tables" opts) "use unicode to display prettier tables"
|
,flagNone ["pretty-tables"] (\opts -> setboolopt "pretty-tables" opts) "use unicode to display prettier tables"
|
||||||
,flagNone ["sort-amount","S"] (\opts -> setboolopt "sort-amount" opts) "sort by amount instead of account code/name (in flat mode). With multiple columns, sorts by the row total, or by row average if that is displayed."
|
,flagNone ["sort-amount","S"] (\opts -> setboolopt "sort-amount" opts) "sort by amount instead of account code/name (in flat mode). With multiple columns, sorts by the row total, or by row average if that is displayed."
|
||||||
,flagNone ["budget"] (setboolopt "budget") "show performance compared to budget goals defined by periodic transactions"
|
,flagNone ["budget"] (setboolopt "budget") "show performance compared to budget goals defined by periodic transactions"
|
||||||
,flagNone ["show-unbudgeted"] (setboolopt "show-unbudgeted") "with --budget, show unbudgeted accounts also"
|
|
||||||
,flagNone ["invert"] (setboolopt "invert") "display all amounts with reversed sign"
|
,flagNone ["invert"] (setboolopt "invert") "display all amounts with reversed sign"
|
||||||
,flagNone ["transpose"] (setboolopt "transpose") "transpose rows and columns"
|
,flagNone ["transpose"] (setboolopt "transpose") "transpose rows and columns"
|
||||||
]
|
]
|
||||||
@ -314,9 +313,8 @@ balance opts@CliOpts{rawopts_=rawopts,reportopts_=ropts} j = do
|
|||||||
(True, _) -> do
|
(True, _) -> do
|
||||||
-- single or multicolumn budget report
|
-- single or multicolumn budget report
|
||||||
reportspan <- reportSpan j ropts
|
reportspan <- reportSpan j ropts
|
||||||
let budgetreport = dbg1 "budgetreport" $ budgetReport ropts assrt showunbudgeted reportspan d j
|
let budgetreport = dbg1 "budgetreport" $ budgetReport ropts assrt reportspan d j
|
||||||
where
|
where
|
||||||
showunbudgeted = boolopt "show-unbudgeted" rawopts
|
|
||||||
assrt = not $ ignore_assertions_ $ inputopts_ opts
|
assrt = not $ ignore_assertions_ $ inputopts_ opts
|
||||||
render = case format of
|
render = case format of
|
||||||
"csv" -> const $ error' "Sorry, CSV output is not yet implemented for this kind of report." -- TODO
|
"csv" -> const $ error' "Sorry, CSV output is not yet implemented for this kind of report." -- TODO
|
||||||
|
|||||||
@ -57,9 +57,6 @@ txt, csv
|
|||||||
`--budget`
|
`--budget`
|
||||||
: show performance compared to budget goals defined by [periodic transactions](journal.html#periodic-transactions)
|
: show performance compared to budget goals defined by [periodic transactions](journal.html#periodic-transactions)
|
||||||
|
|
||||||
`--show-unbudgeted`
|
|
||||||
: with --budget, show unbudgeted accounts also
|
|
||||||
|
|
||||||
The balance command is hledger's most versatile command.
|
The balance command is hledger's most versatile command.
|
||||||
Note, despite the name, it is not always used for showing real-world account balances;
|
Note, despite the name, it is not always used for showing real-world account balances;
|
||||||
the more accounting-aware [balancesheet](#balancesheet)
|
the more accounting-aware [balancesheet](#balancesheet)
|
||||||
@ -304,7 +301,8 @@ period (without -E, leading and trailing columns with all zeroes are
|
|||||||
not shown). Second, all accounts which existed at the report start
|
not shown). Second, all accounts which existed at the report start
|
||||||
date will be considered, not just the ones with activity during the
|
date will be considered, not just the ones with activity during the
|
||||||
report period (use -E to include low-activity accounts which would
|
report period (use -E to include low-activity accounts which would
|
||||||
otherwise would be omitted).
|
otherwise would be omitted). With `--budget`, `--empty` also shows
|
||||||
|
unbudgeted accounts.
|
||||||
|
|
||||||
The `-T/--row-total` flag adds an additional column showing the total
|
The `-T/--row-total` flag adds an additional column showing the total
|
||||||
for each row.
|
for each row.
|
||||||
@ -400,9 +398,9 @@ above, transactions in `expenses:gifts` and `expenses:supplies` are counted towa
|
|||||||
but accounts `expenses:gifts` and `expenses:supplies` are not shown, as they don't have any budgets.
|
but accounts `expenses:gifts` and `expenses:supplies` are not shown, as they don't have any budgets.
|
||||||
|
|
||||||
|
|
||||||
You can use `--show-unbudgeted` shows unbudgeted accounts as well:
|
You can use `--empty` shows unbudgeted accounts as well:
|
||||||
```shell
|
```shell
|
||||||
$ hledger balance -M --budget --show-unbudgeted
|
$ hledger balance -M --budget --empty
|
||||||
Budget performance in 2017/11/01-2017/12/31:
|
Budget performance in 2017/11/01-2017/12/31:
|
||||||
|
|
||||||
|| Nov Dec
|
|| Nov Dec
|
||||||
@ -507,9 +505,9 @@ Budget performance in 2019/01:
|
|||||||
|| 0 [ 0]
|
|| 0 [ 0]
|
||||||
```
|
```
|
||||||
|
|
||||||
And with `--show-unbudgeted`, we can get a better picture of budget allocation and consumption:
|
And with `--empty`, we can get a better picture of budget allocation and consumption:
|
||||||
```shell
|
```shell
|
||||||
$ hledger balance --budget -M --show-unbudgeted
|
$ hledger balance --budget -M --empty
|
||||||
Budget performance in 2019/01:
|
Budget performance in 2019/01:
|
||||||
|
|
||||||
|| Jan
|
|| Jan
|
||||||
|
|||||||
@ -44,8 +44,8 @@ Budget performance in 2016/12/01-2016/12/03:
|
|||||||
------------------++------------------------------------------------------------------
|
------------------++------------------------------------------------------------------
|
||||||
|| 0 [ 0] 0 [ 0] 0 [ 0]
|
|| 0 [ 0] 0 [ 0] 0 [ 0]
|
||||||
|
|
||||||
# 2. --show-unbudgeted
|
# 2. -E
|
||||||
$ hledger bal -D -b 2016-12-01 -e 2016-12-04 -f - --budget --show-unbudgeted
|
$ hledger bal -D -b 2016-12-01 -e 2016-12-04 -f - --budget -E
|
||||||
Budget performance in 2016/12/01-2016/12/03:
|
Budget performance in 2016/12/01-2016/12/03:
|
||||||
|
|
||||||
|| 2016/12/01 2016/12/02 2016/12/03
|
|| 2016/12/01 2016/12/02 2016/12/03
|
||||||
@ -379,7 +379,7 @@ Budget performance in 2019/01/01-2019/01/03:
|
|||||||
-------------------++------------------------------
|
-------------------++------------------------------
|
||||||
|| 0 [ 0]
|
|| 0 [ 0]
|
||||||
|
|
||||||
$ hledger -f- bal --budget --show-unbudgeted
|
$ hledger -f- bal --budget -E
|
||||||
Budget performance in 2019/01/01-2019/01/03:
|
Budget performance in 2019/01/01-2019/01/03:
|
||||||
|
|
||||||
|| 2019/01/01-2019/01/03
|
|| 2019/01/01-2019/01/03
|
||||||
@ -403,7 +403,7 @@ Budget performance in 2019/01/01-2019/01/03:
|
|||||||
-------------++------------------------------
|
-------------++------------------------------
|
||||||
|| 0 [ 0]
|
|| 0 [ 0]
|
||||||
|
|
||||||
$ hledger -f- bal --budget --tree --show-unbudgeted
|
$ hledger -f- bal --budget --tree -E
|
||||||
Budget performance in 2019/01/01-2019/01/03:
|
Budget performance in 2019/01/01-2019/01/03:
|
||||||
|
|
||||||
|| 2019/01/01-2019/01/03
|
|| 2019/01/01-2019/01/03
|
||||||
@ -447,7 +447,7 @@ Budget performance in 2019/01/01-2019/01/03:
|
|||||||
-------------------------------++------------------------------
|
-------------------------------++------------------------------
|
||||||
|| 0 [ 0]
|
|| 0 [ 0]
|
||||||
|
|
||||||
$ hledger -f- bal --budget --show-unbudgeted
|
$ hledger -f- bal --budget -E
|
||||||
Budget performance in 2019/01/01-2019/01/03:
|
Budget performance in 2019/01/01-2019/01/03:
|
||||||
|
|
||||||
|| 2019/01/01-2019/01/03
|
|| 2019/01/01-2019/01/03
|
||||||
@ -472,7 +472,7 @@ Budget performance in 2019/01/01-2019/01/03:
|
|||||||
-----------------++------------------------------
|
-----------------++------------------------------
|
||||||
|| 0 [ 0]
|
|| 0 [ 0]
|
||||||
|
|
||||||
$ hledger -f- bal --budget --tree --show-unbudgeted
|
$ hledger -f- bal --budget --tree -E
|
||||||
Budget performance in 2019/01/01-2019/01/03:
|
Budget performance in 2019/01/01-2019/01/03:
|
||||||
|
|
||||||
|| 2019/01/01-2019/01/03
|
|| 2019/01/01-2019/01/03
|
||||||
@ -525,8 +525,8 @@ Budget performance in 2019/01/01-2019/01/02:
|
|||||||
------------------++-----------------------
|
------------------++-----------------------
|
||||||
|| 0 [ 0]
|
|| 0 [ 0]
|
||||||
|
|
||||||
# --show-unbudgeted shows d
|
# -E shows d
|
||||||
$ hledger bal -f- --budget --show-unbudgeted
|
$ hledger bal -f- --budget -E
|
||||||
Budget performance in 2019/01/01-2019/01/02:
|
Budget performance in 2019/01/01-2019/01/02:
|
||||||
|
|
||||||
|| 2019/01/01-2019/01/02
|
|| 2019/01/01-2019/01/02
|
||||||
@ -537,6 +537,7 @@ Budget performance in 2019/01/01-2019/01/02:
|
|||||||
expenses:bills:b || $40 [ 20% of $200]
|
expenses:bills:b || $40 [ 20% of $200]
|
||||||
expenses:bills:c || 0 [ 0% of $50]
|
expenses:bills:c || 0 [ 0% of $50]
|
||||||
expenses:bills:d || $20
|
expenses:bills:d || $20
|
||||||
|
expenses:bills:e || 0
|
||||||
expenses:bills:f || $10 [ 0]
|
expenses:bills:f || $10 [ 0]
|
||||||
income || $-80 [ 22% of $-370]
|
income || $-80 [ 22% of $-370]
|
||||||
income:cash || $-80 [ 22% of $-370]
|
income:cash || $-80 [ 22% of $-370]
|
||||||
|
|||||||
@ -92,8 +92,8 @@ Budget performance in 2016/12/01-2016/12/03:
|
|||||||
assets || $-10 [ 40% of $-25] $-14 [ 56% of $-25] $-51 [ 204% of $-25] $-75 [ 100% of $-75]
|
assets || $-10 [ 40% of $-25] $-14 [ 56% of $-25] $-51 [ 204% of $-25] $-75 [ 100% of $-75]
|
||||||
assets:cash || $-10 [ 40% of $-25] $-14 [ 56% of $-25] $-51 [ 204% of $-25] $-75 [ 100% of $-75]
|
assets:cash || $-10 [ 40% of $-25] $-14 [ 56% of $-25] $-51 [ 204% of $-25] $-75 [ 100% of $-75]
|
||||||
|
|
||||||
# # 2. --show-unbudgeted
|
# # 2. -E
|
||||||
# $ hledger bal -D -b 2016-12-01 -e 2016-12-04 -f - --budget --show-unbudgeted
|
# $ hledger bal -D -b 2016-12-01 -e 2016-12-04 -f - --budget -E
|
||||||
# Budget performance in 2016/12/01-2016/12/03:
|
# Budget performance in 2016/12/01-2016/12/03:
|
||||||
|
|
||||||
# || 2016/12/01 2016/12/02 2016/12/03
|
# || 2016/12/01 2016/12/02 2016/12/03
|
||||||
@ -180,8 +180,8 @@ Budget performance in 2016/12/01-2016/12/03:
|
|||||||
cash || $-10 [ 40% of $-25] $-14 [ 56% of $-25] $-51 [ 204% of $-25] $-75 [ 100% of $-75]
|
cash || $-10 [ 40% of $-25] $-14 [ 56% of $-25] $-51 [ 204% of $-25] $-75 [ 100% of $-75]
|
||||||
|
|
||||||
#** other ?
|
#** other ?
|
||||||
# with --show-unbudgeted
|
# with -E
|
||||||
# $ hledger bal -D -b 2016-12-01 -e 2016-12-04 -f - --budget --show-unbudgeted
|
# $ hledger bal -D -b 2016-12-01 -e 2016-12-04 -f - --budget -E
|
||||||
# Budget performance in 2016/12/01-2016/12/03:
|
# Budget performance in 2016/12/01-2016/12/03:
|
||||||
|
|
||||||
# || 2016/12/01 2016/12/02 2016/12/03
|
# || 2016/12/01 2016/12/02 2016/12/03
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user