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: support for fetching the rules for orderRouting, creating a new rule and make the actions dynamic(#24) #25

Merged
merged 17 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
5b0b431
Implemented: support for fetching the rules for orderRouting(#24)
ymaheshwari1 Jan 17, 2024
bb2e984
Implemented: support to define state for storing order filters(#24)
ymaheshwari1 Jan 17, 2024
ecb32c3
Implemented: service for fetching routeFilters, defined type for rout…
ymaheshwari1 Jan 17, 2024
c9a78c3
Implemented: support to select filters from available inventory filte…
ymaheshwari1 Jan 17, 2024
401a42d
Merge branch 'main' into #24
ymaheshwari1 Jan 17, 2024
12f73bf
Implemented: services for fetching rule conditions and actions(#24)
ymaheshwari1 Jan 17, 2024
6750d88
Implemented: actions in store for rule actions and conditions(#24)
ymaheshwari1 Jan 17, 2024
7865bd7
Implemented: support for actions configurable on the rules page(#24)
ymaheshwari1 Jan 18, 2024
9634720
Implemented: support to update auto cancel days(#24)
ymaheshwari1 Jan 18, 2024
82e848c
Fixed: autoCancelDays not updating locally after update(#24)
ymaheshwari1 Jan 18, 2024
292e07a
Improved: support to update the rule actions(#24)
ymaheshwari1 Jan 18, 2024
56d213d
Implemented: support to display the options for queue dynamically(#24)
ymaheshwari1 Jan 18, 2024
2cefb9d
Implemented: support to fetch sales channel options from enums and im…
ymaheshwari1 Jan 18, 2024
ad7b0ac
Implemented: support for changing the currently selected routeRule(#24)
ymaheshwari1 Jan 18, 2024
9184c0e
Implemented: support to create a new rule(#24)
ymaheshwari1 Jan 18, 2024
bd49c67
Implemented: support to update partial allocation value for rule(#24)
ymaheshwari1 Jan 18, 2024
f248fe9
Improved: env example(#24)
ymaheshwari1 Jan 18, 2024
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
6 changes: 5 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@ VUE_APP_I18N_FALLBACK_LOCALE=en
VUE_APP_CACHE_MAX_AGE=3600
VUE_APP_VIEW_SIZE=10
VUE_APP_PERMISSION_ID=
VUE_APP_DEFAULT_LOG_LEVEL="error"
VUE_APP_DEFAULT_LOG_LEVEL="error"
VUE_APP_RULE_ENUMS={"FILTER":"ENTCT_FILTER","SORT":"ENTCT_SORT_BY","QUEUE":{"id":"OIP_QUEUE","code":"facilityId"},"SHIPPING_METHOD":{"id":"OIP_SHIP_METH_TYPE","code":"shipmentMethodTypeId"},"PRIORITY":{"id":"OIP_PRIORITY","code":"priority"},"PROMISE_DATE":{"id":"OIP_PROMISE_DATE","code":"promiseDaysCutoff"},"SALES_CHANNEL":{"id":"OIP_SALES_CHANNEL","code":"salesChannelEnumId"},"SHIP_BY":{"id":"OSP_SHIP_BY","code":"shipBeforeDate"},"SHIP_AFTER":{"id":"OSP_SHIP_AFTER","code":"shipAfterDate"},"ORDER_DATE":{"id":"OSP_ORDER_DATE","code":"orderDate"},"SHIPPING_METHOD_SORT":{"id":"OSP_SHIP_METH","code":"deliveryDays"}}
VUE_APP_RULE_FILTER_ENUMS={"FACILITY_GROUP":{"id":"IIP_FACILITY_GROUP","code":"facilityGroupId"},"PROXIMITY":{"id":"IIP_PROXIMITY","code":"distance"},"BRK_SAFETY_STOCK":{"id":"IIP_BRK_SFTY_STOCK","code":"brokeringSafetyStock"},"MEASUREMENT_SYSTEM":{"id":"IIP_MSMNT_SYSTEM","code":"measurementSystem"}}
VUE_APP_RULE_SORT_ENUMS={"PROXIMITY":{"id":"ISP_PROXIMITY","code":"distance"},"INV_BALANCE":{"id":"ISP_INV_BAL","code":"inventoryForAllocation"},"CUSTOMER_SEQ":{"id":"ISP_CUST_SEQ","code":"facilitySequence"}}
VUE_APP_RULE_ACTION_ENUMS={"AUTO_CANCEL_DAYS":{"id":"ORA_AUTO_CANCEL_DATE","code":"ADD_AUTO_CANCEL_DATE"},"NEXT_RULE":{"id":"ORA_NEXT_RULE","code":"NEXT_RULE"},"MOVE_TO_QUEUE":{"id":"ORA_MV_TO_QUEUE","code":"MOVE_TO_QUEUE"}}
34 changes: 34 additions & 0 deletions src/components/AddInventoryFilterOptionsModal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<template>
<ion-page>
<ion-header>
<ion-toolbar>
<ion-title>{{ "Inventory Filters" }}</ion-title>
<ion-buttons slot="end">
<ion-button @click="closeModal">{{ $t('Close') }}</ion-button>
</ion-buttons>
</ion-toolbar>
</ion-header>
<ion-content>
<ion-list>
<ion-item v-for="filter in Object.values(inventoryFilterOptions['INV_FILTER_PRM_TYPE'])" :key="filter.enumId">
<ion-checkbox>{{ filter.description || filter.enumCode }}</ion-checkbox>
</ion-item>
</ion-list>
</ion-content>
</ion-page>
</template>

<script setup lang="ts">
import { IonButton, IonButtons, IonCheckbox, IonContent, IonHeader, IonItem, IonList, IonPage, IonTitle, IonToolbar, modalController } from "@ionic/vue";
import { useRouter } from "vue-router";

Check warning on line 23 in src/components/AddInventoryFilterOptionsModal.vue

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (18.x)

'useRouter' is defined but never used

Check warning on line 23 in src/components/AddInventoryFilterOptionsModal.vue

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (20.x)

'useRouter' is defined but never used
import { useStore } from "vuex";
import { computed } from "vue";

const store = useStore();

const inventoryFilterOptions = computed(() => store.getters["util/getEnums"])

function closeModal() {
modalController.dismiss({ dismissed: true })
}
</script>
33 changes: 33 additions & 0 deletions src/components/AddInventorySortOptionsModal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<template>
<ion-page>
<ion-header>
<ion-toolbar>
<ion-title>{{ "Inventory Sort" }}</ion-title>
<ion-buttons slot="end">
<ion-button @click="closeModal">{{ $t('Close') }}</ion-button>
</ion-buttons>
</ion-toolbar>
</ion-header>
<ion-content>
<ion-list>
<ion-item v-for="filter in Object.values(inventoryFilterOptions['INV_SORT_PARAM_TYPE'])" :key="filter.enumId">
<ion-checkbox>{{ filter.description || filter.enumCode }}</ion-checkbox>
</ion-item>
</ion-list>
</ion-content>
</ion-page>
</template>

<script setup lang="ts">
import { IonButton, IonButtons, IonCheckbox, IonContent, IonHeader, IonItem, IonList, IonPage, IonTitle, IonToolbar, modalController } from "@ionic/vue";
import { useStore } from "vuex";
import { computed } from "vue";

const store = useStore();

const inventoryFilterOptions = computed(() => store.getters["util/getEnums"])

function closeModal() {
modalController.dismiss({ dismissed: true })
}
</script>
5 changes: 3 additions & 2 deletions src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ const routes: Array<RouteRecordRaw> = [
props: true
},
{
path: "brokering/query",
component: () => import("@/views/BrokeringQuery.vue")
path: "brokering/:routingGroupId/:orderRoutingId/rules",
component: () => import("@/views/BrokeringQuery.vue"),
props: true
},
{
path: "settings",
Expand Down
62 changes: 61 additions & 1 deletion src/services/RoutingService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import api from "@/api"
import logger from "@/logger";
import store from "@/store";

Check warning on line 3 in src/services/RoutingService.ts

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (18.x)

'store' is defined but never used

Check warning on line 3 in src/services/RoutingService.ts

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (20.x)

'store' is defined but never used
import { hasError, showToast } from "@/utils";

const fetchRoutingGroups = async (payload: any): Promise<any> => {
return api({
Expand All @@ -24,8 +27,65 @@
});
}

const createRoutingRule = async (payload: any): Promise<any> => {
let routingRuleId = '';
try {
const resp = await api({
url: "rules",
method: "POST",
data: payload
})

if(!hasError(resp) && resp?.data.routingRuleId) {
routingRuleId = resp.data.routingRuleId
}
} catch(err) {
showToast("Failed to create new rule")
logger.error(err)
}

return routingRuleId
}

const fetchRoutingRules = async (payload: any): Promise<any> => {
return api({
url: `routings/${payload.orderRoutingId}/rules`,
method: "GET",
query: payload
});
}

const fetchRoutingFilters = async (payload: any): Promise<any> => {
return api({
url: `routings/${payload.orderRoutingId}/filter-conditions`,
method: "GET",
query: payload
});
}

const fetchRuleConditions = async (payload: any): Promise<any> => {
return api({
url: `rules/${payload.routingRuleId}/condition`,
method: "GET",
query: payload
});
}

const fetchRuleActions = async (payload: any): Promise<any> => {
return api({
url: `rules/${payload.routingRuleId}/actions`,
method: "GET",
query: payload
});
}

export const OrderRoutingService = {
createRoutingGroup,
createRoutingRule,
fetchOrderRoutings,
fetchRoutingGroups
fetchRoutingFilters,
fetchRoutingGroups,
fetchRoutingRules,
fetchRuleActions,
fetchRuleConditions
}
11 changes: 10 additions & 1 deletion src/services/UtilService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ const fetchEnums = async (payload: any): Promise<any> => {
});
}

const fetchFacilities = async (payload: any): Promise<any> => {
return api({
url: "facilities",
method: "GET",
params: payload
});
}

export const UtilService = {
fetchEnums
fetchEnums,
fetchFacilities
}
11 changes: 10 additions & 1 deletion src/store/modules/orderRouting/OrderRoutingState.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
import { RouteFilter } from "@/types";

export default interface OrderRoutingState {
groups: Array<any>; // runs
routes: Array<any>;
rule: Array<any>;
rules: Array<any>;
currentGroupId: string;
currentRouteId: string;
currentRouteFilters: {
[key: string]: { // conditionTypeEnumId as key
[key: string]: RouteFilter // enumCode/fieldName as key
}
};
ruleConditions: {};
ruleActions: {}
}
132 changes: 131 additions & 1 deletion src/store/modules/orderRouting/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { OrderRoutingService } from "@/services/RoutingService"
import { hasError, showToast, sortSequence } from "@/utils"
import * as types from './mutation-types'
import logger from "@/logger"
import { RouteFilter } from "@/types"

const actions: ActionTree<OrderRoutingState, RootState> = {
async fetchOrderRoutingGroups({ commit }) {
Expand Down Expand Up @@ -77,7 +78,136 @@ const actions: ActionTree<OrderRoutingState, RootState> = {
}

commit(types.ORDER_ROUTINGS_UPDATED, orderRoutings)
}
},

async fetchRoutingRules({ commit }, orderRoutingId) {
let routingRules = [] as any;
// filter groups on the basis of productStoreId
const payload = {
orderRoutingId
}

try {
const resp = await OrderRoutingService.fetchRoutingRules(payload);

if(!hasError(resp) && resp.data.length) {
routingRules = resp.data
} else {
throw resp.data
}
} catch(err) {
logger.error(err);
}

if(routingRules.length) {
routingRules = sortSequence(routingRules)
}

commit(types.ORDER_ROUTING_RULES_UPDATED, routingRules)
},

async fetchRoutingFilters({ commit }, orderRoutingId) {
let routingFilters = [] as any;
// filter groups on the basis of productStoreId
const payload = {
orderRoutingId
}

try {
const resp = await OrderRoutingService.fetchRoutingFilters(payload);

if(!hasError(resp) && resp.data.length) {
routingFilters = resp.data.reduce((filters: any, filter: RouteFilter) => {
if(filters[filter.conditionTypeEnumId]) {
filters[filter.conditionTypeEnumId][filter.fieldName] = filter
} else {
filters[filter.conditionTypeEnumId] = {
[filter.fieldName]: filter
}
}
return filters
}, {})
} else {
throw resp.data
}
} catch(err) {
logger.error(err);
}

const sortEnum = JSON.parse(process.env?.VUE_APP_RULE_ENUMS as string)["SORT"] as any

// As we only need to add support of reordering for sortBy filter
if(routingFilters[sortEnum]?.length) {
routingFilters[sortEnum] = sortSequence(routingFilters[sortEnum])
}

commit(types.ORDER_ROUTING_FILTERS_UPDATED, routingFilters)
},

async fetchRuleConditions({ commit }, routingRuleId) {
let ruleConditions = [] as any;
// filter groups on the basis of productStoreId
const payload = {
routingRuleId
}

try {
const resp = await OrderRoutingService.fetchRuleConditions(payload);

if(!hasError(resp) && resp.data.length) {
ruleConditions = resp.data
} else {
throw resp.data
}
} catch(err) {
logger.error(err);
}

// const sortEnum = JSON.parse(process.env?.VUE_APP_RULE_ENUMS as string)["SORT"] as any

// // As we only need to add support of reordering for sortBy filter
// if(routingFilters[sortEnum]?.length) {
// routingFilters[sortEnum] = sortSequence(routingFilters[sortEnum])
// }

commit(types.ORDER_ROUTING_RULE_CONDITIONS_UPDATED, ruleConditions)
},

async fetchRuleActions({ commit }, routingRuleId) {
let ruleActions = {} as any;
const payload = {
routingRuleId
}

try {
const resp = await OrderRoutingService.fetchRuleActions(payload);

if(!hasError(resp) && resp.data.length) {
ruleActions = resp.data.reduce((actions: any, action: any) => {
// considering that only one value for an action is available
actions[action.actionTypeEnumId] = action
return actions
}, {})
} else {
throw resp.data
}
} catch(err) {
logger.error(err);
}

// const sortEnum = JSON.parse(process.env?.VUE_APP_RULE_ENUMS as string)["SORT"] as any

// // As we only need to add support of reordering for sortBy filter
// if(routingFilters[sortEnum]?.length) {
// routingFilters[sortEnum] = sortSequence(routingFilters[sortEnum])
// }

commit(types.ORDER_ROUTING_RULE_ACTIONS_UPDATED, ruleActions)
},

async setCurrentOrderRoutingId({ commit }, payload) {
commit(types.ORDER_ROUTING_CURRENT_ROUTE_UPDATED, payload)
},
}

export default actions;
18 changes: 17 additions & 1 deletion src/store/modules/orderRouting/getters.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { GetterTree } from "vuex"
import OrderRoutingState from "./OrderRoutingState"
import RootState from "@/store/RootState"
import { Group } from "@/types"
import { Group, Route } from "@/types"

const getters: GetterTree<OrderRoutingState, RootState> = {
getRoutingGroups(state) {
Expand All @@ -10,9 +10,25 @@ const getters: GetterTree<OrderRoutingState, RootState> = {
getOrderRoutings(state) {
return state.routes
},
getRoutingRules(state) {
return state.rules
},
getCurrentRoutingGroup(state) {
const currentRoutingGroup = state.groups?.find((group: Group) => group.routingGroupId === state.currentGroupId)
return currentRoutingGroup ? currentRoutingGroup : {}
},
getCurrentOrderRouting(state) {
const orderRouting = state.routes?.find((route: Route) => route.orderRoutingId === state.currentRouteId)
return orderRouting ? orderRouting : {}
},
getCurrentRouteFilters(state) {
return state.currentRouteFilters
},
getRuleConditions(state) {
return JSON.parse(JSON.stringify(state.ruleConditions))
},
getRuleActions(state) {
return JSON.parse(JSON.stringify(state.ruleActions))
}
}

Expand Down
Loading
Loading