From edf85dfa0dd3fde3cd5cba8af2cf06eee4fc86e9 Mon Sep 17 00:00:00 2001 From: DominikNoga Date: Mon, 2 Sep 2024 13:50:22 +0200 Subject: [PATCH] ANGOLASUP-909: resolving first request --- .../physical-inventory-draft.controller.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/stock-physical-inventory-draft/physical-inventory-draft.controller.js b/src/stock-physical-inventory-draft/physical-inventory-draft.controller.js index fea72af..bc29e62 100644 --- a/src/stock-physical-inventory-draft/physical-inventory-draft.controller.js +++ b/src/stock-physical-inventory-draft/physical-inventory-draft.controller.js @@ -479,6 +479,13 @@ }); } + function setItemsWithUnit() { + var itemsWithUnit = draft.lineItems.filter(function(item) { + return item.unit; + }); + draft.lineItems = itemsWithUnit; + } + /** * @ngdoc method * @methodOf stock-physical-inventory-draft.controller:PhysicalInventoryDraftController @@ -488,6 +495,7 @@ * Save physical inventory draft. */ vm.saveDraft = function(withNotification) { + setItemsWithUnit(); multiplyUnitsByFactor(draft.lineItems); loadingModalService.open(); return physicalInventoryFactory.saveDraft(draft).then(function() { @@ -614,7 +622,7 @@ draft.occurredDate = resolvedData.occurredDate; draft.signature = resolvedData.signature; - + setItemsWithUnit(); return saveLots(draft, function() { physicalInventoryService.submitPhysicalInventory(draft).then(function() { notificationService.success('stockPhysicalInventoryDraft.submitted'); @@ -888,10 +896,7 @@ function getUnitById(unitId) { if (!unitId) { - return { - name: '-', - factor: 1 - }; + return undefined; } return vm.unitsOfOrderable.find(function(unit) {