extra: tests for equity and rewrite

This commit is contained in:
Mykola Orliuk 2017-01-01 10:49:36 +02:00 committed by Simon Michael
parent fe457fa12a
commit 44538cce57
2 changed files with 172 additions and 0 deletions

97
tests/extra/equity.test Normal file
View File

@ -0,0 +1,97 @@
# Tests for equity addon
# Simple case
runghc ../../extra/hledger-equity.hs -f- -p 2016 assets liabilities
<<<
2016/1/1 open
assets:bank $100
assets:cash $20
equity:opening
2016/1/15 spend
expenses:sweets $5
assets:cash
2016/1/19 withdraw
assets:cash $20
assets:bank
2016/1/20 lend
liabilities $25
assets:cash
>>>
2016/12/31 closing balances
assets:bank $-80
assets:cash $-10
liabilities $-25
equity:closing balances
2017/01/01 opening balances
assets:bank $80
assets:cash $10
liabilities $25
equity:opening balances
>>>=0
# Verify effect of period
runghc ../../extra/hledger-equity.hs -f- -p 2016 assets liabilities
<<<
2015/12/31 open
assets:bank $100
assets:cash $20
equity:opening
2016/1/15 spend
expenses:sweets $5
assets:cash
2016/1/19 withdraw
assets:cash $20
assets:bank
2017/1/1 lend
liabilities $25
assets:cash
>>>
2016/12/31 closing balances
assets:bank $20
assets:cash $-15
equity:closing balances
2017/01/01 opening balances
assets:bank $-20
assets:cash $15
equity:opening balances
>>>=0
# # Tear transaction across periods
# # TODO: clarify what should we see for this case
# runghc ../../extra/hledger-equity.hs -f- -p 2016 assets liabilities
# <<<
# 2016/1/1 open
# assets:bank $100
# assets:cash $20
# equity:opening
#
# 2016/1/15 spend
# expenses:sweets $5
# assets:cash
#
# 2017/1/1 withdraw and lend
# liabilities $25
# assets:cash $-5
# assets:bank $-20 ; date:2016/12/31
# >>>
# 2016/12/31 closing balances
# assets:bank $-80
# assets:cash $-15
# equity:closing balances
#
# 2017/01/01 opening balances
# assets:bank $80
# assets:cash $15
# equity:opening balances
#
# >>>=0

75
tests/extra/rewrite.test Normal file
View File

@ -0,0 +1,75 @@
# Tests for rewrite addon
# Add proportional income tax (from documentation)
runghc ../../extra/hledger-rewrite.hs -f- ^income --add-posting '(liabilities:tax) *.33'
<<<
2016/1/1 paycheck
income:remuneration $-100
assets:bank
2016/1/1 withdraw
assets:cash $20
assets:bank
>>>
2016/01/01 paycheck
income:remuneration $-100
assets:bank $100
(liabilities:tax) $-33
2016/01/01 withdraw
assets:cash $20
assets:bank $-20
>>>=0
# Duplicate posting for budgeting (from documentation)
runghc ../../extra/hledger-rewrite.hs -f- expenses:gifts --add-posting '(budget:gifts) *-1'
<<<
2016/1/1 withdraw
assets:cash $20
assets:bank
2016/1/1 gift
assets:cash $-15
expenses:gifts
>>>
2016/01/01 withdraw
assets:cash $20
assets:bank $-20
2016/01/01 gift
assets:cash $-15
expenses:gifts $15
(budget:gifts) $-15
>>>=0
# Add absolute bank processing fee
runghc ../../extra/hledger-rewrite.hs -f- assets:bank and 'amt:<0' --add-posting 'expenses:fee $5' --add-posting 'assets:bank $-5'
<<<
2016/1/1 withdraw
assets:cash $20
assets:bank
2016/1/2 withdraw
assets:cash
assets:bank $-30
# # TODO: Fix to filter out this txn by missing amt:<0 condition on assets:bank
# 2016/1/31 paycheck
# income:remuneration $-100
# assets:bank
>>>
2016/01/01 withdraw
assets:cash $20
assets:bank $-20
expenses:fee $5
assets:bank $-5
2016/01/02 withdraw
assets:cash $30
assets:bank $-30
expenses:fee $5
assets:bank $-5
>>>=0