diff --git a/src/services/UserService.ts b/src/services/UserService.ts index 6daf8691..a8069aed 100644 --- a/src/services/UserService.ts +++ b/src/services/UserService.ts @@ -231,8 +231,17 @@ const isEnumExists = async (enumId: string): Promise => { } } +const ensurePartyRole = async (payload: any): Promise => { + return api({ + url: "service/ensurePartyRole", + method: "post", + data: payload + }); +} + export const UserService = { createEnumeration, + ensurePartyRole, login, getCurrentEComStore, getRerouteFulfillmentConfig, diff --git a/src/views/OrderDetail.vue b/src/views/OrderDetail.vue index 022b43e4..e893d42d 100644 --- a/src/views/OrderDetail.vue +++ b/src/views/OrderDetail.vue @@ -338,7 +338,7 @@ export default defineComponent({ }); assignPickerModal.onDidDismiss().then(async(result: any) => { - if(result.data.dismissed) { + if(result.data.selectedPicker) { await this.store.dispatch('order/packShipGroupItems', { order, part, facilityId, selectedPicker: result.data.selectedPicker }) } }) @@ -395,7 +395,7 @@ export default defineComponent({ return rejectOrderModal.present(); }, async readyForPickup(order: any, part: any) { - if (this.configurePicker) return this.assignPicker(order, part, this.currentFacility.facilityId); + if(this.configurePicker && order.isPicked !== 'Y') return this.assignPicker(order, part, this.currentFacility.facilityId); const pickup = part?.shipmentMethodEnum?.shipmentMethodEnumId === 'STOREPICKUP'; const header = pickup ? translate('Ready for pickup') : translate('Ready to ship'); const message = pickup ? translate('An email notification will be sent to that their order is ready for pickup. This order will also be moved to the packed orders tab.', { customerName: order.customer.name, space: '

' }) : ''; @@ -410,12 +410,35 @@ export default defineComponent({ }, { text: header, handler: async () => { - await this.store.dispatch('order/packShipGroupItems', { order: order, part: part, facilityId: this.currentFacility.facilityId }) + if(!pickup) { + this.packShippingOrders(order, part); + } else { + this.store.dispatch('order/packShipGroupItems', {order, part, facilityId: this.currentFacility.facilityId}) + } } }] }); return alert.present(); }, + async packShippingOrders(currentOrder: any, part: any) { + try { + const resp = await OrderService.packOrder({ + 'picklistBinId': currentOrder.picklistBinId, + 'orderId': currentOrder.orderId + }) + + if(!hasError(resp)) { + showToast(translate("Order packed and ready for delivery")); + this.store.dispatch("order/updateCurrent", { order: { ...currentOrder, readyToShip: true } }) + this.store.dispatch("order/removeOpenOrder", { order: currentOrder, part }) + } else { + throw resp.data; + } + } catch(error: any) { + logger.error(error); + showToast(translate("Something went wrong")) + } + }, async fetchRejectReasons() { await this.store.dispatch('util/fetchRejectReasons'); }, diff --git a/src/views/Orders.vue b/src/views/Orders.vue index e5ebc426..41acf68b 100644 --- a/src/views/Orders.vue +++ b/src/views/Orders.vue @@ -213,6 +213,7 @@ import { api, hasError } from '@/adapter'; import { translate } from "@hotwax/dxp-components"; import AssignPickerModal from "./AssignPickerModal.vue"; import { OrderService } from "@/services/OrderService"; +import { UserService } from "@/services/UserService"; import { Actions, hasPermission } from '@/authorization' import logger from "@/logger"; @@ -276,7 +277,7 @@ export default defineComponent({ }); assignPickerModal.onDidDismiss().then(async(result: any) => { - if(result.data?.dismissed) { + if(result.data?.selectedPicker) { await this.store.dispatch('order/packShipGroupItems', { order, part, facilityId, selectedPicker: result.data.selectedPicker }) } }) @@ -516,6 +517,20 @@ export default defineComponent({ } if(!this.configurePicker) { + try { + const resp = await UserService.ensurePartyRole({ + partyId: "_NA_", + roleTypeId: "WAREHOUSE_PICKER", + }) + + if(hasError(resp)) { + throw resp.data; + } + } catch (error) { + showToast(translate("Something went wrong. Picklist can not be created.")); + logger.error(error) + return; + } await this.createPicklist(order, "_NA_"); return; } @@ -526,7 +541,7 @@ export default defineComponent({ }); assignPickerModal.onDidDismiss().then(async(result: any) => { - if(result.data?.dismissed) { + if(result.data?.selectedPicker) { this.createPicklist(order, result.data.selectedPicker) } })