Skip to content

Commit

Permalink
Merge pull request #733 from hotwax/#725_shipping_label_error_message
Browse files Browse the repository at this point in the history
Fixed: Fetched shipping gateway error when retry shipping label failed. Also reset the gateway error message on change of carrier/shipping method. (#725)
  • Loading branch information
ravilodhi authored Sep 6, 2024
2 parents 233be09 + 73f1181 commit d61e133
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 9 deletions.
21 changes: 18 additions & 3 deletions src/components/GenerateTrackingCodeModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export default defineComponent({
isGeneratingShippingLabel: false
}
},
props: ["order", "updateCarrierShipmentDetails"],
props: ["order", "updateCarrierShipmentDetails", "shipmentLabelErrorMessages", "fetchShipmentLabelError"],
async mounted() {
this.isTrackingRequired = this.isTrackingRequiredForAnyShipmentPackage()
if(this.facilityCarriers) {
Expand Down Expand Up @@ -208,6 +208,7 @@ export default defineComponent({
throw resp.data;
}
} catch(error: any) {
this.fetchShipmentLabelError && this.fetchShipmentLabelError()
logger.error(error);
showToast(translate("Failed to generate shipping label"))
return false;
Expand Down Expand Up @@ -248,8 +249,22 @@ export default defineComponent({
"carrierPartyId": carrierPartyId,
"shipmentMethodTypeId" : shipmentMethodTypeId ? shipmentMethodTypeId : "",
}) as any;
if(hasError(resp)) {
throw resp.data;
if(!hasError(resp)) {
//on changing the shipment carrier/method, voiding the gatewayMessage and gatewayStatus
if (this.shipmentLabelErrorMessages) {
resp = await OrderService.updateShipmentPackageRouteSeg({
"shipmentId": shipmentPackage.shipmentId,
"shipmentRouteSegmentId": shipmentPackage.shipmentRouteSegmentId,
"shipmentPackageSeqId": shipmentPackage.shipmentPackageSeqId,
"gatewayMessage": "",
"gatewayStatus": ""
}) as any;
if (hasError(resp)) {
throw resp.data
}
}
} else {
throw resp.data
}
}
} else {
Expand Down
33 changes: 27 additions & 6 deletions src/views/OrderDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -535,13 +535,16 @@ export default defineComponent({
}
// Fetching shipment label errors
const shipmentIds = this.order?.shipmentIds?.length > 0 ? this.order?.shipmentIds : this.order.shipments?.map((shipment: any) => shipment.shipmentId);
if (shipmentIds && shipmentIds.length > 0) {
const labelErrors = await OrderService.fetchShipmentLabelError(shipmentIds);
this.shipmentLabelErrorMessages = labelErrors.join(', ');
}
await this.fetchShipmentLabelError()
},
methods: {
async fetchShipmentLabelError() {
const shipmentIds = this.order?.shipmentIds?.length > 0 ? this.order?.shipmentIds : this.order.shipments?.map((shipment: any) => shipment.shipmentId);
if (shipmentIds && shipmentIds.length > 0) {
const labelErrors = await OrderService.fetchShipmentLabelError(shipmentIds);
this.shipmentLabelErrorMessages = labelErrors.join(', ');
}
},
getCarrierName(carrierPartyId: string) {
const selectedCarrier = this.facilityCarriers.find((carrier: any) => carrier.partyId === carrierPartyId)
return selectedCarrier && selectedCarrier.groupName ? selectedCarrier.groupName : carrierPartyId
Expand Down Expand Up @@ -587,6 +590,22 @@ export default defineComponent({
"shipmentMethodTypeId": shipmentMethodTypeId ? shipmentMethodTypeId : ""
}) as any;
if (!hasError(resp)) {
//on changing the shipment carrier/method, voiding the gatewayMessage and gatewayStatus
if (this.shipmentLabelErrorMessages) {
resp = await OrderService.updateShipmentPackageRouteSeg({
"shipmentId": shipmentPackage.shipmentId,
"shipmentRouteSegmentId": shipmentPackage.shipmentRouteSegmentId,
"shipmentPackageSeqId": shipmentPackage.shipmentPackageSeqId,
"gatewayMessage": "",
"gatewayStatus": ""
}) as any;
if (!hasError(resp)) {
this.shipmentLabelErrorMessages = ""
} else {
throw resp.data
}
}
this.shipmentMethodTypeId = shipmentMethodTypeId
showToast(translate("Shipment method detail updated successfully."))
//fetching updated shipment packages
Expand All @@ -612,6 +631,7 @@ export default defineComponent({
updateCarrierShipmentDetails(carrierPartyId: string, shipmentMethodTypeId: string) {
this.carrierPartyId = carrierPartyId
this.shipmentMethodTypeId = shipmentMethodTypeId
this.shipmentLabelErrorMessages = ""
},
async fetchKitComponent(orderItem: any, isOtherShipment = false ) {
await this.store.dispatch('product/fetchProductComponents', { productId: orderItem.productId })
Expand Down Expand Up @@ -1029,6 +1049,7 @@ export default defineComponent({
order.isGeneratingShippingLabel = false
} else {
showToast(translate("Failed to generate shipping label"))
this.fetchShipmentLabelError()
}
},
async shippingPopover(ev: Event) {
Expand Down Expand Up @@ -1523,7 +1544,7 @@ export default defineComponent({
async generateTrackingCodeForPacking(order: any) {
const modal = await modalController.create({
component: GenerateTrackingCodeModal,
componentProps: { order, updateCarrierShipmentDetails: this.updateCarrierShipmentDetails }
componentProps: { order, updateCarrierShipmentDetails: this.updateCarrierShipmentDetails, shipmentLabelErrorMessages: this.shipmentLabelErrorMessages, fetchShipmentLabelError: this.fetchShipmentLabelError }
})
modal.onDidDismiss().then((result: any) => {
Expand Down

0 comments on commit d61e133

Please sign in to comment.