hledger/tests/balance-assertions.test

114 lines
1.6 KiB
Plaintext
Raw Normal View History

#!/usr/bin/env shelltest
# 1. test some balance assertions
hledgerdev -f - stats
<<<
2013/1/1
a $1 =$1
b =-$1
2013/1/2
a $1 =$2
b $-1 =$-2
2013/1/3
a $1 = $3
b $-1 = $-3
(b) $1 = $-2
>>> /Transactions/
>>>2
>>>=0
# 2. same entries as 1 but different parse order, assertion should still pass based on date
hledgerdev -f - stats
<<<
2013/1/1
a $1 =$1
b =-$1
2013/1/3
a $1 = $3
b $-1 = $-3
(b) $1 = $-2
2013/1/2
a $1 =$2
b $-1 =$-2
>>> /Transactions/
>>>2
>>>=0
# 3. like 1 but switch order of postings in last entry,
# assertion should fail and exit code should be non zero
hledgerdev -f - stats
<<<
2013/1/1
a $1 =$1
b =-$1
2013/1/2
a $1 =$2
b $-1 =$-2
2013/1/3
a $1 = $3
(b) $1 = $-2
b $-1 = $-3
>>>
>>>2 /Balance assertion failed for account b on 2013-01-03/
>>>=1
# 4. should also work without commodity symbols
hledgerdev -f - stats
<<<
2013/1/1
(a) 1 =1
>>> /Transactions/
>>>2
>>>=0
# 5. should work for fractional amount with trailing zeros
hledgerdev -f - stats
<<<
2013/1/1
a $1.20 =$1.20
b =-$1.20
2013/1/2
a $0.10 =$1.3
b =-$1.3
2013/1/3
a $0.7 =$2
b =-$2
>>> /Transactions/
>>>2
>>>=0
# 6. what should happen here ? Currently,
# in a, 3.4 EUR @@ $5.6 and -3.4 EUR cancel out (wrong ?)
# in b,
#
# hledgerdev -f - stats
# <<<
# 2013/1/1
# a $1.20
# a 3.4 EUR @@ $5.6
# b
# 2013/1/2
# a -3.4 EUR
# b
# 2013/1/3
# a $0.1 =$1.30
# b =-$1.30
# >>> /Transactions/
# >>>2
# >>>=0