Index: CHANGELOG.md =================================================================== diff -u -N -r3a14d894d39b5bf7b877eb705a4c9f6992f6e787 -r65b4d8ff6555ac16d77240a28d324d95863a71fb --- CHANGELOG.md (.../CHANGELOG.md) (revision 3a14d894d39b5bf7b877eb705a4c9f6992f6e787) +++ CHANGELOG.md (.../CHANGELOG.md) (revision 65b4d8ff6555ac16d77240a28d324d95863a71fb) @@ -6,6 +6,7 @@ Bug fixes: * [OLMIS-7579](https://openlmis.atlassian.net/browse/OLMIS-7579): Fixed issue with moving into next screen when current stock = 0 - mobile app +* [OLMIS-7574](https://openlmis.atlassian.net/browse/OLMIS-7574): Fixed wrong stock card calculations by adding unaccounted quantity validation 2.1.2 / 2022-04-21 ================== Index: src/stock-physical-inventory-draft/messages_en.json =================================================================== diff -u -N -r52b2f13a61d96b1c5ad7c66b06525f877e5a3d0e -r65b4d8ff6555ac16d77240a28d324d95863a71fb --- src/stock-physical-inventory-draft/messages_en.json (.../messages_en.json) (revision 52b2f13a61d96b1c5ad7c66b06525f877e5a3d0e) +++ src/stock-physical-inventory-draft/messages_en.json (.../messages_en.json) (revision 65b4d8ff6555ac16d77240a28d324d95863a71fb) @@ -39,5 +39,6 @@ "stockPhysicalInventoryDraft.deactivated": "The Product has been successfully deactivated", "stockPhysicalInventoryDraft.deactivateItem": "Do you want to deactivate Product with Lot Code: ${lot} for ${product}? \n This lot will also be deactivated on stock card", "stockPhysicalInventoryDraft.unaccountedQuantity": "Unaccounted Quantity", + "stockPhysicalInventoryDraft.unaccountedQuantityError": "Unnacounted quantity must be 0", "stockPhysicalInventoryDraft.actions": "Actions" } Index: src/stock-physical-inventory-draft/physical-inventory-draft.controller.js =================================================================== diff -u -N -r9fc644043ff7a036dca1f5e3c90be488f7e798f7 -r65b4d8ff6555ac16d77240a28d324d95863a71fb --- src/stock-physical-inventory-draft/physical-inventory-draft.controller.js (.../physical-inventory-draft.controller.js) (revision 9fc644043ff7a036dca1f5e3c90be488f7e798f7) +++ src/stock-physical-inventory-draft/physical-inventory-draft.controller.js (.../physical-inventory-draft.controller.js) (revision 65b4d8ff6555ac16d77240a28d324d95863a71fb) @@ -573,6 +573,26 @@ return lineItem.quantityInvalid; }; + /** + * @ngdoc method + * @methodOf stock-adjustment-creation.controller:StockAdjustmentCreationController + * @name validateUnaccountedQuantity + * + * @description + * Validate line item quantity and returns self. + * + * @param {Object} lineItem line item to be validated. + */ + vm.validateUnaccountedQuantity = function(lineItem) { + if (lineItem.unaccountedQuantity === 0) { + lineItem.unaccountedQuantityInvalid = false; + } else { + lineItem.unaccountedQuantityInvalid = messageService + .get('stockPhysicalInventoryDraft.unaccountedQuantityError'); + } + return lineItem.unaccountedQuantityInvalid; + }; + function isEmpty(value) { return value === '' || value === undefined || value === null; } @@ -585,7 +605,7 @@ .each(function(item) { if (!item.active) { activeError = 'stockPhysicalInventoryDraft.submitInvalidActive'; - } else if (vm.validateQuantity(item)) { + } else if (vm.validateQuantity(item) || vm.validateUnaccountedQuantity(item)) { qtyError = 'stockPhysicalInventoryDraft.submitInvalid'; } }); Index: src/stock-physical-inventory-draft/physical-inventory-draft.controller.spec.js =================================================================== diff -u -N -r9fc644043ff7a036dca1f5e3c90be488f7e798f7 -r65b4d8ff6555ac16d77240a28d324d95863a71fb --- src/stock-physical-inventory-draft/physical-inventory-draft.controller.spec.js (.../physical-inventory-draft.controller.spec.js) (revision 9fc644043ff7a036dca1f5e3c90be488f7e798f7) +++ src/stock-physical-inventory-draft/physical-inventory-draft.controller.spec.js (.../physical-inventory-draft.controller.spec.js) (revision 65b4d8ff6555ac16d77240a28d324d95863a71fb) @@ -309,13 +309,22 @@ it('should show modal for occurred date if no quantity missing', function() { this.lineItem1.active = true; this.lineItem3.active = true; + this.lineItem3.quantity = 1234; this.lineItem3.quantity = 123; + this.lineItem1.stockAdjustments = [{ + quantity: 1234, + reason: { + reasonType: 'CREDIT' + } + }]; this.lineItem3.stockAdjustments = [{ quantity: 123, reason: { reasonType: 'CREDIT' } }]; + this.lineItem1.unaccountedQuantity = 0; + this.lineItem3.unaccountedQuantity = 0; var deferred = this.$q.defer(); deferred.resolve(); chooseDateModalService.show.andReturn(deferred.promise); @@ -358,13 +367,22 @@ beforeEach(function() { this.lineItem1.active = true; this.lineItem3.active = true; + this.lineItem3.quantity = 1234; this.lineItem3.quantity = 123; + this.lineItem1.stockAdjustments = [{ + quantity: 1234, + reason: { + reasonType: 'CREDIT' + } + }]; this.lineItem3.stockAdjustments = [{ quantity: 123, reason: { reasonType: 'CREDIT' } }]; + this.lineItem1.unaccountedQuantity = 0; + this.lineItem3.unaccountedQuantity = 0; spyOn(this.$window, 'open').andCallThrough(); chooseDateModalService.show.andReturn(this.$q.when({})); spyOn(this.accessTokenFactory, 'addAccessToken').andCallThrough(); Index: src/stock-physical-inventory-draft/physical-inventory-draft.html =================================================================== diff -u -N -r36d9c34355d46e2058bb5befe07ebf31875c531a -r65b4d8ff6555ac16d77240a28d324d95863a71fb --- src/stock-physical-inventory-draft/physical-inventory-draft.html (.../physical-inventory-draft.html) (revision 36d9c34355d46e2058bb5befe07ebf31875c531a) +++ src/stock-physical-inventory-draft/physical-inventory-draft.html (.../physical-inventory-draft.html) (revision 65b4d8ff6555ac16d77240a28d324d95863a71fb) @@ -100,9 +100,10 @@ ng-model="lineItem.stockAdjustments" line-item="lineItem" reasons="vm.reasons" - ng-change="vm.checkUnaccountedStockAdjustments(lineItem)" + ng-change="vm.checkUnaccountedStockAdjustments(lineItem); vm.validateUnaccountedQuantity(lineItem)" /> -