Skip to content

Commit

Permalink
Merge pull request #419 from ymaheshwari1/#410
Browse files Browse the repository at this point in the history
Improved: logic to calculate derived status for order ship group and added check for displaying pending allocation as default category(#410)
  • Loading branch information
ymaheshwari1 authored Aug 21, 2024
2 parents fb41723 + a6d85b3 commit 7c21155
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
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 @@ -1134,15 +1134,14 @@ const actions: ActionTree<OrderState , RootState> ={

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

0 comments on commit 7c21155

Please sign in to comment.