fix accountcode filter

deepsource-autofix-76c6eb20
Dan Gowans 2023-04-18 12:57:03 -04:00
parent d74598c877
commit 75cdf7e036
2 changed files with 21 additions and 21 deletions

View File

@ -7,18 +7,18 @@ if (configFunctions.getProperty('settings.dynamicsGP.integrationIsEnabled')) {
}
function filterCashReceipt(cashReceipt) {
const accountCodes = configFunctions.getProperty('settings.dynamicsGP.accountCodes');
for (const accountCode of accountCodes) {
let found = cashReceipt.details.some((detailRecord) => {
return detailRecord.accountCode === accountCode;
});
if (!found) {
found = cashReceipt.distributions.some((distributionRecord) => {
return distributionRecord.accountCode === accountCode;
});
if (accountCodes.length > 0) {
for (const detail of cashReceipt.details) {
if (accountCodes.includes(detail.accountCode)) {
return cashReceipt;
}
}
if (!found) {
return undefined;
for (const distribution of cashReceipt.distributions) {
if (accountCodes.includes(distribution.accountCode)) {
return cashReceipt;
}
}
return undefined;
}
return cashReceipt;
}

View File

@ -31,20 +31,20 @@ function filterCashReceipt(
'settings.dynamicsGP.accountCodes'
)
for (const accountCode of accountCodes) {
let found = cashReceipt.details.some((detailRecord) => {
return detailRecord.accountCode === accountCode
})
if (!found) {
found = cashReceipt.distributions.some((distributionRecord) => {
return distributionRecord.accountCode === accountCode
})
if (accountCodes.length > 0) {
for (const detail of cashReceipt.details) {
if (accountCodes.includes(detail.accountCode)) {
return cashReceipt
}
}
if (!found) {
return undefined
for (const distribution of cashReceipt.distributions) {
if (accountCodes.includes(distribution.accountCode)) {
return cashReceipt
}
}
return undefined
}
return cashReceipt