@zeniai/client-epic-state 5.1.20-betaRD4 → 5.1.20-betaRD5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationViewEpic.js +4 -24
- package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +2 -70
- package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationViewEpic.d.ts +2 -2
- package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationViewEpic.js +2 -22
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +1 -4
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +3 -71
- package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +0 -16
- package/package.json +1 -1
|
@@ -6,8 +6,8 @@ import { fetchAccountList } from '../../../accountList/accountListReducer';
|
|
|
6
6
|
import { fetchClassList } from '../../../classList/classListReducer';
|
|
7
7
|
import { fetchOwnerList } from '../../../ownerList/ownerListReducer';
|
|
8
8
|
import { fetchProjectList } from '../../../projectList/projectListReducer';
|
|
9
|
-
import { fetchTransactionCategorization, fetchTransactionCategorizationView,
|
|
10
|
-
import { TRANSACTIONS_TABS
|
|
9
|
+
import { fetchTransactionCategorization, fetchTransactionCategorizationView, } from '../../reducers/transactionsViewReducer';
|
|
10
|
+
import { TRANSACTIONS_TABS } from '../../types/transactionsViewState';
|
|
11
11
|
export const fetchTransactionCategorizationViewEpic = (actions$, state$) => actions$.pipe(filter(fetchTransactionCategorizationView.match), mergeMap((action) => {
|
|
12
12
|
const { selectedTab, cacheOverride, keepExistingListItems, pageToken, period, refreshViewInBackground, searchString, resetListItems, isUncategorizedExpenseCategoryEnabled, } = action.payload;
|
|
13
13
|
const updateActions = [];
|
|
@@ -19,12 +19,6 @@ export const fetchTransactionCategorizationViewEpic = (actions$, state$) => acti
|
|
|
19
19
|
};
|
|
20
20
|
const periodId = toMonthYearPeriodId(monthYearPeriod);
|
|
21
21
|
const transactionIds = transactionIdsBySelectedPeriod[periodId] ?? [];
|
|
22
|
-
const hasUsableSnapshot = (tabKey) => {
|
|
23
|
-
const snapshot = expenseAutomationTransactionsViewState.transactionCategorizationView[tabKey].fullDatasetSnapshot;
|
|
24
|
-
return (snapshot != null &&
|
|
25
|
-
snapshot.periodId === periodId &&
|
|
26
|
-
snapshot.transactionIds.length > 0);
|
|
27
|
-
};
|
|
28
22
|
const accountList = state$.value.accountListState.byReportId['accountList'];
|
|
29
23
|
if (accountList.hasValidState() === false &&
|
|
30
24
|
accountList.fetchState === 'Not-Started') {
|
|
@@ -46,16 +40,7 @@ export const fetchTransactionCategorizationViewEpic = (actions$, state$) => acti
|
|
|
46
40
|
vendorOwnerList.fetchState === 'Not-Started') {
|
|
47
41
|
updateActions.push(fetchOwnerList());
|
|
48
42
|
}
|
|
49
|
-
|
|
50
|
-
// snapshot if one exists — avoids a round-trip since all data is already
|
|
51
|
-
// in the entity store. Fall back to a fresh fetch if no snapshot (either
|
|
52
|
-
// the tab was never loaded, or the snapshot was invalidated because a
|
|
53
|
-
// categorization happened during search).
|
|
54
|
-
const clearingSearchWithNoSnapshot = searchString === '' && !hasUsableSnapshot(selectedTab);
|
|
55
|
-
if (searchString === '' && hasUsableSnapshot(selectedTab)) {
|
|
56
|
-
updateActions.push(restoreFullDatasetSnapshot({ selectedTab, period }));
|
|
57
|
-
}
|
|
58
|
-
else if (clearingSearchWithNoSnapshot ||
|
|
43
|
+
if (searchString === '' ||
|
|
59
44
|
cacheOverride === true ||
|
|
60
45
|
fetchState === 'Not-Started' ||
|
|
61
46
|
transactionIds.length === 0) {
|
|
@@ -82,12 +67,7 @@ export const fetchTransactionCategorizationViewEpic = (actions$, state$) => acti
|
|
|
82
67
|
TRANSACTIONS_TABS.filter((tab) => tab !== selectedTab).forEach((otherTab) => {
|
|
83
68
|
const otherTabSearchString = expenseAutomationTransactionsViewState.transactionCategorizationView[otherTab].uiState.searchString;
|
|
84
69
|
if (searchString !== otherTabSearchString) {
|
|
85
|
-
|
|
86
|
-
updateActions.push(restoreFullDatasetSnapshot({ selectedTab: otherTab, period }));
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
updateActions.push(fetchTransactionCategorization(otherTab, period, true, keepExistingListItems, searchString, undefined, true, true, isUncategorizedExpenseCategoryEnabled));
|
|
90
|
-
}
|
|
70
|
+
updateActions.push(fetchTransactionCategorization(otherTab, period, true, keepExistingListItems, searchString, undefined, true, true, isUncategorizedExpenseCategoryEnabled));
|
|
91
71
|
}
|
|
92
72
|
});
|
|
93
73
|
}
|
|
@@ -38,7 +38,6 @@ export const initialTransactionTabViewState = {
|
|
|
38
38
|
hasValidState() {
|
|
39
39
|
return this.fetchState == 'Completed';
|
|
40
40
|
},
|
|
41
|
-
fullDatasetSnapshot: undefined,
|
|
42
41
|
transactionReviewLocalDataById: {},
|
|
43
42
|
transactionIdsBySelectedPeriod: {},
|
|
44
43
|
selectedCheckBoxTransactionIds: [],
|
|
@@ -178,29 +177,6 @@ const expenseAutomationTransactionsView = createSlice({
|
|
|
178
177
|
const periodId = toMonthYearPeriodId(monthYearPeriod);
|
|
179
178
|
const transactionIdsBySelectedPeriod = draft.transactionCategorizationView[selectedTab]
|
|
180
179
|
.transactionIdsBySelectedPeriod[periodId] ?? [];
|
|
181
|
-
// Snapshot before any list mutation so clearing the search restores
|
|
182
|
-
// instantly without an API round-trip — for BOTH active and synced tabs.
|
|
183
|
-
// Active-tab search dispatches resetListItems=false, so this must live
|
|
184
|
-
// outside the resetListItems block. fullDatasetSnapshot == null prevents
|
|
185
|
-
// overwriting the original snapshot on search refinement ('ama'→'amazon').
|
|
186
|
-
if (searchString !== undefined &&
|
|
187
|
-
searchString !== '' &&
|
|
188
|
-
transactionIdsBySelectedPeriod.length > 0 &&
|
|
189
|
-
draft.transactionCategorizationView[selectedTab].fullDatasetSnapshot ==
|
|
190
|
-
null) {
|
|
191
|
-
draft.transactionCategorizationView[selectedTab].fullDatasetSnapshot =
|
|
192
|
-
{
|
|
193
|
-
parentTotalCount: draft.parentTotalCountByTab[selectedTab][periodId],
|
|
194
|
-
periodId,
|
|
195
|
-
totalCount: draft.transactionCategorizationView[selectedTab].uiState
|
|
196
|
-
.totalCount[periodId],
|
|
197
|
-
transactionIds: [...transactionIdsBySelectedPeriod],
|
|
198
|
-
transactionReviewLocalDataById: {
|
|
199
|
-
...draft.transactionCategorizationView[selectedTab]
|
|
200
|
-
.transactionReviewLocalDataById,
|
|
201
|
-
},
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
180
|
// Reset list when we change the sort order and fetch list again
|
|
205
181
|
if (resetListItems === true) {
|
|
206
182
|
transactionIdsBySelectedPeriod.forEach((transactionId) => {
|
|
@@ -718,47 +694,6 @@ const expenseAutomationTransactionsView = createSlice({
|
|
|
718
694
|
// leave the other tab's state untouched — it has its own active fetch.
|
|
719
695
|
});
|
|
720
696
|
},
|
|
721
|
-
restoreFullDatasetSnapshot(draft, action) {
|
|
722
|
-
const { selectedTab, period } = action.payload;
|
|
723
|
-
const periodId = toMonthYearPeriodId({
|
|
724
|
-
month: period.start.month,
|
|
725
|
-
year: period.start.year,
|
|
726
|
-
});
|
|
727
|
-
const snapshot = draft.transactionCategorizationView[selectedTab].fullDatasetSnapshot;
|
|
728
|
-
if (snapshot == null || snapshot.periodId !== periodId) {
|
|
729
|
-
return;
|
|
730
|
-
}
|
|
731
|
-
draft.transactionCategorizationView[selectedTab]
|
|
732
|
-
.transactionIdsBySelectedPeriod[periodId] = snapshot.transactionIds;
|
|
733
|
-
// Merge back per-transaction local data; skip entries that were updated
|
|
734
|
-
// during the search (e.g. a save that happened while filtered results
|
|
735
|
-
// were showing) so those saves are not overwritten.
|
|
736
|
-
Object.entries(snapshot.transactionReviewLocalDataById).forEach(([transactionId, localData]) => {
|
|
737
|
-
if (draft.transactionCategorizationView[selectedTab]
|
|
738
|
-
.transactionReviewLocalDataById[transactionId] == null) {
|
|
739
|
-
draft.transactionCategorizationView[selectedTab]
|
|
740
|
-
.transactionReviewLocalDataById[transactionId] = localData;
|
|
741
|
-
}
|
|
742
|
-
});
|
|
743
|
-
if (snapshot.totalCount != null) {
|
|
744
|
-
draft.transactionCategorizationView[selectedTab].uiState.totalCount[periodId] = snapshot.totalCount;
|
|
745
|
-
}
|
|
746
|
-
if (snapshot.parentTotalCount != null) {
|
|
747
|
-
draft.parentTotalCountByTab[selectedTab][periodId] =
|
|
748
|
-
snapshot.parentTotalCount;
|
|
749
|
-
}
|
|
750
|
-
draft.transactionCategorizationView[selectedTab].uiState.searchString =
|
|
751
|
-
'';
|
|
752
|
-
draft.transactionCategorizationView[selectedTab].uiState.pageToken = null;
|
|
753
|
-
draft.transactionCategorizationView[selectedTab].fetchState = 'Completed';
|
|
754
|
-
draft.transactionCategorizationView[selectedTab].refreshStatus = {
|
|
755
|
-
fetchState: 'Not-Started',
|
|
756
|
-
error: undefined,
|
|
757
|
-
};
|
|
758
|
-
draft.transactionCategorizationView[selectedTab].error = undefined;
|
|
759
|
-
draft.transactionCategorizationView[selectedTab].fullDatasetSnapshot =
|
|
760
|
-
undefined;
|
|
761
|
-
},
|
|
762
697
|
fetchTransactionCategorizationFailure(draft, action) {
|
|
763
698
|
const { selectedTab, selectedPeriod } = action.payload;
|
|
764
699
|
draft.transactionCategorizationView[selectedTab].transactionIdsBySelectedPeriod[toMonthYearPeriodId(selectedPeriod)] =
|
|
@@ -1087,7 +1022,6 @@ const expenseAutomationTransactionsView = createSlice({
|
|
|
1087
1022
|
if (allReviewed) {
|
|
1088
1023
|
if (existsInReview) {
|
|
1089
1024
|
removeTransactionFromTabView(reviewTabView, txnId);
|
|
1090
|
-
reviewTabView.fullDatasetSnapshot = undefined;
|
|
1091
1025
|
}
|
|
1092
1026
|
return;
|
|
1093
1027
|
}
|
|
@@ -1134,13 +1068,11 @@ const expenseAutomationTransactionsView = createSlice({
|
|
|
1134
1068
|
reducer(draft, action) {
|
|
1135
1069
|
const { transactionId } = action.payload;
|
|
1136
1070
|
for (const tab of TRANSACTIONS_TABS) {
|
|
1137
|
-
|
|
1138
|
-
removeTransactionFromTabView(tabView, transactionId);
|
|
1139
|
-
tabView.fullDatasetSnapshot = undefined;
|
|
1071
|
+
removeTransactionFromTabView(draft.transactionCategorizationView[tab], transactionId);
|
|
1140
1072
|
}
|
|
1141
1073
|
},
|
|
1142
1074
|
},
|
|
1143
1075
|
},
|
|
1144
1076
|
});
|
|
1145
|
-
export const { fetchTransactionCategorization, updateTransactionCategorizationUIState, updateTransactionFilters, initializeTransactionCategorizationViewLocalData, saveTransactionCategorizationLocalData, fetchTransactionCategorizationFailure, saveTransactionCategorization, updateTransactionCategorization, updateCurrentSelectedTransactionCategorizationTab, updateTransactionCategorizationCompletedSubTab, updateTransactionCategorizationSaveStatus, markTransactionAsNotMiscategorized, updateStatusForTransactionNotMiscategorizedUpdateForCategorization, updateSelectedVendorForTransaction, updateSelectedCustomerForTransaction, setAllItemsToCategoryClassInLocalDataForCategorization, updateTotalCountForTransactionCategorization, updateParentTotalCountForTab, fetchTransactionCategorizationSuccess, resetOtherTabsFetchState,
|
|
1077
|
+
export const { fetchTransactionCategorization, updateTransactionCategorizationUIState, updateTransactionFilters, initializeTransactionCategorizationViewLocalData, saveTransactionCategorizationLocalData, fetchTransactionCategorizationFailure, saveTransactionCategorization, updateTransactionCategorization, updateCurrentSelectedTransactionCategorizationTab, updateTransactionCategorizationCompletedSubTab, updateTransactionCategorizationSaveStatus, markTransactionAsNotMiscategorized, updateStatusForTransactionNotMiscategorizedUpdateForCategorization, updateSelectedVendorForTransaction, updateSelectedCustomerForTransaction, setAllItemsToCategoryClassInLocalDataForCategorization, updateTotalCountForTransactionCategorization, updateParentTotalCountForTab, fetchTransactionCategorizationSuccess, resetOtherTabsFetchState, fetchTransactionCategorizationView, updateSelectedCheckboxTransactionIds, clearExpenseAutomationTransactionsViewPerTabView, clearExpenseAutomationTransactionsView, setEntityRecommendationForLineIdsForCategorization, markCategoryClassRecommendationsInProgressForCategorization, markCategoryClassRecommendationsCompletedForCategorization, markCategoryClassRecommendationsFailureForCategorization, updateSelectedTransactionId, syncTransactionCategorizationFromDetailSave, backgroundRefetchReviewTab, removeTransactionFromAllTabs, updateTransactionCategorizationUploadReceiptState, uploadTransactionCategorizationReceiptSuccess, } = expenseAutomationTransactionsView.actions;
|
|
1146
1078
|
export default expenseAutomationTransactionsView.reducer;
|
|
@@ -5,6 +5,6 @@ import { fetchAccountList } from '../../../accountList/accountListReducer';
|
|
|
5
5
|
import { fetchClassList } from '../../../classList/classListReducer';
|
|
6
6
|
import { fetchOwnerList } from '../../../ownerList/ownerListReducer';
|
|
7
7
|
import { fetchProjectList } from '../../../projectList/projectListReducer';
|
|
8
|
-
import { fetchTransactionCategorization, fetchTransactionCategorizationView
|
|
9
|
-
export type ActionType = ReturnType<typeof fetchTransactionCategorizationView> | ReturnType<typeof fetchTransactionCategorization> | ReturnType<typeof
|
|
8
|
+
import { fetchTransactionCategorization, fetchTransactionCategorizationView } from '../../reducers/transactionsViewReducer';
|
|
9
|
+
export type ActionType = ReturnType<typeof fetchTransactionCategorizationView> | ReturnType<typeof fetchTransactionCategorization> | ReturnType<typeof fetchAccountList> | ReturnType<typeof fetchClassList> | ReturnType<typeof fetchOwnerList> | ReturnType<typeof fetchProjectList>;
|
|
10
10
|
export declare const fetchTransactionCategorizationViewEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>) => Observable<ActionType>;
|
|
@@ -22,12 +22,6 @@ const fetchTransactionCategorizationViewEpic = (actions$, state$) => actions$.pi
|
|
|
22
22
|
};
|
|
23
23
|
const periodId = (0, timePeriod_1.toMonthYearPeriodId)(monthYearPeriod);
|
|
24
24
|
const transactionIds = transactionIdsBySelectedPeriod[periodId] ?? [];
|
|
25
|
-
const hasUsableSnapshot = (tabKey) => {
|
|
26
|
-
const snapshot = expenseAutomationTransactionsViewState.transactionCategorizationView[tabKey].fullDatasetSnapshot;
|
|
27
|
-
return (snapshot != null &&
|
|
28
|
-
snapshot.periodId === periodId &&
|
|
29
|
-
snapshot.transactionIds.length > 0);
|
|
30
|
-
};
|
|
31
25
|
const accountList = state$.value.accountListState.byReportId['accountList'];
|
|
32
26
|
if (accountList.hasValidState() === false &&
|
|
33
27
|
accountList.fetchState === 'Not-Started') {
|
|
@@ -49,16 +43,7 @@ const fetchTransactionCategorizationViewEpic = (actions$, state$) => actions$.pi
|
|
|
49
43
|
vendorOwnerList.fetchState === 'Not-Started') {
|
|
50
44
|
updateActions.push((0, ownerListReducer_1.fetchOwnerList)());
|
|
51
45
|
}
|
|
52
|
-
|
|
53
|
-
// snapshot if one exists — avoids a round-trip since all data is already
|
|
54
|
-
// in the entity store. Fall back to a fresh fetch if no snapshot (either
|
|
55
|
-
// the tab was never loaded, or the snapshot was invalidated because a
|
|
56
|
-
// categorization happened during search).
|
|
57
|
-
const clearingSearchWithNoSnapshot = searchString === '' && !hasUsableSnapshot(selectedTab);
|
|
58
|
-
if (searchString === '' && hasUsableSnapshot(selectedTab)) {
|
|
59
|
-
updateActions.push((0, transactionsViewReducer_1.restoreFullDatasetSnapshot)({ selectedTab, period }));
|
|
60
|
-
}
|
|
61
|
-
else if (clearingSearchWithNoSnapshot ||
|
|
46
|
+
if (searchString === '' ||
|
|
62
47
|
cacheOverride === true ||
|
|
63
48
|
fetchState === 'Not-Started' ||
|
|
64
49
|
transactionIds.length === 0) {
|
|
@@ -85,12 +70,7 @@ const fetchTransactionCategorizationViewEpic = (actions$, state$) => actions$.pi
|
|
|
85
70
|
transactionsViewState_1.TRANSACTIONS_TABS.filter((tab) => tab !== selectedTab).forEach((otherTab) => {
|
|
86
71
|
const otherTabSearchString = expenseAutomationTransactionsViewState.transactionCategorizationView[otherTab].uiState.searchString;
|
|
87
72
|
if (searchString !== otherTabSearchString) {
|
|
88
|
-
|
|
89
|
-
updateActions.push((0, transactionsViewReducer_1.restoreFullDatasetSnapshot)({ selectedTab: otherTab, period }));
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
updateActions.push((0, transactionsViewReducer_1.fetchTransactionCategorization)(otherTab, period, true, keepExistingListItems, searchString, undefined, true, true, isUncategorizedExpenseCategoryEnabled));
|
|
93
|
-
}
|
|
73
|
+
updateActions.push((0, transactionsViewReducer_1.fetchTransactionCategorization)(otherTab, period, true, keepExistingListItems, searchString, undefined, true, true, isUncategorizedExpenseCategoryEnabled));
|
|
94
74
|
}
|
|
95
75
|
});
|
|
96
76
|
}
|
|
@@ -137,10 +137,7 @@ export declare const fetchTransactionCategorization: import("@reduxjs/toolkit").
|
|
|
137
137
|
}, "expenseAutomationTransactionsView/fetchTransactionCategorizationSuccess">, resetOtherTabsFetchState: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
138
138
|
tabs: TransactionsTab[];
|
|
139
139
|
refreshViewInBackground?: boolean;
|
|
140
|
-
}, "expenseAutomationTransactionsView/resetOtherTabsFetchState">,
|
|
141
|
-
period: TimePeriod;
|
|
142
|
-
selectedTab: TransactionsTab;
|
|
143
|
-
}, "expenseAutomationTransactionsView/restoreFullDatasetSnapshot">, fetchTransactionCategorizationView: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[selectedTab: "review" | "autoCategorized", period: TimePeriod, cacheOverride?: any, keepExistingListItems?: any, searchString?: string | undefined, pageToken?: PageToken | undefined, refreshViewInBackground?: any, resetListItems?: any, isUncategorizedExpenseCategoryEnabled?: boolean | undefined], {
|
|
140
|
+
}, "expenseAutomationTransactionsView/resetOtherTabsFetchState">, fetchTransactionCategorizationView: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[selectedTab: "review" | "autoCategorized", period: TimePeriod, cacheOverride?: any, keepExistingListItems?: any, searchString?: string | undefined, pageToken?: PageToken | undefined, refreshViewInBackground?: any, resetListItems?: any, isUncategorizedExpenseCategoryEnabled?: boolean | undefined], {
|
|
144
141
|
selectedTab: "review" | "autoCategorized";
|
|
145
142
|
period: TimePeriod;
|
|
146
143
|
searchString: string | undefined;
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
var _a;
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.uploadTransactionCategorizationReceiptSuccess = exports.updateTransactionCategorizationUploadReceiptState = exports.removeTransactionFromAllTabs = exports.backgroundRefetchReviewTab = exports.syncTransactionCategorizationFromDetailSave = exports.updateSelectedTransactionId = exports.markCategoryClassRecommendationsFailureForCategorization = exports.markCategoryClassRecommendationsCompletedForCategorization = exports.markCategoryClassRecommendationsInProgressForCategorization = exports.setEntityRecommendationForLineIdsForCategorization = exports.clearExpenseAutomationTransactionsView = exports.clearExpenseAutomationTransactionsViewPerTabView = exports.updateSelectedCheckboxTransactionIds = exports.fetchTransactionCategorizationView = exports.
|
|
7
|
+
exports.uploadTransactionCategorizationReceiptSuccess = exports.updateTransactionCategorizationUploadReceiptState = exports.removeTransactionFromAllTabs = exports.backgroundRefetchReviewTab = exports.syncTransactionCategorizationFromDetailSave = exports.updateSelectedTransactionId = exports.markCategoryClassRecommendationsFailureForCategorization = exports.markCategoryClassRecommendationsCompletedForCategorization = exports.markCategoryClassRecommendationsInProgressForCategorization = exports.setEntityRecommendationForLineIdsForCategorization = exports.clearExpenseAutomationTransactionsView = exports.clearExpenseAutomationTransactionsViewPerTabView = exports.updateSelectedCheckboxTransactionIds = exports.fetchTransactionCategorizationView = exports.resetOtherTabsFetchState = exports.fetchTransactionCategorizationSuccess = exports.updateParentTotalCountForTab = exports.updateTotalCountForTransactionCategorization = exports.setAllItemsToCategoryClassInLocalDataForCategorization = exports.updateSelectedCustomerForTransaction = exports.updateSelectedVendorForTransaction = exports.updateStatusForTransactionNotMiscategorizedUpdateForCategorization = exports.markTransactionAsNotMiscategorized = exports.updateTransactionCategorizationSaveStatus = exports.updateTransactionCategorizationCompletedSubTab = exports.updateCurrentSelectedTransactionCategorizationTab = exports.updateTransactionCategorization = exports.saveTransactionCategorization = exports.fetchTransactionCategorizationFailure = exports.saveTransactionCategorizationLocalData = exports.initializeTransactionCategorizationViewLocalData = exports.updateTransactionFilters = exports.updateTransactionCategorizationUIState = exports.fetchTransactionCategorization = exports.initialState = exports.initialTransactionTabViewState = void 0;
|
|
8
8
|
const toolkit_1 = require("@reduxjs/toolkit");
|
|
9
9
|
const get_1 = __importDefault(require("lodash/get"));
|
|
10
10
|
const uniq_1 = __importDefault(require("lodash/uniq"));
|
|
@@ -45,7 +45,6 @@ exports.initialTransactionTabViewState = {
|
|
|
45
45
|
hasValidState() {
|
|
46
46
|
return this.fetchState == 'Completed';
|
|
47
47
|
},
|
|
48
|
-
fullDatasetSnapshot: undefined,
|
|
49
48
|
transactionReviewLocalDataById: {},
|
|
50
49
|
transactionIdsBySelectedPeriod: {},
|
|
51
50
|
selectedCheckBoxTransactionIds: [],
|
|
@@ -185,29 +184,6 @@ const expenseAutomationTransactionsView = (0, toolkit_1.createSlice)({
|
|
|
185
184
|
const periodId = (0, timePeriod_1.toMonthYearPeriodId)(monthYearPeriod);
|
|
186
185
|
const transactionIdsBySelectedPeriod = draft.transactionCategorizationView[selectedTab]
|
|
187
186
|
.transactionIdsBySelectedPeriod[periodId] ?? [];
|
|
188
|
-
// Snapshot before any list mutation so clearing the search restores
|
|
189
|
-
// instantly without an API round-trip — for BOTH active and synced tabs.
|
|
190
|
-
// Active-tab search dispatches resetListItems=false, so this must live
|
|
191
|
-
// outside the resetListItems block. fullDatasetSnapshot == null prevents
|
|
192
|
-
// overwriting the original snapshot on search refinement ('ama'→'amazon').
|
|
193
|
-
if (searchString !== undefined &&
|
|
194
|
-
searchString !== '' &&
|
|
195
|
-
transactionIdsBySelectedPeriod.length > 0 &&
|
|
196
|
-
draft.transactionCategorizationView[selectedTab].fullDatasetSnapshot ==
|
|
197
|
-
null) {
|
|
198
|
-
draft.transactionCategorizationView[selectedTab].fullDatasetSnapshot =
|
|
199
|
-
{
|
|
200
|
-
parentTotalCount: draft.parentTotalCountByTab[selectedTab][periodId],
|
|
201
|
-
periodId,
|
|
202
|
-
totalCount: draft.transactionCategorizationView[selectedTab].uiState
|
|
203
|
-
.totalCount[periodId],
|
|
204
|
-
transactionIds: [...transactionIdsBySelectedPeriod],
|
|
205
|
-
transactionReviewLocalDataById: {
|
|
206
|
-
...draft.transactionCategorizationView[selectedTab]
|
|
207
|
-
.transactionReviewLocalDataById,
|
|
208
|
-
},
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
187
|
// Reset list when we change the sort order and fetch list again
|
|
212
188
|
if (resetListItems === true) {
|
|
213
189
|
transactionIdsBySelectedPeriod.forEach((transactionId) => {
|
|
@@ -725,47 +701,6 @@ const expenseAutomationTransactionsView = (0, toolkit_1.createSlice)({
|
|
|
725
701
|
// leave the other tab's state untouched — it has its own active fetch.
|
|
726
702
|
});
|
|
727
703
|
},
|
|
728
|
-
restoreFullDatasetSnapshot(draft, action) {
|
|
729
|
-
const { selectedTab, period } = action.payload;
|
|
730
|
-
const periodId = (0, timePeriod_1.toMonthYearPeriodId)({
|
|
731
|
-
month: period.start.month,
|
|
732
|
-
year: period.start.year,
|
|
733
|
-
});
|
|
734
|
-
const snapshot = draft.transactionCategorizationView[selectedTab].fullDatasetSnapshot;
|
|
735
|
-
if (snapshot == null || snapshot.periodId !== periodId) {
|
|
736
|
-
return;
|
|
737
|
-
}
|
|
738
|
-
draft.transactionCategorizationView[selectedTab]
|
|
739
|
-
.transactionIdsBySelectedPeriod[periodId] = snapshot.transactionIds;
|
|
740
|
-
// Merge back per-transaction local data; skip entries that were updated
|
|
741
|
-
// during the search (e.g. a save that happened while filtered results
|
|
742
|
-
// were showing) so those saves are not overwritten.
|
|
743
|
-
Object.entries(snapshot.transactionReviewLocalDataById).forEach(([transactionId, localData]) => {
|
|
744
|
-
if (draft.transactionCategorizationView[selectedTab]
|
|
745
|
-
.transactionReviewLocalDataById[transactionId] == null) {
|
|
746
|
-
draft.transactionCategorizationView[selectedTab]
|
|
747
|
-
.transactionReviewLocalDataById[transactionId] = localData;
|
|
748
|
-
}
|
|
749
|
-
});
|
|
750
|
-
if (snapshot.totalCount != null) {
|
|
751
|
-
draft.transactionCategorizationView[selectedTab].uiState.totalCount[periodId] = snapshot.totalCount;
|
|
752
|
-
}
|
|
753
|
-
if (snapshot.parentTotalCount != null) {
|
|
754
|
-
draft.parentTotalCountByTab[selectedTab][periodId] =
|
|
755
|
-
snapshot.parentTotalCount;
|
|
756
|
-
}
|
|
757
|
-
draft.transactionCategorizationView[selectedTab].uiState.searchString =
|
|
758
|
-
'';
|
|
759
|
-
draft.transactionCategorizationView[selectedTab].uiState.pageToken = null;
|
|
760
|
-
draft.transactionCategorizationView[selectedTab].fetchState = 'Completed';
|
|
761
|
-
draft.transactionCategorizationView[selectedTab].refreshStatus = {
|
|
762
|
-
fetchState: 'Not-Started',
|
|
763
|
-
error: undefined,
|
|
764
|
-
};
|
|
765
|
-
draft.transactionCategorizationView[selectedTab].error = undefined;
|
|
766
|
-
draft.transactionCategorizationView[selectedTab].fullDatasetSnapshot =
|
|
767
|
-
undefined;
|
|
768
|
-
},
|
|
769
704
|
fetchTransactionCategorizationFailure(draft, action) {
|
|
770
705
|
const { selectedTab, selectedPeriod } = action.payload;
|
|
771
706
|
draft.transactionCategorizationView[selectedTab].transactionIdsBySelectedPeriod[(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)] =
|
|
@@ -1094,7 +1029,6 @@ const expenseAutomationTransactionsView = (0, toolkit_1.createSlice)({
|
|
|
1094
1029
|
if (allReviewed) {
|
|
1095
1030
|
if (existsInReview) {
|
|
1096
1031
|
(0, transactionCategorizationLocalDataHelper_1.removeTransactionFromTabView)(reviewTabView, txnId);
|
|
1097
|
-
reviewTabView.fullDatasetSnapshot = undefined;
|
|
1098
1032
|
}
|
|
1099
1033
|
return;
|
|
1100
1034
|
}
|
|
@@ -1141,13 +1075,11 @@ const expenseAutomationTransactionsView = (0, toolkit_1.createSlice)({
|
|
|
1141
1075
|
reducer(draft, action) {
|
|
1142
1076
|
const { transactionId } = action.payload;
|
|
1143
1077
|
for (const tab of transactionsViewState_1.TRANSACTIONS_TABS) {
|
|
1144
|
-
|
|
1145
|
-
(0, transactionCategorizationLocalDataHelper_1.removeTransactionFromTabView)(tabView, transactionId);
|
|
1146
|
-
tabView.fullDatasetSnapshot = undefined;
|
|
1078
|
+
(0, transactionCategorizationLocalDataHelper_1.removeTransactionFromTabView)(draft.transactionCategorizationView[tab], transactionId);
|
|
1147
1079
|
}
|
|
1148
1080
|
},
|
|
1149
1081
|
},
|
|
1150
1082
|
},
|
|
1151
1083
|
});
|
|
1152
|
-
_a = expenseAutomationTransactionsView.actions, exports.fetchTransactionCategorization = _a.fetchTransactionCategorization, exports.updateTransactionCategorizationUIState = _a.updateTransactionCategorizationUIState, exports.updateTransactionFilters = _a.updateTransactionFilters, exports.initializeTransactionCategorizationViewLocalData = _a.initializeTransactionCategorizationViewLocalData, exports.saveTransactionCategorizationLocalData = _a.saveTransactionCategorizationLocalData, exports.fetchTransactionCategorizationFailure = _a.fetchTransactionCategorizationFailure, exports.saveTransactionCategorization = _a.saveTransactionCategorization, exports.updateTransactionCategorization = _a.updateTransactionCategorization, exports.updateCurrentSelectedTransactionCategorizationTab = _a.updateCurrentSelectedTransactionCategorizationTab, exports.updateTransactionCategorizationCompletedSubTab = _a.updateTransactionCategorizationCompletedSubTab, exports.updateTransactionCategorizationSaveStatus = _a.updateTransactionCategorizationSaveStatus, exports.markTransactionAsNotMiscategorized = _a.markTransactionAsNotMiscategorized, exports.updateStatusForTransactionNotMiscategorizedUpdateForCategorization = _a.updateStatusForTransactionNotMiscategorizedUpdateForCategorization, exports.updateSelectedVendorForTransaction = _a.updateSelectedVendorForTransaction, exports.updateSelectedCustomerForTransaction = _a.updateSelectedCustomerForTransaction, exports.setAllItemsToCategoryClassInLocalDataForCategorization = _a.setAllItemsToCategoryClassInLocalDataForCategorization, exports.updateTotalCountForTransactionCategorization = _a.updateTotalCountForTransactionCategorization, exports.updateParentTotalCountForTab = _a.updateParentTotalCountForTab, exports.fetchTransactionCategorizationSuccess = _a.fetchTransactionCategorizationSuccess, exports.resetOtherTabsFetchState = _a.resetOtherTabsFetchState, exports.
|
|
1084
|
+
_a = expenseAutomationTransactionsView.actions, exports.fetchTransactionCategorization = _a.fetchTransactionCategorization, exports.updateTransactionCategorizationUIState = _a.updateTransactionCategorizationUIState, exports.updateTransactionFilters = _a.updateTransactionFilters, exports.initializeTransactionCategorizationViewLocalData = _a.initializeTransactionCategorizationViewLocalData, exports.saveTransactionCategorizationLocalData = _a.saveTransactionCategorizationLocalData, exports.fetchTransactionCategorizationFailure = _a.fetchTransactionCategorizationFailure, exports.saveTransactionCategorization = _a.saveTransactionCategorization, exports.updateTransactionCategorization = _a.updateTransactionCategorization, exports.updateCurrentSelectedTransactionCategorizationTab = _a.updateCurrentSelectedTransactionCategorizationTab, exports.updateTransactionCategorizationCompletedSubTab = _a.updateTransactionCategorizationCompletedSubTab, exports.updateTransactionCategorizationSaveStatus = _a.updateTransactionCategorizationSaveStatus, exports.markTransactionAsNotMiscategorized = _a.markTransactionAsNotMiscategorized, exports.updateStatusForTransactionNotMiscategorizedUpdateForCategorization = _a.updateStatusForTransactionNotMiscategorizedUpdateForCategorization, exports.updateSelectedVendorForTransaction = _a.updateSelectedVendorForTransaction, exports.updateSelectedCustomerForTransaction = _a.updateSelectedCustomerForTransaction, exports.setAllItemsToCategoryClassInLocalDataForCategorization = _a.setAllItemsToCategoryClassInLocalDataForCategorization, exports.updateTotalCountForTransactionCategorization = _a.updateTotalCountForTransactionCategorization, exports.updateParentTotalCountForTab = _a.updateParentTotalCountForTab, exports.fetchTransactionCategorizationSuccess = _a.fetchTransactionCategorizationSuccess, exports.resetOtherTabsFetchState = _a.resetOtherTabsFetchState, exports.fetchTransactionCategorizationView = _a.fetchTransactionCategorizationView, exports.updateSelectedCheckboxTransactionIds = _a.updateSelectedCheckboxTransactionIds, exports.clearExpenseAutomationTransactionsViewPerTabView = _a.clearExpenseAutomationTransactionsViewPerTabView, exports.clearExpenseAutomationTransactionsView = _a.clearExpenseAutomationTransactionsView, exports.setEntityRecommendationForLineIdsForCategorization = _a.setEntityRecommendationForLineIdsForCategorization, exports.markCategoryClassRecommendationsInProgressForCategorization = _a.markCategoryClassRecommendationsInProgressForCategorization, exports.markCategoryClassRecommendationsCompletedForCategorization = _a.markCategoryClassRecommendationsCompletedForCategorization, exports.markCategoryClassRecommendationsFailureForCategorization = _a.markCategoryClassRecommendationsFailureForCategorization, exports.updateSelectedTransactionId = _a.updateSelectedTransactionId, exports.syncTransactionCategorizationFromDetailSave = _a.syncTransactionCategorizationFromDetailSave, exports.backgroundRefetchReviewTab = _a.backgroundRefetchReviewTab, exports.removeTransactionFromAllTabs = _a.removeTransactionFromAllTabs, exports.updateTransactionCategorizationUploadReceiptState = _a.updateTransactionCategorizationUploadReceiptState, exports.uploadTransactionCategorizationReceiptSuccess = _a.uploadTransactionCategorizationReceiptSuccess;
|
|
1153
1085
|
exports.default = expenseAutomationTransactionsView.reducer;
|
|
@@ -94,24 +94,8 @@ export interface SupportedTransactionCategorization {
|
|
|
94
94
|
transactionId?: ID;
|
|
95
95
|
}
|
|
96
96
|
export declare const initialSupportedTransactionCategorization: SupportedTransactionCategorization;
|
|
97
|
-
/**
|
|
98
|
-
* Snapshot of a tab's full (pre-search) dataset taken the moment the user
|
|
99
|
-
* first applies a non-empty search string. When the search is cleared the
|
|
100
|
-
* view epic restores from here instead of issuing a new API request.
|
|
101
|
-
*
|
|
102
|
-
* Only saved when there are actual rows to restore (`transactionIds` is
|
|
103
|
-
* non-empty); cleared once consumed or replaced by a fresh search.
|
|
104
|
-
*/
|
|
105
|
-
export interface FullDatasetSnapshot {
|
|
106
|
-
parentTotalCount: number | undefined;
|
|
107
|
-
periodId: MonthYearPeriodId;
|
|
108
|
-
totalCount: number | undefined;
|
|
109
|
-
transactionIds: ID[];
|
|
110
|
-
transactionReviewLocalDataById: Record<ID | TransactionDetailKey, SupportedTransactionCategorization>;
|
|
111
|
-
}
|
|
112
97
|
export interface TransactionsTabViewState extends FetchedState {
|
|
113
98
|
filters: TransactionFilters;
|
|
114
|
-
fullDatasetSnapshot: FullDatasetSnapshot | undefined;
|
|
115
99
|
markAsNotMiscategorizedStatus: FetchStateAndError;
|
|
116
100
|
refreshStatus: FetchStateAndError;
|
|
117
101
|
saveStatus: FetchStateAndError;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "5.1.20-
|
|
3
|
+
"version": "5.1.20-betaRD5",
|
|
4
4
|
"description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/esm/index.js",
|