Skip to content

Commit

Permalink
Improved: added flow for packing orders after creating picklist for s…
Browse files Browse the repository at this point in the history
…hipping orders (#415)
  • Loading branch information
amansinghbais committed Sep 6, 2024
1 parent 07be9ec commit 2a56c2a
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 4 deletions.
9 changes: 9 additions & 0 deletions src/services/OrderService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,14 @@ const fetchTrackingCodes = async (shipmentIds: Array<string>): Promise<any> => {
return shipmentTrackingCodes;
}

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

export const OrderService = {
fetchOrderItems,
fetchOrderPaymentPreferences,
Expand All @@ -359,6 +367,7 @@ export const OrderService = {
getShipmentItems,
getCustomerContactDetails,
getShippingPhoneNumber,
packOrder,
printPicklist,
printShippingLabelAndPackingSlip
}
5 changes: 3 additions & 2 deletions src/store/modules/order/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ const actions: ActionTree<OrderState , RootState> ={
shippingInstructions: orderItem.shippingInstructions,
shipGroupSeqId: orderItem.shipGroupSeqId,
isPicked: orderItem.isPicked,
picklistId: orderItem.picklistId
picklistId: orderItem.picklistId,
picklistBinId: orderItem.picklistBinId
}
})

Expand Down Expand Up @@ -592,7 +593,7 @@ const actions: ActionTree<OrderState , RootState> ={
const shipmentMethodTypeId = payload.part?.shipmentMethodEnum?.shipmentMethodEnumId
if (shipmentMethodTypeId !== 'STOREPICKUP') {
// TODO: find a better way to get the shipmentId
const shipmentId = resp.data._EVENT_MESSAGE_.match(/\d+/g)[0]
const shipmentId = resp.data.shipmentId ? resp.data.shipmentId : resp.data._EVENT_MESSAGE_.match(/\d+/g)[0]
await dispatch('packDeliveryItems', shipmentId).then((data) => {
if (!hasError(data) && !data.data._EVENT_MESSAGE_) {
showToast(translate("Something went wrong"))
Expand Down
36 changes: 34 additions & 2 deletions src/views/Orders.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
{{ order.part.shipmentMethodEnum?.shipmentMethodEnumId === 'STOREPICKUP' ? translate("Ready for pickup") : translate("Ready to ship") }}
</ion-button>
<div></div>
<ion-button v-if="printPicklistPref" slot="end" fill="clear" @click.stop="printPicklist(order, order.part)">
<ion-button v-if="printPicklistPref" :disabled="order.isPicked === 'Y'" slot="end" fill="clear" @click.stop="printPicklist(order, order.part)">
<ion-icon :icon="printOutline" slot="icon-only" />
</ion-button>
</div>
Expand Down Expand Up @@ -407,12 +407,43 @@ export default defineComponent({
},{
text: header,
handler: () => {
this.store.dispatch('order/packShipGroupItems', {order, 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(currenOrder: any, part: any) {

Check warning on line 420 in src/views/Orders.vue

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (18.x)

'part' is defined but never used

Check warning on line 420 in src/views/Orders.vue

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (20.x)

'part' is defined but never used
try {
const resp = await OrderService.packOrder({
'picklistBinId': currenOrder.picklistBinId,
'orderId': currenOrder.orderId
})
if(!hasError(resp)) {
showToast(translate("Order packed and ready for delivery"));
const orders = JSON.parse(JSON.stringify(this.orders));
const orderIndex = orders.findIndex((order: any) => {
return order.orderId === currenOrder.orderId && order.parts.some((part: any) => {
return part.orderPartSeqId === part.orderPartSeqId;
});
});
if (orderIndex > -1) {
orders.splice(orderIndex, 1);
this.store.dispatch("order/updateOpenOrder", { orders, total: orders.length })
}
} else {
throw resp.data;
}
} catch(error: any) {
logger.error(error);
showToast(translate("Something went wrong"))
}
},
async deliverShipment (order: any) {
await this.store.dispatch('order/deliverShipment', order)
.then((resp) => {
Expand Down Expand Up @@ -535,6 +566,7 @@ export default defineComponent({
const updatedOrder = orders.find((currentOrder: any) => currentOrder.orderId === order.orderId);
updatedOrder["isPicked"] = "Y"
updatedOrder["picklistId"] = resp.data.picklistId
updatedOrder["picklistBinId"] = resp.data.picklistBinId
this.store.dispatch("order/updateOpenOrder", { orders, total: orders.length })
} else {
throw resp.data;
Expand Down

0 comments on commit 2a56c2a

Please sign in to comment.