asgrim / ofxparser

:moneybag: OFX File Parser
MIT License
108 stars 102 forks source link

Additional metadata on transactions #47

Open troygilbert opened 6 years ago

troygilbert commented 6 years ago

The OFX file includes some additional details for each transaction that are not captured when parsing. Would it be possible to extract those fields or include a SimpleXMLElement referencing the whole transaction so that other tools could pluck them out as needed? This seems to be the most straightforward way to extend the library without having to build a more extensive system.

asgrim commented 6 years ago

What does the metadata look like exactly please?

mkopinsky commented 6 years ago

Unfortunately OFX/SGML files are not valid xml, so simply delegating to SimpleXML doesn't work. I do wish there were an SGML parser we could piggyback off of.

asgrim commented 6 years ago

This library does use SimpleXML, after bodging it up a bit, so it may be possible; though I'd rather have an explicit API for capturing metadata like this.

Do you have some anonymised sample data to show the structure of this metadata at all please?

troygilbert commented 6 years ago

This is what I added to Ofx.php:231:

$transaction->cardNumber = (string)$t->CCACCTTO->ACCTID;

This represents the card number of the credit/debit card used for a specific transaction for accounts with multiple credit/debit cards.

I've not looked it up in any specifications, I just browsed the OFX file directly curious if the information was in there. ;-)

asgrim commented 6 years ago

Hmm - does the ACCTID in the (non-immediate) parent "credit account" node not already provide what you're looking for? - $creditAccount->accountNumber on L210 here

https://github.com/asgrim/ofxparser/blob/11f64bd269bc0842d89fba1a23833e0c56121a45/lib/OfxParser/Ofx.php#L200-L210

troygilbert commented 6 years ago

It shows up there, but each transaction has the ID specified and they appear to be a mixture (as far as I can tell inspecting the resulting parsed data). (Wish I could provide some anonymized data, but I don't have the time to prepare that for you at the moment.)

troygilbert commented 6 years ago

Hi James, I'm gonna send you some anonymized data via email -- not posting here in case I did a bad job of anonymizing! ;-)

asgrim commented 6 years ago

Thanks, received it; I'm not gonna be able to look at this for at least a couple months probably tho, got a lot of conferences/trips coming up I'm afraid :/