diff --git a/src/authorization/Actions.ts b/src/authorization/Actions.ts index b16619ff8..2fded09ff 100644 --- a/src/authorization/Actions.ts +++ b/src/authorization/Actions.ts @@ -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', } \ No newline at end of file diff --git a/src/authorization/Rules.ts b/src/authorization/Rules.ts index 6d5f374f8..4518da7e2 100644 --- a/src/authorization/Rules.ts +++ b/src/authorization/Rules.ts @@ -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 \ No newline at end of file diff --git a/src/locales/en.json b/src/locales/en.json index 84b38c667..e0adbfd23 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -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?", @@ -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 }", @@ -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", diff --git a/src/locales/es.json b/src/locales/es.json index ead13bdf2..ca63ff360 100644 --- a/src/locales/es.json +++ b/src/locales/es.json @@ -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?", @@ -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 }", @@ -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", diff --git a/src/locales/ja.json b/src/locales/ja.json index ba7469349..fa909b0bf 100644 --- a/src/locales/ja.json +++ b/src/locales/ja.json @@ -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?": "タイムゾーンを変更してもよろしいですか?", @@ -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 }", @@ -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": "スタッフ", diff --git a/src/services/UserService.ts b/src/services/UserService.ts index eda9d5bf2..68a14e068 100644 --- a/src/services/UserService.ts +++ b/src/services/UserService.ts @@ -131,7 +131,29 @@ const updateRerouteFulfillmentConfig = async (payload: any): Promise => { }); } +const getPartialOrderRejectionConfig = async (payload: any): Promise => { + return api({ + url: "performFind", + method: "get", + params: payload, + }); +} + +const createPartialOrderRejectionConfig = async (payload: any): Promise => { + return api({ + url: "service/createProductStoreSetting", + method: "post", + data: payload + }); +} +const updatePartialOrderRejectionConfig = async (payload: any): Promise => { + return api({ + url: "service/updateProductStoreSetting", + method: "post", + data: payload + }); +} const getUserPermissions = async (payload: any, token: any): Promise => { const baseURL = store.getters['user/getBaseUrl']; @@ -232,5 +254,8 @@ export const UserService = { setUserPreference, getUserPermissions, getUserProfile, - updateRerouteFulfillmentConfig + updateRerouteFulfillmentConfig, + getPartialOrderRejectionConfig, + createPartialOrderRejectionConfig, + updatePartialOrderRejectionConfig } \ No newline at end of file diff --git a/src/store/modules/user/UserState.ts b/src/store/modules/user/UserState.ts index 43b7d14e5..f3057d856 100644 --- a/src/store/modules/user/UserState.ts +++ b/src/store/modules/user/UserState.ts @@ -7,6 +7,7 @@ export default interface UserState { locale: string; permissions: any; currentEComStore: any; + partialOrderRejectionConfig: any notifications: any; notificationPrefs: any; firebaseDeviceId: string; diff --git a/src/store/modules/user/actions.ts b/src/store/modules/user/actions.ts index f2cc3e103..b8b5fd758 100644 --- a/src/store/modules/user/actions.ts +++ b/src/store/modules/user/actions.ts @@ -93,6 +93,10 @@ const actions: ActionTree = { 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. @@ -110,6 +114,7 @@ const actions: ActionTree = { // TODO add any other tasks if need dispatch("product/clearProducts", null, { root: true }) dispatch('clearNotificationState') + dispatch('clearPartialOrderRejectionConfig'); commit(types.USER_END_SESSION) resetPermissions(); resetConfig(); @@ -155,6 +160,64 @@ const actions: ActionTree = { } }, + 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({ @@ -224,6 +287,10 @@ const actions: ActionTree = { setUnreadNotificationsStatus({ commit }, payload) { commit(types.USER_UNREAD_NOTIFICATIONS_STATUS_UPDATED, payload) + }, + + clearPartialOrderRejectionConfig ({ commit }) { + commit(types.USER_PARTIAL_ORDER_REJECTION_CONFIG_UPDATED, {}) } } export default actions; \ No newline at end of file diff --git a/src/store/modules/user/getters.ts b/src/store/modules/user/getters.ts index dea7e427a..ab2daeffd 100644 --- a/src/store/modules/user/getters.ts +++ b/src/store/modules/user/getters.ts @@ -48,6 +48,9 @@ const getters: GetterTree = { getCurrentEComStore(state) { return state.currentEComStore; }, + getPartialOrderRejectionConfig(state) { + return state.partialOrderRejectionConfig; + }, getNotifications(state) { return state.notifications.sort((a: any, b: any) => b.time - a.time) }, diff --git a/src/store/modules/user/index.ts b/src/store/modules/user/index.ts index 356046050..f1816bf33 100644 --- a/src/store/modules/user/index.ts +++ b/src/store/modules/user/index.ts @@ -19,6 +19,7 @@ const userModule: Module = { }, locale: 'en', currentEComStore: {}, + partialOrderRejectionConfig: {}, permissions: [], notifications: [], notificationPrefs: [], diff --git a/src/store/modules/user/mutation-types.ts b/src/store/modules/user/mutation-types.ts index fa0cbb16f..21b928207 100644 --- a/src/store/modules/user/mutation-types.ts +++ b/src/store/modules/user/mutation-types.ts @@ -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' diff --git a/src/store/modules/user/mutations.ts b/src/store/modules/user/mutations.ts index 7ef5de562..371a2d620 100644 --- a/src/store/modules/user/mutations.ts +++ b/src/store/modules/user/mutations.ts @@ -33,6 +33,9 @@ const mutations: MutationTree = { [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 }, @@ -45,5 +48,6 @@ const mutations: MutationTree = { [types.USER_UNREAD_NOTIFICATIONS_STATUS_UPDATED] (state, payload) { state.hasUnreadNotifications = payload } + } export default mutations; \ No newline at end of file diff --git a/src/views/Settings.vue b/src/views/Settings.vue index 09edd7a0c..6f742d11f 100644 --- a/src/views/Settings.vue +++ b/src/views/Settings.vue @@ -89,6 +89,21 @@ + + + + + {{ $t("Partial Order rejection") }} + + + + {{ $t('Specify whether you reject a BOPIS order partially when any order item inventory is insufficient at the store.') }} + + + {{ $t("Allow partial rejection") }} + + + @@ -294,6 +309,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' @@ -442,6 +458,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