-
Notifications
You must be signed in to change notification settings - Fork 40
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
Changes from 10 commits
414c192
820b6b1
2bcc47d
989a00d
c8ae6cd
765f079
6f5e778
6bb32cf
2677fac
a48e309
2ee7a82
a86e3a9
68a08d1
c874095
a9d5da5
d44c387
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
import emitter from '@/event-bus' | ||
import store from "@/store"; | ||
import { prepareOrderQuery } from "@/utils/solrHelper"; | ||
import { getOrderCategory } from "@/utils/order"; | ||
|
||
const actions: ActionTree<OrderState , RootState> ={ | ||
async getOpenOrders({ commit, state }, payload) { | ||
|
@@ -73,7 +74,8 @@ | |
return arr | ||
}, []), | ||
placedDate: orderItem.orderDate, | ||
shippingInstructions: orderItem.shippingInstructions | ||
shippingInstructions: orderItem.shippingInstructions, | ||
shipGroupSeqId: orderItem.shipGroupSeqId | ||
} | ||
}) | ||
|
||
|
@@ -113,6 +115,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) { | ||
|
@@ -205,8 +208,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) { | ||
|
@@ -271,7 +275,8 @@ | |
ids.push(picker.split('/')[0]); | ||
return ids; | ||
}, [])) : "", | ||
picklistId: orderItem.picklistId | ||
picklistId: orderItem.picklistId, | ||
shipGroupSeqId: orderItem.shipGroupSeqId | ||
} | ||
}) | ||
this.dispatch('product/getProductInformation', { orders }); | ||
|
@@ -408,7 +413,7 @@ | |
return resp; | ||
}, | ||
|
||
async packDeliveryItems ({ commit }, shipmentId) { | ||
Check warning on line 416 in src/store/modules/order/actions.ts GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (18.x)
|
||
const params = { | ||
shipmentId: shipmentId, | ||
statusId: 'SHIPMENT_PACKED' | ||
|
@@ -524,7 +529,7 @@ | |
}).catch(err => err); | ||
}, | ||
|
||
async rejectOrderItems ({ commit }, order) { | ||
Check warning on line 532 in src/store/modules/order/actions.ts GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (18.x)
|
||
const payload = { | ||
'orderId': order.orderId | ||
} | ||
|
@@ -911,6 +916,157 @@ | |
} | ||
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, as in case of kit comp we does not get shipGroupSeqId on some items | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update comment. |
||
'-shipGroupSeqId': order.shipGroupSeqId, | ||
orderId: order.orderId, | ||
docType: 'ORDER' | ||
} | ||
|
||
const orderQueryPayload = prepareOrderQuery(params) | ||
|
||
let resp, total, shipGroups = []; | ||
const facilityTypeIds: Array<string> = []; | ||
|
||
try { | ||
resp = await OrderService.findOrderShipGroup(orderQueryPayload); | ||
|
||
if (resp.status === 200 && !hasError(resp) && resp.data.grouped?.shipGroupSeqId.matches > 0) { | ||
total = resp.data.grouped.shipGroupSeqId.ngroups | ||
Check warning on line 945 in src/store/modules/order/actions.ts GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (18.x)
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unused variable. |
||
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this TODO.