diff --git a/src/components/OrderLookupLabelActionsPopover.vue b/src/components/OrderLookupLabelActionsPopover.vue index 5936f290..55f30571 100644 --- a/src/components/OrderLookupLabelActionsPopover.vue +++ b/src/components/OrderLookupLabelActionsPopover.vue @@ -62,33 +62,16 @@ export default defineComponent({ try { for(const shipmentPackage of this.currentOrder.shipmentPackages[shipGroupSeqId]) { - resp = await OrderService.updateShipmentPackageRouteSeg({ + resp = await OrderService.voidShipmentLabel({ "shipmentId": shipmentPackage.shipmentId, - "shipmentRouteSegmentId": shipmentPackage.shipmentRouteSegmentId, - "shipmentPackageSeqId": shipmentPackage.shipmentPackageSeqId, - "trackingCode": "", - "labelImage": "", - "labelIntlSignImage": "", - "labelHtml": "", - "labelImageUrl": "", - "internationalInvoiceUrl": "" - }); - if(!hasError(resp)) { - resp = await OrderService.updateShipmentRouteSegment({ - "shipmentId": shipmentPackage.shipmentId, - "shipmentRouteSegmentId": shipmentPackage.shipmentRouteSegmentId, - "carrierServiceStatusId": "SHRSCS_VOIDED", - "trackingIdNumber": "" - }) as any; - if(!hasError(resp)) { - showToast(translate("Shipping label voided successfully.")) - } else { - throw resp.data; - } - } else { + "shipmentRouteSegmentId": shipmentPackage.shipmentRouteSegmentId + }) + + if(hasError(resp)) { throw resp.data; } } + showToast(translate("Shipping label voided successfully.")) } catch (err) { logger.error("Failed to void shipping label", err); showToast(translate("Failed to void shipping label")); diff --git a/src/components/ShippingLabelActionPopover.vue b/src/components/ShippingLabelActionPopover.vue index ddd80311..2f32a7fa 100644 --- a/src/components/ShippingLabelActionPopover.vue +++ b/src/components/ShippingLabelActionPopover.vue @@ -64,31 +64,16 @@ let resp = {} as any; try { for (const shipmentPackage of order.shipmentPackages) { - resp = await OrderService.updateShipmentPackageRouteSeg({ + resp = await OrderService.voidShipmentLabel({ "shipmentId": shipmentPackage.shipmentId, - "shipmentRouteSegmentId": shipmentPackage.shipmentRouteSegmentId, - "shipmentPackageSeqId": shipmentPackage.shipmentPackageSeqId, - "trackingCode": "", - "labelImage": "", - "labelIntlSignImage": "", - "labelHtml": "", - "labelImageUrl": "", - "internationalInvoiceUrl": "" - }); - if (!hasError(resp)) { - resp = await OrderService.updateShipmentRouteSegment({ - "shipmentId": shipmentPackage.shipmentId, - "shipmentRouteSegmentId": shipmentPackage.shipmentRouteSegmentId, - "carrierServiceStatusId": "SHRSCS_VOIDED", - "trackingIdNumber": "" - }) as any; - if (hasError(resp)) { - throw resp.data; - } - } else { + "shipmentRouteSegmentId": shipmentPackage.shipmentRouteSegmentId + }) + + if(hasError(resp)) { throw resp.data; } } + showToast(translate("Shipping label voided successfully.")) //fetching updated shipment packages await this.store.dispatch('order/updateShipmentPackageDetail', order) } catch (err) { diff --git a/src/services/OrderService.ts b/src/services/OrderService.ts index 384867d9..1a9dc7d0 100644 --- a/src/services/OrderService.ts +++ b/src/services/OrderService.ts @@ -163,6 +163,15 @@ const updateShipmentPackageRouteSeg = async (payload: any): Promise => { data: payload }) } + +const voidShipmentLabel = async (payload: any): Promise => { + return api({ + url: "service/voidShipmentLabel", + method: "POST", + data: payload + }) +} + const updateOrderItemShipGroup = async (payload: any): Promise => { return api({ url: "service/updateOrderItemShipGroup", @@ -177,7 +186,12 @@ const addTrackingCode = async (payload: any): Promise => { "shipmentId": payload.shipmentId, "shipmentRouteSegmentId": payload.shipmentRouteSegmentId, "shipmentPackageSeqId": payload.shipmentPackageSeqId, - "trackingCode": payload.trackingCode + "trackingCode": payload.trackingCode, + "labelImage": "", + "labelIntlSignImage": "", + "labelHtml": "", + "labelImageUrl": "", + "internationalInvoiceUrl": "" }); if (!hasError(resp)) { resp = await updateShipmentRouteSegment({ @@ -373,7 +387,7 @@ const fetchShipmentPackages = async (shipmentIds: Array, isTrackingRequi "shipmentItemSeqId_op": "not-empty", ...trackingCodeFilters }, - "fieldList": ["shipmentId", "shipmentRouteSegmentId", "shipmentPackageSeqId", "shipmentBoxTypeId", "packageName", "primaryOrderId", "carrierPartyId", "isTrackingRequired", "primaryShipGroupSeqId", "labelImageUrl"], + "fieldList": ["shipmentId", "shipmentRouteSegmentId", "shipmentPackageSeqId", "shipmentBoxTypeId", "packageName", "primaryOrderId", "carrierPartyId", "isTrackingRequired", "primaryShipGroupSeqId", "labelImageUrl", "carrierServiceStatusId"], "viewSize": 250, // maximum records we could have "distinct": "Y" } @@ -387,6 +401,13 @@ const fetchShipmentPackages = async (shipmentIds: Array, isTrackingRequi if (!hasError(resp)) { shipmentPackages = resp?.data.docs; + shipmentPackages.map((shipmentPackage: any) => { + if(shipmentPackage.carrierServiceStatusId === "SHRSCS_VOIDED") { + shipmentPackage.trackingCode = "" + shipmentPackage.labelImageUrl = "" + shipmentPackage.internationalInvoiceUrl = "" + } + }) } else if (!resp?.data.error || (resp.data.error && resp.data.error !== "No record found")) { return Promise.reject(resp?.data.error); } @@ -906,5 +927,6 @@ export const OrderService = { fetchOrderItemShipGroup, fetchShippingAddress, fetchOrderPaymentPreferences, - getShippingPhoneNumber + getShippingPhoneNumber, + voidShipmentLabel } diff --git a/src/services/UtilService.ts b/src/services/UtilService.ts index 8c252431..288ab659 100644 --- a/src/services/UtilService.ts +++ b/src/services/UtilService.ts @@ -85,7 +85,7 @@ const findShipmentPackages = async(shipmentIds: Array): Promise => "shipmentId": shipmentIds, "shipmentId_op": "in" }, - "fieldList": ["shipmentId", "shipmentPackageSeqId", "shipmentRouteSegmentId", "shipmentMethodTypeId", "shipmentBoxTypeId", "packageName", "primaryOrderId", "carrierPartyId", "picklistBinId", "isTrackingRequired", "trackingCode", "internationalInvoiceUrl", "labelImageUrl"], + "fieldList": ["shipmentId", "shipmentPackageSeqId", "shipmentRouteSegmentId", "shipmentMethodTypeId", "shipmentBoxTypeId", "packageName", "primaryOrderId", "carrierPartyId", "picklistBinId", "isTrackingRequired", "trackingCode", "internationalInvoiceUrl", "labelImageUrl", "carrierServiceStatusId"], "viewSize": shipmentIds.length, "distinct": "Y" } @@ -101,6 +101,11 @@ const findShipmentPackages = async(shipmentIds: Array): Promise => shipmentPackages = resp.data.docs.reduce((shipmentForOrders: any, shipmentPackage: any) => { // creating key in this pattern as the same order can have multiple picklist bin and in that we need to find to which picklist bin shipment is associated const key = `${shipmentPackage.primaryOrderId}_${shipmentPackage.picklistBinId}` + if(shipmentPackage.carrierServiceStatusId === "SHRSCS_VOIDED") { + shipmentPackage.trackingCode = "" + shipmentPackage.labelImageUrl = "" + shipmentPackage.internationalInvoiceUrl = "" + } if (shipmentPackage.labelImageUrl && isPdf(shipmentPackage.labelImageUrl)) { shipmentPackage.labelPdfUrl = shipmentPackage.labelImageUrl; } @@ -117,7 +122,7 @@ const findShipmentPackages = async(shipmentIds: Array): Promise => } catch(err) { logger.error('Failed to fetch shipment packages information', err) } - + return shipmentPackages; } diff --git a/src/store/modules/order/actions.ts b/src/store/modules/order/actions.ts index 81aabb53..78819c9d 100644 --- a/src/store/modules/order/actions.ts +++ b/src/store/modules/order/actions.ts @@ -118,6 +118,7 @@ const actions: ActionTree = { }, []); // When the shipment method for product store is configured then only check for shipmentPackages otherwise we won't show missing label error button + const missingLabelImage = this.state.util.productStoreShipmentMethCount > 0 ? currentShipmentPackages.length > 0 : false; return {