Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ledger UUID breaks ofxid matching #133

Open
trcoffman opened this issue Feb 3, 2022 · 6 comments
Open

ledger UUID breaks ofxid matching #133

trcoffman opened this issue Feb 3, 2022 · 6 comments

Comments

@trcoffman
Copy link

trcoffman commented Feb 3, 2022

2022/01/24 * AUTOMATIC PAYMENT - THANK
    ; UUID: aa5a57fc-c3ec-46b9-9353-1e250d1c3464
    Liabilities:Credit Card.                                $1302.32
    ; ofxid: xxxxxxxxxxxxxxxxxxxxxxxxx
    Assets:Chase Checking                            -$1302.32

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.

@egh
Copy link
Owner

egh commented Feb 4, 2022

Huh, interesting. This is a feature I didn't know about. I suspect it probably modifies the output somewhat. I will take a look.

@trcoffman
Copy link
Author

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.

@501st-alpha1
Copy link
Contributor

@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 included 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.

@trcoffman
Copy link
Author

trcoffman commented Feb 7, 2022

@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.

@501st-alpha1
Copy link
Contributor

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].)

@egh
Copy link
Owner

egh commented May 13, 2022

@501st-alpha1 Thank you for looking into this and providing a workaround!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants