mirror of
https://github.com/simonmichael/hledger.git
synced 2024-11-08 07:09:28 +03:00
266 lines
8.1 KiB
Plaintext
266 lines
8.1 KiB
Plaintext
# Test budget addon
|
|
|
|
# Rewrite rules within journal always applied
|
|
../../bin/hledger-budget bal -f - --no-total -DH budget
|
|
<<<
|
|
= ^assets:bank$ date:2017/1 amt:<0
|
|
assets:bank *0.008
|
|
expenses:fee *-0.008 ; cash withdraw fee
|
|
= ^expenses:housing
|
|
(budget:housing) *-1
|
|
= ^expenses:grocery ^expenses:food
|
|
(budget:food) *-1
|
|
|
|
2016/12/31
|
|
expenses:housing $600
|
|
assets:cash
|
|
|
|
2017/1/1
|
|
expenses:food $20
|
|
expenses:leisure $15
|
|
expenses:grocery $30
|
|
assets:cash
|
|
|
|
2017/1/2
|
|
assets:cash $200.00
|
|
assets:bank
|
|
|
|
2017/2/1
|
|
assets:cash $100.00
|
|
assets:bank
|
|
|
|
; order with normal entries doesn't matter
|
|
; but relative order matters to refer-rewritten transactions
|
|
= ^expenses not:housing not:grocery not:food
|
|
(budget:misc) *-1
|
|
>>>
|
|
Ending balances (historical) in 2016/12/31-2017/01/02:
|
|
|
|
|| 2016/12/31 2017/01/01 2017/01/02
|
|
================++====================================
|
|
budget:food || 0 $-50.00 $-50.00
|
|
budget:housing || $-600.00 $-600.00 $-600.00
|
|
budget:misc || 0 $-15.00 $-16.60
|
|
|
|
>>>2
|
|
>>>=0
|
|
|
|
# Rewrite rules can chain one another according to order of definition
|
|
../../bin/hledger-budget reg -f -
|
|
<<<
|
|
|
|
; unfortunately date override in posting comment doesn't work
|
|
|
|
= liabilities:credit amt:<0 date:2016/12
|
|
liabilities:credit *-1 ; [2017/1/1]
|
|
assets:bank *1 ; [2017/1/1]
|
|
|
|
= liabilities:credit amt:<0 date:2017/1
|
|
liabilities:credit *-1 ; [2017/2/1]
|
|
assets:bank *1 ; [2017/2/1]
|
|
|
|
= liabilities:credit amt:<0 date:2017/2
|
|
liabilities:credit *-1 ; [2017/3/1]
|
|
assets:bank *1 ; [2017/3/1]
|
|
|
|
= assets:bank date:2017/2 amt:<0
|
|
assets:bank *0.008
|
|
expenses:fee *-0.008 ; :salary-card: cash withdraw fee
|
|
|
|
= expenses:fee tag:salary-card date:2017-2017/12/26
|
|
income:compensate *-0.5
|
|
assets:bank *0.5 ; compensation from employer
|
|
|
|
2016/12/31
|
|
expenses:housing $600
|
|
liabilities:credit
|
|
|
|
2017/1/1
|
|
expenses:food $20
|
|
expenses:leisure $15
|
|
expenses:grocery $30
|
|
liabilities:credit
|
|
|
|
2017/1/2
|
|
assets:cash $200.00
|
|
liabilities:credit
|
|
|
|
2017/2/1
|
|
assets:cash $100.00
|
|
liabilities:credit
|
|
>>>
|
|
2016/12/31 expenses:housing $600.00 $600.00
|
|
liabilities:credit $-600.00 0
|
|
liabilities:credit $600.00 $600.00
|
|
assets:bank $-600.00 0
|
|
2017/01/01 expenses:food $20.00 $20.00
|
|
expenses:leisure $15.00 $35.00
|
|
expenses:grocery $30.00 $65.00
|
|
liabilities:credit $-65.00 0
|
|
liabilities:credit $65.00 $65.00
|
|
assets:bank $-65.00 0
|
|
2017/01/02 assets:cash $200.00 $200.00
|
|
liabilities:credit $-200.00 0
|
|
liabilities:credit $200.00 $200.00
|
|
assets:bank $-200.00 0
|
|
2017/02/01 assets:cash $100.00 $100.00
|
|
liabilities:credit $-100.00 0
|
|
liabilities:credit $100.00 $100.00
|
|
assets:bank $-100.00 0
|
|
assets:bank $-0.80 $-0.80
|
|
expenses:fee $0.80 0
|
|
income:compensate $-0.40 $-0.40
|
|
assets:bank $0.40 0
|
|
>>>2
|
|
>>>=0
|
|
|
|
# Periodical transactions within journal being applied with inverted sign in amounts
|
|
# As well, accounts from periodic transaction being used for bucketing
|
|
../../bin/hledger-budget bal -f - --no-total -DH expenses
|
|
<<<
|
|
~ daily from 2016/12/31
|
|
expenses:food $8
|
|
assets
|
|
|
|
~ weekly
|
|
expenses:leisure $20
|
|
expenses:grocery $50
|
|
expenses:housing $250
|
|
expenses:fee $10
|
|
assets
|
|
|
|
= ^assets:bank$ date:2017/1 amt:<0
|
|
assets:bank *0.008
|
|
expenses:fee *-0.008 ; cash withdraw fee
|
|
|
|
2016/12/31
|
|
expenses:housing:rent $600
|
|
assets:cash
|
|
|
|
2017/1/1
|
|
expenses:food $20
|
|
expenses:leisure $15
|
|
expenses:grocery $30
|
|
assets:cash
|
|
|
|
2017/1/2
|
|
assets:cash $200.00
|
|
assets:bank
|
|
|
|
2017/1/4
|
|
assets:cash $100.00
|
|
assets:bank
|
|
>>>
|
|
Ending balances (historical) in 2016/12/26-2017/01/04:
|
|
|
|
|| 2016/12/26 2016/12/27 2016/12/28 2016/12/29 2016/12/30 2016/12/31 2017/01/01 2017/01/02 2017/01/03 2017/01/04
|
|
==================++========================================================================================================================
|
|
expenses:fee || $-10 $-10 $-10 $-10 $-10 $-10 $-10 $-18.40 $-18.40 $-17.60
|
|
expenses:food || 0 0 0 0 0 $-8 $4.00 $-4.00 $-12.00 $-20.00
|
|
expenses:grocery || $-50 $-50 $-50 $-50 $-50 $-50 $-20.00 $-70.00 $-70.00 $-70.00
|
|
expenses:housing || $-250 $-250 $-250 $-250 $-250 $350.00 $350.00 $100.00 $100.00 $100.00
|
|
expenses:leisure || $-20 $-20 $-20 $-20 $-20 $-20 $-5.00 $-25.00 $-25.00 $-25.00
|
|
|
|
>>>2
|
|
>>>=0
|
|
|
|
# We still can disable bucketing keeping rewrites and budget offset
|
|
../../bin/hledger-budget bal -f - --no-total --no-buckets -DH expenses
|
|
<<<
|
|
~ daily from 2016/12/31
|
|
expenses:food $8
|
|
assets
|
|
|
|
= ^assets:bank$ date:2017/1 amt:<0
|
|
assets:bank *0.008
|
|
expenses:fee *-0.008 ; cash withdraw fee
|
|
|
|
2016/12/31
|
|
expenses:housing:rent $600
|
|
assets:bank
|
|
|
|
2017/1/1
|
|
expenses:food $20
|
|
expenses:leisure $15
|
|
expenses:grocery $30
|
|
assets:bank
|
|
>>>
|
|
Ending balances (historical) in 2016/12/31-2017/01/01:
|
|
|
|
|| 2016/12/31 2017/01/01
|
|
=======================++========================
|
|
expenses:fee || 0 $1
|
|
expenses:food || $-8 $4
|
|
expenses:grocery || 0 $30
|
|
expenses:housing:rent || $600 $600
|
|
expenses:leisure || 0 $15
|
|
|
|
>>>2
|
|
>>>=0
|
|
|
|
# We can disable offset keeping rewrites and bucketing
|
|
# Note that original account names used for query
|
|
../../bin/hledger-budget bal -f - --no-total --no-offset -DH expenses
|
|
<<<
|
|
~ daily from 2016/12/31
|
|
expenses:food $8
|
|
assets
|
|
|
|
= ^assets:bank$ date:2017/1 amt:<0
|
|
assets:bank *0.008
|
|
expenses:fee *-0.008 ; cash withdraw fee
|
|
|
|
2016/12/31
|
|
expenses:housing:rent $600
|
|
assets:bank
|
|
|
|
2017/1/1
|
|
expenses:food $20
|
|
expenses:leisure $15
|
|
expenses:grocery $30
|
|
assets:bank
|
|
>>>
|
|
Ending balances (historical) in 2016/12/31-2017/01/01:
|
|
|
|
|| 2016/12/31 2017/01/01
|
|
===============++========================
|
|
<unbucketed> || $600 $646
|
|
expenses:food || 0 $20
|
|
|
|
>>>2
|
|
>>>=0
|
|
|
|
# We can keep just rewrites
|
|
../../bin/hledger-budget bal -f - --no-total --no-buckets --no-offset -DH expenses
|
|
<<<
|
|
~ daily from 2016/12/31
|
|
expenses:food $8
|
|
assets
|
|
|
|
= ^assets:bank$ date:2017/1 amt:<0
|
|
assets:bank *0.008
|
|
expenses:fee *-0.008 ; cash withdraw fee
|
|
|
|
2016/12/31
|
|
expenses:housing:rent $600
|
|
assets:bank
|
|
|
|
2017/1/1
|
|
expenses:food $20
|
|
expenses:leisure $15
|
|
expenses:grocery $30
|
|
assets:bank
|
|
>>>
|
|
Ending balances (historical) in 2016/12/31-2017/01/01:
|
|
|
|
|| 2016/12/31 2017/01/01
|
|
=======================++========================
|
|
expenses:fee || 0 $1
|
|
expenses:food || 0 $20
|
|
expenses:grocery || 0 $30
|
|
expenses:housing:rent || $600 $600
|
|
expenses:leisure || 0 $15
|
|
|
|
>>>2
|
|
>>>=0
|