Open trcoffman opened 2 years ago
Huh, interesting. This is a feature I didn't know about. I suspect it probably modifies the output somewhat. I will take a look.
It's not just the UUID that breaks it I think. It's any metadata comments on the transaction.
Just curious, why is it that the ofxid is below the account as opposed to below the transaction? I just started learning ledger-cli a few weeks ago, so there's a lot I don't know. I only found that thing about the UUID thanks to a lucky google search when I was trying to deduplicate transactions.
@trcoffman For the positioning of the ofxid
tag, see #22 (TL;DR: tag is applied to account in case transaction is a transfer between two accounts both managed by ledger-autosync
).
For your original issue, I'm also not familiar with the UUID feature. Am I correct in assuming that you will end up with two transactions with the same UUID, one with an ofxid
and one without? These transactions are both in the same file (or are in separate files that are both include
d into one file)?
I'll note also that I have a lot of other metadata tags in my Ledger files, and I haven't run into this issue yet (though I'm not sure if I'm on the latest version of ledger-autosync
at the moment). If I find the time I'll see if I can reproduce this issue.
@501st-alpha1, Basically, I'm downloading 2 QFX files from my bank. One is for the credit card, one is for the checking account. When I import them into ledger, I end up with 2 similar transactions that are really referring to 1 transaction: paying my credit card bill from my checking account. Each transaction has its own ofxid.
So, I address this issue by manually attaching the same UUID metadata to both transactions. Ledger will now treat them as a single transaction.
If I do this, then when I go back and run ledger-autosync again, those transactions show up again and ledger-autosync fails to use the ofxid to deduplicate them.
Got around to digging into this issue again.
Given test.ledger
:
2022/05/01 test
; UUID: aa5a57fc-c3ec-46b9-9353-1e250d1c3464
bank $-20.00
; ofxid: bank.someid
credit card $20.00
2022/05/01 test
; UUID: aa5a57fc-c3ec-46b9-9353-1e250d1c3464
bank $-20.00
credit card $20.00
; ofxid: credit.someotherid
Balance correctly doesn't duplicate the payment:
$ ledger -f test.ledger bal
$-20.00 bank
$20.00 credit card
--------------------
0
Likewise, register
only shows one version of the transaction:
$ ledger -f test.ledger reg
22-May-01 test bank $-20.00 $-20.00
credit card $20.00 0
And print
shows us that the first transaction is used, and the second is discarded:
$ ledger -f test.ledger print
2022/05/01 test
; UUID: aa5a57fc-c3ec-46b9-9353-1e250d1c3464
bank $-20.00
; ofxid: bank.someid
credit card
Indeed, according to this comment:
If there is more than one transaction with the same UUID, ledger will only take the first and ignore the rest.
I haven't been able to find a way to disable this functionality in Ledger, so I'm not sure that there is anything ledger-autosync
can do to fix this issue, since Ledger doesn't even expose the second transaction at all.
If you'd like a workaround, then what I do in this case is copy/paste the ofxid
from the second transaction to the first, so that I have one transaction with two ofxid
tags, and then ledger-autosync
can correctly de-duplicate against either one:
2022/05/01 test
; UUID: aa5a57fc-c3ec-46b9-9353-1e250d1c3464
bank $-20.00
; ofxid: bank.someid
credit card $20.00
; ofxid: credit.someotherid
(As mentioned above, this exact scenario is the reason for having the ofxid
at the posting level [below each account] rather than at the transaction level [at the top].)
@501st-alpha1 Thank you for looking into this and providing a workaround!
If I add a UUID to deduplicate this transaction (because it's in the history for both the card and the checking account), then ledger-autosync fails to detect its ofxid and it shows back up in the output of ledger-autosync despite already being synced.