mirror of
https://github.com/actualbudget/actual.git
synced 2026-03-11 12:43:09 -05:00
Support multiple months in experimental ofx parser (#1921)
* Support multiple months in experimental ofx parser * Release notes * Fix lint error
This commit is contained in:
committed by
GitHub
parent
a10b10a87b
commit
f58fae8d16
@@ -44,48 +44,49 @@ function getStmtTrn(data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getBankStmtTrn(ofx) {
|
function getBankStmtTrn(ofx) {
|
||||||
const msg = ofx?.['BANKMSGSRSV1'];
|
// Somes values could be an array or a single object.
|
||||||
const stmtTrnRs = msg?.['STMTTRNRS'];
|
|
||||||
const stmtRs = stmtTrnRs?.['STMTRS'];
|
|
||||||
const tranList = stmtRs?.['BANKTRANLIST'];
|
|
||||||
// Could be an array or a single object.
|
|
||||||
// xml2js serializes single item to an object and multiple to an array.
|
// xml2js serializes single item to an object and multiple to an array.
|
||||||
const stmtTrn = tranList?.['STMTTRN'];
|
const msg = ofx?.['BANKMSGSRSV1'];
|
||||||
|
const stmtTrnRs = getAsArray(msg?.['STMTTRNRS']);
|
||||||
if (!Array.isArray(stmtTrn)) {
|
const result = stmtTrnRs.flatMap(s => {
|
||||||
return [stmtTrn];
|
const stmtRs = s?.['STMTRS'];
|
||||||
}
|
const tranList = stmtRs?.['BANKTRANLIST'];
|
||||||
return stmtTrn;
|
const stmtTrn = tranList?.['STMTTRN'];
|
||||||
|
return getAsArray(stmtTrn);
|
||||||
|
});
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCcStmtTrn(ofx) {
|
function getCcStmtTrn(ofx) {
|
||||||
const msg = ofx?.['CREDITCARDMSGSRSV1'];
|
// Some values could be an array or a single object.
|
||||||
const stmtTrnRs = msg?.['CCSTMTTRNRS'];
|
|
||||||
const stmtRs = stmtTrnRs?.['CCSTMTRS'];
|
|
||||||
const tranList = stmtRs?.['BANKTRANLIST'];
|
|
||||||
// Could be an array or a single object.
|
|
||||||
// xml2js serializes single item to an object and multiple to an array.
|
// xml2js serializes single item to an object and multiple to an array.
|
||||||
const stmtTrn = tranList?.['STMTTRN'];
|
const msg = ofx?.['CREDITCARDMSGSRSV1'];
|
||||||
|
const stmtTrnRs = getAsArray(msg?.['CCSTMTTRNRS']);
|
||||||
if (!Array.isArray(stmtTrn)) {
|
const result = stmtTrnRs.flatMap(s => {
|
||||||
return [stmtTrn];
|
const stmtRs = s?.['CCSTMTRS'];
|
||||||
}
|
const tranList = stmtRs?.['BANKTRANLIST'];
|
||||||
return stmtTrn;
|
const stmtTrn = tranList?.['STMTTRN'];
|
||||||
|
return getAsArray(stmtTrn);
|
||||||
|
});
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getInvStmtTrn(ofx) {
|
function getInvStmtTrn(ofx) {
|
||||||
const msg = ofx?.['INVSTMTMSGSRSV1'];
|
// Somes values could be an array or a single object.
|
||||||
const stmtTrnRs = msg?.['INVSTMTTRNRS'];
|
|
||||||
const stmtRs = stmtTrnRs?.['INVSTMTRS'];
|
|
||||||
const tranList = stmtRs?.['INVTRANLIST'];
|
|
||||||
// Could be an array or a single object.
|
|
||||||
// xml2js serializes single item to an object and multiple to an array.
|
// xml2js serializes single item to an object and multiple to an array.
|
||||||
const stmtTrn = tranList?.['INVBANKTRAN']?.flatMap(t => t?.['STMTTRN']);
|
const msg = ofx?.['INVSTMTMSGSRSV1'];
|
||||||
|
const stmtTrnRs = getAsArray(msg?.['INVSTMTTRNRS']);
|
||||||
|
const result = stmtTrnRs.flatMap(s => {
|
||||||
|
const stmtRs = s?.['INVSTMTRS'];
|
||||||
|
const tranList = stmtRs?.['INVTRANLIST'];
|
||||||
|
const stmtTrn = tranList?.['INVBANKTRAN']?.flatMap(t => t?.['STMTTRN']);
|
||||||
|
return getAsArray(stmtTrn);
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
if (!Array.isArray(stmtTrn)) {
|
function getAsArray(value) {
|
||||||
return [stmtTrn];
|
return Array.isArray(value) ? value : [value];
|
||||||
}
|
|
||||||
return stmtTrn;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function mapOfxTransaction(stmtTrn): OFXTransaction {
|
function mapOfxTransaction(stmtTrn): OFXTransaction {
|
||||||
|
|||||||
6
upcoming-release-notes/1921.md
Normal file
6
upcoming-release-notes/1921.md
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
category: Bugfix
|
||||||
|
authors: [joel-jeremy]
|
||||||
|
---
|
||||||
|
|
||||||
|
Experimental ofx parser: Support multiple months in ofx file
|
||||||
Reference in New Issue
Block a user