OFX example

David Reiser dbreiser at earthlink.net
Thu Aug 12 16:43:12 EDT 2010


On Aug 12, 2010, at 10:45 AM, Wojciech Piekutowski wrote:

> Hi,
> 
> I'm working on a script that will convert my monthly bank statement
> data to OFX format. I have some questions about this. What version of
> OFX is supported? Are there any example OFX files available that will
> work well with gnucash? This would greatly help me and possibly other
> clients of this bank as I'm planning to release this script under MIT
> license.
> 
> I have some questions too.
> 
> <BANKACCTFROM>
>     <BANKID>1234 1234</BANKID>
>     <ACCTID>5678 5678 5678 5678</ACCTID>
> 
> Should I split BANKID and ACCTID like this or is better to stick the
> whole account number into ACCTID and leave BANKID? Or maybe use the
> bank name as BANKID?

<BANKID> is normally the Routing/Transit Number. As long as it is unique among possible files you'll be importing, that's sufficient. I would leave BANKID and ACCTID separate.

> 
> When TRNTYPE is POS, ATM or FEE should I include BANKACCTTO part?

I don't know this one.
> 
> Is FITID used at all by gnucash, for example to match internal
> transactions between two client's accounts?

FITID is used internally to match duplicates. For a valid ofx file FITID _must_ be unique forever within a given account. Gnucash stores the FITID in the data schema and compares incoming transaction FITIDs to existing FITIDs in that account. This duplicate tracking makes ofx imports a lot more convenient if your bank always sends you 30 days of history when you download, but you actually download once a week. The FITIDs make it trivial for gnucash to automatically reject duplicate transactions.

The "always unique" and "always the same for a specific transaction" makes it hard to generate FITIDs for transactions from an arbitrary bank download that doesn't contain some kind of unique identifier.

> 
> Any help would be highly appreciated.
> 
> Greetings,
> Wojciech
> 
> BTW My current output looks like this:
> 
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <?OFX OFXHEADER="200" VERSION="211" SECURITY="NONE" OLDFILEUID="NONE"
> NEWFILEUID="NONE"?>
> <OFX>
> <BANKMSGSRSV1>
> <STMTTRNRS>
> <STMTRS>
>   <CURDEF>PLN</CURDEF>
>   <BANKACCTFROM>
>     <BANKID>1234 1234</BANKID>
>     <ACCTID>5678 5678 5678 5678</ACCTID>
>     <ACCTTYPE>SAVINGS</ACCTTYPE>
>   </BANKACCTFROM>
>   <BANKTRANLIST>
>     <DTSTART>20100501[+1:CET]</DTSTART>
>     <DTEND>20100531[+1:CET]</DTEND>
> <!-- debit card payment -->
> <STMTTRN>
> <TRNTYPE>POS</TRNTYPE>
> <DTPOSTED>20100503[+1:CET]</DTPOSTED>
> <DTUSER>20100426[+1:CET]</DTUSER>
> <TRNAMT>-23.11</TRNAMT>
> <FITID>588fdb8b38401023215007e017fc93ae</FITID>
> <NAME></NAME>
> <MEMO>description</MEMO>
> <BANKACCTTO>
> <BANKID></BANKID>
> <ACCTID></ACCTID>
> <ACCTTYPE>SAVINGS</ACCTTYPE>
> </BANKACCTTO>
> </STMTTRN>
> <!-- regular transfer -->
> <STMTTRN>
> <TRNTYPE>CREDIT</TRNTYPE>
> <DTPOSTED>20100506[+1:CET]</DTPOSTED>
> <DTUSER>20100506[+1:CET]</DTUSER>
> <TRNAMT>1519.97</TRNAMT>
> <FITID>c99bf204ac1167ff12fe1caa861539e5</FITID>
> <NAME>JAN KOWALSKI</NAME>
> <MEMO>PRZELEW</MEMO>
> <BANKACCTTO>
> <BANKID></BANKID>
> <ACCTID>12 3456 3456 3456 3456 3456</ACCTID>
> <ACCTTYPE>SAVINGS</ACCTTYPE>
> </BANKACCTTO>
> </STMTTRN>
> <!-- regular transfer -->
> <STMTTRN>
> <TRNTYPE>DEBIT</TRNTYPE>
> <DTPOSTED>20100506[+1:CET]</DTPOSTED>
> <DTUSER>20100506[+1:CET]</DTUSER>
> <TRNAMT>-1500.0</TRNAMT>
> <FITID>07bce7a5cd4d10e79b333a802fa39ae5</FITID>
> <NAME>JAN KOWALSKI</NAME>
> <MEMO>1875336</MEMO>
> <BANKACCTTO>
> <BANKID>GNB II O./Lublin</BANKID>
> <ACCTID>43 1234 1234 1234 1234 1234 1234</ACCTID>
> <ACCTTYPE>SAVINGS</ACCTTYPE>
> </BANKACCTTO>
> </STMTTRN>
> <!-- ATM transaction -->
> <STMTTRN>
> <TRNTYPE>ATM</TRNTYPE>
> <DTPOSTED>20100514[+1:CET]</DTPOSTED>
> <DTUSER>20100513[+1:CET]</DTUSER>
> <TRNAMT>-200.0</TRNAMT>
> <FITID>ad01139e4079be43e7f2bf9745bec65d</FITID>
> <NAME></NAME>
> <MEMO>WBK S.A.</MEMO>
> <BANKACCTTO>
> <BANKID></BANKID>
> <ACCTID></ACCTID>
> <ACCTTYPE>SAVINGS</ACCTTYPE>
> </BANKACCTTO>
> </STMTTRN>
> <!-- ATM fee -->
> <STMTTRN>
> <TRNTYPE>FEE</TRNTYPE>
> <DTPOSTED>20100526[+1:CET]</DTPOSTED>
> <DTUSER>20100526[+1:CET]</DTUSER>
> <TRNAMT>-5.0</TRNAMT>
> <FITID>34c97d25118cfe684bea6c7765ee2d23</FITID>
> <NAME></NAME>
> <MEMO>BGZ SA</MEMO>
> <BANKACCTTO>
> <BANKID></BANKID>
> <ACCTID></ACCTID>
> <ACCTTYPE>SAVINGS</ACCTTYPE>
> </BANKACCTTO>
> </STMTTRN>
>   </BANKTRANLIST>
> </STMTRS>
> </STMTTRNRS>
> </BANKMSGSRSV1>
> </OFX>
> 

Dave
--
David Reiser
dbreiser at earthlink.net






More information about the gnucash-user mailing list