fix accountcode filter
parent
d74598c877
commit
75cdf7e036
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue