mirror of
https://github.com/simonmichael/hledger.git
synced 2024-11-08 15:14:49 +03:00
8ae303f685
This change means you can make assertions on a multi-commodity account balance (asserting one commodity at a time). On the flip side, you can no longer assert the complete balance of an account (new unexpected commodities will not be detected.) We might restore that ability later, using the == syntax.
126 lines
1.8 KiB
Plaintext
Executable File
126 lines
1.8 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. 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
|