lib: fix behavior of nested budgets and --show-unbudgeted
This commit is contained in:
parent
92e7370f1f
commit
f3366c7256
@ -65,11 +65,16 @@ type BudgetReportRow = PeriodicReportRow BudgetCell
|
|||||||
-- 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 -> Bool -> DateSpan -> Day -> Journal -> BudgetReport
|
||||||
budgetReport ropts assrt showunbudgeted reportspan d j =
|
budgetReport ropts' assrt showunbudgeted reportspan d j =
|
||||||
let
|
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
|
||||||
|
ropts = ropts' { accountlistmode_ = ALTree }
|
||||||
q = queryFromOpts d ropts
|
q = queryFromOpts d ropts
|
||||||
budgetedaccts =
|
budgetedaccts =
|
||||||
dbg2 "budgetedacctsinperiod" $
|
dbg2 "budgetedacctsinperiod" $
|
||||||
|
nub $
|
||||||
|
concatMap expandAccountName $
|
||||||
accountNamesFromPostings $
|
accountNamesFromPostings $
|
||||||
concatMap tpostings $
|
concatMap tpostings $
|
||||||
concatMap (flip runPeriodicTransaction reportspan) $
|
concatMap (flip runPeriodicTransaction reportspan) $
|
||||||
@ -77,7 +82,7 @@ budgetReport ropts assrt showunbudgeted reportspan d j =
|
|||||||
actualj = dbg1 "actualj" $ budgetRollUp budgetedaccts showunbudgeted j
|
actualj = dbg1 "actualj" $ budgetRollUp budgetedaccts showunbudgeted j
|
||||||
budgetj = dbg1 "budgetj" $ budgetJournal assrt ropts reportspan j
|
budgetj = dbg1 "budgetj" $ budgetJournal assrt ropts reportspan j
|
||||||
actualreport@(MultiBalanceReport (actualspans, _, _)) = dbg1 "actualreport" $ multiBalanceReport ropts q actualj
|
actualreport@(MultiBalanceReport (actualspans, _, _)) = dbg1 "actualreport" $ multiBalanceReport ropts q actualj
|
||||||
budgetgoalreport@(MultiBalanceReport (_, budgetgoalitems, budgetgoaltotals)) = dbg1 "budgetgoalreport" $ multiBalanceReport ropts q budgetj
|
budgetgoalreport@(MultiBalanceReport (_, budgetgoalitems, budgetgoaltotals)) = dbg1 "budgetgoalreport" $ multiBalanceReport (ropts{empty_=True}) q budgetj
|
||||||
budgetgoalreport'
|
budgetgoalreport'
|
||||||
-- If no interval is specified:
|
-- If no interval is specified:
|
||||||
-- budgetgoalreport's span might be shorter actualreport's due to periodic txns;
|
-- budgetgoalreport's span might be shorter actualreport's due to periodic txns;
|
||||||
|
|||||||
@ -377,42 +377,149 @@ You can now see a monthly budget report:
|
|||||||
$ hledger balance -M --budget
|
$ hledger balance -M --budget
|
||||||
Budget performance in 2017/11/01-2017/12/31:
|
Budget performance in 2017/11/01-2017/12/31:
|
||||||
|
|
||||||
|| 2017/11 2017/12
|
|| Nov Dec
|
||||||
======================++=================================================
|
======================++====================================================
|
||||||
<unbudgeted> || $20 $100
|
assets || $-2445 [ 99% of $-2480] $-2665 [ 107% of $-2480]
|
||||||
assets:bank:checking || $-2445 [99% of $-2480] $-2665 [107% of $-2480]
|
assets:bank || $-2445 [ 99% of $-2480] $-2665 [ 107% of $-2480]
|
||||||
expenses:bus || $49 [98% of $50] $53 [106% of $50]
|
assets:bank:checking || $-2445 [ 99% of $-2480] $-2665 [ 107% of $-2480]
|
||||||
expenses:food || $396 [99% of $400] $412 [103% of $400]
|
expenses || $495 [ 103% of $480] $565 [ 118% of $480]
|
||||||
expenses:movies || $30 [100% of $30] 0 [0% of $30]
|
expenses:bus || $49 [ 98% of $50] $53 [ 106% of $50]
|
||||||
income || $1950 [98% of $2000] $2100 [105% of $2000]
|
expenses:food || $396 [ 99% of $400] $412 [ 103% of $400]
|
||||||
----------------------++-------------------------------------------------
|
expenses:movies || $30 [ 100% of $30] 0 [ 0% of $30]
|
||||||
|| 0 0
|
income || $1950 [ 98% of $2000] $2100 [ 105% of $2000]
|
||||||
|
----------------------++----------------------------------------------------
|
||||||
|
|| 0 [ 0] 0 [ 0]
|
||||||
```
|
```
|
||||||
By default, only accounts with budget goals during the report period are shown.
|
|
||||||
`--show-unbudgeted` shows unbudgeted accounts as well.
|
By default, only accounts with budget goals during the report period are shown. In the example
|
||||||
Top-level accounts with no budget goals anywhere below them are grouped under `<unbudgeted>`.
|
above, transactions in `expenses:gifts` and `expenses:supplies` are counted towards `expenses` budget,
|
||||||
|
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:
|
||||||
|
```shell
|
||||||
|
$ hledger balance -M --budget --show-unbudgeted
|
||||||
|
Budget performance in 2017/11/01-2017/12/31:
|
||||||
|
|
||||||
|
|| Nov Dec
|
||||||
|
======================++====================================================
|
||||||
|
assets || $-2445 [ 99% of $-2480] $-2665 [ 107% of $-2480]
|
||||||
|
assets:bank || $-2445 [ 99% of $-2480] $-2665 [ 107% of $-2480]
|
||||||
|
assets:bank:checking || $-2445 [ 99% of $-2480] $-2665 [ 107% of $-2480]
|
||||||
|
expenses || $495 [ 103% of $480] $565 [ 118% of $480]
|
||||||
|
expenses:bus || $49 [ 98% of $50] $53 [ 106% of $50]
|
||||||
|
expenses:food || $396 [ 99% of $400] $412 [ 103% of $400]
|
||||||
|
expenses:gifts || 0 $100
|
||||||
|
expenses:movies || $30 [ 100% of $30] 0 [ 0% of $30]
|
||||||
|
expenses:supplies || $20 0
|
||||||
|
income || $1950 [ 98% of $2000] $2100 [ 105% of $2000]
|
||||||
|
----------------------++----------------------------------------------------
|
||||||
|
|| 0 [ 0] 0 [ 0]
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
You can roll over unspent budgets to next period with `--cumulative`:
|
You can roll over unspent budgets to next period with `--cumulative`:
|
||||||
```shell
|
```shell
|
||||||
$ hledger balance -M --budget --cumulative
|
$ hledger balance -M --budget --cumulative
|
||||||
Budget performance in 2017/11/01-2017/12/31:
|
Budget performance in 2017/11/01-2017/12/31:
|
||||||
|
|
||||||
|| 2017/11/30 2017/12/31
|
|| Nov Dec
|
||||||
======================++=================================================
|
======================++====================================================
|
||||||
<unbudgeted> || $20 $120
|
assets || $-2445 [ 99% of $-2480] $-5110 [ 103% of $-4960]
|
||||||
assets:bank:checking || $-2445 [99% of $-2480] $-5110 [103% of $-4960]
|
assets:bank || $-2445 [ 99% of $-2480] $-5110 [ 103% of $-4960]
|
||||||
expenses:bus || $49 [98% of $50] $102 [102% of $100]
|
assets:bank:checking || $-2445 [ 99% of $-2480] $-5110 [ 103% of $-4960]
|
||||||
expenses:food || $396 [99% of $400] $808 [101% of $800]
|
expenses || $495 [ 103% of $480] $1060 [ 110% of $960]
|
||||||
expenses:movies || $30 [100% of $30] $30 [50% of $60]
|
expenses:bus || $49 [ 98% of $50] $102 [ 102% of $100]
|
||||||
income || $1950 [98% of $2000] $4050 [101% of $4000]
|
expenses:food || $396 [ 99% of $400] $808 [ 101% of $800]
|
||||||
----------------------++-------------------------------------------------
|
expenses:movies || $30 [ 100% of $30] $30 [ 50% of $60]
|
||||||
|| 0 0
|
income || $1950 [ 98% of $2000] $4050 [ 101% of $4000]
|
||||||
|
----------------------++----------------------------------------------------
|
||||||
|
|| 0 [ 0] 0 [ 0]
|
||||||
```
|
```
|
||||||
|
|
||||||
Note, the `-S/--sort-amount` flag is not yet fully supported with `--budget`.
|
Note, the `-S/--sort-amount` flag is not yet fully supported with `--budget`.
|
||||||
|
|
||||||
For more examples, see [Budgeting and Forecasting](https://github.com/simonmichael/hledger/wiki/Budgeting and forecasting).
|
For more examples, see [Budgeting and Forecasting](https://github.com/simonmichael/hledger/wiki/Budgeting and forecasting).
|
||||||
|
|
||||||
|
#### Nested budgets
|
||||||
|
|
||||||
|
You can add budgets to any account in your account hierarchy. If you have budgets on both parent account and some of its children, then budget(s)
|
||||||
|
of the child account(s) would be added to the budget of their parent, much like account balances behave.
|
||||||
|
|
||||||
|
In the most simple case this means that once you add a budget to any account, all its parents would have budget as well.
|
||||||
|
|
||||||
|
To illustrate this, consider the following budget:
|
||||||
|
```
|
||||||
|
~ monthly from 2019/01
|
||||||
|
expenses:personal $1,000.00
|
||||||
|
expenses:personal:electronics $100.00
|
||||||
|
liabilities
|
||||||
|
```
|
||||||
|
|
||||||
|
With this, monthly budget for electronics is defined to be $100 and budget for personal expenses is an additional $1000, which implicity means
|
||||||
|
that budget for both `expenses:personal` and `expenses` is $1100.
|
||||||
|
|
||||||
|
Transactions in `expenses:personal:electronics` will be counted both towards its $100 budget and $1100 of `expenses:personal` , and transactions in any other subaccount of `expenses:personal` would be
|
||||||
|
counted towards only towards the budget of `expenses:personal`.
|
||||||
|
|
||||||
|
For example, let's consider these transactions:
|
||||||
|
```journal
|
||||||
|
~ monthly from 2019/01
|
||||||
|
expenses:personal $1,000.00
|
||||||
|
expenses:personal:electronics $100.00
|
||||||
|
liabilities
|
||||||
|
|
||||||
|
2019/01/01 Google home hub
|
||||||
|
expenses:personal:electronics $90.00
|
||||||
|
liabilities $-90.00
|
||||||
|
|
||||||
|
2019/01/02 Phone screen protector
|
||||||
|
expenses:personal:electronics:upgrades $10.00
|
||||||
|
liabilities
|
||||||
|
|
||||||
|
2019/01/02 Weekly train ticket
|
||||||
|
expenses:personal:train tickets $153.00
|
||||||
|
liabilities
|
||||||
|
|
||||||
|
2019/01/03 Flowers
|
||||||
|
expenses:personal $30.00
|
||||||
|
liabilities
|
||||||
|
```
|
||||||
|
|
||||||
|
As you can see, we have transactions in `expenses:personal:electronics:upgrades` and `expenses:personal:train tickets`, and since both of these accounts are without explicitly defined budget,
|
||||||
|
these transactions would be counted towards budgets of `expenses:personal:electronics` and `expenses:personal` accordingly:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ hledger balance --budget -M
|
||||||
|
Budget performance in 2019/01:
|
||||||
|
|
||||||
|
|| Jan
|
||||||
|
===============================++===============================
|
||||||
|
expenses || $283.00 [ 26% of $1100.00]
|
||||||
|
expenses:personal || $283.00 [ 26% of $1100.00]
|
||||||
|
expenses:personal:electronics || $100.00 [ 100% of $100.00]
|
||||||
|
liabilities || $-283.00 [ 26% of $-1100.00]
|
||||||
|
-------------------------------++-------------------------------
|
||||||
|
|| 0 [ 0]
|
||||||
|
```
|
||||||
|
|
||||||
|
And with `--show-unbudgeted`, we can get a better picture of budget allocation and consumption:
|
||||||
|
```shell
|
||||||
|
$ hledger balance --budget -M --show-unbudgeted
|
||||||
|
Budget performance in 2019/01:
|
||||||
|
|
||||||
|
|| Jan
|
||||||
|
========================================++===============================
|
||||||
|
expenses || $283.00 [ 26% of $1100.00]
|
||||||
|
expenses:personal || $283.00 [ 26% of $1100.00]
|
||||||
|
expenses:personal:electronics || $100.00 [ 100% of $100.00]
|
||||||
|
expenses:personal:electronics:upgrades || $10.00
|
||||||
|
expenses:personal:train tickets || $153.00
|
||||||
|
liabilities || $-283.00 [ 26% of $-1100.00]
|
||||||
|
----------------------------------------++-------------------------------
|
||||||
|
|| 0 [ 0]
|
||||||
|
```
|
||||||
|
|
||||||
### Output format
|
### Output format
|
||||||
|
|
||||||
The balance command supports [output destination](/manual.html#output-destination) and [output format](/manual.html#output-format) selection.
|
The balance command supports [output destination](/manual.html#output-destination) and [output format](/manual.html#output-format) selection.
|
||||||
|
|||||||
@ -35,12 +35,13 @@ $ hledger bal -D -b 2016-12-01 -e 2016-12-04 -f - --budget
|
|||||||
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
|
||||||
==================++==============================================================================
|
==================++==================================================================
|
||||||
<unbudgeted> || 0 0 $40
|
assets || $-10 [ 40% of $-25] $-14 [ 56% of $-25] $-51 [ 204% of $-25]
|
||||||
assets:cash || $-10 [ 40% of $-25] $-14 [ 56% of $-25] $-51 [ 204% of $-25]
|
assets:cash || $-10 [ 40% of $-25] $-14 [ 56% of $-25] $-51 [ 204% of $-25]
|
||||||
|
expenses || $10 [ 40% of $25] $14 [ 56% of $25] $51 [ 204% of $25]
|
||||||
expenses:food || $10 [ 100% of $10] $9 [ 90% of $10] $11 [ 110% of $10]
|
expenses:food || $10 [ 100% of $10] $9 [ 90% of $10] $11 [ 110% of $10]
|
||||||
expenses:leisure || 0 [ 0% of $15] $5 [ 33% of $15] 0 [ 0% of $15]
|
expenses:leisure || 0 [ 0% of $15] $5 [ 33% of $15] 0 [ 0% of $15]
|
||||||
------------------++------------------------------------------------------------------------------
|
------------------++------------------------------------------------------------------
|
||||||
|| 0 [ 0] 0 [ 0] 0 [ 0]
|
|| 0 [ 0] 0 [ 0] 0 [ 0]
|
||||||
|
|
||||||
# 2. --show-unbudgeted
|
# 2. --show-unbudgeted
|
||||||
@ -48,13 +49,15 @@ $ hledger bal -D -b 2016-12-01 -e 2016-12-04 -f - --budget --show-unbudgeted
|
|||||||
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
|
||||||
==============================++==============================================================================
|
==================++==================================================================
|
||||||
<unbudgeted>:expenses:cab || 0 0 $15
|
assets || $-10 [ 40% of $-25] $-14 [ 56% of $-25] $-51 [ 204% of $-25]
|
||||||
<unbudgeted>:expenses:movies || 0 0 $25
|
|
||||||
assets:cash || $-10 [ 40% of $-25] $-14 [ 56% of $-25] $-51 [ 204% of $-25]
|
assets:cash || $-10 [ 40% of $-25] $-14 [ 56% of $-25] $-51 [ 204% of $-25]
|
||||||
|
expenses || $10 [ 40% of $25] $14 [ 56% of $25] $51 [ 204% of $25]
|
||||||
|
expenses:cab || 0 0 $15
|
||||||
expenses:food || $10 [ 100% of $10] $9 [ 90% of $10] $11 [ 110% of $10]
|
expenses:food || $10 [ 100% of $10] $9 [ 90% of $10] $11 [ 110% of $10]
|
||||||
expenses:leisure || 0 [ 0% of $15] $5 [ 33% of $15] 0 [ 0% of $15]
|
expenses:leisure || 0 [ 0% of $15] $5 [ 33% of $15] 0 [ 0% of $15]
|
||||||
------------------------------++------------------------------------------------------------------------------
|
expenses:movies || 0 0 $25
|
||||||
|
------------------++------------------------------------------------------------------
|
||||||
|| 0 [ 0] 0 [ 0] 0 [ 0]
|
|| 0 [ 0] 0 [ 0] 0 [ 0]
|
||||||
|
|
||||||
# 3. Test that budget works with mix of commodities
|
# 3. Test that budget works with mix of commodities
|
||||||
@ -96,12 +99,13 @@ $ hledger bal -D -b 2016-12-01 -e 2016-12-04 -f - --budget
|
|||||||
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
|
||||||
==================++=====================================================================================
|
==================++======================================================================================
|
||||||
<unbudgeted> || 0 0 $40
|
assets || $-15 [ 60% of $-25] $-26 [ 104% of $-25] $-51 [ 204% of $-25]
|
||||||
assets:cash || $-15 [ 60% of $-25] $-26 [ 104% of $-25] $-51 [ 204% of $-25]
|
assets:cash || $-15 [ 60% of $-25] $-26 [ 104% of $-25] $-51 [ 204% of $-25]
|
||||||
|
expenses || £10 [ 60% of $25] $5, 20 CAD [ 104% of $25] $51 [ 204% of $25]
|
||||||
expenses:food || £10 [ 150% of $10] 20 CAD [ 210% of $10] $11 [ 110% of $10]
|
expenses:food || £10 [ 150% of $10] 20 CAD [ 210% of $10] $11 [ 110% of $10]
|
||||||
expenses:leisure || 0 [ 0% of $15] $5 [ 33% of $15] 0 [ 0% of $15]
|
expenses:leisure || 0 [ 0% of $15] $5 [ 33% of $15] 0 [ 0% of $15]
|
||||||
------------------++-------------------------------------------------------------------------------------
|
------------------++--------------------------------------------------------------------------------------
|
||||||
|| $-15, £10 [ 0] $-21, 20 CAD [ 0] 0 [ 0]
|
|| $-15, £10 [ 0] $-21, 20 CAD [ 0] 0 [ 0]
|
||||||
|
|
||||||
<
|
<
|
||||||
@ -130,11 +134,11 @@ $ hledger -f- bal --budget
|
|||||||
Budget performance in 2018/01/01-2018/01/03:
|
Budget performance in 2018/01/01-2018/01/03:
|
||||||
|
|
||||||
|| 2018/01/01-2018/01/03
|
|| 2018/01/01-2018/01/03
|
||||||
===++==========================
|
===++=======================
|
||||||
a || 2 [ 7% of 30]
|
a || 2 [ 7% of 30]
|
||||||
b || 2 [ 2% of 100]
|
b || 2 [ 2% of 100]
|
||||||
c || 2 [ 0% of 1000]
|
c || 2 [ 0% of 1000]
|
||||||
---++--------------------------
|
---++-----------------------
|
||||||
|| 6 [ 1% of 1130]
|
|| 6 [ 1% of 1130]
|
||||||
|
|
||||||
# 5. Multiple periodic transactions with different intervals are combined.
|
# 5. Multiple periodic transactions with different intervals are combined.
|
||||||
@ -144,11 +148,11 @@ $ hledger -f- bal --budget -D
|
|||||||
Budget performance in 2018/01/01-2018/01/03:
|
Budget performance in 2018/01/01-2018/01/03:
|
||||||
|
|
||||||
|| 2018/01/01 2018/01/02 2018/01/03
|
|| 2018/01/01 2018/01/02 2018/01/03
|
||||||
===++==============================================================================
|
===++=========================================================
|
||||||
a || 1 [ 10% of 10] 0 [ 0% of 10] 1 [ 10% of 10]
|
a || 1 [ 10% of 10] 0 [ 0% of 10] 1 [ 10% of 10]
|
||||||
b || 1 [ 1% of 100] 0 [ 0] 1 [ 0]
|
b || 1 [ 1% of 100] 0 [ 0] 1 [ 0]
|
||||||
c || 1 [ 0% of 1000] 0 [ 0] 1 [ 0]
|
c || 1 [ 0% of 1000] 0 [ 0] 1 [ 0]
|
||||||
---++------------------------------------------------------------------------------
|
---++---------------------------------------------------------
|
||||||
|| 3 [ 0% of 1110] 0 [ 0% of 10] 3 [ 30% of 10]
|
|| 3 [ 0% of 1110] 0 [ 0% of 10] 3 [ 30% of 10]
|
||||||
|
|
||||||
# 6. Budget goals with higher frequency than the report get added up appropriately.
|
# 6. Budget goals with higher frequency than the report get added up appropriately.
|
||||||
@ -156,11 +160,11 @@ $ hledger -f- bal --budget -W
|
|||||||
Budget performance in 2018/01/01w01:
|
Budget performance in 2018/01/01w01:
|
||||||
|
|
||||||
|| 2018/01/01w01
|
|| 2018/01/01w01
|
||||||
===++==========================
|
===++===================
|
||||||
a || 2 [ 7% of 30]
|
a || 2 [ 7% of 30]
|
||||||
b || 2 [ 2% of 100]
|
b || 2 [ 2% of 100]
|
||||||
c || 2 [ 0% of 1000]
|
c || 2 [ 0% of 1000]
|
||||||
---++--------------------------
|
---++-------------------
|
||||||
|| 6 [ 1% of 1130]
|
|| 6 [ 1% of 1130]
|
||||||
|
|
||||||
# 7. A bounded two day budget. The end date is exclusive as usual.
|
# 7. A bounded two day budget. The end date is exclusive as usual.
|
||||||
@ -188,10 +192,10 @@ $ hledger -f- bal --budget -D
|
|||||||
Budget performance in 2018/01/01-2018/01/04:
|
Budget performance in 2018/01/01-2018/01/04:
|
||||||
|
|
||||||
|| 2018/01/01 2018/01/02 2018/01/03 2018/01/04
|
|| 2018/01/01 2018/01/02 2018/01/03 2018/01/04
|
||||||
==============++========================================================================================================
|
==============++================================================================
|
||||||
<unbudgeted> || 1 1 1 1
|
<unbudgeted> || 1 1 1 1
|
||||||
a || 1 1 [ 100% of 1] 1 [ 100% of 1] 1
|
a || 1 1 [ 100% of 1] 1 [ 100% of 1] 1
|
||||||
--------------++--------------------------------------------------------------------------------------------------------
|
--------------++----------------------------------------------------------------
|
||||||
|| 2 2 [ 200% of 1] 2 [ 200% of 1] 2
|
|| 2 2 [ 200% of 1] 2 [ 200% of 1] 2
|
||||||
|
|
||||||
# 8. Multiple bounded budgets.
|
# 8. Multiple bounded budgets.
|
||||||
@ -218,9 +222,9 @@ $ hledger -f- bal --budget -D
|
|||||||
Budget performance in 2018/01/01-2018/01/04:
|
Budget performance in 2018/01/01-2018/01/04:
|
||||||
|
|
||||||
|| 2018/01/01 2018/01/02 2018/01/03 2018/01/04
|
|| 2018/01/01 2018/01/02 2018/01/03 2018/01/04
|
||||||
===++========================================================================================================
|
===++====================================================================
|
||||||
a || 1 [ 100% of 1] 1 [ 100% of 1] 1 [ 10% of 10] 1 [ 10% of 10]
|
a || 1 [ 100% of 1] 1 [ 100% of 1] 1 [ 10% of 10] 1 [ 10% of 10]
|
||||||
---++--------------------------------------------------------------------------------------------------------
|
---++--------------------------------------------------------------------
|
||||||
|| 1 [ 100% of 1] 1 [ 100% of 1] 1 [ 10% of 10] 1 [ 10% of 10]
|
|| 1 [ 100% of 1] 1 [ 100% of 1] 1 [ 10% of 10] 1 [ 10% of 10]
|
||||||
|
|
||||||
# 9. A "from A to B" budget should not be included in a report beginning on B.
|
# 9. A "from A to B" budget should not be included in a report beginning on B.
|
||||||
@ -228,9 +232,9 @@ $ hledger -f- bal --budget -D -b 2018/1/3
|
|||||||
Budget performance in 2018/01/03-2018/01/04:
|
Budget performance in 2018/01/03-2018/01/04:
|
||||||
|
|
||||||
|| 2018/01/03 2018/01/04
|
|| 2018/01/03 2018/01/04
|
||||||
===++====================================================
|
===++==================================
|
||||||
a || 1 [ 10% of 10] 1 [ 10% of 10]
|
a || 1 [ 10% of 10] 1 [ 10% of 10]
|
||||||
---++----------------------------------------------------
|
---++----------------------------------
|
||||||
|| 1 [ 10% of 10] 1 [ 10% of 10]
|
|| 1 [ 10% of 10] 1 [ 10% of 10]
|
||||||
|
|
||||||
<
|
<
|
||||||
@ -250,9 +254,9 @@ $ hledger -f- bal --budget -D date:2018/1/1-2018/1/3
|
|||||||
Budget performance in 2018/01/01-2018/01/02:
|
Budget performance in 2018/01/01-2018/01/02:
|
||||||
|
|
||||||
|| 2018/01/01 2018/01/02
|
|| 2018/01/01 2018/01/02
|
||||||
===++====================================================
|
===++================================
|
||||||
a || 0 [ 0% of 1] 0 [ 0% of 1]
|
a || 0 [ 0% of 1] 0 [ 0% of 1]
|
||||||
---++----------------------------------------------------
|
---++--------------------------------
|
||||||
|| 0 [ 0% of 1] 0 [ 0% of 1]
|
|| 0 [ 0% of 1] 0 [ 0% of 1]
|
||||||
|
|
||||||
# 11. With -E, zeroes are shown
|
# 11. With -E, zeroes are shown
|
||||||
@ -260,9 +264,9 @@ $ hledger -f- bal --budget -D date:2018/1/1-2018/1/3 -E
|
|||||||
Budget performance in 2018/01/01-2018/01/02:
|
Budget performance in 2018/01/01-2018/01/02:
|
||||||
|
|
||||||
|| 2018/01/01 2018/01/02
|
|| 2018/01/01 2018/01/02
|
||||||
===++====================================================
|
===++================================
|
||||||
a || 0 [ 0% of 1] 0 [ 0% of 1]
|
a || 0 [ 0% of 1] 0 [ 0% of 1]
|
||||||
---++----------------------------------------------------
|
---++--------------------------------
|
||||||
|| 0 [ 0% of 1] 0 [ 0% of 1]
|
|| 0 [ 0% of 1] 0 [ 0% of 1]
|
||||||
|
|
||||||
# 12. subaccounts of budgeted accounts count towards budget
|
# 12. subaccounts of budgeted accounts count towards budget
|
||||||
@ -277,7 +281,7 @@ $ hledger -f- bal --budget -N
|
|||||||
Budget performance in 2018/01/01:
|
Budget performance in 2018/01/01:
|
||||||
|
|
||||||
|| 2018/01/01
|
|| 2018/01/01
|
||||||
===++==========================
|
===++================
|
||||||
a || 1 [ 100% of 1]
|
a || 1 [ 100% of 1]
|
||||||
|
|
||||||
# 13. budget goals on both parent and subaccounts are counted
|
# 13. budget goals on both parent and subaccounts are counted
|
||||||
@ -294,21 +298,22 @@ $ hledger -f- bal --budget
|
|||||||
Budget performance in 2018/01/01:
|
Budget performance in 2018/01/01:
|
||||||
|
|
||||||
|| 2018/01/01
|
|| 2018/01/01
|
||||||
=======++==========================
|
=======++==================
|
||||||
a || 1 [ 1% of 100]
|
a || 2 [ 2% of 101]
|
||||||
|
a:b || 1 [ 100% of 1]
|
||||||
a:b:c || 1 [ 100% of 1]
|
a:b:c || 1 [ 100% of 1]
|
||||||
-------++--------------------------
|
-------++------------------
|
||||||
|| 2 [ 2% of 101]
|
|| 2 [ 2% of 101]
|
||||||
|
|
||||||
$ hledger -f- bal --budget --tree
|
$ hledger -f- bal --budget --tree
|
||||||
Budget performance in 2018/01/01:
|
Budget performance in 2018/01/01:
|
||||||
|
|
||||||
|| 2018/01/01
|
|| 2018/01/01
|
||||||
=======++==========================
|
=======++==================
|
||||||
a || 2 [ 2% of 101]
|
a || 2 [ 2% of 101]
|
||||||
b || 1 [ 100% of 1]
|
b || 1 [ 100% of 1]
|
||||||
c || 1 [ 100% of 1]
|
c || 1 [ 100% of 1]
|
||||||
-------++--------------------------
|
-------++------------------
|
||||||
|| 2 [ 2% of 101]
|
|| 2 [ 2% of 101]
|
||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
@ -337,10 +342,204 @@ $ hledger -f - bal -M --budget --cumulative --forecast --value
|
|||||||
Budget performance in 2018/05/01-2018/06/30:
|
Budget performance in 2018/05/01-2018/06/30:
|
||||||
|
|
||||||
|| May Jun
|
|| May Jun
|
||||||
================++====================================================
|
================++==========================================
|
||||||
<unbudgeted> || €-10 €-10
|
<unbudgeted> || €-10 €-10
|
||||||
|
assets || €10 €10 [ 0]
|
||||||
assets:bank || 0 €-1 [ 100% of €-1]
|
assets:bank || 0 €-1 [ 100% of €-1]
|
||||||
assets:pension || €10 €11 [1100% of €1]
|
assets:pension || €10 €11 [1100% of €1]
|
||||||
----------------++----------------------------------------------------
|
----------------++------------------------------------------
|
||||||
|| 0 0 [ 0]
|
|| 0 0 [ 0]
|
||||||
|
|
||||||
|
# 17. With subaccounts, child accounts are properly included in the parent balance when budget is checked
|
||||||
|
<
|
||||||
|
~ monthly from 2019/01
|
||||||
|
expenses:personal $1,000.00
|
||||||
|
liabilities
|
||||||
|
|
||||||
|
2019/01/01 Google home hub and home mini x2
|
||||||
|
expenses:personal:electronics $10.00
|
||||||
|
liabilities $-10.00
|
||||||
|
|
||||||
|
2019/01/02 Google Home Hub Permium Subscription
|
||||||
|
expenses:personal:electronics:upgrades $10.00
|
||||||
|
liabilities $-10.00
|
||||||
|
|
||||||
|
2019/01/03 Something else
|
||||||
|
expenses:personal $30.00
|
||||||
|
liabilities $-30.00
|
||||||
|
|
||||||
|
$ hledger -f- bal --budget
|
||||||
|
Budget performance in 2019/01/01-2019/01/03:
|
||||||
|
|
||||||
|
|| 2019/01/01-2019/01/03
|
||||||
|
===================++==============================
|
||||||
|
expenses || $50.00 [ 5% of $1,000.00]
|
||||||
|
expenses:personal || $50.00 [ 5% of $1,000.00]
|
||||||
|
liabilities || $-50.00 [ 5% of $-1000.00]
|
||||||
|
-------------------++------------------------------
|
||||||
|
|| 0 [ 0]
|
||||||
|
|
||||||
|
$ hledger -f- bal --budget --show-unbudgeted
|
||||||
|
Budget performance in 2019/01/01-2019/01/03:
|
||||||
|
|
||||||
|
|| 2019/01/01-2019/01/03
|
||||||
|
========================================++==============================
|
||||||
|
expenses || $50.00 [ 5% of $1,000.00]
|
||||||
|
expenses:personal || $50.00 [ 5% of $1,000.00]
|
||||||
|
expenses:personal:electronics || $20.00
|
||||||
|
expenses:personal:electronics:upgrades || $10.00
|
||||||
|
liabilities || $-50.00 [ 5% of $-1000.00]
|
||||||
|
----------------------------------------++------------------------------
|
||||||
|
|| 0 [ 0]
|
||||||
|
|
||||||
|
$ hledger -f- bal --budget --tree
|
||||||
|
Budget performance in 2019/01/01-2019/01/03:
|
||||||
|
|
||||||
|
|| 2019/01/01-2019/01/03
|
||||||
|
=============++==============================
|
||||||
|
expenses || $50.00 [ 5% of $1,000.00]
|
||||||
|
personal || $50.00 [ 5% of $1,000.00]
|
||||||
|
liabilities || $-50.00 [ 5% of $-1000.00]
|
||||||
|
-------------++------------------------------
|
||||||
|
|| 0 [ 0]
|
||||||
|
|
||||||
|
$ hledger -f- bal --budget --tree --show-unbudgeted
|
||||||
|
Budget performance in 2019/01/01-2019/01/03:
|
||||||
|
|
||||||
|
|| 2019/01/01-2019/01/03
|
||||||
|
=================++==============================
|
||||||
|
expenses || $50.00 [ 5% of $1,000.00]
|
||||||
|
personal || $50.00 [ 5% of $1,000.00]
|
||||||
|
electronics || $20.00
|
||||||
|
upgrades || $10.00
|
||||||
|
liabilities || $-50.00 [ 5% of $-1000.00]
|
||||||
|
-----------------++------------------------------
|
||||||
|
|| 0 [ 0]
|
||||||
|
|
||||||
|
# 18. Subaccounts + nested budgets
|
||||||
|
<
|
||||||
|
~ monthly from 2019/01
|
||||||
|
expenses:personal $1,000.00
|
||||||
|
expenses:personal:electronics $100.00
|
||||||
|
liabilities
|
||||||
|
|
||||||
|
2019/01/01 Google home hub and home mini x2
|
||||||
|
expenses:personal:electronics $10.00
|
||||||
|
liabilities $-10.00
|
||||||
|
|
||||||
|
2019/01/02 Google Home Hub Permium Subscription
|
||||||
|
expenses:personal:electronics:upgrades $10.00
|
||||||
|
liabilities $-10.00
|
||||||
|
|
||||||
|
2019/01/03 Something else
|
||||||
|
expenses:personal $30.00
|
||||||
|
liabilities $-30.00
|
||||||
|
|
||||||
|
$ hledger -f- bal --budget
|
||||||
|
Budget performance in 2019/01/01-2019/01/03:
|
||||||
|
|
||||||
|
|| 2019/01/01-2019/01/03
|
||||||
|
===============================++==============================
|
||||||
|
expenses || $50.00 [ 5% of $1100.00]
|
||||||
|
expenses:personal || $50.00 [ 5% of $1100.00]
|
||||||
|
expenses:personal:electronics || $20.00 [ 20% of $100.00]
|
||||||
|
liabilities || $-50.00 [ 5% of $-1100.00]
|
||||||
|
-------------------------------++------------------------------
|
||||||
|
|| 0 [ 0]
|
||||||
|
|
||||||
|
$ hledger -f- bal --budget --show-unbudgeted
|
||||||
|
Budget performance in 2019/01/01-2019/01/03:
|
||||||
|
|
||||||
|
|| 2019/01/01-2019/01/03
|
||||||
|
========================================++==============================
|
||||||
|
expenses || $50.00 [ 5% of $1100.00]
|
||||||
|
expenses:personal || $50.00 [ 5% of $1100.00]
|
||||||
|
expenses:personal:electronics || $20.00 [ 20% of $100.00]
|
||||||
|
expenses:personal:electronics:upgrades || $10.00
|
||||||
|
liabilities || $-50.00 [ 5% of $-1100.00]
|
||||||
|
----------------------------------------++------------------------------
|
||||||
|
|| 0 [ 0]
|
||||||
|
|
||||||
|
$ hledger -f- bal --budget --tree
|
||||||
|
Budget performance in 2019/01/01-2019/01/03:
|
||||||
|
|
||||||
|
|| 2019/01/01-2019/01/03
|
||||||
|
=================++==============================
|
||||||
|
expenses || $50.00 [ 5% of $1100.00]
|
||||||
|
personal || $50.00 [ 5% of $1100.00]
|
||||||
|
electronics || $20.00 [ 20% of $100.00]
|
||||||
|
liabilities || $-50.00 [ 5% of $-1100.00]
|
||||||
|
-----------------++------------------------------
|
||||||
|
|| 0 [ 0]
|
||||||
|
|
||||||
|
$ hledger -f- bal --budget --tree --show-unbudgeted
|
||||||
|
Budget performance in 2019/01/01-2019/01/03:
|
||||||
|
|
||||||
|
|| 2019/01/01-2019/01/03
|
||||||
|
=================++==============================
|
||||||
|
expenses || $50.00 [ 5% of $1100.00]
|
||||||
|
personal || $50.00 [ 5% of $1100.00]
|
||||||
|
electronics || $20.00 [ 20% of $100.00]
|
||||||
|
upgrades || $10.00
|
||||||
|
liabilities || $-50.00 [ 5% of $-1100.00]
|
||||||
|
-----------------++------------------------------
|
||||||
|
|| 0 [ 0]
|
||||||
|
|
||||||
|
## Zero budget == no budget
|
||||||
|
<
|
||||||
|
~ monthly from 2019-01
|
||||||
|
expenses:bills $100 ; bills has a $100 budget of its own, separate from subaccounts
|
||||||
|
expenses:bills:a $20 ; a has non-zero budget and non-zero posted amount
|
||||||
|
expenses:bills:b $200 ; b's budget is larger than bills'; we can see it's added to, not part of, that
|
||||||
|
expenses:bills:c $50 ; c has a budget but no postings
|
||||||
|
expenses:bills:f $0 ; f has an explicit zero budget
|
||||||
|
income:cash ; cash has a negative $370 budget balancing the above
|
||||||
|
|
||||||
|
2019-01-01 transaction1
|
||||||
|
income:cash
|
||||||
|
expenses:bills:a $10
|
||||||
|
expenses:bills:b $40
|
||||||
|
expenses:bills:d $20 ; d has postings but no budget
|
||||||
|
expenses:bills:e $10 ; e has postings summing to zero, and no budget
|
||||||
|
expenses:bills:f $10
|
||||||
|
|
||||||
|
2019-01-02 transaction2
|
||||||
|
income:cash
|
||||||
|
expenses:bills:e -$10
|
||||||
|
|
||||||
|
# By default it hides d (because no budget) and e (because zero posted amount).
|
||||||
|
# f is shown though its budget is zero, it probably shouldn't be.
|
||||||
|
$ hledger bal -f- --budget
|
||||||
|
Budget performance in 2019/01/01-2019/01/02:
|
||||||
|
|
||||||
|
|| 2019/01/01-2019/01/02
|
||||||
|
==================++=======================
|
||||||
|
expenses || $80 [ 22% of $370]
|
||||||
|
expenses:bills || $80 [ 22% of $370]
|
||||||
|
expenses:bills:a || $10 [ 50% of $20]
|
||||||
|
expenses:bills:b || $40 [ 20% of $200]
|
||||||
|
expenses:bills:c || 0 [ 0% of $50]
|
||||||
|
expenses:bills:f || $10 [ 0]
|
||||||
|
income || $-80 [ 22% of $-370]
|
||||||
|
income:cash || $-80 [ 22% of $-370]
|
||||||
|
------------------++-----------------------
|
||||||
|
|| 0 [ 0]
|
||||||
|
|
||||||
|
# --show-unbudgeted shows d
|
||||||
|
$ hledger bal -f- --budget --show-unbudgeted
|
||||||
|
Budget performance in 2019/01/01-2019/01/02:
|
||||||
|
|
||||||
|
|| 2019/01/01-2019/01/02
|
||||||
|
==================++=======================
|
||||||
|
expenses || $80 [ 22% of $370]
|
||||||
|
expenses:bills || $80 [ 22% of $370]
|
||||||
|
expenses:bills:a || $10 [ 50% of $20]
|
||||||
|
expenses:bills:b || $40 [ 20% of $200]
|
||||||
|
expenses:bills:c || 0 [ 0% of $50]
|
||||||
|
expenses:bills:d || $20
|
||||||
|
expenses:bills:f || $10 [ 0]
|
||||||
|
income || $-80 [ 22% of $-370]
|
||||||
|
income:cash || $-80 [ 22% of $-370]
|
||||||
|
------------------++-----------------------
|
||||||
|
|| 0 [ 0]
|
||||||
|
|
||||||
|
|||||||
@ -39,9 +39,10 @@ $ hledger -f- bal --budget -DTN
|
|||||||
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 Total
|
|| 2016/12/01 2016/12/02 2016/12/03 Total
|
||||||
==================++========================================================================================================
|
==================++========================================================================================
|
||||||
<unbudgeted> || 0 0 $40 $40
|
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]
|
||||||
|
expenses || $10 [ 40% of $25] $14 [ 56% of $25] $51 [ 204% of $25] $75 [ 100% of $75]
|
||||||
expenses:food || $10 [ 100% of $10] $9 [ 90% of $10] $11 [ 110% of $10] $30 [ 100% of $30]
|
expenses:food || $10 [ 100% of $10] $9 [ 90% of $10] $11 [ 110% of $10] $30 [ 100% of $30]
|
||||||
expenses:leisure || 0 [ 0% of $15] $5 [ 33% of $15] 0 [ 0% of $15] $5 [ 11% of $45]
|
expenses:leisure || 0 [ 0% of $15] $5 [ 33% of $15] 0 [ 0% of $15] $5 [ 11% of $45]
|
||||||
|
|
||||||
@ -84,10 +85,11 @@ $ hledger -f- bal --budget -DTN
|
|||||||
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 Total
|
|| 2016/12/01 2016/12/02 2016/12/03 Total
|
||||||
==================++========================================================================================================
|
==================++========================================================================================
|
||||||
<unbudgeted> || 0 0 $40 $40
|
expenses || $10 [ 40% of $25] $14 [ 56% of $25] $51 [ 204% of $25] $75 [ 100% of $75]
|
||||||
expenses:leisure || 0 [ 0% of $15] $5 [ 33% of $15] 0 [ 0% of $15] $5 [ 11% of $45]
|
expenses:leisure || 0 [ 0% of $15] $5 [ 33% of $15] 0 [ 0% of $15] $5 [ 11% of $45]
|
||||||
expenses:food || $10 [ 100% of $10] $9 [ 90% of $10] $11 [ 110% of $10] $30 [ 100% of $30]
|
expenses:food || $10 [ 100% of $10] $9 [ 90% of $10] $11 [ 110% of $10] $30 [ 100% of $30]
|
||||||
|
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. --show-unbudgeted
|
||||||
@ -157,10 +159,11 @@ $ hledger -f- bal --budget -DTNS
|
|||||||
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 Total
|
|| 2016/12/01 2016/12/02 2016/12/03 Total
|
||||||
==================++========================================================================================================
|
==================++========================================================================================
|
||||||
<unbudgeted> || 0 0 $40 $40
|
expenses || $10 [ 40% of $25] $14 [ 56% of $25] $51 [ 204% of $25] $75 [ 100% of $75]
|
||||||
expenses:food || $10 [ 100% of $10] $9 [ 90% of $10] $11 [ 110% of $10] $30 [ 100% of $30]
|
expenses:food || $10 [ 100% of $10] $9 [ 90% of $10] $11 [ 110% of $10] $30 [ 100% of $30]
|
||||||
expenses:leisure || 0 [ 0% of $15] $5 [ 33% of $15] 0 [ 0% of $15] $5 [ 11% of $45]
|
expenses:leisure || 0 [ 0% of $15] $5 [ 33% of $15] 0 [ 0% of $15] $5 [ 11% of $45]
|
||||||
|
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]
|
||||||
|
|
||||||
#** Sort by actual amount, tree mode.
|
#** Sort by actual amount, tree mode.
|
||||||
@ -169,9 +172,8 @@ $ hledger -f- bal --budget -DTNS --tree
|
|||||||
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 Total
|
|| 2016/12/01 2016/12/02 2016/12/03 Total
|
||||||
==============++========================================================================================================
|
===========++========================================================================================
|
||||||
<unbudgeted> || 0 0 $40 $40
|
expenses || $10 [ 40% of $25] $14 [ 56% of $25] $51 [ 204% of $25] $75 [ 100% of $75]
|
||||||
expenses || $10 [ 40% of $25] $14 [ 56% of $25] $11 [ 44% of $25] $35 [ 47% of $75]
|
|
||||||
food || $10 [ 100% of $10] $9 [ 90% of $10] $11 [ 110% of $10] $30 [ 100% of $30]
|
food || $10 [ 100% of $10] $9 [ 90% of $10] $11 [ 110% of $10] $30 [ 100% of $30]
|
||||||
leisure || 0 [ 0% of $15] $5 [ 33% of $15] 0 [ 0% of $15] $5 [ 11% of $45]
|
leisure || 0 [ 0% of $15] $5 [ 33% of $15] 0 [ 0% of $15] $5 [ 11% of $45]
|
||||||
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]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user