diff --git a/hledger-lib/Hledger/Reports/BudgetReport.hs b/hledger-lib/Hledger/Reports/BudgetReport.hs index 996d1d69a..1f2e1e8e1 100644 --- a/hledger-lib/Hledger/Reports/BudgetReport.hs +++ b/hledger-lib/Hledger/Reports/BudgetReport.hs @@ -64,12 +64,13 @@ type BudgetReportRow = PeriodicReportRow BudgetCell -- actual balance changes from the regular transactions, -- and compare these to get a 'BudgetReport'. -- Unbudgeted accounts may be hidden or renamed (see budgetRollup). -budgetReport :: ReportOpts -> Bool -> Bool -> DateSpan -> Day -> Journal -> BudgetReport -budgetReport ropts' assrt showunbudgeted reportspan d j = +budgetReport :: ReportOpts -> Bool -> DateSpan -> Day -> Journal -> BudgetReport +budgetReport ropts' assrt reportspan d j = let -- 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 } + showunbudgeted = empty_ ropts q = queryFromOpts d ropts budgetedaccts = dbg2 "budgetedacctsinperiod" $ @@ -162,7 +163,7 @@ budgetJournal assrt _ropts reportspan j = -- -- 2. subaccounts with no budget goal are merged with their closest parent account -- 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 budgetedaccts showunbudgeted j = j { jtxns = remapTxn <$> jtxns j } diff --git a/hledger/Hledger/Cli/Commands/Balance.hs b/hledger/Hledger/Cli/Commands/Balance.hs index dd00eb106..4ba75d722 100644 --- a/hledger/Hledger/Cli/Commands/Balance.hs +++ b/hledger/Hledger/Cli/Commands/Balance.hs @@ -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 ["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 ["show-unbudgeted"] (setboolopt "show-unbudgeted") "with --budget, show unbudgeted accounts also" ,flagNone ["invert"] (setboolopt "invert") "display all amounts with reversed sign" ,flagNone ["transpose"] (setboolopt "transpose") "transpose rows and columns" ] @@ -314,9 +313,8 @@ balance opts@CliOpts{rawopts_=rawopts,reportopts_=ropts} j = do (True, _) -> do -- single or multicolumn budget report 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 - showunbudgeted = boolopt "show-unbudgeted" rawopts assrt = not $ ignore_assertions_ $ inputopts_ opts render = case format of "csv" -> const $ error' "Sorry, CSV output is not yet implemented for this kind of report." -- TODO diff --git a/hledger/hledger_balance.m4.md b/hledger/hledger_balance.m4.md index ee8a79c43..6973ad676 100644 --- a/hledger/hledger_balance.m4.md +++ b/hledger/hledger_balance.m4.md @@ -57,9 +57,6 @@ txt, csv `--budget` : 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. Note, despite the name, it is not always used for showing real-world account balances; 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 date will be considered, not just the ones with activity during the 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 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. -You can use `--show-unbudgeted` shows unbudgeted accounts as well: +You can use `--empty` shows unbudgeted accounts as well: ```shell -$ hledger balance -M --budget --show-unbudgeted +$ hledger balance -M --budget --empty Budget performance in 2017/11/01-2017/12/31: || Nov Dec @@ -507,9 +505,9 @@ Budget performance in 2019/01: || 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 -$ hledger balance --budget -M --show-unbudgeted +$ hledger balance --budget -M --empty Budget performance in 2019/01: || Jan diff --git a/tests/budget/budget.test b/tests/budget/budget.test index 289c83a59..509c4121e 100644 --- a/tests/budget/budget.test +++ b/tests/budget/budget.test @@ -44,8 +44,8 @@ Budget performance in 2016/12/01-2016/12/03: ------------------++------------------------------------------------------------------ || 0 [ 0] 0 [ 0] 0 [ 0] -# 2. --show-unbudgeted -$ hledger bal -D -b 2016-12-01 -e 2016-12-04 -f - --budget --show-unbudgeted +# 2. -E +$ hledger bal -D -b 2016-12-01 -e 2016-12-04 -f - --budget -E Budget performance in 2016/12/01-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] -$ hledger -f- bal --budget --show-unbudgeted +$ hledger -f- bal --budget -E Budget performance in 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] -$ hledger -f- bal --budget --tree --show-unbudgeted +$ hledger -f- bal --budget --tree -E Budget performance in 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] -$ hledger -f- bal --budget --show-unbudgeted +$ hledger -f- bal --budget -E Budget performance in 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] -$ hledger -f- bal --budget --tree --show-unbudgeted +$ hledger -f- bal --budget --tree -E Budget performance in 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] -# --show-unbudgeted shows d -$ hledger bal -f- --budget --show-unbudgeted +# -E shows d +$ hledger bal -f- --budget -E Budget performance in 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:c || 0 [ 0% of $50] expenses:bills:d || $20 + expenses:bills:e || 0 expenses:bills:f || $10 [ 0] income || $-80 [ 22% of $-370] income:cash || $-80 [ 22% of $-370] diff --git a/tests/budget/sorting.test b/tests/budget/sorting.test index 52cfd2858..a7fe8c6af 100644 --- a/tests/budget/sorting.test +++ b/tests/budget/sorting.test @@ -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:cash || $-10 [ 40% of $-25] $-14 [ 56% of $-25] $-51 [ 204% of $-25] $-75 [ 100% of $-75] -# # 2. --show-unbudgeted -# $ hledger bal -D -b 2016-12-01 -e 2016-12-04 -f - --budget --show-unbudgeted +# # 2. -E +# $ hledger bal -D -b 2016-12-01 -e 2016-12-04 -f - --budget -E # Budget performance in 2016/12/01-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] #** other ? -# with --show-unbudgeted -# $ hledger bal -D -b 2016-12-01 -e 2016-12-04 -f - --budget --show-unbudgeted +# with -E +# $ hledger bal -D -b 2016-12-01 -e 2016-12-04 -f - --budget -E # Budget performance in 2016/12/01-2016/12/03: # || 2016/12/01 2016/12/02 2016/12/03