Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented: dropdown for other shipments in a order in order details page (#358) #364

Merged
merged 16 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
414c192
Implemented: services and actions to fetch shipGroups for a order (#358)
amansinghbais Jan 4, 2024
820b6b1
Implemented: UI for showing other shipments in order (#358)
amansinghbais Jan 4, 2024
2bcc47d
Implemented: logic for fetching party details for shipGroups (#358)
amansinghbais Jan 5, 2024
989a00d
Implemented: logic to fetch product information of shipGroups (#358)
amansinghbais Jan 5, 2024
c8ae6cd
Merge branch 'main' of https://github.com/hotwax/bopis into bopis/#358
amansinghbais Jan 5, 2024
765f079
Improved: code to refetch shipGroups on app refresh (#358)
amansinghbais Jan 5, 2024
6f5e778
Improved: code to display inventory count of a product (#358)
amansinghbais Jan 5, 2024
6bb32cf
Improved: code syntax, alphabetical ordering of imports and ununused …
amansinghbais Jan 5, 2024
2677fac
Improved: code syntax and category fetching condition (#358)
amansinghbais Jan 5, 2024
a48e309
Improved: card of other shipments to show color and size (#358)
amansinghbais Jan 5, 2024
2ee7a82
Improved: comments and extracted unused changes (#358)
amansinghbais Jan 8, 2024
a86e3a9
Merge branch 'main' of https://github.com/hotwax/bopis into bopis/#358
amansinghbais Jan 11, 2024
68a08d1
Fixed: getting shipGroupSeqId for completed orders(#358)
amansinghbais Jan 11, 2024
c874095
Merge branch 'main' of https://github.com/hotwax/bopis into bopis/#358
amansinghbais Jan 17, 2024
a9d5da5
Fixed: logic for array handling in not operation in order category (#…
amansinghbais Jan 22, 2024
d44c387
Merge branch 'main' of https://github.com/hotwax/bopis into bopis/#358
amansinghbais Jun 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"Choose language": "Choose language",
"City": "City",
"Click the backdrop to dismiss.": "Click the backdrop to dismiss.",
"Color:": "Color: {color}",
"Colors": "Colors",
"Complete": "Complete",
"Completed": "Completed",
Expand Down Expand Up @@ -107,12 +108,14 @@
"Orders": "Orders",
"Orders Not Found": "Orders Not Found",
"Order item rejection history": "Order item rejection history",
"Other shipments in this order": "Other shipments in this order",
"Other stores": "Other stores",
"Packed": "Packed",
"Packing Slip": "Packing Slip",
"Packing slips help customer reconcile their order against the delivered items.": "Packing slips help customer reconcile their order against the delivered items.",
"Partial Order rejection": "Partial Order rejection",
"Password": "Password",
"Pending allocation": "Pending allocation",
"pending approval": "pending approval",
"Picked by": "Picked by { pickers }",
"Pick up location": "Pick up location",
Expand Down Expand Up @@ -155,6 +158,7 @@
"Ship to this address": "Ship to this address",
"Shop": "Shop",
"Show shipping orders": "Show shipping orders",
"Size:": "Size: {size}",
"Sizes": "Sizes",
"Something went wrong": "Something went wrong",
"Something went wrong, could not edit picker.": "Something went wrong, could not edit picker.",
Expand Down
2 changes: 2 additions & 0 deletions src/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,14 @@
"Orders": "Órdenes",
"Orders Not Found": "Órdenes no encontradas",
"Order item rejection history": "Historial de rechazo de artículos de pedido",
"Other shipments in this order": "Other shipments in this order",
"Other stores": "Otras tiendas",
"Packed": "Empacado",
"Packing Slip": "Remisión de embalaje",
"Packing slips help customer reconcile their order against the delivered items.": "Las remisiones de embalaje ayudan al cliente a conciliar su orden con los artículos entregados.",
"Partial Order rejection": "Rechazo parcial del pedido",
"Password": "Contraseña",
"Pending allocation": "Pending allocation",
"pending approval": "pendiente de aprobación",
"Picked by": "Recogido por { pickers }",
"Pick up location": "Ubicación de recogida",
Expand Down
43 changes: 43 additions & 0 deletions src/services/OrderService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,51 @@ const getShippingPhoneNumber = async (orderId: string): Promise<any> => {
return phoneNumber
}

const findOrderShipGroup = async (query: any): Promise<any> => {
return api({
url: "solr-query",
method: "post",
data: query
});
}

const fetchTrackingCodes = async (shipmentIds: Array<string>): Promise<any> => {
let shipmentTrackingCodes = [];
const params = {
"entityName": "ShipmentPackageRouteSeg",
"inputFields": {
"shipmentId": shipmentIds,
"shipmentId_op": "in",
"shipmentItemSeqId_op": "not-empty"
},
"fieldList": ["shipmentId", "shipmentPackageSeqId", "trackingCode"],
"viewSize": 250, // maximum records we could have
"distinct": "Y"
}

try {
const resp = await api({
url: "performFind",
method: "get",
params
})

if (!hasError(resp)) {
shipmentTrackingCodes = resp?.data.docs;
} else if (!resp?.data.error || (resp.data.error && resp.data.error !== "No record found")) {
return Promise.reject(resp?.data.error);
}
} catch (err) {
console.error('Failed to fetch tracking codes for shipments', err)
}

return shipmentTrackingCodes;
}

export const OrderService = {
fetchOrderPaymentPreferences,
fetchTrackingCodes,
findOrderShipGroup,
getOpenOrders,
getOrderDetails,
getCompletedOrders,
Expand Down
18 changes: 18 additions & 0 deletions src/services/UtilService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,25 @@ const resetPicker = async (payload: any): Promise<any> => {
})
}

const fetchFacilityTypeInformation = async (query: any): Promise<any> => {
return api({
url: "performFind",
method: "get",
params: query
});
}

const fetchPartyInformation = async (query: any): Promise<any> => {
return api({
url: "performFind",
method: "get",
params: query
});
}

export const UtilService = {
fetchFacilityTypeInformation,
fetchPartyInformation,
fetchPaymentMethodTypeDesc,
fetchRejectReasons,
fetchStatusDesc,
Expand Down
164 changes: 160 additions & 4 deletions src/store/modules/order/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import emitter from '@/event-bus'
import store from "@/store";
import { prepareOrderQuery } from "@/utils/solrHelper";
import { getOrderCategory } from "@/utils/order";
import logger from "@/logger";

const actions: ActionTree<OrderState , RootState> ={
Expand Down Expand Up @@ -74,7 +75,8 @@
return arr
}, []),
placedDate: orderItem.orderDate,
shippingInstructions: orderItem.shippingInstructions
shippingInstructions: orderItem.shippingInstructions,
shipGroupSeqId: orderItem.shipGroupSeqId
}
})

Expand Down Expand Up @@ -119,6 +121,7 @@
// As one order can have multiple parts thus checking orderId and partSeq as well before making any api call
if(current.orderId === payload.orderId && current.orderType === orderType && current.part?.orderPartSeqId === payload.orderPartSeqId) {
this.dispatch('product/getProductInformation', { orders: [ current ] })
await dispatch('fetchShipGroupForOrder');
return current
}
if(orders.length) {
Expand Down Expand Up @@ -210,8 +213,9 @@
await dispatch('updateCurrent', { order: currentOrder })
},

updateCurrent ({ commit }, payload) {
async updateCurrent ({ commit, dispatch }, payload) {
commit(types.ORDER_CURRENT_UPDATED, { order: payload.order })
await dispatch('fetchShipGroupForOrder');
},

async getPackedOrders ({ commit, state }, payload) {
Expand Down Expand Up @@ -276,7 +280,8 @@
ids.push(picker.split('/')[0]);
return ids;
}, [])) : "",
picklistId: orderItem.picklistId
picklistId: orderItem.picklistId,
shipGroupSeqId: orderItem.shipGroupSeqId
}
})
this.dispatch('product/getProductInformation', { orders });
Expand Down Expand Up @@ -345,7 +350,8 @@

return arr
}, []),
placedDate: orderItem.orderDate
placedDate: orderItem.orderDate,
shipGroupSeqId: orderItem.shipGroupSeqId
}
})
this.dispatch('product/getProductInformation', { orders });
Expand Down Expand Up @@ -413,7 +419,7 @@
return resp;
},

