hledger/tests/budget/budget.test
2018-03-29 16:36:31 +01:00

231 lines
7.6 KiB
Plaintext

# balance --budget tests
2016/12/01
expenses:food $10
assets:cash
2016/12/02
expenses:food $9
assets:cash
2016/12/03
expenses:food $11
assets:cash
2016/12/02
expenses:leisure $5
assets:cash
2016/12/03
expenses:movies $25
assets:cash
2016/12/03
expenses:cab $15
assets:cash
~ daily from 2016/1/1
expenses:food $10
expenses:leisure $15
assets:cash
# 1. Test --budget switch
$ hledger bal -D -b 2016-12-01 -e 2016-12-04 -f - --budget
Balance changes in 2016/12/01-2016/12/03:
|| 2016/12/01 2016/12/02 2016/12/03
=======================++==============================================================================
<unbudgeted>:expenses || 0 0 $40
assets:cash || $-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:leisure || 0 [ 0% of $15] $5 [ 33% of $15] 0 [ 0% of $15]
-----------------------++------------------------------------------------------------------------------
|| 0 0 0
# 2. --show-unbudgeted
$ hledger bal -D -b 2016-12-01 -e 2016-12-04 -f - --budget --show-unbudgeted
Balance changes in 2016/12/01-2016/12/03:
|| 2016/12/01 2016/12/02 2016/12/03
==================++==============================================================================
assets:cash || $-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:leisure || 0 [ 0% of $15] $5 [ 33% of $15] 0 [ 0% of $15]
expenses:movies || 0 0 $25
------------------++------------------------------------------------------------------------------
|| 0 0 0
# 3. Test that budget works with mix of commodities
<
2016/12/01
expenses:food £10 @@ $15
assets:cash
2016/12/02
expenses:food 10 CAD @ $1
assets:cash
2016/12/02
expenses:food 10 CAD @ $1.1
assets:cash
2016/12/03
expenses:food $11
assets:cash
2016/12/02
expenses:leisure $5
assets:cash
2016/12/03
expenses:movies $25
assets:cash
2016/12/03
expenses:cab $15
assets:cash
~ daily from 2016/1/1
expenses:food $10
expenses:leisure $15
assets:cash
$ hledger bal -D -b 2016-12-01 -e 2016-12-04 -f - --budget
Balance changes in 2016/12/01-2016/12/03:
|| 2016/12/01 2016/12/02 2016/12/03
=======================++=======================================================================================
<unbudgeted>:expenses || 0 0 $40
assets:cash || $-15 [ 60% of $-25] $-26.0 [ 104% of $-25] $-51 [ 204% of $-25]
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]
-----------------------++---------------------------------------------------------------------------------------
|| $-15, £10 $-21.0, 20 CAD 0
<
~ daily
(a) 10
~weekly
(b) 100
~weekly
(c) 1000
2018/1/1
(a) 1
(b) 1
(c) 1
2018/1/3
(a) 1
(b) 1
(c) 1
# 4. --budget uses only periodic transactions of the specified interval.
# No interval - same as a regular balance report.
$ hledger -f- bal --budget
2 a
2 b
2 c
--------------------
6
# 5. With -D it selects the daily budget.
# The budget is unbounded, so extends through the report period.
$ hledger -f- bal --budget -D
Balance changes in 2018/01/01-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]
b || 1 0 1
c || 1 0 1
---++------------------------------------------------------------------------------
|| 3 0 3
# 6. And with -W it selects the weekly budget, defined by all weekly periodic transactions.
$ hledger -f- bal --budget -W
Balance changes in 2018/01/01w01:
|| 2018/01/01w01
===++==========================
a || 2
b || 2 [ 2% of 100]
c || 2 [ 0% of 1000]
---++--------------------------
|| 6
# 7. A bounded two day budget. The end date is exclusive as usual.
<
~ daily from 2018/1/2 to 2018/1/4
(a) 1
2018/1/1
(a) 1
(b) 1
2018/1/2
(a) 1
(b) 1
2018/1/3
(a) 1
(b) 1
2018/1/4
(a) 1
(b) 1
$ hledger -f- bal --budget -D
Balance changes in 2018/01/01-2018/01/04:
|| 2018/01/01 2018/01/02 2018/01/03 2018/01/04
================++========================================================================================================
<unbudgeted>:b || 1 1 1 1
a || 1 1 [ 100% of 1] 1 [ 100% of 1] 1
----------------++--------------------------------------------------------------------------------------------------------
|| 2 2 2 2
# 8. Multiple bounded budgets.
<
~ daily from 2018/1/1 to 2018/1/3
(a) 1
~ daily from 2018/1/3 to 2018/1/5
(a) 10
2018/1/1
(a) 1
2018/1/2
(a) 1
2018/1/3
(a) 1
2018/1/4
(a) 1
$ hledger -f- bal --budget -D
Balance changes in 2018/01/01-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]
---++--------------------------------------------------------------------------------------------------------
|| 1 1 1 1
# 9. A "from A to B" budget should not be included in a report beginning on B.
$ hledger -f- bal --budget -D -b 2018/1/3
Balance changes in 2018/01/03-2018/01/04:
|| 2018/01/03 2018/01/04
===++====================================================
a || 1 [ 10% of 10] 1 [ 10% of 10]
---++----------------------------------------------------
|| 1 1