Skip to content
Snippets Groups Projects
Unverified Commit 76cbd44c authored by Attila Kerekes's avatar Attila Kerekes Committed by GitHub
Browse files

fix ofx amount parsing for longer decimal places (#2421)

parent 0e0d960c
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>20190124212851.000[0:UTC]
<LANGUAGE>ENG
<DTACCTUP>20190124212851.000[0:UTC]
<FI>
<ORG>Bank of America
<FID>5959
</FI>
<INTU.BID>6526
<INTU.USERID>jlongster03
</SONRS>
</SIGNONMSGSRSV1>
<BANKMSGSRSV1>
<STMTTRNRS>
<TRNUID>0
<STATUS>
<CODE>0
<SEVERITY>INFO
</STATUS>
<STMTRS>
<CURDEF>USD
<BANKACCTFROM>
<BANKID>012345678
<ACCTID>123456789123
<ACCTTYPE>CHECKING
</BANKACCTFROM>
<BANKTRANLIST>
<DTSTART>20190119120000
<DTEND>20190124120000
<STMTTRN>
<TRNTYPE>DEBIT
<DTPOSTED>20190123120000
<TRNAMT>-30.000
<FITID>00092990122-30.00019012312798.01
<NAME>PATIENT FIRST TOKEN 01/22 PURCHA
</STMTTRN>
<STMTTRN>
<TRNTYPE>DEBIT
<DTPOSTED>20190123120000
<TRNAMT>-3.77000
<FITID>00092990121-3.77019012312828.01
<NAME>STARBUCKS STORE 07604 01/21 PURC
</STMTTRN>
</BANKTRANLIST>
</STMTRS>
</STMTTRNRS>
</BANKMSGSRSV1>
</OFX>
......@@ -84,6 +84,18 @@ describe('File import', () => {
expect(await getTransactions('one')).toMatchSnapshot();
}, 45000);
test('ofx import works with multiple decimals in amount', async () => {
const ofxFile = __dirname + '/../../mocks/files/data-multi-decimal.ofx';
const { transactions } = (await parseFile(ofxFile)) as {
transactions: { amount: number }[];
};
expect(transactions).toHaveLength(2);
expect(transactions[0].amount).toBe(-30.0);
expect(transactions[1].amount).toBe(-3.77);
}, 45000);
test('ofx import works (credit card)', async () => {
prefs.loadPrefs();
await db.insertAccount({ id: 'one', name: 'one' });
......
......@@ -132,7 +132,7 @@ async function parseOFX(
errors,
transactions: data.transactions.map(trans => {
return {
amount: trans.amount,
amount: Number(trans.amount),
imported_id: trans.fitId,
date: trans.date,
payee_name: trans.name || (useMemoFallback ? trans.memo : null),
......
---
category: Bugfix
authors: [keriati]
---
Fix OFX import amount when more than 2 decimal places are provided
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