Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/hotwax/fulfillment-pwa into…
Browse files Browse the repository at this point in the history
… #715_rejection_page
  • Loading branch information
ravilodhi committed Sep 26, 2024
2 parents 04dea28 + 4979ddd commit c2ca07c
Show file tree
Hide file tree
Showing 26 changed files with 384 additions and 75 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fulfillment",
"version": "2.8.3",
"version": "2.9.1",
"private": true,
"description": "An Ionic project",
"scripts": {
Expand Down
111 changes: 111 additions & 0 deletions src/components/OrderLookupLabelActionsPopover.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<template>
<ion-content>
<ion-list>
<ion-list-header>{{ currentOrder.shipGroups[shipGroupSeqId][0]?.trackingIdNumber }}</ion-list-header>
<ion-item button :disabled="getCarriersTrackingInfo(carrierPartyId)?.trackingUrl" @click="redirectToTrackingUrl()">
{{ getCarriersTrackingInfo(carrierPartyId)?.carrierName ? getCarriersTrackingInfo(carrierPartyId).carrierName : carrierPartyId }}
<ion-icon slot="end" :icon="openOutline" />
</ion-item>
<ion-item button @click="printShippingLabel(shipGroupSeqId)">
{{ translate("View Label") }}
<ion-icon slot="end" :icon="documentOutline" />
</ion-item>
<ion-item button lines="none" @click="voidShippingLabel(shipGroupSeqId)">
{{ translate("Void Label") }}
<ion-icon slot="end" :icon="trashOutline" />
</ion-item>
</ion-list>
</ion-content>
</template>

<script lang="ts">
import {
IonContent,
IonIcon,
IonItem,
IonList,
IonListHeader,
popoverController
} from "@ionic/vue";
import { defineComponent } from "vue";
import { documentOutline, openOutline, trashOutline } from "ionicons/icons";
import { translate } from "@hotwax/dxp-components";
import { mapGetters, useStore } from "vuex";
import { OrderService } from '@/services/OrderService';
import { isPdf, showToast } from '@/utils'
import { hasError } from "@/adapter";
import logger from '@/logger';

export default defineComponent({
name: "OrderLookupLabelActionsPopover",
components: {
IonContent,
IonIcon,
IonItem,
IonList,
IonListHeader
},
computed: {
...mapGetters({
getCarriersTrackingInfo: "orderLookup/getCarriersTrackingInfo",
})
},
props: ["carrierPartyId", "currentOrder", "shipGroupSeqId"],
methods: {
async printShippingLabel(shipGroupSeqId: any) {
const shipmentPackages = this.currentOrder.shipmentPackages[shipGroupSeqId];
const shipmentIds = [] as any;
const shippingLabelPdfUrls = [] as any;

shipmentPackages.map((shipmentPackage: any) => {
shipmentIds.push(shipmentPackage.shipmentId)
this.isPdf(shipmentPackage.labelImageUrl) && shippingLabelPdfUrls.push(shipmentPackage.labelImageUrl)
})

await OrderService.printShippingLabel(shipmentIds, shippingLabelPdfUrls)
popoverController.dismiss()
},

async voidShippingLabel(shipGroupSeqId: any) {
let resp = {} as any;

try {
for(const shipmentPackage of this.currentOrder.shipmentPackages[shipGroupSeqId]) {
resp = await OrderService.voidShipmentLabel({
"shipmentId": shipmentPackage.shipmentId,
"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"));
}
await this.store.dispatch("orderLookup/getOrderDetails", this.currentOrder.orderId)
popoverController.dismiss()
},
redirectToTrackingUrl() {
const trackingUrl = this.getCarriersTrackingInfo(this.carrierPartyId)
const trackingCode = this.currentOrder.shipGroups[this.shipGroupSeqId][0]?.trackingIdNumber
window.open(trackingUrl.replace("${trackingNumber}", trackingCode), "_blank");
popoverController.dismiss()
}
},
setup() {
const store = useStore();

return {
documentOutline,
isPdf,
openOutline,
trashOutline,
store,
translate
};
}
});
</script>
31 changes: 8 additions & 23 deletions src/components/ShippingLabelActionPopover.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{{ translate("View Label") }}
<ion-icon slot="end" :icon="documentOutline" />
</ion-item>
<ion-item button lines="none" @click="voidShippingLabel(currentOrder)">
<ion-item button lines="none" :disabled="isVoidLabelDisabled" @click="voidShippingLabel(currentOrder)">
{{ translate("Void Label") }}
<ion-icon slot="end" :icon="trashOutline" />
</ion-item>
Expand Down Expand Up @@ -41,7 +41,7 @@
IonList,
IonListHeader
},
props: ['currentOrder'],
props: ['currentOrder', 'isVoidLabelDisabled'],
computed: {
...mapGetters({
facilityProductStores: 'facility/getFacilityProductStores',
Expand All @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@
"Import shipped order details from an external system based on tracking codes. Orders that have tracking codes will automatically be shipped at the end of the day.": "Import shipped order details from an external system based on tracking codes. Orders that have tracking codes will automatically be shipped at the end of the day.",
"Import shipped orders": "Import shipped orders",
"In Progress": "In Progress",
"Invoicing facility": "Invoicing facility",
"Key": "Key",
"Kit": "Kit",
"Language": "Language",
Expand Down Expand Up @@ -518,6 +519,7 @@
"Shipping label": "Shipping label",
"Shipping label error": "Shipping label error",
"Shipping Label generated successfully": "Shipping Label generated successfully",
"Shipping label voided successfully.": "Shipping label voided successfully.",
"Shipping labels": "Shipping labels",
"Shopify ID": "Shopify ID",
"Show label error": "Show label error",
Expand Down Expand Up @@ -612,6 +614,8 @@
"Version: ": "Version: {appVersion}",
"View details": "View details",
"View Saved Mappings": "View Saved Mappings",
"Void": "Void",
"Void label": "Void label",
"Web Channel": "Web Channel",
"Weight": "Weight",
"When rejecting an item, automatically reject all other orders for that item as well.": "When rejecting an item, automatically reject all other orders for that item as well.",
Expand Down
4 changes: 4 additions & 0 deletions src/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@
"Import shipped order details from an external system based on tracking codes. Orders that have tracking codes will automatically be shipped at the end of the day.": "Importa los detalles de los pedidos enviados desde un sistema externo basado en códigos de seguimiento. Los pedidos que tienen códigos de seguimiento se enviarán automáticamente al final del día.",
"Import shipped orders": "Importar pedidos enviados",
"In Progress": "En Curso",
"Invoicing facility": "Invoicing facility",
"Key": "Clave",
"Kit": "Kit",
"Language": "Lenguaje",
Expand Down Expand Up @@ -513,6 +514,7 @@
"Shipment method renamed.": "Shipment method renamed.",
"Shipment methods order has been changed. Click save button to update them.": "Shipment methods order has been changed. Click save button to update them.",
"Shipping label": "Etiqueta de Envío",
"Shipping label voided successfully.": "Shipping label voided successfully.",
"Shipping label error": "Etiqueta de Envio con Error",
"Shipping Label generated successfully": "Etiqueta de Envío generada exitosamente",
"Shipping labels": "Etiquetas de Envío",
Expand Down Expand Up @@ -608,6 +610,8 @@
"Variance type updated successfully.": "Variance type updated successfully.",
"View details": "Ver detalles",
"View Saved Mappings": "Ver mapeos guardados",
"Void": "Void",
"Void label": "Void label",
"Web Channel": "Canal Web",
"Weight": "Peso",
"When rejecting an item, automatically reject all other orders for that item as well.": "When rejecting an item, automatically reject all other orders for that item as well.",
Expand Down
4 changes: 4 additions & 0 deletions src/locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@
"Import shipped order details from an external system based on tracking codes. Orders that have tracking codes will automatically be shipped at the end of the day.": "追跡コードに基づいて外部システムから出荷済み注文の詳細をインポートします。追跡コードのある注文は、日末に自動的に出荷されます。",
"Import shipped orders": "出荷済み注文をインポート",
"In Progress": "進行中",
"Invoicing facility": "Invoicing facility",
"Key": "キー",
"Language": "言語",
"Last 7 days": "過去7日間",
Expand Down Expand Up @@ -515,6 +516,7 @@
"Shipping label": "配送ラベル",
"Shipping label error": "配送ラベルエラー",
"Shipping Label generated successfully": "配送ラベルが正常に生成されました",
"Shipping label voided successfully.": "Shipping label voided successfully.",
"Shipping labels": "配送ラベル",
"Shopify ID": "Shopify ID",
"Show label error": "ラベルエラーを表示",
Expand Down Expand Up @@ -608,6 +610,8 @@
"Version: ": "バージョン: {appVersion}",
"View details": "詳細を表示",
"View Saved Mappings": "保存されたマッピングを表示",
"Void": "Void",
"Void label": "Void label",
"Web Channel": "ウェブチャネル",
"Weight": "重量",
"When rejecting an item, automatically reject all other orders for that item as well.": "When rejecting an item, automatically reject all other orders for that item as well.",
Expand Down
68 changes: 46 additions & 22 deletions src/services/OrderService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,15 @@ const updateShipmentPackageRouteSeg = async (payload: any): Promise<any> => {
data: payload
})
}

const voidShipmentLabel = async (payload: any): Promise<any> => {
return api({
url: "service/voidShipmentLabel",
method: "POST",
data: payload
})
}

const updateOrderItemShipGroup = async (payload: any): Promise<any> => {
return api({
url: "service/updateOrderItemShipGroup",
Expand All @@ -173,29 +182,25 @@ const updateOrderItemShipGroup = async (payload: any): Promise<any> => {

const addTrackingCode = async (payload: any): Promise<any> => {
try {
let resp = await updateShipmentRouteSegment({
let resp = await updateShipmentPackageRouteSeg({
"shipmentId": payload.shipmentId,
"shipmentRouteSegmentId": payload.shipmentRouteSegmentId,
"carrierServiceStatusId": "SHRSCS_CONFIRMED"
}) as any;
"shipmentPackageSeqId": payload.shipmentPackageSeqId,
"trackingCode": payload.trackingCode,
"labelImage": "",
"labelIntlSignImage": "",
"labelHtml": "",
"labelImageUrl": "",
"internationalInvoiceUrl": ""
});
if (!hasError(resp)) {
resp = await updateShipmentPackageRouteSeg({
resp = await updateShipmentRouteSegment({
"shipmentId": payload.shipmentId,
"shipmentRouteSegmentId": payload.shipmentRouteSegmentId,
"shipmentPackageSeqId": payload.shipmentPackageSeqId,
"trackingCode": payload.trackingCode
"trackingIdNumber": payload.trackingCode,
"carrierServiceStatusId": "SHRSCS_ACCEPTED"
});
if (!hasError(resp)) {
resp = await updateShipmentRouteSegment({
"shipmentId": payload.shipmentId,
"shipmentRouteSegmentId": payload.shipmentRouteSegmentId,
"trackingIdNumber": payload.trackingCode,
"carrierServiceStatusId": "SHRSCS_ACCEPTED"
});
if (hasError(resp)) {
throw resp.data;
}
} else {
if (hasError(resp)) {
throw resp.data;
}
} else {
Expand Down Expand Up @@ -364,17 +369,28 @@ const fetchShipments = async (picklistBinIds: Array<string>, orderIds: Array<str
return shipments;
}

const fetchShipmentPackages = async (shipmentIds: Array<string>): Promise<any> => {
const fetchShipmentPackages = async (shipmentIds: Array<string>, isTrackingRequired = false): Promise<any> => {
let shipmentPackages = [];
let trackingCodeFilters = {};

if(!isTrackingRequired) {
trackingCodeFilters = {
"trackingCode_op": "empty",
"trackingCode_grp": "1",
"fetchShipmentPackages_op": "SHRSCS_VOIDED",
"fetchShipmentPackages_grp": "2"
}
}

const params = {
"entityName": "ShipmentPackageRouteSegDetail",
"inputFields": {
"shipmentId": shipmentIds,
"shipmentId_op": "in",
"trackingCode_op": "empty",
"shipmentItemSeqId_op": "not-empty"
"shipmentItemSeqId_op": "not-empty",
...trackingCodeFilters
},
"fieldList": ["shipmentId", "shipmentRouteSegmentId", "shipmentPackageSeqId", "shipmentBoxTypeId", "packageName", "primaryOrderId", "carrierPartyId", "isTrackingRequired"],
"fieldList": ["shipmentId", "shipmentRouteSegmentId", "shipmentPackageSeqId", "shipmentBoxTypeId", "packageName", "primaryOrderId", "carrierPartyId", "isTrackingRequired", "primaryShipGroupSeqId", "labelImageUrl", "carrierServiceStatusId"],
"viewSize": 250, // maximum records we could have
"distinct": "Y"
}
Expand All @@ -388,6 +404,13 @@ const fetchShipmentPackages = async (shipmentIds: Array<string>): Promise<any> =

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);
}
Expand Down Expand Up @@ -907,5 +930,6 @@ export const OrderService = {
fetchOrderItemShipGroup,
fetchShippingAddress,
fetchOrderPaymentPreferences,
getShippingPhoneNumber
getShippingPhoneNumber,
voidShipmentLabel
}
Loading

0 comments on commit c2ca07c

Please sign in to comment.