mirror of
https://github.com/simonmichael/hledger.git
synced 2024-12-28 12:54:07 +03:00
1c6702d598
[ci skip]
319 lines
10 KiB
Plaintext
319 lines
10 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
|
|
Budget performance in 2016/12/01-2016/12/03:
|
|
|
|
|| 2016/12/01 2016/12/02 2016/12/03
|
|
==================++==============================================================================
|
|
<unbudgeted> || 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 [ 0] 0 [ 0]
|
|
|
|
# 2. --show-unbudgeted
|
|
$ hledger bal -D -b 2016-12-01 -e 2016-12-04 -f - --budget --show-unbudgeted
|
|
Budget performance in 2016/12/01-2016/12/03:
|
|
|
|
|| 2016/12/01 2016/12/02 2016/12/03
|
|
==============================++==============================================================================
|
|
<unbudgeted>:expenses:cab || 0 0 $15
|
|
<unbudgeted>:expenses:movies || 0 0 $25
|
|
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 [ 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
|
|
Budget performance in 2016/12/01-2016/12/03:
|
|
|
|
|| 2016/12/01 2016/12/02 2016/12/03
|
|
==================++=====================================================================================
|
|
<unbudgeted> || 0 0 $40
|
|
assets:cash || $-15 [ 60% of $-25] $-26 [ 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 [ 0] $-21, 20 CAD [ 0] 0 [ 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 with no interval shows total budget for the journal period
|
|
# (in tabular format).
|
|
$ hledger -f- bal --budget
|
|
Budget performance in 2018/01/01-2018/01/03:
|
|
|
|
|| 2018/01/01-2018/01/03
|
|
===++==========================
|
|
a || 2 [ 7% of 30]
|
|
b || 2 [ 2% of 100]
|
|
c || 2 [ 0% of 1000]
|
|
---++--------------------------
|
|
|| 6 [ 1% of 1130]
|
|
|
|
# 5. Multiple periodic transactions with different intervals are combined.
|
|
# Budget goals with lower frequency than the report are posted in the
|
|
# appropriate intermittent periods.
|
|
$ hledger -f- bal --budget -D
|
|
Budget performance 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 [ 1% of 100] 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]
|
|
|
|
# 6. Budget goals with higher frequency than the report get added up appropriately.
|
|
$ hledger -f- bal --budget -W
|
|
Budget performance in 2018/01/01w01:
|
|
|
|
|| 2018/01/01w01
|
|
===++==========================
|
|
a || 2 [ 7% of 30]
|
|
b || 2 [ 2% of 100]
|
|
c || 2 [ 0% of 1000]
|
|
---++--------------------------
|
|
|| 6 [ 1% of 1130]
|
|
|
|
# 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
|
|
Budget performance in 2018/01/01-2018/01/04:
|
|
|
|
|| 2018/01/01 2018/01/02 2018/01/03 2018/01/04
|
|
==============++========================================================================================================
|
|
<unbudgeted> || 1 1 1 1
|
|
a || 1 1 [ 100% of 1] 1 [ 100% of 1] 1
|
|
--------------++--------------------------------------------------------------------------------------------------------
|
|
|| 2 2 [ 200% of 1] 2 [ 200% of 1] 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
|
|
Budget performance 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 [ 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.
|
|
$ hledger -f- bal --budget -D -b 2018/1/3
|
|
Budget performance in 2018/01/03-2018/01/04:
|
|
|
|
|| 2018/01/03 2018/01/04
|
|
===++====================================================
|
|
a || 1 [ 10% of 10] 1 [ 10% of 10]
|
|
---++----------------------------------------------------
|
|
|| 1 [ 10% of 10] 1 [ 10% of 10]
|
|
|
|
<
|
|
~ daily
|
|
(a) 1
|
|
|
|
2018/1/2
|
|
(a) 2
|
|
|
|
2018/1/2
|
|
(a) -2
|
|
|
|
# 10. accounts with non-zero budget should be shown by default
|
|
# even if there are no actual transactions in the period,
|
|
# or if the actual amount is zero.
|
|
$ hledger -f- bal --budget -D date:2018/1/1-2018/1/3
|
|
Budget performance in 2018/01/01-2018/01/02:
|
|
|
|
|| 2018/01/01 2018/01/02
|
|
===++====================================================
|
|
a || 0 [ 0% of 1] 0 [ 0% of 1]
|
|
---++----------------------------------------------------
|
|
|| 0 [ 0% of 1] 0 [ 0% of 1]
|
|
|
|
# 11. With -E, zeroes are shown
|
|
$ hledger -f- bal --budget -D date:2018/1/1-2018/1/3 -E
|
|
Budget performance in 2018/01/01-2018/01/02:
|
|
|
|
|| 2018/01/01 2018/01/02
|
|
===++====================================================
|
|
a || 0 [ 0% of 1] 0 [ 0% of 1]
|
|
---++----------------------------------------------------
|
|
|| 0 [ 0% of 1] 0 [ 0% of 1]
|
|
|
|
# 12. subaccounts of budgeted accounts count towards budget
|
|
<
|
|
~ daily
|
|
(a) 1
|
|
|
|
2018/1/1
|
|
(a:b) 1
|
|
|
|
$ hledger -f- bal --budget -N
|
|
Budget performance in 2018/01/01:
|
|
|
|
|| 2018/01/01
|
|
===++==========================
|
|
a || 1 [ 100% of 1]
|
|
|
|
# 13. budget goals on both parent and subaccounts are counted
|
|
<
|
|
~ daily
|
|
(a) 100
|
|
(a:b:c) 1
|
|
|
|
2018/1/1
|
|
(a) 1
|
|
(a:b:c) 1
|
|
|
|
$ hledger -f- bal --budget
|
|
Budget performance in 2018/01/01:
|
|
|
|
|| 2018/01/01
|
|
=======++==========================
|
|
a || 1 [ 1% of 100]
|
|
a:b:c || 1 [ 100% of 1]
|
|
-------++--------------------------
|
|
|| 2 [ 2% of 101]
|
|
|
|
$ hledger -f- bal --budget --tree
|
|
Budget performance in 2018/01/01:
|
|
|
|
|| 2018/01/01
|
|
=======++==========================
|
|
a || 2 [ 2% of 101]
|
|
b || 1 [ 100% of 1]
|
|
c || 1 [ 100% of 1]
|
|
-------++--------------------------
|
|
|| 2 [ 2% of 101]
|
|
|
|
# TODO
|
|
# 14. respect hierarchy when sorting in tree mode
|
|
|
|
# TODO
|
|
# 15. respect --sort-amount
|