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

Empty tags #81

Open
sanderkruger opened this issue Jun 11, 2015 · 6 comments
Open

Empty tags #81

sanderkruger opened this issue Jun 11, 2015 · 6 comments

Comments

@sanderkruger
Copy link

My bank exports files with empty tags here and there, for example:
<FI><ORG/><FID/></FI>

The empty tag syntax is valid XML but the parser doesn't like it. I can remove empty tags of course, but then I have to process all my bank statements. It would be much better if ofxparse sees the empty tag format and ignores the tags.

@nathangrigg
Copy link
Collaborator

After merging #108, the parser is more lenient. My guess is that this will go away. If you are able, could you check if this is still an issue?

@bruny
Copy link
Contributor

bruny commented Aug 3, 2018

I continue to see similar issues with ofxparse 0.18.

My bank has exported an OFX file with the following empty fields:
CHECKNUM, FITID, NAME, CURDEF, BRANCHID, ACCTTYPE, REFNUM

(Being new to OFX file formats, I'm not sure whether this is actually valid, and whether the bank is at fault, or ofxparse should handle the case more gracefully?)

The stacktrace is

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/bin/hledger-autosync", line 11, in <module>
    sys.exit(run())
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ledgerautosync/cli.py", line 311, in run
    import_ofx(ledger, args)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ledgerautosync/cli.py", line 114, in import_ofx
    ofx = OfxSynchronizer.parse_file(args.PATH)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ledgerautosync/sync.py", line 41, in parse_file
    return OfxParser.parse(open(path))
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ofxparse/ofxparse.py", line 432, in parse
    ofx_obj.accounts += cls.parseStmtrs(stmtrs_ofx, AccountType.Bank)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ofxparse/ofxparse.py", line 818, in parseStmtrs
    account.curdef = act_curdef.contents[0].strip()
IndexError: list index out of range

@jseutter
Copy link
Owner

jseutter commented Aug 4, 2018

Some unit tests would be helpful to check for this behavior. If I have time I'll create some.

@bruny
Copy link
Contributor

bruny commented Aug 5, 2018

I can add the OFX files I'm using as test cases on a PR. 2 x separate OFX files from Australian banks, both using version 1.02 (SGML!).

@bruny
Copy link
Contributor

bruny commented Aug 9, 2018

PR #143 added fixes for some elements, still some others to go.

@bruny
Copy link
Contributor

bruny commented Aug 9, 2018

Two sample STMTTRN entries, both using v1.02 spec:

 <TRNTYPE>Credit</TRNTYPE>
 <DTPOSTED>20180801</DTPOSTED>
 <TRNAMT>0.0</TRNAMT>
 <FITID></FITID>
 <VALUEDATE>20180801</VALUEDATE>
 <NAME></NAME>
 <TRANSACTIONSPLIT>No</TRANSACTIONSPLIT>
 <CATEGORY>Uncategorised</CATEGORY>
 <ACCTBAL>-400.52</ACCTBAL>
 <CHECKNUM></CHECKNUM>
 <REFNUM></REFNUM>
 <MEMO>NEW INTEREST RATE  3.870%</MEMO>
 <CURRENCY>
  <CURRATE>1.0000</CURRATE>
  <CURSYM>AUD</CURSYM>
 </CURRENCY>
</STMTTRN>```

and

```<STMTTRN>
<TRNTYPE>DEBIT
<DTPOSTED>20180801
<DTUSER>20180801
<TRNAMT>-10.00
<FITID>
<MEMO>Account Fee
</STMTTRN>```

Both have empty FITID fields. One has empty NAME field. Either empty or missing CHECKNUM and REFNUM fields.

Since transactions can be parsed by ofxparse if CHECKNUM, REFNAME, NAME and FITID are missing, empty fields should be handled in the same way.

Will try and put together a PR for these in the next few days.

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

4 participants