From a329e243cdecf98b897e22dc52263d21f50b2354 Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Mon, 11 Mar 2024 12:41:25 +0530 Subject: [PATCH 1/2] Fixed: payload to pass shipmentItemSeqId for externally added item for a shipment(#357) --- src/store/modules/shipment/actions.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/store/modules/shipment/actions.ts b/src/store/modules/shipment/actions.ts index 7f563a1a..a5fe26bd 100644 --- a/src/store/modules/shipment/actions.ts +++ b/src/store/modules/shipment/actions.ts @@ -100,6 +100,10 @@ const actions: ActionTree = { return Promise.reject("Missing locationSeqId on item") } + if(!item.itemSeqId) { + return Promise.reject("Missing shipmentItemSeqId on item") + } + const params = { shipmentId: payload.shipmentId, facilityId: this.state.user.currentFacility.facilityId, @@ -155,7 +159,14 @@ const actions: ActionTree = { const resp = await ShipmentService.addShipmentItem(params); if(resp.status == 200 && !hasError(resp)){ dispatch('updateProductCount', { shipmentId: resp.data.shipmentId }) - if (!payload.shipmentId) commit(types.SHIPMENT_CURRENT_PRODUCT_ADDED, product) + if (!payload.shipmentId) { + // When adding item to a shipment from details page, then adding the shipmentItemSeqId to item level, as we do not generate shipmentItemSeqId app side, + // when adding an item to shipment + commit(types.SHIPMENT_CURRENT_PRODUCT_ADDED, { + ...product, + itemSeqId: resp.data.shipmentItemSeqId + }) + } return resp; } else { showToast(translate('Something went wrong')); From e0736ade6e29f078d3332666a98bb32c10eada46 Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Wed, 13 Mar 2024 11:00:31 +0530 Subject: [PATCH 2/2] Improved: code to remove the check for shipmentItemSeqId on receiving and added the same check when adding the product(#357) --- src/store/modules/shipment/actions.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/store/modules/shipment/actions.ts b/src/store/modules/shipment/actions.ts index a5fe26bd..88abc451 100644 --- a/src/store/modules/shipment/actions.ts +++ b/src/store/modules/shipment/actions.ts @@ -100,10 +100,6 @@ const actions: ActionTree = { return Promise.reject("Missing locationSeqId on item") } - if(!item.itemSeqId) { - return Promise.reject("Missing shipmentItemSeqId on item") - } - const params = { shipmentId: payload.shipmentId, facilityId: this.state.user.currentFacility.facilityId, @@ -157,7 +153,7 @@ const actions: ActionTree = { locationSeqId: product.locationSeqId } const resp = await ShipmentService.addShipmentItem(params); - if(resp.status == 200 && !hasError(resp)){ + if(resp.status == 200 && !hasError(resp) && resp.data.shipmentId && resp.data.shipmentItemSeqId) { dispatch('updateProductCount', { shipmentId: resp.data.shipmentId }) if (!payload.shipmentId) { // When adding item to a shipment from details page, then adding the shipmentItemSeqId to item level, as we do not generate shipmentItemSeqId app side,