async packDeliveryItems ({ commit }, shipmentId) {

Check warning on line 422 in src/store/modules/order/actions.ts

View workflow job for this annotation

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

'commit' is defined but never used

Check warning on line 422 in src/store/modules/order/actions.ts

View workflow job for this annotation

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

'commit' is defined but never used
const params = {
shipmentId: shipmentId,
statusId: 'SHIPMENT_PACKED'
Expand Down Expand Up @@ -529,7 +535,7 @@
}).catch(err => err);
},

async rejectOrderItems ({ commit }, order) {

Check warning on line 538 in src/store/modules/order/actions.ts

View workflow job for this annotation

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

'commit' is defined but never used

Check warning on line 538 in src/store/modules/order/actions.ts

View workflow job for this annotation

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

'commit' is defined but never used
const payload = {
'orderId': order.orderId
}
Expand Down Expand Up @@ -916,6 +922,156 @@
}
commit(types.ORDER_CURRENT_UPDATED, { order });
},

async fetchShipGroupForOrder({ dispatch, state }) {
const order = JSON.parse(JSON.stringify(state.current))

// return if orderId is not found on order
if (!order?.orderId) {
return;
}

const params = {
groupBy: 'shipGroupSeqId',
'shipGroupSeqId': '[* TO *]', // check to ignore all those records for which shipGroupSeqId is not present
'-shipGroupSeqId': order.shipGroupSeqId,
orderId: order.orderId,
docType: 'ORDER'
}

const orderQueryPayload = prepareOrderQuery(params)

let resp, total, shipGroups = [];

Check warning on line 944 in src/store/modules/order/actions.ts

View workflow job for this annotation

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

'total' is defined but never used

Check warning on line 944 in src/store/modules/order/actions.ts

View workflow job for this annotation

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

'total' is defined but never used
const facilityTypeIds: Array<string> = [];

try {
resp = await OrderService.findOrderShipGroup(orderQueryPayload);

if (resp.status === 200 && !hasError(resp) && resp.data.grouped?.shipGroupSeqId.matches > 0) {
shipGroups = resp.data.grouped.shipGroupSeqId.groups
} else {
throw resp.data
}
} catch (err) {
console.error('Failed to fetch ship group information for order', err)
}

// return if shipGroups are not found for order
if (!shipGroups.length) {
return;
}

shipGroups = shipGroups.map((shipGroup: any) => {
const shipItem = shipGroup?.doclist?.docs[0]

if (!shipItem) {
return;
}

// In some case we are not having facilityTypeId in resp, resulting in undefined being pushed in the array
// so checking for facilityTypeId before updating the array
shipItem.facilityTypeId && facilityTypeIds.push(shipItem.facilityTypeId)

return {
items: shipGroup.doclist.docs,
facilityId: shipItem.facilityId,
facilityTypeId: shipItem.facilityTypeId,
facilityName: shipItem.facilityName,
shippingMethod: shipItem.shippingMethod,
orderId: shipItem.orderId,
shipGroupSeqId: shipItem.shipGroupSeqId
}
})

this.dispatch('util/fetchFacilityTypeInformation', facilityTypeIds)

// fetching reservation information for shipGroup from OISGIR doc
await dispatch('fetchAdditionalShipGroupForOrder', { shipGroups });
},

