Skip to content
Snippets Groups Projects
Unverified Commit d2185909 authored by Jed Fox's avatar Jed Fox Committed by GitHub
Browse files

Add support for credit card OFX files (#987)

parent 646d0d90
No related branches found
No related tags found
No related merge requests found
OFXHEADER:100
DATA:OFXSGML
VERSION:102
SECURITY:NONE
ENCODING:USASCII
CHARSET:1252
COMPRESSION:NONE
OLDFILEUID:NONE
NEWFILEUID:NONE
<OFX><SIGNONMSGSRSV1><SONRS><STATUS><CODE>0<SEVERITY>INFO</STATUS><DTSERVER>20230407120000[0:GMT]<LANGUAGE>ENG<FI><ORG>Apple Card<FID>12345</FI></SONRS></SIGNONMSGSRSV1><CREDITCARDMSGSRSV1><CCSTMTTRNRS><TRNUID>0<STATUS><CODE>0<SEVERITY>INFO</STATUS><CCSTMTRS><CURDEF>USD<CCACCTFROM><ACCTID>7dc6a2fd-2124-457a-a14</CCACCTFROM><BANKTRANLIST><DTSTART>20230301120000[0:GMT]<DTEND>20230331120000[0:GMT]<STMTTRN><TRNTYPE>DEBIT<DTPOSTED>20230330120000[0:GMT]<TRNAMT>-6.00<FITID>57f91dca-0460-4692-be90-84165b7002<NAME>LOUISIANA STATE MUSEUM751 PLACE JOHN PAUL NEW ORLEANS 70116-3205LA USA</STMTTRN></BANKTRANLIST><LEDGERBAL><BALAMT>-9654.01<DTASOF>20230331120000[0:GMT]</LEDGERBAL><AVAILBAL><BALAMT>1173.02<DTASOF>20230331120000[0:GMT]</AVAILBAL></CCSTMTRS></CCSTMTTRNRS></CREDITCARDMSGSRSV1></OFX>
......@@ -29,6 +29,35 @@ Array [
]
`;
exports[`File import ofx import works (credit card) 1`] = `
Array [
Object {
"acct": "one",
"amount": -600,
"category": null,
"cleared": 1,
"date": 20230330,
"description": "id2",
"error": null,
"financial_id": "57f91dca-0460-4692-be90-84165b7002",
"id": "id3",
"imported_description": "LOUISIANA STATE MUSEUM751 PLACE JOHN PAUL NEW ORLEANS 70116-3205LA USA",
"isChild": 0,
"isParent": 0,
"location": null,
"notes": null,
"parent_id": null,
"pending": 0,
"schedule": null,
"sort_order": 123456789,
"starting_balance_flag": 0,
"tombstone": 0,
"transferred_id": null,
"type": null,
},
]
`;
exports[`File import ofx import works 1`] = `
Array [
Object {
......
......@@ -81,6 +81,18 @@ describe('File import', () => {
expect(await getTransactions('one')).toMatchSnapshot();
}, 45000);
test('ofx import works (credit card)', async () => {
prefs.loadPrefs();
await db.insertAccount({ id: 'one', name: 'one' });
let { errors } = await importFileWithRealTime(
'one',
__dirname + '/../../mocks/files/credit-card.ofx',
);
expect(errors.length).toBe(0);
expect(await getTransactions('one')).toMatchSnapshot();
}, 45000);
test('qfx import works', async () => {
prefs.loadPrefs();
await db.insertAccount({ id: 'one', name: 'one' });
......
......@@ -215,7 +215,10 @@ async function parseOfxJavascript(filepath) {
}
// .STMTTRN may be a list or a single object.
const transactions = [
data.body.OFX.BANKMSGSRSV1.STMTTRNRS.STMTRS.BANKTRANLIST.STMTTRN,
(
data.body.OFX.BANKMSGSRSV1?.STMTTRNRS.STMTRS ||
data.body.OFX.CREDITCARDMSGSRSV1?.CCSTMTTRNRS.CCSTMTRS
).BANKTRANLIST.STMTTRN,
].flat();
return {
errors,
......
---
category: Enhancements
authors: [j-f1]
---
Add support for credit card OFX files
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment