mirror of
https://github.com/simonmichael/hledger.git
synced 2024-11-08 07:09:28 +03:00
7437c96ff6
* cli: fix bug in pivot for postings without tag Without this fix for postings without tag query checked effective account which is always empty text (""). * rewrite: inherit dates, change application order For budgeting it is important to inherit actual date of posting if it differs from date of transaction. These dates will be added as a separate line of comment. More natural order of rewrites is when result of first defined one is available for all next rewrites. * rewrite: factor out Hledger.Data.AutoTransaction * rewrite: add diff output With this option you can modify your original files without loosing inter-transaction comments etc. I.e. you can run: hledger-rewrite --diff Agency \ --add-posting 'Expenses:Taxes *0.17' \ | patch As result multiple files should be updated. Also it is nice to review your changes using colordiff instead of patch. * lib: track source lines range for journal * doc: auto entries and diff output for rewrite
311 lines
3.9 KiB
Plaintext
Executable File
311 lines
3.9 KiB
Plaintext
Executable File
#!/usr/bin/env shelltest
|
|
# 1. test some balance assertions
|
|
hledger -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
|
|
hledger -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
|
|
hledger -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 error.*lines 9-12/
|
|
>>>=1
|
|
|
|
# 4. should also work without commodity symbols
|
|
hledger -f - stats
|
|
<<<
|
|
2013/1/1
|
|
(a) 1 =1
|
|
|
|
>>> /Transactions/
|
|
>>>2
|
|
>>>=0
|
|
|
|
# 5. should work for fractional amount with trailing zeros
|
|
hledger -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
|
|
hledger -f - stats
|
|
<<<
|
|
1/2
|
|
(a) A1
|
|
(a) B1 = A1
|
|
(a) 0 = A1
|
|
(a) C0 = D0
|
|
>>> /Transactions/
|
|
>>>2
|
|
>>>=0
|
|
|
|
# 7. balances should accumulate (#195)
|
|
hledger -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,
|
|
#
|
|
# hledger -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
|
|
|
|
# 8. resetting a balance
|
|
hledger -f - stats
|
|
<<<
|
|
2013/1/1
|
|
a $1.20
|
|
b
|
|
|
|
2013/1/2
|
|
a =$1.3
|
|
b
|
|
|
|
2013/1/2
|
|
a $10 =$11.3
|
|
b =$-11.3
|
|
|
|
>>> /Transactions/
|
|
>>>2
|
|
>>>=0
|
|
|
|
|
|
# 9. Multiple assertions for an account in the same transaction.
|
|
hledger -f - stats
|
|
<<<
|
|
2013/1/1
|
|
a $1 =$1
|
|
b =-$1
|
|
|
|
2013/1/2
|
|
a $1 =$2
|
|
b $-1 =$-2
|
|
|
|
2013/1/3
|
|
a $2 = $4
|
|
b $-1 = $-3
|
|
b $-1 = $-4
|
|
|
|
>>> /Transactions/
|
|
>>>2
|
|
>>>=0
|
|
|
|
# 10. Multiple assertions and assignments for an account in the same transaction.
|
|
hledger -f - stats
|
|
<<<
|
|
2013/1/1
|
|
a $1 =$1
|
|
b =-$1
|
|
|
|
2013/1/3
|
|
a $6 = $7
|
|
b $-1 = $-2
|
|
b $-1 = $-3
|
|
b $-7 = $-10
|
|
b $-1
|
|
b $-1 = $-12
|
|
b
|
|
|
|
2013/1/4
|
|
a $0 = $7
|
|
b $0 = $-7
|
|
|
|
>>> /Transactions/
|
|
>>>2
|
|
>>>=0
|
|
|
|
# 11. Assignments and virtual postings
|
|
hledger -f - stats
|
|
<<<
|
|
2013/1/1
|
|
b
|
|
[a] 1$
|
|
(b) = $14
|
|
[b]
|
|
a 4$
|
|
|
|
|
|
2013/1/2
|
|
[a] = $5
|
|
b = $9
|
|
|
|
|
|
|
|
|
|
>>> /Transactions/
|
|
>>>2
|
|
>>>=0
|
|
# 12. Having both assignements and posting dates is not supported.
|
|
hledger -f - stats
|
|
<<<
|
|
2013/1/1
|
|
a $1 =$1
|
|
b =$-1 ; date:2012/1/1
|
|
|
|
>>>2 /Not supported/
|
|
>>>=1
|
|
|
|
# 13. Having both assignements and posting dates is not supported.
|
|
hledger -f - stats
|
|
<<<
|
|
|
|
2013/1/1
|
|
a 1 = -2
|
|
b
|
|
c = 5
|
|
|
|
2014/1/1
|
|
a -3 = -3 ; date:2012/1/1
|
|
d = 3
|
|
|
|
|
|
>>>2 /Not supported/
|
|
>>>=1
|
|
|
|
# 14. Posting Date
|
|
hledger -f - stats
|
|
<<<
|
|
|
|
2011/5/5
|
|
[a] = -10
|
|
|
|
2013/1/1
|
|
a 1 = -12
|
|
b
|
|
c = 5
|
|
|
|
2014/1/1
|
|
a ; date:2012/1/1
|
|
d 3 = 3
|
|
|
|
2015/1/1
|
|
[a] ; date:2011/1/1
|
|
[d] 10
|
|
|
|
|
|
>>> /Transactions/
|
|
>>>2
|
|
>>>=0
|
|
|
|
# 15. Mix different commodities
|
|
hledger -f - stats
|
|
<<<
|
|
2016/1/1
|
|
a $1
|
|
b -1 zorkmids
|
|
|
|
2016/1/2
|
|
a $-1 = $0
|
|
b
|
|
>>> /Transactions/
|
|
>>>2
|
|
>>>=0
|
|
|
|
# 16. Mix different commodities and assignments
|
|
hledger -f - stats
|
|
<<<
|
|
2016/1/1
|
|
a $1
|
|
b -1 zorkmids
|
|
|
|
2016/1/4
|
|
[a] = $1
|
|
|
|
|
|
2016/1/5
|
|
[a] = -1 zorkmids
|
|
|
|
2016/1/2
|
|
a
|
|
b = 0 zorkmids
|
|
>>> /Transactions/
|
|
>>>2
|
|
>>>=0
|