mirror of
https://github.com/simonmichael/hledger.git
synced 2024-11-08 15:14:49 +03:00
257ce57383
A sequence of balance assertions asserting first one commodity, then another, then the first again, was not working.
139 lines
1.9 KiB
Plaintext
Executable File
139 lines
1.9 KiB
Plaintext
Executable File
#!/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. assertions currently check only a single commodity's balance, like Ledger
|
|
hledgerdev -f - stats
|
|
<<<
|
|
1/2
|
|
(a) A1
|
|
(a) B1 = A1
|
|
(a) 0 = A1
|
|
(a) C0 = D0
|
|
>>> /Transactions/
|
|
>>>2
|
|
>>>=0
|
|
|
|
# 7. balances should accumulate (#195)
|
|
hledgerdev -f - stats
|
|
<<<
|
|
1/1
|
|
(a) 1F = 1F
|
|
(a) 2G = 2G
|
|
|
|
1/2
|
|
(a) 3F = 4F
|
|
>>> !/assertion failed/
|
|
>>>2
|
|
>>>=0
|
|
|
|
# 8. 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
|