From f8e1e26b346bc4b89517835f44b4206e1a373e79 Mon Sep 17 00:00:00 2001 From: Ravi Lodhi Date: Thu, 10 Oct 2024 15:19:04 +0530 Subject: [PATCH] Fixed: Fetched updated package detail on updating order (#801). --- src/store/modules/order/actions.ts | 24 ++++++++++++++++-------- src/views/InProgress.vue | 1 + src/views/OrderDetail.vue | 1 + 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/store/modules/order/actions.ts b/src/store/modules/order/actions.ts index b0c47caf..281b3d85 100644 --- a/src/store/modules/order/actions.ts +++ b/src/store/modules/order/actions.ts @@ -647,17 +647,26 @@ const actions: ActionTree = { const missingLabelImage = this.state.util.productStoreShipmentMethCount > 0 ? shipmentPackageValues.some((shipmentPackage:any) => !shipmentPackage.trackingCode) : false; const updateShipmentPackages = (order:any) => { - order.shipmentPackages.forEach((shipmentPackage:any) => { + + const updatedShipmentPackages = order.shipmentPackages.reduce((updatedShipmentPackages: any[], shipmentPackage: any) => { const key = `${shipmentPackage.shipmentId}-${shipmentPackage.shipmentPackageSeqId}`; const updatedShipmentPackage = shipmentPackagesMap[key]; + + // Only add the shipment package if updatedShipmentPackage exists if (updatedShipmentPackage) { - shipmentPackage.trackingCode = updatedShipmentPackage.trackingCode; - shipmentPackage.labelPdfUrl = updatedShipmentPackage.labelPdfUrl; - shipmentPackage.shipmentMethodTypeId = updatedShipmentPackage.shipmentMethodTypeId; - shipmentPackage.carrierPartyId = updatedShipmentPackage.carrierPartyId; - shipmentPackage.missingLabelImage = missingLabelImage; + const newShipmentPackage = { ...shipmentPackage }; + newShipmentPackage.trackingCode = updatedShipmentPackage.trackingCode; + newShipmentPackage.labelPdfUrl = updatedShipmentPackage.labelPdfUrl; + newShipmentPackage.shipmentMethodTypeId = updatedShipmentPackage.shipmentMethodTypeId; + newShipmentPackage.carrierPartyId = updatedShipmentPackage.carrierPartyId; + newShipmentPackage.missingLabelImage = missingLabelImage; + updatedShipmentPackages.push(newShipmentPackage); } - }); + + return updatedShipmentPackages; + }, []); + + order.shipmentPackages = updatedShipmentPackages order.trackingCode = order.shipmentPackages?.[0]?.trackingCode order.missingLabelImage = missingLabelImage }; @@ -1134,7 +1143,6 @@ const actions: ActionTree = { } item.selectedBox = shipmentPackageContents[`${item.shipmentId}`].find((shipmentPackageContent: any) => shipmentPackageContent.shipmentItemSeqId === item.shipmentItemSeqId)?.packageName - item.selectedBox = shipmentPackagesByOrderAndPicklistBin[`${item.orderId}_${item.picklistBinId}`]?.find((shipmentPackage: any) => shipmentPackage.shipmentId === item.shipmentId)?.packageName }) const orderItem = current.items[0]; diff --git a/src/views/InProgress.vue b/src/views/InProgress.vue index 77c88b24..03535795 100644 --- a/src/views/InProgress.vue +++ b/src/views/InProgress.vue @@ -848,6 +848,7 @@ export default defineComponent({ order.items = items await this.store.dispatch('order/updateInProgressOrder', order) + await this.store.dispatch('order/updateShipmentPackageDetail', order) } showToast(translate('Order updated successfully')) } else { diff --git a/src/views/OrderDetail.vue b/src/views/OrderDetail.vue index 8871c2b5..d8c9c5df 100644 --- a/src/views/OrderDetail.vue +++ b/src/views/OrderDetail.vue @@ -1319,6 +1319,7 @@ export default defineComponent({ order.isModified = false; await this.store.dispatch('order/updateInProgressOrder', order) + await this.store.dispatch('order/updateShipmentPackageDetail', order) showToast(translate('Order updated successfully')) return Promise.resolve(order); } else {