Index: CHANGELOG.md =================================================================== diff -u -N -r92e834d67d364bbd32d2d9e4308f0c60b0b7d110 -r3c646cc3f7bbde10d017f86e2faadf9d38a4db70 --- CHANGELOG.md (.../CHANGELOG.md) (revision 92e834d67d364bbd32d2d9e4308f0c60b0b7d110) +++ CHANGELOG.md (.../CHANGELOG.md) (revision 3c646cc3f7bbde10d017f86e2faadf9d38a4db70) @@ -11,6 +11,7 @@ * [OLMIS-7581](https://openlmis.atlassian.net/browse/OLMIS-7581): Fixed wrong order of displaying products after adding a new one in Physical Inventory - mobile app * [OLMIS-7582](https://openlmis.atlassian.net/browse/OLMIS-7582): fixed getStockAdjustment function when there is no draft in Physical Inventory - mobile app * [OLMIS-7599](https://openlmis.atlassian.net/browse/OLMIS-7599): fixed refreshing the app - mobile app +* [OLMIS-7608](https://openlmis.atlassian.net/browse/OLMIS-7608): Fixed wrong error displaying when making receives and updating physical inventory Improvements: * [OLMIS-7588](https://openlmis.atlassian.net/browse/OLMIS-7588): Physical Inventory validation for unaccounted quantity - mobile app Index: src/stock-adjustment-creation/adjustment-creation.controller.js =================================================================== diff -u -N -r4ab1e5e0a5a657ca718bcd646162990cd5f5ada5 -r3c646cc3f7bbde10d017f86e2faadf9d38a4db70 --- src/stock-adjustment-creation/adjustment-creation.controller.js (.../adjustment-creation.controller.js) (revision 4ab1e5e0a5a657ca718bcd646162990cd5f5ada5) +++ src/stock-adjustment-creation/adjustment-creation.controller.js (.../adjustment-creation.controller.js) (revision 3c646cc3f7bbde10d017f86e2faadf9d38a4db70) @@ -470,8 +470,16 @@ }) .catch(function(response) { if (response.data.messageKey === - 'referenceData.error.lot.lotCode.mustBeUnique') { - errorLots.push(lot.lotCode); + 'referenceData.error.lot.lotCode.mustBeUnique' || + response.data.messageKey === + 'referenceData.error.lot.tradeItem.required') { + errorLots.push({ + lotCode: lot.lotCode, + error: response.data.messageKey === + 'referenceData.error.lot.lotCode.mustBeUnique' ? + 'stockPhysicalInventoryDraft.lotCodeMustBeUnique' : + 'stockPhysicalInventoryDraft.tradeItemRequuiredToAddLotCode' + }); } })); }); @@ -513,8 +521,17 @@ .catch(function(errorResponse) { loadingModalService.close(); if (errorLots) { - alertService.error('stockPhysicalInventoryDraft.lotCodeMustBeUnique', - errorLots.join(', ')); + var errorLotsReduced = errorLots.reduce(function(result, currentValue) { + if (currentValue.error in result) { + result[currentValue.error].push(currentValue.lotCode); + } else { + result[currentValue.error] = [currentValue.lotCode]; + } + return result; + }, {}); + for (var error in errorLotsReduced) { + alertService.error(error, errorLotsReduced[error].join(', ')); + } vm.selectedOrderableGroup = undefined; vm.selectedLot = undefined; vm.lotChanged(); Index: src/stock-physical-inventory-draft/messages_en.json =================================================================== diff -u -N -r129c9506234e1f464ee7323a6d3472b7ba8a4279 -r3c646cc3f7bbde10d017f86e2faadf9d38a4db70 --- src/stock-physical-inventory-draft/messages_en.json (.../messages_en.json) (revision 129c9506234e1f464ee7323a6d3472b7ba8a4279) +++ src/stock-physical-inventory-draft/messages_en.json (.../messages_en.json) (revision 3c646cc3f7bbde10d017f86e2faadf9d38a4db70) @@ -12,7 +12,8 @@ "stockPhysicalInventoryDraft.productWithDisplayUnit": "${fullProductName} - ${displayUnit}", "stockPhysicalInventoryDraft.productCode": "Product Code", "stockPhysicalInventoryDraft.lotCode": "Lot Code", - "stockPhysicalInventoryDraft.lotCodeMustBeUnique": "Trade Item is required to add a Lot Code", + "stockPhysicalInventoryDraft.lotCodeMustBeUnique": "Lot code must be unique", + "stockPhysicalInventoryDraft.tradeItemRequuiredToAddLotCode": "Trade Item is required to add a Lot Code", "stockPhysicalInventoryDraft.expiryDate": "Expiry Date", "stockPhysicalInventoryDraft.soh": "Stock on Hand", "stockPhysicalInventoryDraft.currentStock": "Current Stock", Index: src/stock-physical-inventory-draft/physical-inventory-draft.controller.js =================================================================== diff -u -N -r65b4d8ff6555ac16d77240a28d324d95863a71fb -r3c646cc3f7bbde10d017f86e2faadf9d38a4db70 --- src/stock-physical-inventory-draft/physical-inventory-draft.controller.js (.../physical-inventory-draft.controller.js) (revision 65b4d8ff6555ac16d77240a28d324d95863a71fb) +++ src/stock-physical-inventory-draft/physical-inventory-draft.controller.js (.../physical-inventory-draft.controller.js) (revision 3c646cc3f7bbde10d017f86e2faadf9d38a4db70) @@ -519,8 +519,16 @@ }) .catch(function(response) { if (response.data.messageKey === - 'referenceData.error.lot.lotCode.mustBeUnique') { - errorLots.push(lineItem.lot.lotCode); + 'referenceData.error.lot.lotCode.mustBeUnique' || + response.data.messageKey === + 'referenceData.error.lot.tradeItem.required') { + errorLots.push({ + lotCode: lineItem.lot.lotCode, + error: response.data.messageKey === + 'referenceData.error.lot.lotCode.mustBeUnique' ? + 'stockPhysicalInventoryDraft.lotCodeMustBeUnique' : + 'stockPhysicalInventoryDraft.tradeItemRequuiredToAddLotCode' + }); } })); } @@ -544,8 +552,17 @@ .catch(function(errorResponse) { loadingModalService.close(); if (errorLots) { - alertService.error('stockPhysicalInventoryDraft.lotCodeMustBeUnique', - errorLots.join(', ')); + var errorLotsReduced = errorLots.reduce(function(result, currentValue) { + if (currentValue.error in result) { + result[currentValue.error].push(currentValue.lotCode); + } else { + result[currentValue.error] = [currentValue.lotCode]; + } + return result; + }, {}); + for (var error in errorLotsReduced) { + alertService.error(error, errorLotsReduced[error].join(', ')); + } return $q.reject(errorResponse.data.message); } alertService.error(errorResponse.data.message);