Lately I've taken to splitting transactions from financial institutions into
their own files, rather than having everything piled into one gigantic file.
This allows me to adopt a "one-file-per-statement" approach which makes heavy
reconciling jobs a lot easier. I take the approach of asserting at the
beginning and end of each file that it matches the opening and ending balances
on the corresponding statement.
However, there was a key limitation to this approach when dealing with balance
transfers. For example, in Checking.dat file I might have a credit card
payment, while in MasterCard.dat I also have the same payment. I need to
represent it on both sides for the opening/ending balances to match.
So, a little while back I added the notion of "UUID" metadata tags, with some
special magic which says:
- If two transactions have the same UUID, they must also have the same
number of postings, to the same accounts, in the same amounts. The date,
payee and metadata are not checked for the notion of "transactional
identity".
- Only keep the first such transaction.
What I didn't know until today is that *balance assertions are performed
separately in each of these equivalent transactions*. So even though Ledger's
reporting behaves as though it only saw the first such transactions, each
separate transaction with the same UUID can have its own balance assertions.
I found this out because I sat down today to add this very feature to Ledger.
My first step was to write a test proving that it didn't work, when in fact it
is doing just what I needed it to do!
Here's what this looks like in code:
2012-01-01 Test
Expenses:Unknown $100.00
Liabilities:MasterCard
2012-01-02 Test
Expenses:Unknown $100.00
Liabilities:MasterCard
2012-01-03 Test
Expenses:Unknown $100.00
Liabilities:MasterCard
2012-01-04 Test
; UUID: foo
Liabilities:MasterCard $300.00 = $0
Assets:Checking
2012-01-01 Test
Assets:Checking $150.00
Income
2012-01-02 Test
Assets:Checking $150.00
Income
2012-01-03 Test
Assets:Checking $150.00
Income
2012-01-04 Test
; UUID: foo
Liabilities:MasterCard $300.00
Assets:Checking $-300.00 = $150.00
Both balance assertions are in effect, which you can see by changing either
one of them. And yet only the first transaction is present in the final
report.
John
--
---
You received this message because you are subscribed to the Google Groups
"Ledger" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.