fix: issue in edit payment receive with invoices payment amount chaning.

This commit is contained in:
a.bouhuolia
2020-12-19 17:04:11 +02:00
parent 1a0aad7dc4
commit fb135913bb
8 changed files with 103 additions and 108 deletions

View File

@@ -190,10 +190,15 @@ const entriesAmountDiff = (
.mapValues((group) => _.sumBy(group, amountAttribute) || 0)
.value();
return _.chain(newEntries)
const newEntriesTable = _.chain(newEntries)
.groupBy(idAttribute)
.mapValues((group) => _.sumBy(group, amountAttribute) || 0)
.mapValues((value, key) => value - (oldEntriesTable[key] || 0))
.mergeWith(oldEntriesTable, (objValue, srcValue) => {
return (_.isNumber(objValue) ? objValue - srcValue : srcValue * -1);
})
.value();
return _.chain(newEntriesTable)
.mapValues((value, key) => ({
[idAttribute]: key,
[amountAttribute]: value,