Skip to content

Commit

Permalink
Merge pull request #327 from ymaheshwari1/fulfillment/#313
Browse files Browse the repository at this point in the history
Fixed: issue related to wrong status on related shipGroups for order(#313)
  • Loading branch information
ravilodhi authored Oct 23, 2023
2 parents bc6eb69 + 91e3522 commit fef5e71
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 27 deletions.
26 changes: 21 additions & 5 deletions src/store/modules/order/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { UtilService } from '@/services/UtilService'
import logger from '@/logger'
import { getOrderCategory } from '@/utils/order'


const actions: ActionTree<OrderState, RootState> = {
async fetchInProgressOrdersAdditionalInformation({ commit, state }, payload = { viewIndex: 0 }) {
// getting all the orders from state
Expand Down Expand Up @@ -574,6 +573,12 @@ const actions: ActionTree<OrderState, RootState> = {

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',
filters: {
Expand Down Expand Up @@ -609,7 +614,11 @@ const actions: ActionTree<OrderState, RootState> = {
}

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

if(!shipItem) {
return;
}

facilityTypeIds.push(shipItem.facilityTypeId)

Expand All @@ -632,6 +641,12 @@ const actions: ActionTree<OrderState, RootState> = {

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

Expand Down Expand Up @@ -661,7 +676,7 @@ 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 reservedShipGroupForOrder = shipGroups.find((group: any) => shipGroup.shipGroupSeqId === group.doclist?.docs[0]?.shipGroupSeqId)

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

Expand All @@ -670,9 +685,10 @@ const actions: ActionTree<OrderState, RootState> = {
items: reservedShipGroupForOrder.doclist.docs,
carrierPartyId: reservedShipGroup.carrierPartyId,
shipmentId: reservedShipGroup.shipmentId,
groupCategory: getOrderCategory(order), // category defines that the order is in which state like open, inProgress or completed
category: getOrderCategory(reservedShipGroupForOrder.doclist.docs[0])
} : {
...shipGroup
...shipGroup,
category: getOrderCategory(shipGroup.items[0])
}
})

Expand Down
30 changes: 12 additions & 18 deletions src/utils/order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,28 +61,22 @@ const handleParameterMatching = (orderVal: any, parameterVal: any, operation?: s
}

const getOrderCategory = (order: any) => {
const orderCategoryParametersEntries = Object.entries(orderCategoryParameters)
let result = '' as string
orderCategoryParametersEntries.forEach((entry: any) => {
const orderCategoryParameterEntries = Object.entries(orderCategoryParameters)
let result = ''
// using find, as once any of the category is matched then return from here;
orderCategoryParameterEntries.find((entry: any) => {
const [category, parameters] = entry
const paramKeys = Object.keys(parameters)
// used some as it will stop execution on a true condition
const isNotMatched = paramKeys.some((key: string) => {
if (
!Object.prototype.hasOwnProperty.call(order, key) ||
!handleParameterMatching(order[key], parameters[key].value, parameters[key]['OP'])
) {
return true
}
return false
})
// break the loop if any param is not matched
if (isNotMatched) {
return
// 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']))

// return the value when all params matched for an order
if (isMatched) {
result = category;
return result;
}
result = category
})
return result
return result;
}


Expand Down
6 changes: 2 additions & 4 deletions src/views/OpenOrders.vue
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ import {
popoverController
} from '@ionic/vue';
import { defineComponent } from 'vue';
import { caretDownOutline, cubeOutline, locateOutline, optionsOutline, pricetagOutline, printOutline,} from 'ionicons/icons';
import { caretDownOutline, cubeOutline, optionsOutline, pricetagOutline, printOutline,} from 'ionicons/icons';
import AssignPickerModal from '@/views/AssignPickerModal.vue';
import { mapGetters, useStore } from 'vuex';
import { ShopifyImg } from '@hotwax/dxp-components';
import { formatUtcDate, getFeature, getIdentificationId, showToast } from '@/utils'
import { formatUtcDate, getFeature, showToast } from '@/utils'
import { hasError } from '@/adapter';
import { UtilService } from '@/services/UtilService';
import { prepareOrderQuery } from '@/utils/solrHelper';
Expand Down Expand Up @@ -366,9 +366,7 @@ export default defineComponent({
cubeOutline,
formatUtcDate,
getFeature,
getIdentificationId,
hasPermission,
locateOutline,
optionsOutline,
pricetagOutline,
printOutline,
Expand Down

0 comments on commit fef5e71

Please sign in to comment.