hledger/tests/bin/rewrite.test
Mykola Orliuk 8954944ee6 Apply ModifierTransaction's from journal during hledger-rewrite. (#477)
* rewrite: rewrite every posting

Also start using ModifierTransaction

* rewrite: use journal parser for postings

* rewrite: use ModifierTransactions from Journal

See simonmichael/hledger#99
2017-01-13 12:41:16 -08:00

148 lines
3.2 KiB
Plaintext

# Tests for rewrite addon
# Add proportional income tax (from documentation)
runghc ../../bin/hledger-rewrite.hs -f- ^income --add-posting '(liabilities:tax) *.33 ; income tax'
<<<
2016/1/1 paycheck
income:remuneration $-100
income:donations $-15
assets:bank
2016/1/1 withdraw
assets:cash $20
assets:bank
>>>
2016/01/01 paycheck
income:remuneration $-100
income:donations $-15
assets:bank
(liabilities:tax) $-33 ; income tax
(liabilities:tax) $-5 ; income tax
2016/01/01 withdraw
assets:cash $20
assets:bank
>>>2
>>>=0
# Duplicate posting for budgeting (from documentation)
runghc ../../bin/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
2016/01/01 gift
assets:cash $-15
expenses:gifts
(budget:gifts) $-15
>>>2
>>>=0
# Add absolute bank processing fee
runghc ../../bin/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
expenses:fee $5
assets:bank $-5
2016/01/02 withdraw
assets:cash
assets:bank $-30
expenses:fee $5
assets:bank $-5
>>>2
>>>=0
# Rewrite rule within journal
runghc ../../bin/hledger-rewrite.hs -f- date:2017/1 --add-posting 'Here comes Santa $0'
<<<
= ^expenses:housing
(budget:housing) *-1
= ^expenses:grocery or ^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
= ^expenses not:housing not:grocery not:food
(budget:misc) *-1
= ^assets:bank$ date:2017/1 amt:<0
assets:bank *0.008
expenses:fee *-0.008 ; cash withdraw fee
>>>
2016/12/31
expenses:housing $600.00
assets:cash
2017/01/01
expenses:food $20.00
expenses:leisure $15.00
expenses:grocery $30.00
assets:cash
Here comes Santa 0
Here comes Santa 0
Here comes Santa 0
Here comes Santa 0
(budget:misc) $-15.00
(budget:food) $-20.00
(budget:food) $-30.00
2017/01/02
assets:cash $200.00
assets:bank
Here comes Santa 0
Here comes Santa 0
assets:bank $-1.60
expenses:fee $1.60 ; cash withdraw fee
(budget:misc) $-1.60
2017/02/01
assets:cash $100.00
assets:bank
>>>2
>>>=0