From 9001e2ab12620c513a7fd2691cf69e081dadec72 Mon Sep 17 00:00:00 2001 From: k2maan Date: Thu, 5 Oct 2023 15:48:57 +0530 Subject: [PATCH 1/6] Implemented: common admin permission on ship now button if any shipment package require tracking (#281) --- src/authorization/Actions.ts | 1 + src/authorization/Rules.ts | 1 + src/services/OrderService.ts | 2 +- src/views/Completed.vue | 11 +++++++++-- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/authorization/Actions.ts b/src/authorization/Actions.ts index f09c45db..667d5ff8 100644 --- a/src/authorization/Actions.ts +++ b/src/authorization/Actions.ts @@ -3,4 +3,5 @@ export default { "APP_UPDT_ECOM_INV_CONFIG": "APP_UPDT_ECOM_INV_CONFIG", "APP_UNPACK_ORDER": "APP_UNPACK_ORDER", "APP_RECYCLE_ORDER": "APP_RECYCLE_ORDER", + "APP_SHIP_ORDER": "APP_SHIP_ORDER" } \ No newline at end of file diff --git a/src/authorization/Rules.ts b/src/authorization/Rules.ts index 21a838dc..2c15f508 100644 --- a/src/authorization/Rules.ts +++ b/src/authorization/Rules.ts @@ -10,4 +10,5 @@ export default { "APP_UNPACK_ORDER": "COMMON_ADMIN", "APP_RECYCLE_ORDER": "COMMON_ADMIN", "APP_STOREFULFILLMENT_ADMIN": "STOREFULFILLMENT_ADMIN", + "APP_SHIP_ORDER": "COMMON_ADMIN" } as any \ No newline at end of file diff --git a/src/services/OrderService.ts b/src/services/OrderService.ts index 1928f271..e22c2cb1 100644 --- a/src/services/OrderService.ts +++ b/src/services/OrderService.ts @@ -149,7 +149,7 @@ const fetchShipmentPackages = async (shipmentIds: Array): Promise = "trackingCode_op": "empty", "shipmentItemSeqId_op": "not-empty" }, - "fieldList": ["shipmentId", "shipmentPackageSeqId", "shipmentBoxTypeId", "packageName", "primaryOrderId", "carrierPartyId"], + "fieldList": ["shipmentId", "shipmentPackageSeqId", "shipmentBoxTypeId", "packageName", "primaryOrderId", "carrierPartyId", "isTrackingRequired"], "viewSize": 250, // maximum records we could have "distinct": "Y" } diff --git a/src/views/Completed.vue b/src/views/Completed.vue index 3a676ac5..5cc56606 100644 --- a/src/views/Completed.vue +++ b/src/views/Completed.vue @@ -93,7 +93,7 @@
- {{ $t("Ship Now") }} + {{ $t("Ship Now") }} @@ -104,7 +104,7 @@
{{ $t("Shipped") }} - {{ $t("Ship Now") }} + {{ $t("Ship Now") }} {{ $t("Regenerate Shipping Label") }} @@ -609,6 +609,13 @@ export default defineComponent({ }, fetchProductStock(productId: string) { this.store.dispatch('stock/fetchStock', { productId }) + }, + isTrackingRequiredForAnyShipmentPackage(order: any) { + if (!order.shipmentPackages) { + return false + } + + return order.shipmentPackages.some((shipmentPackage: any) => shipmentPackage.isTrackingRequired === 'Y') } }, setup() { From 25e2d67ec8c8406bb74967380005518f7f05bcaf Mon Sep 17 00:00:00 2001 From: k2maan Date: Mon, 9 Oct 2023 14:29:15 +0530 Subject: [PATCH 2/6] Implemented: permission on bulk ship button and honoured tracking required condition (#281) --- src/views/Completed.vue | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/views/Completed.vue b/src/views/Completed.vue index 5cc56606..7207568f 100644 --- a/src/views/Completed.vue +++ b/src/views/Completed.vue @@ -41,7 +41,7 @@
- {{ $t("Ship") }} + {{ $t("Ship") }}
@@ -127,7 +127,7 @@
- + @@ -332,6 +332,15 @@ export default defineComponent({ handler: async () => { let orderList = JSON.parse(JSON.stringify(this.completedOrders.list)) + // if there are orders with tracking required and label image present + const trackingRequiredOrders = orderList.filter((order: any) => this.isTrackingRequiredForAnyShipmentPackage(order)) + if (trackingRequiredOrders.length) { + const orderHasMissingLabelImage = orderList.some((order: any) => order.missingLabelImage) + if (!orderHasMissingLabelImage) { + orderList = trackingRequiredOrders + } + } + let shipmentIds = orderList.reduce((shipmentIds: any, order: any) => { if (order.shipments) { order.shipments.reduce((shipmentIds: any, shipment: any) => { From fdf58d190ac2682ce129fad9a96932c74306f656 Mon Sep 17 00:00:00 2001 From: k2maan Date: Mon, 9 Oct 2023 14:38:18 +0530 Subject: [PATCH 3/6] Improved: removed comment (#281) --- src/views/Completed.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/src/views/Completed.vue b/src/views/Completed.vue index 7207568f..2372da03 100644 --- a/src/views/Completed.vue +++ b/src/views/Completed.vue @@ -125,7 +125,6 @@
- From 71f6c6263e7d954b96ae325459b587ff1ae6c591 Mon Sep 17 00:00:00 2001 From: k2maan Date: Mon, 16 Oct 2023 16:30:17 +0530 Subject: [PATCH 4/6] Improved: permission and variable naming (#281) --- src/authorization/Actions.ts | 2 +- src/authorization/Rules.ts | 2 +- src/views/Completed.vue | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/authorization/Actions.ts b/src/authorization/Actions.ts index 667d5ff8..2faebbe6 100644 --- a/src/authorization/Actions.ts +++ b/src/authorization/Actions.ts @@ -3,5 +3,5 @@ export default { "APP_UPDT_ECOM_INV_CONFIG": "APP_UPDT_ECOM_INV_CONFIG", "APP_UNPACK_ORDER": "APP_UNPACK_ORDER", "APP_RECYCLE_ORDER": "APP_RECYCLE_ORDER", - "APP_SHIP_ORDER": "APP_SHIP_ORDER" + "APP_FORCE_SHIP_ORDER": "APP_FORCE_SHIP_ORDER" } \ No newline at end of file diff --git a/src/authorization/Rules.ts b/src/authorization/Rules.ts index 2c15f508..afb3aa33 100644 --- a/src/authorization/Rules.ts +++ b/src/authorization/Rules.ts @@ -10,5 +10,5 @@ export default { "APP_UNPACK_ORDER": "COMMON_ADMIN", "APP_RECYCLE_ORDER": "COMMON_ADMIN", "APP_STOREFULFILLMENT_ADMIN": "STOREFULFILLMENT_ADMIN", - "APP_SHIP_ORDER": "COMMON_ADMIN" + "APP_FORCE_SHIP_ORDER": "COMMON_ADMIN" } as any \ No newline at end of file diff --git a/src/views/Completed.vue b/src/views/Completed.vue index 2372da03..099ad457 100644 --- a/src/views/Completed.vue +++ b/src/views/Completed.vue @@ -41,7 +41,7 @@
- {{ $t("Ship") }} + {{ $t("Ship") }}
@@ -93,7 +93,7 @@
- {{ $t("Ship Now") }} + {{ $t("Ship Now") }} @@ -104,7 +104,7 @@
{{ $t("Shipped") }} - {{ $t("Ship Now") }} + {{ $t("Ship Now") }} {{ $t("Regenerate Shipping Label") }} @@ -126,7 +126,7 @@
- + @@ -334,8 +334,8 @@ export default defineComponent({ // if there are orders with tracking required and label image present const trackingRequiredOrders = orderList.filter((order: any) => this.isTrackingRequiredForAnyShipmentPackage(order)) if (trackingRequiredOrders.length) { - const orderHasMissingLabelImage = orderList.some((order: any) => order.missingLabelImage) - if (!orderHasMissingLabelImage) { + const isTrackingCodeRequired = orderList.some((order: any) => order.missingLabelImage) + if (!isTrackingCodeRequired) { orderList = trackingRequiredOrders } } From 0515ff0bd1606fe026375bb1f24a986f79343943 Mon Sep 17 00:00:00 2001 From: k2maan Date: Tue, 17 Oct 2023 12:32:24 +0530 Subject: [PATCH 5/6] Improved: logic to exclude tracking required and missing label orders (#281) --- src/views/Completed.vue | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/views/Completed.vue b/src/views/Completed.vue index 5934b08f..53e1ea0b 100644 --- a/src/views/Completed.vue +++ b/src/views/Completed.vue @@ -329,13 +329,13 @@ export default defineComponent({ text: translate("Ship"), handler: async () => { let orderList = JSON.parse(JSON.stringify(this.completedOrders.list)) - - // if there are orders with tracking required and label image present + // orders with tracking required and missing label must be excluded const trackingRequiredOrders = orderList.filter((order: any) => this.isTrackingRequiredForAnyShipmentPackage(order)) if (trackingRequiredOrders.length) { - const isTrackingCodeRequired = orderList.some((order: any) => order.missingLabelImage) - if (!isTrackingCodeRequired) { - orderList = trackingRequiredOrders + // filtering and excluding orders having missing label image with tracking required + const trackingRequiredAndMissingLabelOrders = trackingRequiredOrders.filter((order: any) => order.missingLabelImage).map((order: any) => order.orderId) + if (trackingRequiredAndMissingLabelOrders.length) { + orderList = orderList.filter((order: any) => !trackingRequiredAndMissingLabelOrders.includes(order.orderId)) } } From 74ae56bbf5323f8ea110194dad21f34536d42128 Mon Sep 17 00:00:00 2001 From: k2maan Date: Tue, 17 Oct 2023 14:53:38 +0530 Subject: [PATCH 6/6] Improved: experience by adding toast messages if tracking is required for some or all orders (#281) --- src/locales/en.json | 2 ++ src/locales/es.json | 2 ++ src/views/Completed.vue | 16 ++++++++++++---- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/locales/en.json b/src/locales/en.json index 8e444ed1..5ceba440 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -129,6 +129,7 @@ "No capacity sets the fulfillment capacity to 0, preventing any new orders from being allocated to this facility. Use the \"Reject all orders\" option in the fulfillment pages to clear your facilities fulfillment queue. To add a fulfillment capacity to this facility, use the custom option.": "No capacity sets the fulfillment capacity to 0, preventing any new orders from being allocated to this facility. Use the \"Reject all orders\" option in the fulfillment pages to clear your facilities fulfillment queue. {space}To add a fulfillment capacity to this facility, use the custom option.", "No new file upload. Please try again": "No new file upload. Please try again", "No fulfillment capacity": "No fulfillment capacity", + "No orders are currently able to be shipped due to missing tracking codes.": "No orders are currently able to be shipped due to missing tracking codes.", "No reason": "No reason", "No results found for . Try searching Open or Completed tab instead. If you still can't find what you're looking for, try switching stores.": "No results found for { searchedQuery }. Try searching Open or Completed tab instead.{ lineBreak } If you still can't find what you're looking for, try switching stores.", "No results found for . Try searching In Progress or Open tab instead. If you still can't find what you're looking for, try switching stores.": "No results found for { searchedQuery }. Try searching In Progress or Open tab instead.{ lineBreak } If you still can't find what you're looking for, try switching stores.", @@ -160,6 +161,7 @@ "Order updated successfully": "Order updated successfully", "orders": "orders", "Out of stock": "Out of stock", + "out of cannot be shipped due to missing tracking codes.": "{remainingOrders} out of {totalOrders} cannot be shipped due to missing tracking codes.", "package": "package", "packages": "packages", "Pack": "Pack", diff --git a/src/locales/es.json b/src/locales/es.json index f1170dcf..4d4ef3bb 100644 --- a/src/locales/es.json +++ b/src/locales/es.json @@ -129,6 +129,7 @@ "No data available!": "No data available!", "No data Found.": "No data Found.", "No new file upload. Please try again": "No se cargó ningún archivo nuevo. Por favor, inténtalo nuevamente.", + "No orders are currently able to be shipped due to missing tracking codes.": "No orders are currently able to be shipped due to missing tracking codes.", "No reason": "Sin motivo", "No results found for . Try searching Open or Completed tab instead. If you still can't find what you're looking for, try switching stores.": "No results found for { searchedQuery }. Try searching Open or Completed tab instead.{ lineBreak }If you still can't find what you're looking for, try switching stores.", "No results found for . Try searching In Progress or Open tab instead. If you still can't find what you're looking for, try switching stores.": "No results found for { searchedQuery }. Try searching In Progress or Open tab instead.{ lineBreak } If you still can't find what you're looking for, try switching stores.", @@ -160,6 +161,7 @@ "Order updated successfully": "Pedido actualizado exitosamente", "orders": "pedidos", "Out of stock": "Agotado", + "out of cannot be shipped due to missing tracking codes.": "{remainingOrders} out of {totalOrders} cannot be shipped due to missing tracking codes.", "package": "paquete", "packages": "paquetes", "Pack": "Empacar", diff --git a/src/views/Completed.vue b/src/views/Completed.vue index 53e1ea0b..436c19ca 100644 --- a/src/views/Completed.vue +++ b/src/views/Completed.vue @@ -41,7 +41,7 @@
- {{ translate("Ship") }} + {{ translate("Ship") }}
@@ -331,14 +331,20 @@ export default defineComponent({ let orderList = JSON.parse(JSON.stringify(this.completedOrders.list)) // orders with tracking required and missing label must be excluded const trackingRequiredOrders = orderList.filter((order: any) => this.isTrackingRequiredForAnyShipmentPackage(order)) + let trackingRequiredAndMissingLabelOrders: any if (trackingRequiredOrders.length) { // filtering and excluding orders having missing label image with tracking required - const trackingRequiredAndMissingLabelOrders = trackingRequiredOrders.filter((order: any) => order.missingLabelImage).map((order: any) => order.orderId) + trackingRequiredAndMissingLabelOrders = trackingRequiredOrders.filter((order: any) => order.missingLabelImage).map((order: any) => order.orderId) if (trackingRequiredAndMissingLabelOrders.length) { orderList = orderList.filter((order: any) => !trackingRequiredAndMissingLabelOrders.includes(order.orderId)) } } + if (!orderList.length) { + showToast(translate("No orders are currently able to be shipped due to missing tracking codes.")) + return; + } + let shipmentIds = orderList.reduce((shipmentIds: any, order: any) => { if (order.shipments) { order.shipments.reduce((shipmentIds: any, shipment: any) => { @@ -366,8 +372,10 @@ export default defineComponent({ try { const resp = await OrderService.bulkShipOrders(payload) - if(resp.status == 200 && !hasError(resp)) { - showToast(translate('Orders shipped successfully')) + if (resp.status == 200 && !hasError(resp)) { + !trackingRequiredAndMissingLabelOrders.length + ? showToast(translate('Orders shipped successfully')) + : showToast(translate('out of cannot be shipped due to missing tracking codes.', { remainingOrders: trackingRequiredAndMissingLabelOrders.length, totalOrders: packedOrdersCount })) // TODO: handle the case of data not updated correctly await Promise.all([this.initialiseOrderQuery(), this.fetchShipmentMethods(), this.fetchCarrierPartyIds()]); } else {