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

Improved: logic to calculate derived status for order ship group and added check for displaying pending allocation as default category(#410) #419

Merged
merged 2 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions src/locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
"Packing slips help customer reconcile their order against the delivered items.": "内容明細票はお客様が注文と配送された商品を確認(照合)する際に役立ちます。",
"Partial Order rejection": "部分的な注文拒否",
"Password": "パスワード",
"Pending allocation": "Pending allocation",
"pending approval": "承認待ち",
"Picked by": "{pickers} によってピックアップされました",
"Pick up location": "受取場所",
Expand Down
3 changes: 1 addition & 2 deletions src/store/modules/order/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@
return resp;
},

async packDeliveryItems ({ commit }, shipmentId) {

Check warning on line 530 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 530 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 @@ -643,7 +643,7 @@
}).catch(err => err);
},

async rejectOrderItems ({ commit }, order) {

Check warning on line 646 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 646 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 @@ -1049,7 +1049,7 @@

const orderQueryPayload = prepareOrderQuery(params)

let resp, total, shipGroups = [];

Check warning on line 1052 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 1052 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 {
Expand Down Expand Up @@ -1134,15 +1134,14 @@

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])
category: getOrderCategory({ ...reservedShipGroupForOrder.doclist.docs[0], ...shipGroup.items[0] }) // Passing shipGroup item information as we need to derive the order status and for that we need some properties those are available on ORDER doc
} : {
...shipGroup,
category: getOrderCategory(shipGroup.items[0])
Expand Down
26 changes: 12 additions & 14 deletions src/utils/order.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import store from "@/store"

const orderCategoryParameters = {
'Open': {
'shipmentMethodTypeId': {
'value': 'STOREPICKUP',
'OP': 'NOT'
},
'shipmentStatusId': {
'value': '*',
'OP': 'NOT',
Expand All @@ -20,10 +18,6 @@ const orderCategoryParameters = {
}
},
'Packed': {
'shipmentMethodTypeId': {
'value': 'STOREPICKUP',
'OP': 'NOT'
},
'shipmentStatusId': {
'value': 'SHIPMENT_PACKED',
},
Expand All @@ -36,10 +30,6 @@ const orderCategoryParameters = {
},
},
'Completed': {
'shipmentMethodTypeId': {
'value': 'STOREPICKUP',
'OP': 'NOT'
},
'orderItemStatusId': {
'value': 'ITEM_COMPLETED'
},
Expand All @@ -50,7 +40,7 @@ const orderCategoryParameters = {
'value': 'ORDER'
}
}
}
} as any

const handleParameterMatching = (orderVal: any, parameterVal: any, operation?: string) => {
// considering params will always be an Array for ORing and ANDing
Expand All @@ -73,6 +63,13 @@ const handleParameterMatching = (orderVal: any, parameterVal: any, operation?: s
}

const getOrderCategory = (order: any) => {

if(!store.state.user.preference.showShippingOrders) {
orderCategoryParameters["Open"]["shipmentMethodTypeId"] = { value: "STOREPICKUP" }
orderCategoryParameters["Packed"]["shipmentMethodTypeId"] = { value: "STOREPICKUP" }
orderCategoryParameters["Completed"]["shipmentMethodTypeId"] = { value: "STOREPICKUP" }
}

const orderCategoryParameterEntries = Object.entries(orderCategoryParameters)
let result = ''
// using find, as once any of the category is matched then return from here;
Expand All @@ -81,7 +78,8 @@ const getOrderCategory = (order: any) => {
const paramKeys = Object.keys(parameters)
// used every as to check against each filtering property

const isMatched = paramKeys.every((key: string) => Object.prototype.hasOwnProperty.call(order, key) && handleParameterMatching(order[key], parameters[key].value, parameters[key]['OP']))
// Added check for property value *, as we will add * as value when operator NOT is defined and also for * values we do not want to check for property existence directly on order
const isMatched = paramKeys.every((key: string) => (parameters[key].value === "*" || Object.prototype.hasOwnProperty.call(order, key)) && handleParameterMatching(order[key], parameters[key].value, parameters[key]['OP']))

// return the value when all params matched for an order
if (isMatched) {
Expand Down
2 changes: 1 addition & 1 deletion src/views/OrderDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
<ion-card-title>{{ shipGroup.facilityName }}</ion-card-title>
{{ shipGroup.shipGroupSeqId }}
</div>
<ion-badge :color="shipGroup.category ? 'primary' : 'medium'">{{ shipGroup.category ? shipGroup.category : '-' }}</ion-badge>
<ion-badge :color="shipGroup.category ? 'primary' : 'medium'">{{ shipGroup.category ? shipGroup.category : translate('Pending allocation') }}</ion-badge>
</ion-card-header>

<ion-item v-if="shipGroup.carrierPartyId">
Expand Down
Loading