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

Implemented: Setting for the Partial Order Rejection of BOPIS Orders #288

Merged
merged 5 commits into from
Oct 10, 2023
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/authorization/Actions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export default {
'APP_ORDER_UPDATE': 'APP_ORDER_UPDATE',
'APP_RF_CONFIG_UPDATE': 'APP_RF_CONFIG_UPDATE',
'APP_PARTIAL_ORDER_REJECTION_CONFIG_UPDATE': 'APP_PARTIAL_ORDER_REJECTION_CONFIG_UPDATE',
}
1 change: 1 addition & 0 deletions src/authorization/Rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ export default {
"APP_PRODUCT_DETAIL_VIEW": "",
"APP_ORDER_UPDATE": "COMMON_ADMIN",
"APP_RF_CONFIG_UPDATE": "COMMON_ADMIN",
"APP_PARTIAL_ORDER_REJECTION_CONFIG_UPDATE": "COMMON_ADMIN",
"APP_STOREFULFILLMENT_ADMIN": "STOREFULFILLMENT_ADMIN"
} as any
3 changes: 3 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"App": "App",
"All items were canceled from the order": "All items were canceled from the order",
"Allow partial rejection": "Allow partial rejection",
"An email notification will be sent to that their order is ready for pickup. This order will also be moved to the packed orders tab.": "An email notification will be sent to { customerName } that their order is ready for pickup.{ space } This order will also be moved to the packed orders tab.",
"An email notification will be sent to that their order is ready for pickup.": "An email notification will be sent to { customerName } that their order is ready for pickup.",
"Are you sure you want to change the time zone to?": "Are you sure you want to change the time zone to?",
Expand Down Expand Up @@ -92,6 +93,7 @@
"Packed": "Packed",
"Packing Slip": "Packing Slip",
"Packing slips help customer reconcile their order against the delivered items.": "Packing slips help customer reconcile their order against the delivered items.",
"Partial Order rejection": "Partial Order rejection",
"Password": "Password",
"pending approval": "pending approval",
"Picked by": "Picked by { pickers }",
Expand Down Expand Up @@ -132,6 +134,7 @@
"Something went wrong while sending the email.": "Something went wrong while sending the email.",
"Something went wrong while login. Please contact administrator": "Something went wrong while login. Please contact administrator.",
"Sorry, your username or password is incorrect. Please try again.": "Sorry, your username or password is incorrect. Please try again.",
"Specify whether you reject a BOPIS order partially when any order item inventory is insufficient at the store.": "Specify whether you reject a BOPIS order partially when any order item inventory is insufficient at the store.",
"Specify which facility you want to operate from. Order, inventory and other configuration data will be specific to the facility you select.": "Specify which facility you want to operate from. Order, inventory and other configuration data will be specific to the facility you select.",
"State": "State",
"Staff": "Staff",
Expand Down
3 changes: 3 additions & 0 deletions src/locales/es.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"App": "Aplicación",
"All items were canceled from the order": "Todos los artículos se cancelaron del pedido",
"Allow partial rejection": "Allow partial rejection",
"An email notification will be sent to that their order is ready for pickup. This order will also be moved to the packed orders tab.": "Se enviará una notificación por correo electrónico a {customerName} de que su pedido está listo para recoger.{ space } Este pedido también se moverá a la pestaña de pedidos empacados.",
"An email notification will be sent to that their order is ready for pickup.": "Se enviará una notificación por correo electrónico a {customerName} de que su pedido está listo para recoger.",
"Are you sure you want to change the time zone to?": "¿Estás seguro de que quieres cambiar la zona horaria a?",
Expand Down Expand Up @@ -91,6 +92,7 @@
"Packed": "Empacado",
"Packing Slip": "Remisión de embalaje",
"Packing slips help customer reconcile their order against the delivered items.": "Las remisiones de embalaje ayudan al cliente a conciliar su orden con los artículos entregados.",
"Partial Order rejection": "Partial Order rejection",
"Password": "Contraseña",
"pending approval": "pendiente de aprobación",
"Picked by": "Picked by { pickers }",
Expand Down Expand Up @@ -131,6 +133,7 @@
"Something went wrong while sending the email.": "Algo salió mal al enviar el correo electrónico.",
"Something went wrong while login. Please contact administrator": "Algo salió mal al iniciar sesión. Por favor, contacta al administrador.",
"Sorry, your username or password is incorrect. Please try again.": "Lo siento, tu nombre de usuario o contraseña es incorrecto. Por favor, inténtalo de nuevo.",
"Specify whether you reject a BOPIS order partially when any order item inventory is insufficient at the store.": "Specify whether you reject a BOPIS order partially when any order item inventory is insufficient at the store.",
"Specify which facility you want to operate from. Order, inventory, and other configuration data will be specific to the facility you select.": "Especifique desde qué instalación desea operar. El pedido, el inventario y otros datos de configuración serán específicos de la instalación que seleccione.",
"State": "Estado",
"Staff": "Personal",
Expand Down
3 changes: 3 additions & 0 deletions src/locales/ja.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"App": "App",
"All items were canceled from the order": "全ての商品が注文からキャンセルされました",
"Allow partial rejection": "Allow partial rejection",
"An email notification will be sent to that their order is ready for pickup. This order will also be moved to the packed orders tab.": "{ customerName }様宛に注文の受け取り準備が完了したことをお知らするメールが送信されます。{ space } この注文は「梱包済み注文」タブに移動されます.",
"An email notification will be sent to that their order is ready for pickup.": "{ customerName }様宛に注文の受け取り準備が完了したことをお知らするメールが送信されます。",
"Are you sure you want to change the time zone to?": "タイムゾーンを変更してもよろしいですか?",
Expand Down Expand Up @@ -91,6 +92,7 @@
"Packed": "梱包済み",
"Packing slip": "納品書",
"Packing slips help customer reconcile their order against the delivered items.": "内容明細票はお客様が注文と配送された商品を確認(照合)する際に役立ちます。",
"Partial Order rejection": "Partial Order rejection",
"Password": "パスワード",
"pending approval": "承認待ち",
"Picked by": "Picked by { pickers }",
Expand Down Expand Up @@ -131,6 +133,7 @@
"Something went wrong while sending the email.": "メールの送信中に何か問題が発生しました",
"Something went wrong while login. Please contact administrator": "ログイン中に何らかの問題が発生しました。管理者に確認してください。",
"Sorry, your username or password is incorrect. Please try again.": "ユーザー名またはパスワードが正しくありません。もう一度お試しください。",
"Specify whether you reject a BOPIS order partially when any order item inventory is insufficient at the store.": "Specify whether you reject a BOPIS order partially when any order item inventory is insufficient at the store.",
"Specify which facility you want to operate from. Order, inventory and other configuration data will be specific to the facility you select.": "どの拠点からオペレーションを行うかを指定します。注文、在庫、その他の設定データは、選択した拠点に固有のものとなります。",
"State": "都道府県",
"Staff": "スタッフ",
Expand Down
27 changes: 26 additions & 1 deletion src/services/UserService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,29 @@ const updateRerouteFulfillmentConfig = async (payload: any): Promise<any> => {
});
}

