Skip to content

Commit

Permalink
Merge pull request #894 from hotwax/#879
Browse files Browse the repository at this point in the history
Implemented: Added 'Affect QOH on Rejection' setting (#879).
  • Loading branch information
ravilodhi authored Jan 7, 2025
2 parents a3e18c7 + 18119ab commit 6013b8b
Show file tree
Hide file tree
Showing 15 changed files with 154 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/authorization/Actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default {
"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_AFFECT_QOH_CONFIG_UPDATE": "APP_AFFECT_QOH_CONFIG_UPDATE",
"APP_UPDT_FULFILL_FORCE_SCAN_CONFIG": "APP_UPDT_FULFILL_FORCE_SCAN_CONFIG",
"APP_ORGANIZATION_HEADER_VIEW": "APP_ORGANIZATION_HEADER_VIEW",
"APP_REJECTIONS_VIEW": "APP_REJECTIONS_VIEW",
Expand Down
1 change: 1 addition & 0 deletions src/authorization/Rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default {
"APP_NEW_REJECTION_API_CONFIG_UPDATE": "COMMON_ADMIN",
"APP_PARTIAL_ORDER_REJECTION_CONFIG_UPDATE": "COMMON_ADMIN",
"APP_COLLATERAL_REJECTION_CONFIG_UPDATE": "COMMON_ADMIN",
"APP_AFFECT_QOH_CONFIG_UPDATE": "COMMON_ADMIN",
"APP_UPDT_FULFILL_FORCE_SCAN_CONFIG": "COMMON_ADMIN",
"APP_ORGANIZATION_HEADER_VIEW": "SFA_ADMIN OR CARRIER_SETUP_VIEW OR FF_ORDER_LOOKUP_VIEW",
"APP_REJECTIONS_VIEW": "SFA_ADMIN",
Expand Down
3 changes: 3 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"Activate gift card": "Activate gift card",
"Activation code": "Activation code",
"Add": "Add",
"Adjust the QOH along with ATP on rejection.": "Adjust the QOH along with ATP on rejection.",
"Affect QOH": "Affect QOH",
"Affect QOH on rejection": "Affect QOH on rejection",
"All": "All",
"App": "App",
"Approved for fulfillment": "Approved for fulfillment",
Expand Down
3 changes: 3 additions & 0 deletions src/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"Activate gift card": "Activar gift card",
"Activation code": "Código de Activación",
"Add": "Agregar",
"Adjust the QOH along with ATP on rejection.": "Adjust the QOH along with ATP on rejection.",
"Affect QOH": "Affect QOH",
"Affect QOH on rejection": "Affect QOH on rejection",
"All": "Todo",
"App": "Aplicación",
"Are you sure you want to remove this rejection reason?": "¿Estás seguro de que quieres eliminar este motivo de rechazo?",
Expand Down
3 changes: 3 additions & 0 deletions src/locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"Activate gift card": "Activate gift card",
"Activation code": "Activation code",
"Add": "追加",
"Adjust the QOH along with ATP on rejection.": "Adjust the QOH along with ATP on rejection.",
"Affect QOH": "Affect QOH",
"Affect QOH on rejection": "Affect QOH on rejection",
"All": "すべて",
"App": "アプリ",
"Approved for fulfillment": "出荷承認済み",
Expand Down
24 changes: 24 additions & 0 deletions src/services/UserService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,16 +360,39 @@ const updateCollateralRejectionConfig = async (payload: any): Promise<any> => {
data: payload
});
}
const getAffectQohConfig = async (payload: any): Promise<any> => {
return api({
url: "performFind",
method: "get",
params: payload,
});
}
const createAffectQohConfig = async (payload: any): Promise<any> => {
return api({
url: "service/createProductStoreSetting",
method: "post",
data: payload
});
}
const updateAffectQohConfig = async (payload: any): Promise<any> => {
return api({
url: "service/updateProductStoreSetting",
method: "post",
data: payload
});
}


export const UserService = {
addFacilityToGroup,
createAffectQohConfig,
createCollateralRejectionConfig,
createEnumeration,
createFieldMapping,
createPartialOrderRejectionConfig,
deleteFieldMapping,
login,
getAffectQohConfig,
getCollateralRejectionConfig,
getDisableShipNowConfig,
getDisableUnpackConfig,
Expand All @@ -387,6 +410,7 @@ export const UserService = {
recycleOutstandingOrders,
setUserPreference,
getUserPermissions,
updateAffectQohConfig,
updateFacility,
updateFacilityToGroup,
updateFieldMapping,
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 @@ -23,6 +23,7 @@ export default interface UserState {
newRejectionApiConfig: any;
partialOrderRejectionConfig: any;
collateralRejectionConfig: any;
affectQohConfig: any;
isShipNowDisabled: boolean;
isUnpackDisabled: boolean;
}
57 changes: 57 additions & 0 deletions src/store/modules/user/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ const actions: ActionTree<UserState, RootState> = {
await dispatch('getNewRejectionApiConfig')
await dispatch('getPartialOrderRejectionConfig')
await dispatch('getCollateralRejectionConfig')
await dispatch('getAffectQohConfig')
await dispatch('getDisableShipNowConfig')
await dispatch('getDisableUnpackConfig')

Expand Down Expand Up @@ -625,6 +626,62 @@ const actions: ActionTree<UserState, RootState> = {
commit(types.USER_COLLATERAL_REJECTION_CONFIG_UPDATED, config);
},

async updateAffectQohConfig ({ dispatch }, payload) {
let resp = {} as any;
try {
if (!payload.fromDate) {
//Create Product Store Setting
payload = {
...payload,
"productStoreId": getProductStoreId(),
"settingTypeEnumId": "AFFECT_QOH_ON_REJ",
"fromDate": DateTime.now().toMillis()
}
resp = await UserService.createAffectQohConfig(payload) as any
} else {
//Update Product Store Setting
resp = await UserService.updateAffectQohConfig(payload) as any
}

if (!hasError(resp)) {
showToast(translate('Configuration updated'))
} else {
showToast(translate('Failed to update configuration'))
}
} catch(err) {
showToast(translate('Failed to update configuration'))
logger.error(err)
}

// Fetch the updated configuration
await dispatch("getAffectQohConfig");
},
async getAffectQohConfig ({ commit }) {
let config = {};
const params = {
"inputFields": {
"productStoreId": getProductStoreId(),
"settingTypeEnumId": "AFFECT_QOH_ON_REJ"
},
"filterByDate": 'Y',
"entityName": "ProductStoreSetting",
"fieldList": ["productStoreId", "settingTypeEnumId", "settingValue", "fromDate"],
"viewSize": 1
} as any

try {
const resp = await UserService.getAffectQohConfig(params)
if (resp.status === 200 && !hasError(resp) && resp.data?.docs) {
config = resp.data?.docs[0];
} else {
logger.error('Failed to fetch affect QOH configuration');
}
} catch (err) {
logger.error(err);
}
commit(types.USER_AFFECT_QOH_CONFIG_UPDATED, config);
},

addNotification({ state, commit }, payload) {
const notifications = JSON.parse(JSON.stringify(state.notifications))
notifications.push({ ...payload.notification, time: DateTime.now().toMillis() })
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 @@ -67,6 +67,9 @@ const getters: GetterTree <UserState, RootState> = {
getCollateralRejectionConfig(state) {
return state.collateralRejectionConfig;
},
getAffectQohConfig(state) {
return state.affectQohConfig;
},
isShipNowDisabled(state) {
return state.isShipNowDisabled;
},
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 @@ -35,6 +35,7 @@ const userModule: Module<UserState, RootState> = {
newRejectionApiConfig: {},
partialOrderRejectionConfig: {},
collateralRejectionConfig: {},
affectQohConfig: {},
isShipNowDisabled: false,
isUnpackDisabled: false
},
Expand Down
3 changes: 2 additions & 1 deletion src/store/modules/user/mutation-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ export const USER_NEW_REJECTION_API_CONFIG_UPDATED = SN_USER + '/NEW_REJECTION_
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'
export const USER_DISABLE_SHIP_NOW_CONFIG_UPDATED = SN_USER + '/DISABLE_SHIP_NOW_CONFIG_UPDATED'
export const USER_DISABLE_UNPACK_CONFIG_UPDATED = SN_USER + '/DISABLE_UNPACK_CONFIG_UPDATED'
export const USER_DISABLE_UNPACK_CONFIG_UPDATED = SN_USER + '/DISABLE_UNPACK_CONFIG_UPDATED'
export const USER_AFFECT_QOH_CONFIG_UPDATED = SN_USER + '/USER_AFFECT_QOH_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 @@ -64,6 +64,9 @@ const mutations: MutationTree <UserState> = {
[types.USER_COLLATERAL_REJECTION_CONFIG_UPDATED] (state, payload) {
state.collateralRejectionConfig = payload
},
[types.USER_AFFECT_QOH_CONFIG_UPDATED] (state, payload) {
state.affectQohConfig = payload
},
[types.USER_DISABLE_SHIP_NOW_CONFIG_UPDATED] (state, payload) {
state.isShipNowDisabled = payload
},
Expand Down
4 changes: 3 additions & 1 deletion src/views/InProgress.vue
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,8 @@ export default defineComponent({
isForceScanEnabled: 'util/isForceScanEnabled',
newRejectionApiConfig: 'user/getNewRejectionApiConfig',
partialOrderRejectionConfig: 'user/getPartialOrderRejectionConfig',
collateralRejectionConfig: 'user/getCollateralRejectionConfig'
collateralRejectionConfig: 'user/getCollateralRejectionConfig',
affectQohConfig: 'user/getAffectQohConfig'
}),
},
data() {
Expand Down Expand Up @@ -810,6 +811,7 @@ export default defineComponent({
facilityId : this.currentFacility?.facilityId,
rejectEntireShipment: this.isEntierOrderRejectionEnabled(order) ? "Y" : "N",
rejectAllRelatedShipment: this.collateralRejectionConfig?.settingValue === 'true' ? "Y" : "N",
affectQOH: this.affectQohConfig && this.affectQohConfig?.settingValue ? this.affectQohConfig?.settingValue : false,
defaultReason: this.rejectEntireOrderReasonId, //default reason for items for which reason is not selected but rejecting due to entire order rejection config.
items: rejectedOrderItems
}
Expand Down
2 changes: 2 additions & 0 deletions src/views/OrderDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ export default defineComponent({
newRejectionApiConfig: 'user/getNewRejectionApiConfig',
partialOrderRejectionConfig: 'user/getPartialOrderRejectionConfig',
collateralRejectionConfig: 'user/getCollateralRejectionConfig',
affectQohConfig: 'user/getAffectQohConfig',
isForceScanEnabled: 'util/isForceScanEnabled',
productStoreShipmentMethods: 'carrier/getProductStoreShipmentMethods',
facilityCarriers: 'carrier/getFacilityCarriers',
Expand Down Expand Up @@ -1274,6 +1275,7 @@ export default defineComponent({
facilityId : this.currentFacility?.facilityId,
rejectEntireShipment: this.isEntierOrderRejectionEnabled(order) ? "Y" : "N",
rejectAllRelatedShipment: this.collateralRejectionConfig?.settingValue === 'true' ? "Y" : "N",
affectQOH: this.affectQohConfig && this.affectQohConfig?.settingValue ? this.affectQohConfig?.settingValue : false,
defaultReason: this.rejectEntireOrderReasonId, //default reason for items for which reason is not selected but rejecting due to entire order rejection config.
items: rejectedOrderItems
}
Expand Down
47 changes: 47 additions & 0 deletions src/views/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,19 @@
<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>
<ion-card>
<ion-card-header>
<ion-card-title>
{{ translate("Affect QOH on rejection") }}
</ion-card-title>
</ion-card-header>
<ion-card-content>
{{ translate('Adjust the QOH along with ATP on rejection.') }}
</ion-card-content>
<ion-item lines="none" :disabled="!hasPermission(Actions.APP_AFFECT_QOH_CONFIG_UPDATE)">
<ion-toggle label-placement="start" :checked="'true' === affectQohConfig.settingValue" @click.prevent="confirmAffectQohConfig(affectQohConfig, $event)">{{ translate("Affect QOH") }}</ion-toggle>
</ion-item>
</ion-card>
</template>
</section>
</ion-content>
Expand Down Expand Up @@ -273,6 +286,7 @@ export default defineComponent({
newRejectionApiConfig: 'user/getNewRejectionApiConfig',
partialOrderRejectionConfig: 'user/getPartialOrderRejectionConfig',
collateralRejectionConfig: 'user/getCollateralRejectionConfig',
affectQohConfig: 'user/getAffectQohConfig',
barcodeIdentificationPref: 'util/getBarcodeIdentificationPref'
})
},
Expand Down Expand Up @@ -677,6 +691,39 @@ export default defineComponent({
}
await this.store.dispatch('user/updateCollateralRejectionConfig', params)
},
async confirmAffectQohConfig(config: any, event: any) {
event.stopImmediatePropagation();
const isChecked = !event.target.checked;
const message = translate("Are you sure you want to perform this action?");
const header = isChecked ? translate('Affect QOH on rejection') : translate('Do not affect QOH on rejection')
const alert = await alertController.create({
header,
message,
buttons: [
{
text: translate("Cancel"),
role: "cancel"
},
{
text: translate("Confirm"),
handler: async () => {
alertController.dismiss()
await this.updateAffectQohConfig(config, !event.target.checked)
}
}
],
});
return alert.present();
},
async updateAffectQohConfig(config: any, value: any) {
const params = {
...config,
"settingValue": value
}
await this.store.dispatch('user/updateAffectQohConfig', params)
},
setBarcodeIdentificationPref(value: string) {
this.store.dispatch('util/setBarcodeIdentificationPref', value)
},
Expand Down

0 comments on commit 6013b8b

Please sign in to comment.