hledger/tests/misc/pivot.test
Simon Michael 5c09553481 lib: keep amounts aligned when rendering a transaction with posting flags
Related to #563, when rendering a transaction, we reserve two more chars
of width so that amounts remain aligned when there are posting flags.
Affects hledger-ui's transaction screen, print, hledger-rewrite etc.
2017-06-04 21:26:18 -07:00

139 lines
4.3 KiB
Plaintext

# --pivot tests
# check pivot with print
hledger -f- --pivot TAG print
<<<
2016/02/16 Test Transaction
Account1 2 EUR
Account2 -2 EUR
; TAG: value
>>>
2016/02/16 Test Transaction
2 EUR
value -2 EUR
; TAG: value
>>>=0
# check pivot with bal
hledger -f- --pivot member bal --no-total
<<<
2016/02/16 Member Fee Payment John Doe
assets:bank account 2 EUR
income:member fees -2 EUR
; member: John Doe
>>>
2 EUR
-2 EUR John Doe
>>>=0
# check with another example
hledger -f- --pivot budget bal --no-total
<<<
2016/02/16 Donation Freifunk
assets:bank account 2 EUR
income:donations -2 EUR
; budget: Freifunk
>>>
2 EUR
-2 EUR Freifunk
>>>=0
# query on account will find either effective name or original one
hledger -f- --pivot TAG reg '^Account2$' '^fun$' not:hidden
<<<
2016/02/16 Test Transaction
Account1 2 EUR
; TAG: fun
Account2 -1 EUR
; TAG: value
Account2 -1 EUR
; TAG: hidden
>>>
2016/02/16 Test Transaction fun 2 EUR 2 EUR
value -1 EUR 1 EUR
>>>=0
# We should be able to query on original account names
hledger -f- --pivot expenses reg not:liabilities
<<<
2017/1/1 prepay
assets $1500 ; expenses:a
assets $100 ; expenses:b
assets $5 ; expenses:c
liabilities $-1605
>>>
2017/01/01 prepay a $1500 $1500
b $100 $1600
c $5 $1605
>>>=0
# pivot for implicit tag desc (technical sample)
hledger -f- --pivot description reg -M
<<<
2016/02/16 Freifunk
assets:bank account 2 EUR ; date:03/01
income:donations -2 EUR
>>>
2016/02 Freifunk -2 EUR -2 EUR
2016/03 Freifunk 2 EUR 0
>>>=0
# pivot for implicit tag code (technical sample)
hledger -f- --pivot code reg -M
<<<
2016/02/16 (Freifunk) Donation Freifunk
assets:bank account 2 EUR ; date:03/01
income:donations -2 EUR
>>>
2016/02 Freifunk -2 EUR -2 EUR
2016/03 Freifunk 2 EUR 0
>>>=0
# use of pivot with code-based budgeting
hledger -f- --pivot code reg ^income
<<<
2016/02/16 (Freifunk) Donation Freifunk
assets:bank account 2 EUR
income:donations -2 EUR
>>>
2016/02/16 Donation Freifunk Freifunk -2 EUR -2 EUR
>>>=0
# get expenses balance by description/payee
hledger -f- --pivot payee bal --no-total --flat ^expense
<<<
2016/02/16 (1138) Auchan | buy a food for tomorrow morning
assets:bank account
expense:snacks 2 EUR
expense:grocery 20 EUR
2016/02/16 StarBars
assets:bank account
expense:coffee 5 EUR
>>>
22 EUR Auchan
5 EUR StarBars
>>>=0
# get daily expenses by description/payee
hledger -f- --pivot payee reg -D ^expense
<<<
2016/02/16 (1138) Auchan
assets:bank account
expense:snacks 2 EUR
expense:grocery 20 EUR
2016/02/16 StarBars
assets:bank account
expense:coffee 5 EUR
2016/02/17 (1139) Auchan
assets:bank account
expense:grocery 30 EUR
>>>
2016/02/16 Auchan 22 EUR 22 EUR
StarBars 5 EUR 27 EUR
2016/02/17 Auchan 30 EUR 57 EUR
>>>=0