const getPartialOrderRejectionConfig = 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",
method: "post",
data: payload
});
}

const updatePartialOrderRejectionConfig = async (payload: any): Promise<any> => {
return api({
url: "service/updateProductStoreSetting",
method: "post",
data: payload
});
}

const getUserPermissions = async (payload: any, token: any): Promise<any> => {
const baseURL = store.getters['user/getBaseUrl'];
Expand Down Expand Up @@ -232,5 +254,8 @@ export const UserService = {
setUserPreference,
getUserPermissions,
getUserProfile,
updateRerouteFulfillmentConfig
updateRerouteFulfillmentConfig,
getPartialOrderRejectionConfig,
createPartialOrderRejectionConfig,
updatePartialOrderRejectionConfig
}
1 change: 1 addition & 0 deletions src/store/modules/user/UserState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export default interface UserState {
locale: string;
permissions: any;
currentEComStore: any;
partialOrderRejectionConfig: any
notifications: any;
notificationPrefs: any;
firebaseDeviceId: string;
Expand Down
67 changes: 67 additions & 0 deletions src/store/modules/user/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ const actions: ActionTree<UserState, RootState> = {
commit(types.USER_PREFERENCE_UPDATED, userPreference)
commit(types.USER_PERMISSIONS_UPDATED, appPermissions);
commit(types.USER_TOKEN_CHANGED, { newToken: token })

//fetching partial order rejection config for BOPIS orders
await dispatch("getPartialOrderRejectionConfig");

} 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.
// TODO Check if handling of specific status codes is required.
Expand All @@ -110,6 +114,7 @@ const actions: ActionTree<UserState, RootState> = {
// TODO add any other tasks if need
dispatch("product/clearProducts", null, { root: true })
dispatch('clearNotificationState')
dispatch('clearPartialOrderRejectionConfig');
commit(types.USER_END_SESSION)
resetPermissions();
resetConfig();
Expand Down Expand Up @@ -155,6 +160,64 @@ const actions: ActionTree<UserState, RootState> = {
}
},

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

try {
const resp = await UserService.getPartialOrderRejectionConfig(params)
if (resp.status === 200 && !hasError(resp) && resp.data?.docs) {
config = resp.data?.docs[0];
} else {
console.error('Failed to fetch partial order rejection configuration');
}
} catch (err) {
console.error(err);
}
commit(types.USER_PARTIAL_ORDER_REJECTION_CONFIG_UPDATED, config);
},

async updatePartialOrderRejectionConfig ({ dispatch }, payload) {
let resp = {};
try {

if (!payload.fromDate) {
//Create Product Store Setting
payload = {
...payload,
"productStoreId": this.state.user.currentEComStore.productStoreId,
"settingTypeEnumId": "BOPIS_PART_ODR_REJ",
"fromDate": DateTime.now().toMillis()
}
resp = await UserService.createPartialOrderRejectionConfig(payload) as any
} else {
//Update Product Store Setting
resp = await UserService.updatePartialOrderRejectionConfig(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'))
console.error(err)
}

// Fetch the updated configuration
await dispatch("getPartialOrderRejectionConfig");
},

setUserPreference( {state, commit }, payload){
commit(types.USER_PREFERENCE_UPDATED, payload)
UserService.setUserPreference({
Expand Down Expand Up @@ -224,6 +287,10 @@ const actions: ActionTree<UserState, RootState> = {

setUnreadNotificationsStatus({ commit }, payload) {
commit(types.USER_UNREAD_NOTIFICATIONS_STATUS_UPDATED, payload)
},

clearPartialOrderRejectionConfig ({ commit }) {
commit(types.USER_PARTIAL_ORDER_REJECTION_CONFIG_UPDATED, {})
}
}
export default actions;
3 changes: 3 additions & 0 deletions src/store/modules/user/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ const getters: GetterTree <UserState, RootState> = {
getCurrentEComStore(state) {
return state.currentEComStore;
},
getPartialOrderRejectionConfig(state) {
return state.partialOrderRejectionConfig;
},
getNotifications(state) {
return state.notifications.sort((a: any, b: any) => b.time - a.time)
},
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 @@ -19,6 +19,7 @@ const userModule: Module<UserState, RootState> = {
},
locale: 'en',
currentEComStore: {},
partialOrderRejectionConfig: {},
permissions: [],
notifications: [],
notificationPrefs: [],
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 @@ -8,6 +8,7 @@ export const USER_PREFERENCE_UPDATED = SN_USER + '/PREFERENCE_UPDATED'
export const USER_LOCALE_UPDATED = SN_USER + '/LOCALE_UPDATED'
export const USER_CURRENT_ECOM_STORE_UPDATED = SN_USER + '/CURRENT_ECOM_STORE_UPDATED'
export const USER_PERMISSIONS_UPDATED = SN_USER + '/PERMISSIONS_UPDATED'
export const USER_PARTIAL_ORDER_REJECTION_CONFIG_UPDATED = SN_USER + '/PARTIAL_ORDER_REJECTION_CONFIG_UPDATED'
export const USER_NOTIFICATIONS_UPDATED = SN_USER + '/NOTIFICATIONS_UPDATED'
export const USER_NOTIFICATIONS_PREFERENCES_UPDATED = SN_USER + '/NOTIFICATIONS_PREFERENCES_UPDATED'
export const USER_FIREBASE_DEVICEID_UPDATED = SN_USER + '/FIREBASE_DEVICEID_UPDATED'
Expand Down
4 changes: 4 additions & 0 deletions src/store/modules/user/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ const mutations: MutationTree <UserState> = {
[types.USER_PERMISSIONS_UPDATED] (state, payload) {
state.permissions = payload
},
[types.USER_PARTIAL_ORDER_REJECTION_CONFIG_UPDATED] (state, payload) {
state.partialOrderRejectionConfig = payload
},
[types.USER_NOTIFICATIONS_UPDATED] (state, payload) {
state.notifications = payload
},
Expand All @@ -45,5 +48,6 @@ const mutations: MutationTree <UserState> = {
[types.USER_UNREAD_NOTIFICATIONS_STATUS_UPDATED] (state, payload) {
state.hasUnreadNotifications = payload
}

}
export default mutations;
23 changes: 23 additions & 0 deletions src/views/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,21 @@
</ion-select>
</ion-item>
</ion-card>

<ion-card>
<ion-card-header>
<ion-card-title>
{{ $t("Partial Order rejection") }}
</ion-card-title>
</ion-card-header>
<ion-card-content>
{{ $t('Specify whether you reject a BOPIS order partially when any order item inventory is insufficient at the store.') }}
</ion-card-content>
<ion-item lines="none">
<ion-label>{{ $t("Allow partial rejection") }}</ion-label>
<ion-toggle :disabled="!hasPermission(Actions.APP_PARTIAL_ORDER_REJECTION_CONFIG_UPDATE)" :checked="partialOrderRejectionConfig.settingValue" @ionChange="updatePartialOrderRejectionConfig(partialOrderRejectionConfig, $event.detail.checked)" slot="end" />
</ion-item>
</ion-card>

</section>

Expand Down Expand Up @@ -311,6 +326,7 @@ export default defineComponent({
configurePicker: "user/configurePicker",
showShippingOrders: 'user/showShippingOrders',
showPackingSlip: 'user/showPackingSlip',
partialOrderRejectionConfig: 'user/getPartialOrderRejectionConfig',
locale: 'user/getLocale',
firebaseDeviceId: 'user/getFirebaseDeviceId',
notificationPrefs: 'user/getNotificationPrefs'
Expand Down Expand Up @@ -462,6 +478,13 @@ export default defineComponent({
// Fetch the updated configuration
await this.getRerouteFulfillmentConfiguration(config.settingTypeEnumId);
},
async updatePartialOrderRejectionConfig(config: any, value: any) {
const params = {
...config,
"settingValue": value
}
await this.store.dispatch('user/updatePartialOrderRejectionConfig', params)
},
async updateNotificationPref(enumId: string, event: any) {
try {
const ofbizInstanceName = this.userProfile.ofbizInstanceName
Expand Down
Loading