egh / ledger-autosync

Synchronize your ledger-cli files with your bank.
GNU General Public License v3.0
273 stars 42 forks source link

QFX (~= OFX) files with no NAME/payee field #71

Closed 501st-alpha1 closed 5 years ago

501st-alpha1 commented 5 years ago

My bank recently dropped support for plain OFX files for transaction downloads. Thankfully, they offer files in the QFX format ("for Quicken"), which appear to be an XML-compliant version of the OFX standard. However, they've made some changes in how they format the data in the files.

Here is an example transaction (whitespace for readability, original file is entirely on one line):

<STMTTRN>
  <TRNTYPE>DEBIT</TRNTYPE>
  <DTPOSTED>20190331000000.000</DTPOSTED>
  <TRNAMT>1.23</TRNAMT>
  <FITID>201903311234</FITID>
  <MEMO>Monthly Interest Paid</MEMO>
</STMTTRN>

You may spot a couple other issues here, but the one I care about in this issue is the payee/memo fields.

In the previous OFX files, they used the <NAME> field and had no <MEMO>, but this QFX file reverses that, which has broken syncing for me. It doesn't appear that they've changed the content at all; the <MEMO> field in the QFX file looks just like the <NAME> field in the OFX file did. (I guess this change actually makes sense given the contents of the field, I just wish they would put a useful payee in the <NAME> field.) My main concern is using my new payee-matching functionality (#62) to get a useful payee for my Ledger file.

I see a couple possible solutions:

I have the first solution working locally (and I use a payee_format of {payee} anyway, so I don't care what happens to memo), but I wanted to get your input before I submit a PR.

egh commented 5 years ago

In my experience payee/name and memo seem completely interchangeable in real world OFX files. It doesn't seem unreasonable to copy one to the other, although the default formatter is {payee} {memo} so that would be weird. Also it kind of messes with expectations of how the payee format would work. (I realize now that I probably should have called {payee} {name} instead as that is what it is called in OFX.)

I prefer the second option because it doesn't really mess with expectations of what is contained in payee and memo. I did some of this kind of manipulation of payee/memo before and when it got too complicated I gave up and added the --payee-format option which I think works a lot better - you can't really account for the varieties of OFX file.