diff --git a/src/locales/en.json b/src/locales/en.json index 322a726..108014a 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -89,6 +89,7 @@ "Order Rule Filters": "Order Rule Filters", "Order Rule Sort": "Order Rule Sort", "operator": "operator", + "Partial allocation cannot be disabled. Orders are filtered by item when filtering by promise date.": "Partial allocation cannot be disabled. Orders are filtered by item when filtering by promise date.", "Partially available": "Partially available", "Passed duration": "Passed duration", "Password": "Password", diff --git a/src/store/modules/orderRouting/OrderRoutingState.ts b/src/store/modules/orderRouting/OrderRoutingState.ts index 4cc7024..16d7934 100644 --- a/src/store/modules/orderRouting/OrderRoutingState.ts +++ b/src/store/modules/orderRouting/OrderRoutingState.ts @@ -3,4 +3,5 @@ export default interface OrderRoutingState { rules: any; currentGroup: any; currentRoute: any; + routingHistory: any; } \ No newline at end of file diff --git a/src/store/modules/orderRouting/actions.ts b/src/store/modules/orderRouting/actions.ts index 61387f7..2f134f0 100644 --- a/src/store/modules/orderRouting/actions.ts +++ b/src/store/modules/orderRouting/actions.ts @@ -162,6 +162,44 @@ const actions: ActionTree = { commit(types.ORDER_ROUTING_CURRENT_ROUTE_UPDATED, payload) }, + async fetchRoutingHistory({ commit, state }, routingGroupId) { + const history = Object.values(state.routingHistory)[0] as any + + // If the routing history for the current group is already available then don't fetch the history again + if(history?.length && history[0].routingGroupId === routingGroupId) { + return; + } + + let routingHistory = {} + + try { + const resp = await OrderRoutingService.fetchRoutingHistory(routingGroupId) + + if(!hasError(resp)) { + // Sorting the history based on startTime, as we does not get the records in sorted order from api + const sortedRoutingHistory = resp.data.sort((a: any, b: any) => b.startDate - a.startDate) + + routingHistory = sortedRoutingHistory.reduce((routings: any, routing: any) => { + if(routings[routing.orderRoutingId]) { + routings[routing.orderRoutingId].push(routing) + } else { + routings = { + ...routings, + [routing.orderRoutingId]: [routing] + } + } + return routings + }, {}) + } else { + throw resp.data; + } + } catch(err) { + logger.error(err) + } + + commit(types.ORDER_ROUTING_HISTORY_UPDATED, routingHistory) + }, + async deleteRoutingFilters({ dispatch }, payload) { let hasAllFiltersDeletedSuccessfully = true; try { diff --git a/src/store/modules/orderRouting/getters.ts b/src/store/modules/orderRouting/getters.ts index 6b6e181..5792302 100644 --- a/src/store/modules/orderRouting/getters.ts +++ b/src/store/modules/orderRouting/getters.ts @@ -14,6 +14,9 @@ const getters: GetterTree = { }, getCurrentOrderRouting(state) { return JSON.parse(JSON.stringify(state.currentRoute)) + }, + getRoutingHistory(state) { + return JSON.parse(JSON.stringify(state.routingHistory)) } } diff --git a/src/store/modules/orderRouting/index.ts b/src/store/modules/orderRouting/index.ts index 91c96f6..4b576a5 100644 --- a/src/store/modules/orderRouting/index.ts +++ b/src/store/modules/orderRouting/index.ts @@ -11,7 +11,8 @@ const orderRoutingModule: Module = { groups: [], rules: {}, currentGroup: {}, - currentRoute: {} + currentRoute: {}, + routingHistory: {} }, getters, actions, diff --git a/src/store/modules/orderRouting/mutation-types.ts b/src/store/modules/orderRouting/mutation-types.ts index d4b3cf1..db94981 100644 --- a/src/store/modules/orderRouting/mutation-types.ts +++ b/src/store/modules/orderRouting/mutation-types.ts @@ -3,4 +3,5 @@ export const ORDER_ROUTING_GROUPS_UPDATED = SN_ORDER_ROUTING + "/GROUPS_UPDATED" export const ORDER_ROUTING_RULES_UPDATED = SN_ORDER_ROUTING + "/RULE_UPDATED" export const ORDER_ROUTING_CURRENT_GROUP_UPDATED = SN_ORDER_ROUTING + "/CURRENT_GROUP_UPDATED" export const ORDER_ROUTING_CURRENT_ROUTE_UPDATED = SN_ORDER_ROUTING + "/CURRENT_ROUTE_UPDATED" +export const ORDER_ROUTING_HISTORY_UPDATED = SN_ORDER_ROUTING + "/ROUTING_HISTORY_UPDATED" export const ORDER_ROUTING_CLEARED = SN_ORDER_ROUTING + "/CLEARED" \ No newline at end of file diff --git a/src/store/modules/orderRouting/mutations.ts b/src/store/modules/orderRouting/mutations.ts index 4eb28fe..5a0348d 100644 --- a/src/store/modules/orderRouting/mutations.ts +++ b/src/store/modules/orderRouting/mutations.ts @@ -15,11 +15,15 @@ const mutations: MutationTree = { [types.ORDER_ROUTING_CURRENT_ROUTE_UPDATED](state, payload) { state.currentRoute = payload }, + [types.ORDER_ROUTING_HISTORY_UPDATED](state, payload) { + state.routingHistory = payload + }, [types.ORDER_ROUTING_CLEARED](state) { state.groups = [] state.rules = {} state.currentGroup = {} state.currentRoute = {} + state.routingHistory = {} }, } export default mutations; \ No newline at end of file diff --git a/src/utils/index.ts b/src/utils/index.ts index 264e263..bd03e36 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -41,4 +41,9 @@ function getDateAndTime(time: any) { return time ? DateTime.fromMillis(time).toLocaleString(DateTime.DATETIME_MED) : "-"; } -export { getDate, getDateAndTime, getTime, getTimeFromSeconds, showToast, hasError, sortSequence } +function getDateAndTimeShort(time: any) { + // format: hh:mm(localized 24-hour time) date/month + return time ? DateTime.fromMillis(time).toFormat("T dd/LL") : "-"; +} + +export { getDate, getDateAndTime, getDateAndTimeShort, getTime, getTimeFromSeconds, showToast, hasError, sortSequence } diff --git a/src/views/BrokeringQuery.vue b/src/views/BrokeringQuery.vue index 6937ac1..46efe79 100644 --- a/src/views/BrokeringQuery.vue +++ b/src/views/BrokeringQuery.vue @@ -5,12 +5,32 @@