diff --git a/src/authorization/Actions.ts b/src/authorization/Actions.ts index f09c45db..2faebbe6 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_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 21a838dc..afb3aa33 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_FORCE_SHIP_ORDER": "COMMON_ADMIN" } as any \ No newline at end of file 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/services/OrderService.ts b/src/services/OrderService.ts index c22b7da1..44b7707f 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 25c9d1a3..436c19ca 100644 --- a/src/views/Completed.vue +++ b/src/views/Completed.vue @@ -41,8 +41,7 @@
- {{ translate("Ship") }} - + {{ translate("Ship") }}
@@ -93,7 +92,7 @@
- {{ translate("Ship Now") }} + {{ translate("Ship Now") }} @@ -104,7 +103,7 @@
{{ translate("Shipped") }} - {{ translate("Ship Now") }} + {{ translate("Ship Now") }} {{ translate("Regenerate Shipping Label") }} @@ -125,9 +124,8 @@
- - + @@ -331,6 +329,21 @@ export default defineComponent({ text: translate("Ship"), handler: async () => { 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 + 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) { @@ -359,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 { @@ -609,6 +624,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() {