hledger/tests/journal/virtual-postings.test
Johannes Gerer 45401e538e Balance Assignments and accounts resetting (#438)
* Changed behavior of `readJournalFiles` to be identical to `readJournalFile` for singleton lists

* Balance Assertions have to be simple Amounts

* Add 'isAssignment' and 'assignmentPostings' to Hledger.Data.Posting and Transaction

* Implemented 'balanceTransactionUpdate', a more general version of 'balanceTransaction' that takes an update function

* Fixed test cases.

* Implemented balance assignment ("resetting a balance")

* Add assertions to show function

* updated the comments

* numbering is not needed in journalCheckBalanceAssertions

* remove prices before balance checks

* rename functions
2016-12-10 07:04:48 -08:00

56 lines
903 B
Plaintext

# 1. virtual posting shouldn't affect balance
hledger -f- print
<<<
2009/1/1 x
(virtual) 100
a 1
b
>>>=0
#
# 2. balanced virtual postings should be required to balance (themselves)
hledger -f- print
<<<
2010/1/1 x
[balanced virtual] 10
a 1
b
>>>= !0
#
# 3. balanced virtual postings should be required to balance (themselves)
hledger -f- print
<<<
2010/1/1 x
[balanced virtual] 10
[balanced virtual] -10
a 1
b
>>>=0
#
# 4. a virtual posting with implicit amount should be handled correctly
hledger -f- print
<<<
2010/1/1 x
[a] 10
[b]
>>>=0
#
# 5. real and balanced virtual postings are balanced separately, and multiple blank virtuals are ok
hledger -f- balance
<<<
2010/1/1 x
a 1
b
[e] 10
[f]
(c)
(d)
>>>
1 a
-1 b
10 e
-10 f
--------------------
0
>>>2
>>>=0