async fetchAdditionalShipGroupForOrder({ commit, state }, payload) {
const order = JSON.parse(JSON.stringify(state.current))


// return if orderId is not found on order
if (!order?.orderId) {
return;
}

const shipGroupSeqIds = payload.shipGroups.map((shipGroup: any) => shipGroup.shipGroupSeqId)
const orderId = order.orderId

const params = {
groupBy: 'shipGroupSeqId',
'shipGroupSeqId': `(${shipGroupSeqIds.join(' OR ')})`,
'-fulfillmentStatus': '(Rejected OR Cancelled)',
orderId: orderId
}

const orderQueryPayload = prepareOrderQuery(params)

let resp, total, shipGroups: any = [];

try {
resp = await OrderService.findOrderShipGroup(orderQueryPayload);
if (resp.status === 200 && !hasError(resp) && resp.data.grouped?.shipGroupSeqId.matches > 0) {
total = resp.data.grouped.shipGroupSeqId.ngroups
shipGroups = resp.data.grouped.shipGroupSeqId.groups
} else {
throw resp.data
}
} catch (err) {
console.error('Failed to fetch ship group information for order', err)
}

shipGroups = payload.shipGroups.map((shipGroup: any) => {
const reservedShipGroupForOrder = shipGroups.find((group: any) => shipGroup.shipGroupSeqId === group.doclist?.docs[0]?.shipGroupSeqId)

const reservedShipGroup = reservedShipGroupForOrder?.groupValue ? reservedShipGroupForOrder.doclist.docs[0] : ''

return reservedShipGroup ? {
...shipGroup,
items: reservedShipGroupForOrder.doclist.docs,
carrierPartyId: reservedShipGroup.carrierPartyId,
shipmentId: reservedShipGroup.shipmentId,
category: getOrderCategory(reservedShipGroupForOrder.doclist.docs[0])
} : {
...shipGroup,
category: getOrderCategory(shipGroup.items[0])
}
})

const carrierPartyIds: Array<string> = [];
const shipmentIds: Array<string> = [];


if (total) {
shipGroups.map((shipGroup: any) => {
if (shipGroup.shipmentId) shipmentIds.push(shipGroup.shipmentId)
if (shipGroup.carrierPartyId) carrierPartyIds.push(shipGroup.carrierPartyId)
})
}

try {
this.dispatch('util/fetchPartyInformation', carrierPartyIds)
const shipmentTrackingCodes = await OrderService.fetchTrackingCodes(shipmentIds)

shipGroups.find((shipGroup: any) => {
const trackingCode = shipmentTrackingCodes.find((shipmentTrackingCode: any) => shipGroup.shipmentId === shipmentTrackingCode.shipmentId)?.trackingCode

shipGroup.trackingCode = trackingCode;
})
} catch (err) {
console.error('Failed to fetch information for ship groups', err)
}

this.dispatch('product/getProductInformation', { orders: [{ parts: shipGroups }] })

order['shipGroups'] = shipGroups

commit(types.ORDER_CURRENT_UPDATED, {order})
return shipGroups;
},
}

export default actions;
2 changes: 2 additions & 0 deletions src/store/modules/util/UtilState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ export default interface UtilState {
rejectReasons: [];
paymentMethodTypeDesc: any;
statusDesc: any;
facilityTypeDesc: any;
partyNames: any;
}
Loading
Loading