Skip to content

Commit

Permalink
Merge pull request #731 from hotwax/new_rejection_api
Browse files Browse the repository at this point in the history
Made usage of new rejection api configurable.
  • Loading branch information
ravilodhi authored Sep 6, 2024
2 parents 3b8be1d + 1c8b822 commit f21dd8b
Show file tree
Hide file tree
Showing 13 changed files with 102 additions and 26 deletions.
1 change: 1 addition & 0 deletions src/authorization/Actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default {
"APP_CARRIERS_VIEW" : "APP_CARRIERS_VIEW",
"APP_CARRIERS_CREATE" : "APP_CARRIERS_CREATE",
"APP_ORDER_LOOKUP_VIEW": "APP_ORDER_LOOKUP_VIEW",
"APP_NEW_REJECTION_API_CONFIG_UPDATE": "APP_NEW_REJECTION_API_CONFIG_UPDATE",
"APP_PARTIAL_ORDER_REJECTION_CONFIG_UPDATE": "APP_PARTIAL_ORDER_REJECTION_CONFIG_UPDATE",
"APP_COLLATERAL_REJECTION_CONFIG_UPDATE": "APP_COLLATERAL_REJECTION_CONFIG_UPDATE",
"APP_UPDT_FULFILL_FORCE_SCAN_CONFIG": "APP_UPDT_FULFILL_FORCE_SCAN_CONFIG",
Expand Down
1 change: 1 addition & 0 deletions src/authorization/Rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default {
"APP_CARRIERS_VIEW": "CARRIER_SETUP_VIEW",
"APP_CARRIERS_CREATE": "CARRIER_SETUP_VIEW",
"APP_ORDER_LOOKUP_VIEW": "FF_ORDER_LOOKUP_VIEW",
"APP_NEW_REJECTION_API_CONFIG_UPDATE": "COMMON_ADMIN",
"APP_PARTIAL_ORDER_REJECTION_CONFIG_UPDATE": "COMMON_ADMIN",
"APP_COLLATERAL_REJECTION_CONFIG_UPDATE": "COMMON_ADMIN",
"APP_UPDT_FULFILL_FORCE_SCAN_CONFIG": "COMMON_ADMIN",
Expand Down
2 changes: 1 addition & 1 deletion src/components/GenerateTrackingCodeModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
</ion-content>

<ion-fab vertical="bottom" horizontal="end" slot="fixed">
<ion-fab-button :disabled="isTrackingRequired ? !shipmentMethodTypeId: ''" @click="confirmSave()">
<ion-fab-button :disabled="isTrackingRequired ? !shipmentMethodTypeId: false" @click="confirmSave()">
<ion-icon :icon="isForceScanEnabled ? barcodeOutline : saveOutline" />
</ion-fab-button>
</ion-fab>
Expand Down
9 changes: 9 additions & 0 deletions src/services/UserService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,14 @@ const isEnumExists = async (enumId: string): Promise<any> => {
}
}

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

const createPartialOrderRejectionConfig = async (payload: any): Promise<any> => {
return api({
url: "service/createProductStoreSetting",
Expand Down Expand Up @@ -387,6 +395,7 @@ export const UserService = {
getFieldMappings,
getFacilityGroupDetails,
getFacilityGroupAndMemberDetails,
getNewRejectionApiConfig,
getPartialOrderRejectionConfig,
getUserProfile,
getPreferredStore,
Expand Down
1 change: 1 addition & 0 deletions src/store/modules/user/UserState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default interface UserState {
firebaseDeviceId: string;
hasUnreadNotifications: boolean;
allNotificationPrefs: any;
newRejectionApiConfig: any;
partialOrderRejectionConfig: any;
collateralRejectionConfig: any;
}
30 changes: 28 additions & 2 deletions src/store/modules/user/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,9 @@ const actions: ActionTree<UserState, RootState> = {
await dispatch("fetchAllNotificationPrefs");
this.dispatch('util/findProductStoreShipmentMethCount')
this.dispatch('util/getForceScanSetting', preferredStore.productStoreId);
await dispatch('user/getPartialOrderRejectionConfig')
await dispatch('user/getCollateralRejectionConfig')
await dispatch('getNewRejectionApiConfig')
await dispatch('getPartialOrderRejectionConfig')
await dispatch('getCollateralRejectionConfig')

} catch (err: any) {
// If any of the API call in try block has status code other than 2xx it will be handled in common catch block.
Expand Down Expand Up @@ -412,6 +413,31 @@ const actions: ActionTree<UserState, RootState> = {
commit(types.USER_PWA_STATE_UPDATED, payload);
},

async getNewRejectionApiConfig ({ commit }) {
let config = {};
const params = {
"inputFields": {
"productStoreId": this.state.user.currentEComStore.productStoreId,
"settingTypeEnumId": "FF_USE_NEW_REJ_API"
},
"filterByDate": 'Y',
"entityName": "ProductStoreSetting",
"fieldList": ["productStoreId", "settingTypeEnumId", "settingValue", "fromDate"],
"viewSize": 1
} as any

try {
const resp = await UserService.getNewRejectionApiConfig(params)
if (resp.status === 200 && !hasError(resp) && resp.data?.docs) {
config = resp.data?.docs[0];
} else {
logger.error('Failed to fetch new rejection API configuration');
}
} catch (err) {
logger.error(err);
}
commit(types.USER_NEW_REJECTION_API_CONFIG_UPDATED, config);
},
async updatePartialOrderRejectionConfig ({ dispatch }, payload) {
let resp = {} as any;
try {
Expand Down
3 changes: 3 additions & 0 deletions src/store/modules/user/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ const getters: GetterTree <UserState, RootState> = {
getAllNotificationPrefs(state) {
return state.allNotificationPrefs
},
getNewRejectionApiConfig(state) {
return state.newRejectionApiConfig;
},
getPartialOrderRejectionConfig(state) {
return state.partialOrderRejectionConfig;
},
Expand Down
1 change: 1 addition & 0 deletions src/store/modules/user/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const userModule: Module<UserState, RootState> = {
firebaseDeviceId: '',
hasUnreadNotifications: true,
allNotificationPrefs: [],
newRejectionApiConfig: {},
partialOrderRejectionConfig: {},
collateralRejectionConfig: {}
},
Expand Down
1 change: 1 addition & 0 deletions src/store/modules/user/mutation-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ export const USER_NOTIFICATIONS_PREFERENCES_UPDATED = SN_USER + '/NOTIFICATIONS_
export const USER_FIREBASE_DEVICEID_UPDATED = SN_USER + '/FIREBASE_DEVICEID_UPDATED'
export const USER_UNREAD_NOTIFICATIONS_STATUS_UPDATED = SN_USER + '/UNREAD_NOTIFICATIONS_STATUS_UPDATED'
export const USER_ALL_NOTIFICATION_PREFS_UPDATED = SN_USER + '/ALL_NOTIFICATION_PREFS_UPDATED'
export const USER_NEW_REJECTION_API_CONFIG_UPDATED = SN_USER + '/NEW_REJECTION_API_CONFIG_UPDATED'
export const USER_PARTIAL_ORDER_REJECTION_CONFIG_UPDATED = SN_USER + '/PARTIAL_ORDER_REJECTION_CONFIG_UPDATED'
export const USER_COLLATERAL_REJECTION_CONFIG_UPDATED = SN_USER + '/COLLATERAL_REJECTION_CONFIG_UPDATED'
3 changes: 3 additions & 0 deletions src/store/modules/user/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ const mutations: MutationTree <UserState> = {
[types.USER_ALL_NOTIFICATION_PREFS_UPDATED] (state, payload) {
state.allNotificationPrefs = payload
},
[types.USER_NEW_REJECTION_API_CONFIG_UPDATED] (state, payload) {
state.newRejectionApiConfig = payload
},
[types.USER_PARTIAL_ORDER_REJECTION_CONFIG_UPDATED] (state, payload) {
state.partialOrderRejectionConfig = payload
},
Expand Down
35 changes: 23 additions & 12 deletions src/views/InProgress.vue
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
<ion-icon :icon="closeCircleOutline" />
</ion-chip>
</template>
<template v-else-if="isEntierOrderRejectionEnabled(order)">
<template v-else-if="useNewRejectionApi() && isEntierOrderRejectionEnabled(order)">
<ion-chip outline color="danger">
<ion-label> {{ getRejectionReasonDescription(rejectEntireOrderReasonId) ? getRejectionReasonDescription(rejectEntireOrderReasonId) : translate('Reject entire order')}}</ion-label>
</ion-chip>
Expand Down Expand Up @@ -363,6 +363,7 @@ export default defineComponent({
boxTypeDesc: 'util/getShipmentBoxDesc',
getProductStock: 'stock/getProductStock',
isForceScanEnabled: 'util/isForceScanEnabled',
newRejectionApiConfig: 'user/getNewRejectionApiConfig',
partialOrderRejectionConfig: 'user/getPartialOrderRejectionConfig',
collateralRejectionConfig: 'user/getCollateralRejectionConfig'
}),
Expand Down Expand Up @@ -753,24 +754,31 @@ export default defineComponent({
items.map((item: any, index: number) => {
const shipmentPackage = order.shipmentPackages.find((shipmentPackage: any) => shipmentPackage.packageName === item.selectedBox)
let prefix = 'rtp'
if (updateParameter === 'report' && item.rejectReason) {
rejectedOrderItems.push({
"shipmentId": item.shipmentId,
"shipmentItemSeqId": item.shipmentItemSeqId,
"reason": item.rejectReason
})
//prefix = 'rej'
//form.append(`${prefix}_rejectionReason_${index}`, item.rejectReason)
if (this.useNewRejectionApi()) {
rejectedOrderItems.push({
"shipmentId": item.shipmentId,
"shipmentItemSeqId": item.shipmentItemSeqId,
"reason": item.rejectReason
})
} else {
prefix = 'rej'
form.append(`${prefix}_rejectionReason_${index}`, item.rejectReason)
form.append(`${prefix}_shipmentId_${index}`, item.shipmentId)
form.append(`${prefix}_shipmentItemSeqId_${index}`, item.shipmentItemSeqId)
form.append(`${index}_${prefix}_rowSubmit_`, ''+index)
}
} else {
const prefix = 'rtp'
prefix = 'rtp'
form.append(`${prefix}_newShipmentId_${index}`, shipmentPackage.shipmentId)
form.append(`${prefix}_shipmentId_${index}`, item.shipmentId)
form.append(`${prefix}_shipmentItemSeqId_${index}`, item.shipmentItemSeqId)
form.append(`${index}_${prefix}_rowSubmit_`, ''+index)
}
})
if (this.isEntierOrderRejectionEnabled(order)) {
if (this.useNewRejectionApi() && this.isEntierOrderRejectionEnabled(order)) {
const shipmentIds = rejectedOrderItems.map((item:any) => item.shipmentId);
items.map((item: any) => {
if (!shipmentIds.includes(item.shipmentId)) {
Expand Down Expand Up @@ -802,7 +810,7 @@ export default defineComponent({
}
//Run this logic only when entire order rejection is disabled. This logic will now be used only to update shipment boxes, not to reject items.
if (!this.isEntierOrderRejectionEnabled(order)) {
if (!this.useNewRejectionApi() || !this.isEntierOrderRejectionEnabled(order)) {
resp = await OrderService.updateOrder({
headers: {
'Content-Type': 'multipart/form-data;'
Expand Down Expand Up @@ -862,6 +870,9 @@ export default defineComponent({
isEntierOrderRejectionEnabled(order: any) {
return (!this.partialOrderRejectionConfig || !this.partialOrderRejectionConfig.settingValue || !JSON.parse(this.partialOrderRejectionConfig.settingValue)) && order.hasRejectedItem
},
useNewRejectionApi() {
return this.newRejectionApiConfig && this.newRejectionApiConfig.settingValue && JSON.parse(this.newRejectionApiConfig.settingValue)
},
updateBox(updatedBox: string, item: any, order: any) {
item.selectedBox = updatedBox;
order.items.map((orderItem: any) => {
Expand Down
34 changes: 23 additions & 11 deletions src/views/OrderDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
<ion-icon :icon="closeCircleOutline" />
</ion-chip>
</template>
<template v-else-if="isEntierOrderRejectionEnabled(order)">
<template v-else-if="useNewRejectionApi() && isEntierOrderRejectionEnabled(order)">
<ion-chip outline color="danger">
<ion-label> {{ getRejectionReasonDescription(rejectEntireOrderReasonId) ? getRejectionReasonDescription(rejectEntireOrderReasonId) : translate('Reject entire order')}}</ion-label>
</ion-chip>
Expand Down Expand Up @@ -481,6 +481,7 @@ export default defineComponent({
getPaymentMethodDesc: 'util/getPaymentMethodDesc',
getStatusDesc: 'util/getStatusDesc',
productStoreShipmentMethCount: 'util/getProductStoreShipmentMethCount',
newRejectionApiConfig: 'user/getNewRejectionApiConfig',
partialOrderRejectionConfig: 'user/getPartialOrderRejectionConfig',
collateralRejectionConfig: 'user/getCollateralRejectionConfig',
isForceScanEnabled: 'util/isForceScanEnabled',
Expand Down Expand Up @@ -630,6 +631,9 @@ export default defineComponent({
isEntierOrderRejectionEnabled(order: any) {
return (!this.partialOrderRejectionConfig || !this.partialOrderRejectionConfig.settingValue || !JSON.parse(this.partialOrderRejectionConfig.settingValue)) && order.hasRejectedItem
},
useNewRejectionApi() {
return this.newRejectionApiConfig && this.newRejectionApiConfig.settingValue && JSON.parse(this.newRejectionApiConfig.settingValue)
},
async printPicklist (order: any) {
await OrderService.printPicklist(order.picklistId)
},
Expand Down Expand Up @@ -1168,17 +1172,25 @@ export default defineComponent({
items.map((item: any, index: number) => {
const shipmentPackage = order.shipmentPackages.find((shipmentPackage: any) => shipmentPackage.packageName === item.selectedBox)
let prefix = 'rtp'
// reject the item only when item is having a rejection reason
if(updateParameter === 'report' && item.rejectReason) {
rejectedOrderItems.push({
"shipmentId": item.shipmentId,
"shipmentItemSeqId": item.shipmentItemSeqId,
"reason": item.rejectReason
})
//prefix = 'rej'
//form.append(`${prefix}_rejectionReason_${index}`, item.rejectReason)
if (this.useNewRejectionApi()) {
rejectedOrderItems.push({
"shipmentId": item.shipmentId,
"shipmentItemSeqId": item.shipmentItemSeqId,
"reason": item.rejectReason
})
} else {
prefix = 'rej'
form.append(`${prefix}_rejectionReason_${index}`, item.rejectReason)
form.append(`${prefix}_shipmentId_${index}`, item.shipmentId)
form.append(`${prefix}_shipmentItemSeqId_${index}`, item.shipmentItemSeqId)
form.append(`${index}_${prefix}_rowSubmit_`, ''+index)
}
} else {
const prefix = 'rtp'
prefix = 'rtp'
form.append(`${prefix}_newShipmentId_${index}`, shipmentPackage.shipmentId)
form.append(`${prefix}_shipmentId_${index}`, item.shipmentId)
form.append(`${prefix}_shipmentItemSeqId_${index}`, item.shipmentItemSeqId)
Expand All @@ -1204,7 +1216,7 @@ export default defineComponent({
}
//Run this logic only when entire order rejection is disabled. This logic will now be used only to update shipment boxes, not to reject items.
if (!this.isEntierOrderRejectionEnabled(order)) {
if (!this.useNewRejectionApi() || !this.isEntierOrderRejectionEnabled(order)) {
resp = await OrderService.updateOrder({
headers: {
'Content-Type': 'multipart/form-data;'
Expand Down Expand Up @@ -1285,7 +1297,7 @@ export default defineComponent({
await this.updateOrder(order, 'report').then(async () => {
// redirect user to inProgress list page only when the order has a single item, and the user initiated report action on the same
// update the current order only when order contains multiple items in it.
if(order.items.length === 1 || this.isEntierOrderRejectionEnabled(order)) {
if(order.items.length === 1 || (this.useNewRejectionApi() && this.isEntierOrderRejectionEnabled(order))) {
this.router.push('/in-progress')
} else {
await this.store.dispatch('order/getInProgressOrder', { orderId: this.orderId, shipGroupSeqId: this.shipGroupSeqId, isModified: true })
Expand Down
7 changes: 7 additions & 0 deletions src/views/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@
</ion-item>
</ion-card>

<template v-if="useNewRejectionApi()">
<ion-card>
<ion-card-header>
<ion-card-title>
Expand All @@ -197,6 +198,7 @@
<ion-toggle label-placement="start" :checked="'true' === collateralRejectionConfig.settingValue" @click.prevent="confirmCollateralRejection(collateralRejectionConfig, $event)">{{ translate("Auto reject related items") }}</ion-toggle>
</ion-item>
</ion-card>
</template>
</section>
</ion-content>
</ion-page>
Expand Down Expand Up @@ -299,6 +301,7 @@ export default defineComponent({
allNotificationPrefs: 'user/getAllNotificationPrefs',
firebaseDeviceId: 'user/getFirebaseDeviceId',
isForceScanEnabled: 'util/isForceScanEnabled',
newRejectionApiConfig: 'user/getNewRejectionApiConfig',
partialOrderRejectionConfig: 'user/getPartialOrderRejectionConfig',
collateralRejectionConfig: 'user/getCollateralRejectionConfig',
})
Expand All @@ -309,12 +312,16 @@ export default defineComponent({
// fetching partial order rejection when entering setting page to have latest information
await this.store.dispatch('user/getPartialOrderRejectionConfig')
await this.store.dispatch('user/getCollateralRejectionConfig')
await this.store.dispatch('user/getNewRejectionApiConfig')
// as notification prefs can also be updated from the notification pref modal,
// latest state is fetched each time we open the settings page
await this.store.dispatch('user/fetchNotificationPreferences')
},
methods: {
useNewRejectionApi() {
return this.newRejectionApiConfig && this.newRejectionApiConfig.settingValue && JSON.parse(this.newRejectionApiConfig.settingValue)
},
async getCurrentFacilityDetails() {
let resp: any;
try {
Expand Down

0 comments on commit f21dd8b

Please sign in to comment.