@zeniai/client-epic-state 5.0.64-betaAR2 → 5.0.64-betaSS1

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.
Files changed (45) hide show
  1. package/lib/entity/account/accountSelector.d.ts +1 -20
  2. package/lib/entity/account/accountSelector.js +1 -35
  3. package/lib/entity/account/accountState.d.ts +0 -5
  4. package/lib/entity/account/accountState.js +4 -11
  5. package/lib/entity/class/classSelector.d.ts +0 -5
  6. package/lib/entity/class/classSelector.js +0 -8
  7. package/lib/esm/entity/account/accountSelector.js +1 -33
  8. package/lib/esm/entity/account/accountState.js +1 -7
  9. package/lib/esm/entity/class/classSelector.js +0 -7
  10. package/lib/esm/index.js +7 -12
  11. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +2 -1
  12. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +6 -0
  13. package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.js +11 -1
  14. package/lib/esm/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +2 -1
  15. package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +114 -11
  16. package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +28 -59
  17. package/lib/esm/view/expenseAutomationView/types/completedSubTab.js +17 -0
  18. package/lib/esm/view/expenseAutomationView/types/missingReceiptsViewState.js +0 -2
  19. package/lib/esm/view/spendManagement/spendManagementFilterHelpers.js +0 -2
  20. package/lib/index.d.ts +8 -9
  21. package/lib/index.js +39 -44
  22. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +2 -1
  23. package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +6 -0
  24. package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.d.ts +2 -2
  25. package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.js +10 -0
  26. package/lib/view/expenseAutomationView/payload/transactionCategorizationPayload.d.ts +21 -0
  27. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +2 -1
  28. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +2 -1
  29. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +9 -7
  30. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +115 -12
  31. package/lib/view/expenseAutomationView/selectorTypes/missingReceiptsSelectorTypes.d.ts +2 -1
  32. package/lib/view/expenseAutomationView/selectorTypes/transactionsViewSelectorTypes.d.ts +14 -0
  33. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.d.ts +1 -4
  34. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +28 -61
  35. package/lib/view/expenseAutomationView/types/completedSubTab.d.ts +10 -0
  36. package/lib/view/expenseAutomationView/types/completedSubTab.js +21 -0
  37. package/lib/view/expenseAutomationView/types/missingReceiptsViewState.d.ts +1 -2
  38. package/lib/view/expenseAutomationView/types/missingReceiptsViewState.js +1 -4
  39. package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +35 -3
  40. package/lib/view/spendManagement/spendManagementFilterHelpers.js +0 -2
  41. package/package.json +1 -1
  42. package/lib/esm/view/expenseAutomationView/transactionFilterHelpers.js +0 -186
  43. package/lib/tsconfig.typecheck.tsbuildinfo +0 -1
  44. package/lib/view/expenseAutomationView/transactionFilterHelpers.d.ts +0 -65
  45. package/lib/view/expenseAutomationView/transactionFilterHelpers.js +0 -190
@@ -14,7 +14,6 @@ import { ZeniAPIStatus } from '../../../responsePayload';
14
14
  import { UncategorizedAccounts } from '../../accountList/accountListSelector';
15
15
  import { UpdateTransactionCategorizationResponsePayload } from '../payload/transactionCategorizationPayload';
16
16
  import { SupportedTransactionCategorization, TransactionSaveUpdates, TransactionsTab, TransactionsTabViewState, TransactionsViewState, TransactionsViewUIState } from '../types/transactionsViewState';
17
- import { TransactionFilters } from '../transactionFilterHelpers';
18
17
  export declare const initialTransactionTabViewState: TransactionsTabViewState;
19
18
  export declare const initialState: TransactionsViewState;
20
19
  export declare const fetchTransactionCategorization: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[selectedTab: "review" | "autoCategorized", period: TimePeriod, cacheOverride?: any, keepExistingListItems?: any, searchString?: string | undefined, pageToken?: PageToken | undefined, refreshViewInBackground?: any, resetListItems?: boolean | undefined, isUncategorizedExpenseCategoryEnabled?: boolean | undefined], {
@@ -30,10 +29,7 @@ export declare const fetchTransactionCategorization: import("@reduxjs/toolkit").
30
29
  }, "expenseAutomationTransactionsView/fetchTransactionCategorization", never, never>, updateTransactionCategorizationUIState: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
31
30
  selectedTab: TransactionsTab;
32
31
  uiState: Partial<TransactionsViewUIState>;
33
- }, "expenseAutomationTransactionsView/updateTransactionCategorizationUIState">, updateTransactionFilters: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
34
- filters: TransactionFilters;
35
- selectedTab: TransactionsTab;
36
- }, "expenseAutomationTransactionsView/updateTransactionFilters">, initializeTransactionCategorizationViewLocalData: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[selectedTab: "review" | "autoCategorized", transactionIds: string[], selectedPeriod: MonthYearPeriod, keepExistingListItems: any, pageToken: PageToken, totalCount: number, lineItemsByTransactionIds: Record<string, string[]>, refreshViewInBackground?: any, isUncategorizedExpenseCategoryEnabled?: boolean | undefined], {
32
+ }, "expenseAutomationTransactionsView/updateTransactionCategorizationUIState">, initializeTransactionCategorizationViewLocalData: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[selectedTab: "review" | "autoCategorized", transactionIds: string[], selectedPeriod: MonthYearPeriod, keepExistingListItems: any, pageToken: PageToken, totalCount: number, lineItemsByTransactionIds: Record<string, string[]>, refreshViewInBackground?: any, isUncategorizedExpenseCategoryEnabled?: boolean | undefined], {
37
33
  selectedTab: "review" | "autoCategorized";
38
34
  transactionIds: string[];
39
35
  selectedPeriod: MonthYearPeriod;
@@ -69,7 +65,9 @@ export declare const fetchTransactionCategorization: import("@reduxjs/toolkit").
69
65
  isUncategorizedExpenseCategoryEnabled: boolean | undefined;
70
66
  }, "expenseAutomationTransactionsView/updateTransactionCategorization", never, never>, updateCurrentSelectedTransactionCategorizationTab: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[newSelectedTab: "review" | "autoCategorized"], {
71
67
  newSelectedTab: "review" | "autoCategorized";
72
- }, "expenseAutomationTransactionsView/updateCurrentSelectedTransactionCategorizationTab", never, never>, updateTransactionCategorizationSaveStatus: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[selectedTab: "review" | "autoCategorized", fetchState: FetchState, error?: ZeniAPIStatus<Record<string, unknown>> | undefined], {
68
+ }, "expenseAutomationTransactionsView/updateCurrentSelectedTransactionCategorizationTab", never, never>, updateTransactionCategorizationCompletedSubTab: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[newSubTab: "all" | "manual" | "ai_accountant"], {
69
+ newSubTab: "all" | "manual" | "ai_accountant";
70
+ }, "expenseAutomationTransactionsView/updateTransactionCategorizationCompletedSubTab", never, never>, updateTransactionCategorizationSaveStatus: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[selectedTab: "review" | "autoCategorized", fetchState: FetchState, error?: ZeniAPIStatus<Record<string, unknown>> | undefined], {
73
71
  selectedTab: "review" | "autoCategorized";
74
72
  fetchState: FetchState;
75
73
  error: ZeniAPIStatus<Record<string, unknown>> | undefined;
@@ -124,7 +122,11 @@ export declare const fetchTransactionCategorization: import("@reduxjs/toolkit").
124
122
  selectedPeriod: MonthYearPeriod;
125
123
  selectedTab: TransactionsTab;
126
124
  totalCount: number;
127
- }, "expenseAutomationTransactionsView/updateTotalCountForTransactionCategorization">, fetchTransactionCategorizationSuccess: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
125
+ }, "expenseAutomationTransactionsView/updateTotalCountForTransactionCategorization">, updateParentTotalCountForTab: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
126
+ parentTotalCount: number;
127
+ selectedPeriod: MonthYearPeriod;
128
+ selectedTab: TransactionsTab;
129
+ }, "expenseAutomationTransactionsView/updateParentTotalCountForTab">, fetchTransactionCategorizationSuccess: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
128
130
  selectedTab: TransactionsTab;
129
131
  status: ZeniAPIStatus;
130
132
  refreshViewInBackground?: boolean;
@@ -4,13 +4,14 @@ 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.backgroundRefetchReviewTab = exports.syncTransactionCategorizationFromDetailSave = exports.updateSelectedTransactionId = exports.setEntityRecommendationForLineIdsForCategorization = exports.clearExpenseAutomationTransactionsView = exports.clearExpenseAutomationTransactionsViewPerTabView = exports.updateSelectedCheckboxTransactionIds = exports.fetchTransactionCategorizationView = exports.resetOtherTabsFetchState = exports.fetchTransactionCategorizationSuccess = exports.updateTotalCountForTransactionCategorization = exports.setAllItemsToCategoryClassInLocalDataForCategorization = exports.updateSelectedCustomerForTransaction = exports.updateSelectedVendorForTransaction = exports.updateStatusForTransactionNotMiscategorizedUpdateForCategorization = exports.markTransactionAsNotMiscategorized = exports.updateTransactionCategorizationSaveStatus = exports.updateCurrentSelectedTransactionCategorizationTab = exports.updateTransactionCategorization = exports.saveTransactionCategorization = exports.fetchTransactionCategorizationFailure = exports.saveTransactionCategorizationLocalData = exports.initializeTransactionCategorizationViewLocalData = exports.updateTransactionFilters = exports.updateTransactionCategorizationUIState = exports.fetchTransactionCategorization = exports.initialState = exports.initialTransactionTabViewState = void 0;
7
+ exports.uploadTransactionCategorizationReceiptSuccess = exports.updateTransactionCategorizationUploadReceiptState = exports.backgroundRefetchReviewTab = exports.syncTransactionCategorizationFromDetailSave = exports.updateSelectedTransactionId = 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.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"));
11
11
  const timePeriod_1 = require("../../../commonStateTypes/timePeriod");
12
12
  const vendorTransaction_1 = require("../../../entity/transaction/stateTypes/vendorTransaction");
13
13
  const transactionCategorizationLocalDataHelper_1 = require("../helpers/transactionCategorizationLocalDataHelper");
14
+ const completedSubTab_1 = require("../types/completedSubTab");
14
15
  exports.initialTransactionTabViewState = {
15
16
  saveStatus: {
16
17
  fetchState: 'Not-Started',
@@ -34,10 +35,6 @@ exports.initialTransactionTabViewState = {
34
35
  totalCount: {},
35
36
  limit: 10,
36
37
  },
37
- filters: {
38
- categoryCombinationOperator: 'AND',
39
- categories: [],
40
- },
41
38
  fetchState: 'Not-Started',
42
39
  error: undefined,
43
40
  hasValidState() {
@@ -52,12 +49,68 @@ exports.initialTransactionTabViewState = {
52
49
  selectedTransactionLineId: undefined,
53
50
  };
54
51
  exports.initialState = {
52
+ autoCategorizedSubTabCache: {},
53
+ parentTotalCountByTab: {
54
+ review: {},
55
+ autoCategorized: {},
56
+ },
55
57
  selectedTransactionCategorizationTab: 'review',
58
+ selectedTransactionCategorizationCompletedSubTab: completedSubTab_1.DEFAULT_COMPLETED_SUB_TAB,
56
59
  transactionCategorizationView: {
57
60
  review: { ...exports.initialTransactionTabViewState },
58
61
  autoCategorized: { ...exports.initialTransactionTabViewState },
59
62
  },
60
63
  };
64
+ /**
65
+ * Capture the autoCategorized tab's current paginated dataset for a sub-tab.
66
+ * The mid-flight `'In-Progress'` state is normalised to `'Completed'` because
67
+ * the in-flight request is cancelled by `switchMap` in the fetch epic when the
68
+ * sub-tab changes — restoring `'In-Progress'` later would leave the UI stuck
69
+ * showing a phantom loading state with no fetch actually running. Length-zero
70
+ * datasets degrade to `'Not-Started'` so the next visit triggers a fresh
71
+ * fetch from page 1 instead of short-circuiting on stale empty caches.
72
+ *
73
+ * Snapshot scope (deliberately narrow):
74
+ * - Captured: `pageToken`, `totalCount`, `transactionIdsBySelectedPeriod`,
75
+ * `fetchState`, `error`. These are the keys the fetch epic's cache check
76
+ * reads to decide whether to short-circuit a sub-tab revisit.
77
+ * - Intentionally NOT captured (left in place on `autoCat` and inherited by
78
+ * the incoming sub-tab):
79
+ * - `uiState.searchString`, `uiState.sortKey`, `uiState.sortOrder`,
80
+ * `uiState.scrollPosition`, `uiState.nodeCollapseState`,
81
+ * `uiState.limit` — search and sort are user-applied preferences that
82
+ * persist across sub-tabs by design (a search query stays active when
83
+ * the user toggles between Manual / AI Accountant).
84
+ * - `selectedCheckBoxTransactionIds` — selection state is intentionally
85
+ * cleared at the action source (the fetch epic / save flow), not
86
+ * by the snapshot path. Carrying selection across sub-tabs is safe
87
+ * because every sub-tab change goes through a fetch round-trip that
88
+ * reconciles selection against the new row IDs.
89
+ * - `transactionReviewLocalDataById`, `transactionIdsWithUnsavedData`,
90
+ * `uploadReceiptStatusById`, `saveStatus`, `refreshStatus`,
91
+ * `markAsNotMiscategorizedStatus` — these are per-row / per-flight
92
+ * caches that are write-through global state, not sub-tab-scoped.
93
+ *
94
+ * If the contract changes (e.g. selection should reset on every sub-tab
95
+ * switch), update both this comment and the snapshot return shape together.
96
+ */
97
+ function snapshotAutoCategorizedTab(autoCat) {
98
+ const transactionIdsBySelectedPeriod = {
99
+ ...autoCat.transactionIdsBySelectedPeriod,
100
+ };
101
+ const hasAnyLoadedRows = Object.values(transactionIdsBySelectedPeriod).some((ids) => ids.length > 0);
102
+ let normalisedFetchState = autoCat.fetchState;
103
+ if (normalisedFetchState === 'In-Progress') {
104
+ normalisedFetchState = hasAnyLoadedRows ? 'Completed' : 'Not-Started';
105
+ }
106
+ return {
107
+ error: autoCat.error,
108
+ fetchState: normalisedFetchState,
109
+ pageToken: autoCat.uiState.pageToken,
110
+ totalCount: { ...autoCat.uiState.totalCount },
111
+ transactionIdsBySelectedPeriod,
112
+ };
113
+ }
61
114
  const expenseAutomationTransactionsView = (0, toolkit_1.createSlice)({
62
115
  name: 'expenseAutomationTransactionsView',
63
116
  initialState: exports.initialState,
@@ -247,12 +300,6 @@ const expenseAutomationTransactionsView = (0, toolkit_1.createSlice)({
247
300
  uiState.totalCount;
248
301
  }
249
302
  },
250
- updateTransactionFilters(draft, action) {
251
- const { selectedTab, filters } = action.payload;
252
- if (filters != null) {
253
- draft.transactionCategorizationView[selectedTab].filters = filters;
254
- }
255
- },
256
303
  saveTransactionCategorization: {
257
304
  prepare(selectedTab, transactionIds, cotTrackingByTransactionId, isUncategorizedExpenseCategoryEnabled) {
258
305
  return {
@@ -277,6 +324,48 @@ const expenseAutomationTransactionsView = (0, toolkit_1.createSlice)({
277
324
  return { payload: { newSelectedTab } };
278
325
  },
279
326
  },
327
+ updateTransactionCategorizationCompletedSubTab: {
328
+ reducer(draft, action) {
329
+ const { newSubTab } = action.payload;
330
+ const previousSubTab = draft.selectedTransactionCategorizationCompletedSubTab;
331
+ if (previousSubTab === newSubTab) {
332
+ return;
333
+ }
334
+ const autoCat = draft.transactionCategorizationView.autoCategorized;
335
+ // Snapshot the outgoing sub-tab so a future revisit can short-circuit
336
+ // the fetch epic (mirrors the parent-tab "don't refetch what's
337
+ // already cached" behaviour). Period-scoped data is preserved as-is
338
+ // because the snapshot itself is keyed only by sub-tab; the active
339
+ // tab's per-period maps remain the source of truth while live.
340
+ draft.autoCategorizedSubTabCache[previousSubTab] =
341
+ snapshotAutoCategorizedTab(autoCat);
342
+ const cached = draft.autoCategorizedSubTabCache[newSubTab];
343
+ if (cached != null) {
344
+ autoCat.uiState.pageToken = cached.pageToken;
345
+ autoCat.uiState.totalCount = { ...cached.totalCount };
346
+ autoCat.transactionIdsBySelectedPeriod = {
347
+ ...cached.transactionIdsBySelectedPeriod,
348
+ };
349
+ autoCat.fetchState = cached.fetchState;
350
+ autoCat.error = cached.error;
351
+ }
352
+ else {
353
+ // Sub-tab has never been visited — clear the active slot so the
354
+ // view-epic's `fetchState === 'Not-Started' || transactionIds.length
355
+ // === 0` cache check falls through and triggers a fresh page-1
356
+ // fetch for the new dataset.
357
+ autoCat.uiState.pageToken = null;
358
+ autoCat.uiState.totalCount = {};
359
+ autoCat.transactionIdsBySelectedPeriod = {};
360
+ autoCat.fetchState = 'Not-Started';
361
+ autoCat.error = undefined;
362
+ }
363
+ draft.selectedTransactionCategorizationCompletedSubTab = newSubTab;
364
+ },
365
+ prepare(newSubTab) {
366
+ return { payload: { newSubTab } };
367
+ },
368
+ },
280
369
  updateTransactionCategorization: {
281
370
  reducer(draft, action) {
282
371
  const selectedTab = action.payload.selectedTab;
@@ -714,6 +803,10 @@ const expenseAutomationTransactionsView = (0, toolkit_1.createSlice)({
714
803
  const { selectedTab, selectedPeriod, totalCount } = action.payload;
715
804
  draft.transactionCategorizationView[selectedTab].uiState.totalCount[(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)] = totalCount;
716
805
  },
806
+ updateParentTotalCountForTab(draft, action) {
807
+ const { selectedTab, selectedPeriod, parentTotalCount } = action.payload;
808
+ draft.parentTotalCountByTab[selectedTab][(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)] = parentTotalCount;
809
+ },
717
810
  updateSelectedCheckboxTransactionIds(draft, action) {
718
811
  const selectedTab = action.payload.selectedTab;
719
812
  const transactionIds = action.payload.transactionIds;
@@ -724,6 +817,16 @@ const expenseAutomationTransactionsView = (0, toolkit_1.createSlice)({
724
817
  draft.transactionCategorizationView[selectedTab] = {
725
818
  ...exports.initialTransactionTabViewState,
726
819
  };
820
+ draft.parentTotalCountByTab[selectedTab] = {};
821
+ // The per-sub-tab snapshot cache lives at the slice root and is
822
+ // exclusively populated by the autoCategorized tab's sub-tab switching
823
+ // (see updateTransactionCategorizationCompletedSubTab). When that tab
824
+ // is reset, leaving stale snapshots behind would short-circuit the
825
+ // next sub-tab visit with phantom row IDs / page tokens that no longer
826
+ // correspond to anything in state — drop them in lockstep.
827
+ if (selectedTab === 'autoCategorized') {
828
+ draft.autoCategorizedSubTabCache = {};
829
+ }
727
830
  },
728
831
  clearExpenseAutomationTransactionsView(draft) {
729
832
  Object.assign(draft, exports.initialState);
@@ -820,5 +923,5 @@ const expenseAutomationTransactionsView = (0, toolkit_1.createSlice)({
820
923
  },
821
924
  },
822
925
  });
823
- _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.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.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.updateSelectedTransactionId = _a.updateSelectedTransactionId, exports.syncTransactionCategorizationFromDetailSave = _a.syncTransactionCategorizationFromDetailSave, exports.backgroundRefetchReviewTab = _a.backgroundRefetchReviewTab, exports.updateTransactionCategorizationUploadReceiptState = _a.updateTransactionCategorizationUploadReceiptState, exports.uploadTransactionCategorizationReceiptSuccess = _a.uploadTransactionCategorizationReceiptSuccess;
926
+ _a = expenseAutomationTransactionsView.actions, exports.fetchTransactionCategorization = _a.fetchTransactionCategorization, exports.updateTransactionCategorizationUIState = _a.updateTransactionCategorizationUIState, 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.updateSelectedTransactionId = _a.updateSelectedTransactionId, exports.syncTransactionCategorizationFromDetailSave = _a.syncTransactionCategorizationFromDetailSave, exports.backgroundRefetchReviewTab = _a.backgroundRefetchReviewTab, exports.updateTransactionCategorizationUploadReceiptState = _a.updateTransactionCategorizationUploadReceiptState, exports.uploadTransactionCategorizationReceiptSuccess = _a.uploadTransactionCategorizationReceiptSuccess;
824
927
  exports.default = expenseAutomationTransactionsView.reducer;
@@ -2,7 +2,8 @@ import { CompletionStatusType, FetchStateAndError, ID } from '../../../commonSta
2
2
  import { SortOrder } from '../../../commonStateTypes/selectorTypes/sortOrderTypes';
3
3
  import { SelectorView } from '../../../commonStateTypes/viewAndReport/viewAndReport';
4
4
  import { SupportedTransaction } from '../../../entity/transaction/transactionState';
5
- import type { BatchFileStatus, BatchListItem, BatchStatus, BulkUploadPhase, BulkUploadResultsTab, BulkUploadSortKey, CompletedSubTab, ManualSearchState, MatchSource, MissingReceiptsViewUIState } from '../types/missingReceiptsViewState';
5
+ import type { CompletedSubTab } from '../types/completedSubTab';
6
+ import type { BatchFileStatus, BatchListItem, BatchStatus, BulkUploadPhase, BulkUploadResultsTab, BulkUploadSortKey, ManualSearchState, MatchSource, MissingReceiptsViewUIState } from '../types/missingReceiptsViewState';
6
7
  export interface CompletedTransactionsSelectorData {
7
8
  fetchState: FetchStateAndError;
8
9
  nextPageToken: string | null;
@@ -7,6 +7,7 @@ import { ClassBase } from '../../../entity/class/classState';
7
7
  import { SupportedTransactionWithCOT } from '../../../entity/transaction/transactionState';
8
8
  import { UncategorizedAccounts } from '../../accountList/accountListSelector';
9
9
  import { ProjectListSelectorView } from '../../projectList/projectListSelector';
10
+ import { CompletedSubTab } from '../types/completedSubTab';
10
11
  import { TransactionReviewLocalData, TransactionsTab, TransactionsViewUIState } from '../types/transactionsViewState';
11
12
  export interface TransactionReviewLocalDataSelectorView {
12
13
  transactionId: ID;
@@ -21,10 +22,23 @@ export interface ExpenseAutomationTransactionViewSelector extends SelectorView {
21
22
  fetchStateByTransactionTabs: Record<TransactionsTab, FetchStateAndError>;
22
23
  isAccountingProjectsEnabled: boolean;
23
24
  markAsNotMiscategorizedStatus: FetchStateAndError;
25
+ /**
26
+ * Parent tab badge counts, sourced from the listing response's
27
+ * `parent_tab_total_count`. Used exclusively to drive the navbar / tab
28
+ * strip badge labels — every other count consumer (pagination, in-list
29
+ * "showing X of Y", save flows) keeps reading {@link totalCountByTab}.
30
+ */
31
+ parentTabTotalCountByTab: Record<TransactionsTab, number>;
24
32
  projectList: ProjectListSelectorView;
25
33
  refreshStatus: FetchStateAndError;
26
34
  saveStatus: FetchStateAndError;
27
35
  selectedCheckBoxTransactionIds: ID[];
36
+ selectedTransactionCategorizationCompletedSubTab: CompletedSubTab;
37
+ /**
38
+ * Per-(sub-)tab counts mirroring `total_count` from the listing response.
39
+ * Powers pagination via `InfiniteLoader.itemCount`, in-list count copy,
40
+ * and the `resetTransactionCategorizationLocalData` round-trip.
41
+ */
28
42
  totalCountByTab: Record<TransactionsTab, number>;
29
43
  transactionIdsWithUnsavedData: ID[];
30
44
  transactionLocalData: TransactionReviewLocalDataSelectorView[];
@@ -1,6 +1,3 @@
1
- import { TransactionWithCOT } from '../../../entity/transaction/stateTypes/transaction';
2
1
  import { RootState } from '../../../reducer';
3
- import { TransactionView } from '../transactionFilterHelpers';
4
- import { ExpenseAutomationTransactionViewSelector, TransactionReviewLocalDataSelectorView } from '../selectorTypes/transactionsViewSelectorTypes';
5
- export declare const toTransactionView: (transaction: TransactionWithCOT, transactionLocalData?: TransactionReviewLocalDataSelectorView) => TransactionView;
2
+ import { ExpenseAutomationTransactionViewSelector } from '../selectorTypes/transactionsViewSelectorTypes';
6
3
  export declare function getExpenseAutomationTransactionView(state: RootState): ExpenseAutomationTransactionViewSelector;
@@ -3,7 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.toTransactionView = void 0;
7
6
  exports.getExpenseAutomationTransactionView = getExpenseAutomationTransactionView;
8
7
  const omit_1 = __importDefault(require("lodash/omit"));
9
8
  const reduceFetchState_1 = require("../../../commonStateTypes/reduceFetchState");
@@ -11,34 +10,14 @@ const timePeriod_1 = require("../../../commonStateTypes/timePeriod");
11
10
  const tenantSelector_1 = require("../../../entity/tenant/tenantSelector");
12
11
  const transactionHelper_1 = require("../../../entity/transaction/transactionHelper");
13
12
  const transactionSelector_1 = require("../../../entity/transaction/transactionSelector");
14
- const transactionFilterHelpers_1 = require("../transactionFilterHelpers");
15
13
  const accountListSelector_1 = require("../../accountList/accountListSelector");
16
14
  const classListSelector_1 = require("../../classList/classListSelector");
17
15
  const projectListSelector_1 = require("../../projectList/projectListSelector");
18
16
  const expenseAutomationViewSelectorTypes_1 = require("../selectorTypes/expenseAutomationViewSelectorTypes");
19
- const toTransactionView = (transaction, transactionLocalData) => {
20
- return {
21
- id: transaction.id,
22
- date: transaction.date,
23
- amount: transaction.amount,
24
- vendorName: transaction.vendorName,
25
- customerName: transaction.customerName,
26
- vendorId: transaction.vendorId,
27
- customerId: transaction.customerId,
28
- description: transaction.description,
29
- memo: transaction.memo,
30
- type: transaction.type,
31
- typeName: transaction.typeName,
32
- createTime: transaction.createTime,
33
- transaction: transaction,
34
- transactionLocalData,
35
- };
36
- };
37
- exports.toTransactionView = toTransactionView;
38
17
  function getExpenseAutomationTransactionView(state) {
39
18
  const { accountState, classState, classListState, accountListState, expenseAutomationTransactionsViewState, expenseAutomationViewState, projectState, projectListState, transactionState, monthEndCloseChecksState, monthEndCloseChecksViewState, } = state;
40
- const { selectedTransactionCategorizationTab } = expenseAutomationTransactionsViewState;
41
- const { uiState, refreshStatus, saveStatus, markAsNotMiscategorizedStatus, transactionIdsBySelectedPeriod, transactionReviewLocalDataById, selectedCheckBoxTransactionIds, transactionIdsWithUnsavedData, uploadReceiptStatusById, selectedTransactionId, selectedTransactionLineId, filters, } = expenseAutomationTransactionsViewState.transactionCategorizationView[selectedTransactionCategorizationTab];
19
+ const { selectedTransactionCategorizationCompletedSubTab, selectedTransactionCategorizationTab, } = expenseAutomationTransactionsViewState;
20
+ const { uiState, refreshStatus, saveStatus, markAsNotMiscategorizedStatus, transactionIdsBySelectedPeriod, transactionReviewLocalDataById, selectedCheckBoxTransactionIds, transactionIdsWithUnsavedData, uploadReceiptStatusById, selectedTransactionId, selectedTransactionLineId, } = expenseAutomationTransactionsViewState.transactionCategorizationView[selectedTransactionCategorizationTab];
42
21
  const uncategorizedIncomeExpense = (0, accountListSelector_1.getUncategorizedAccounts)(accountState, accountListState, 'accountList');
43
22
  const accountList = (0, accountListSelector_1.getAccountList)(accountState, accountListState, 'accountList');
44
23
  const classList = (0, classListSelector_1.getClassList)(classState, classListState);
@@ -57,43 +36,10 @@ function getExpenseAutomationTransactionView(state) {
57
36
  ? transactionIdsBySelectedPeriod[monthYearPeriodId]
58
37
  : null;
59
38
  const transactionIds = transactionIdsForSelectedPeriod ?? [];
60
- const transactions = (0, transactionSelector_1.getSupportedTransactionsByIds)(transactionState, transactionIds);
61
- const transactionsWithCOT = transactions.map((transaction) => (0, transactionHelper_1.getTransactionWithCOT)(transaction));
62
- const transactionLocalDataMap = new Map();
63
- transactionIds.forEach((transactionId) => {
64
- const transactionData = transactionReviewLocalDataById[transactionId];
65
- if (transactionData != null) {
66
- transactionLocalDataMap.set(transactionId, {
67
- transactionId,
68
- transactionReviewLocalData: transactionData.transactionReviewLocalData,
69
- });
70
- }
71
- });
72
- // Step 2: Convert to TransactionView and apply advanced filters
73
- const transactionViews = transactionsWithCOT.map((transaction) => {
74
- const localData = transactionLocalDataMap.get(transaction.id);
75
- return (0, exports.toTransactionView)(transaction, localData);
76
- });
77
- // Apply TC-specific filters (lives under expenseAutomationView, independent
78
- // of the Spend Management filter pipeline).
79
- const filteredTransactionViews = (0, transactionFilterHelpers_1.applyTransactionFilters)(transactionViews, filters);
80
- // Convert back to TransactionWithCOT for return
81
- const filteredTransactionsWithCOT = filteredTransactionViews.map((view) => view.transaction);
82
- // Get transactionLocalData for filtered transactions
83
- // Also include transactionLocalData for transactions that don't exist in transactionState
84
- // but have local data (to match original behavior)
85
- const filteredTransactionIds = new Set(filteredTransactionViews.map((view) => view.id));
86
- const filteredTransactionLocalData = transactionIds
39
+ const transactionLocalData = transactionIds
87
40
  .map((transactionId) => {
88
41
  const transactionData = transactionReviewLocalDataById[transactionId];
89
- if (transactionData == null) {
90
- return null;
91
- }
92
- // Include if transaction is in filtered results, or if transaction doesn't exist in state
93
- // (to maintain backward compatibility with tests)
94
- const transactionExists = transactions.some((t) => t.id === transactionId);
95
- if (filteredTransactionIds.has(transactionId) ||
96
- !transactionExists) {
42
+ if (transactionData != null) {
97
43
  return {
98
44
  transactionId,
99
45
  transactionReviewLocalData: transactionData.transactionReviewLocalData,
@@ -101,7 +47,9 @@ function getExpenseAutomationTransactionView(state) {
101
47
  }
102
48
  return null;
103
49
  })
104
- .filter((data) => data != null);
50
+ .filter((transaction) => transaction != null);
51
+ const transactions = (0, transactionSelector_1.getSupportedTransactionsByIds)(transactionState, transactionIds);
52
+ const transactionsWithCOT = transactions.map((transaction) => (0, transactionHelper_1.getTransactionWithCOT)(transaction));
105
53
  const monthEndFetchState = monthYearPeriodId != null
106
54
  ? (monthEndCloseChecksViewState.monthEndCloseChecksViewByTenantId[currentTenant.tenantId]?.[monthYearPeriodId] ?? { fetchState: 'Not-Started', error: undefined })
107
55
  : { fetchState: 'Not-Started', error: undefined };
@@ -121,10 +69,27 @@ function getExpenseAutomationTransactionView(state) {
121
69
  .uiState.totalCount;
122
70
  const totalCountByAutoCat = expenseAutomationTransactionsViewState.transactionCategorizationView
123
71
  .autoCategorized.uiState.totalCount;
72
+ // Per-(sub-)tab counts powering pagination, in-list "showing X of Y", and
73
+ // any save/refresh round-trips. Sourced from `uiState.totalCount` which
74
+ // mirrors the response's `total_count` for whatever tab/sub-tab the user is
75
+ // viewing (e.g. only the Manual sub-tab rows for Completed → Manual).
124
76
  const totalCountByTab = {
125
77
  review: monthYearPeriodId != null ? totalCountByReview[monthYearPeriodId] : 0,
126
78
  autoCategorized: monthYearPeriodId != null ? totalCountByAutoCat[monthYearPeriodId] : 0,
127
79
  };
80
+ // Parent-tab badge counts. Sourced from `parent_tab_total_count` in the
81
+ // listing response and used exclusively by the navbar / tab strip badges.
82
+ // Independent of which Completed sub-tab is active so the badge stays
83
+ // stable across sub-tab switches.
84
+ const parentTotalCountByTab = expenseAutomationTransactionsViewState.parentTotalCountByTab;
85
+ const parentTabTotalCountByTab = {
86
+ review: monthYearPeriodId != null
87
+ ? (parentTotalCountByTab.review[monthYearPeriodId] ?? 0)
88
+ : 0,
89
+ autoCategorized: monthYearPeriodId != null
90
+ ? (parentTotalCountByTab.autoCategorized[monthYearPeriodId] ?? 0)
91
+ : 0,
92
+ };
128
93
  const fetchStateByTab = {
129
94
  review: {
130
95
  fetchState: expenseAutomationTransactionsViewState.transactionCategorizationView
@@ -148,7 +113,7 @@ function getExpenseAutomationTransactionView(state) {
148
113
  version: 0,
149
114
  fetchState: fetchStatus.fetchState,
150
115
  error: fetchStatus.error,
151
- transactions: filteredTransactionsWithCOT,
116
+ transactions: transactionsWithCOT,
152
117
  selectedCheckBoxTransactionIds,
153
118
  transactionIdsWithUnsavedData,
154
119
  uncategorizedAccounts: uncategorizedIncomeExpense,
@@ -159,16 +124,18 @@ function getExpenseAutomationTransactionView(state) {
159
124
  classHierarchyList,
160
125
  isAccountingProjectsEnabled,
161
126
  projectList,
162
- transactionLocalData: filteredTransactionLocalData,
127
+ transactionLocalData,
163
128
  uiState,
164
129
  refreshStatus,
165
130
  saveStatus,
166
131
  markAsNotMiscategorizedStatus,
167
132
  completionStatus,
168
133
  totalCountByTab,
134
+ parentTabTotalCountByTab,
169
135
  fetchStateByTransactionTabs: fetchStateByTab,
170
136
  uploadReceiptStatusById,
171
137
  selectedTransactionId,
172
138
  selectedTransactionLineId,
139
+ selectedTransactionCategorizationCompletedSubTab,
173
140
  };
174
141
  }
@@ -0,0 +1,10 @@
1
+ export declare const toCompletedSubTab: (v: string) => "all" | "manual" | "ai_accountant";
2
+ export type CompletedSubTab = ReturnType<typeof toCompletedSubTab>;
3
+ /**
4
+ * "No sub-tab filter" sentinel — single source of truth for the default
5
+ * value of {@link CompletedSubTab}. Use this constant in initial slice
6
+ * state and at any call site that needs to fall back to the parent-tab
7
+ * listing semantics (review tab requests, manual-search overrides, etc.)
8
+ * so a future rename of the union doesn't require chasing literals.
9
+ */
10
+ export declare const DEFAULT_COMPLETED_SUB_TAB: CompletedSubTab;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_COMPLETED_SUB_TAB = exports.toCompletedSubTab = void 0;
4
+ const stringToUnion_1 = require("../../../commonStateTypes/stringToUnion");
5
+ /**
6
+ * Sub-tabs that can appear under any "Completed" tab in the Expense Automation
7
+ * surface (Transaction Categorization Completed and Missing Receipts Completed
8
+ * both use this exact union). Forwarded verbatim to listing APIs as `sub_tab`
9
+ * / `match_type`. `'all'` preserves parent-tab semantics on the backend.
10
+ */
11
+ const COMPLETED_SUB_TABS = ['all', 'ai_accountant', 'manual'];
12
+ const toCompletedSubTab = (v) => (0, stringToUnion_1.stringToUnion)(v.trim().toLowerCase(), COMPLETED_SUB_TABS);
13
+ exports.toCompletedSubTab = toCompletedSubTab;
14
+ /**
15
+ * "No sub-tab filter" sentinel — single source of truth for the default
16
+ * value of {@link CompletedSubTab}. Use this constant in initial slice
17
+ * state and at any call site that needs to fall back to the parent-tab
18
+ * listing semantics (review tab requests, manual-search overrides, etc.)
19
+ * so a future rename of the union doesn't require chasing literals.
20
+ */
21
+ exports.DEFAULT_COMPLETED_SUB_TAB = 'all';
@@ -1,6 +1,7 @@
1
1
  import { FetchStateAndError, FetchedState, ID } from '../../../commonStateTypes/common';
2
2
  import { SortOrder } from '../../../commonStateTypes/selectorTypes/sortOrderTypes';
3
3
  import { MonthYearPeriodId } from '../../../commonStateTypes/timePeriod';
4
+ import { CompletedSubTab } from './completedSubTab';
4
5
  export declare const toMissingReceiptsSortKey: (v: string) => "date" | "amount" | "vendor" | "category" | "class";
5
6
  export type MissingReceiptsSortKey = ReturnType<typeof toMissingReceiptsSortKey>;
6
7
  export interface MissingReceiptsViewUIState {
@@ -31,8 +32,6 @@ export declare const toBulkUploadResultsTab: (v: string) => "completed" | "unmat
31
32
  export type BulkUploadResultsTab = ReturnType<typeof toBulkUploadResultsTab>;
32
33
  export declare const toMissingReceiptsTab: (v: string) => "completed" | "unmatched" | "missing";
33
34
  export type MissingReceiptsTab = ReturnType<typeof toMissingReceiptsTab>;
34
- export declare const toCompletedSubTab: (v: string) => "all" | "manual" | "ai_accountant";
35
- export type CompletedSubTab = ReturnType<typeof toCompletedSubTab>;
36
35
  export declare const toMatchSource: (v: string) => "manual" | "ai";
37
36
  export type MatchSource = ReturnType<typeof toMatchSource>;
38
37
  export declare const toBulkUploadSortKey: (v: string) => "date" | "amount" | "vendor" | "category" | "class";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toBulkUploadSortKey = exports.toMatchSource = exports.toCompletedSubTab = exports.toMissingReceiptsTab = exports.toBulkUploadResultsTab = exports.toBulkUploadPhase = exports.toBatchFileStatus = exports.BATCH_FILE_STATUSES = exports.toBatchStatusValue = exports.MIN_MANUAL_TRANSACTION_SEARCH_LENGTH = exports.toMissingReceiptsSortKey = void 0;
3
+ exports.toBulkUploadSortKey = exports.toMatchSource = exports.toMissingReceiptsTab = exports.toBulkUploadResultsTab = exports.toBulkUploadPhase = exports.toBatchFileStatus = exports.BATCH_FILE_STATUSES = exports.toBatchStatusValue = exports.MIN_MANUAL_TRANSACTION_SEARCH_LENGTH = exports.toMissingReceiptsSortKey = void 0;
4
4
  exports.isUnmatchedTabFileStatus = isUnmatchedTabFileStatus;
5
5
  const stringToUnion_1 = require("../../../commonStateTypes/stringToUnion");
6
6
  const MISSING_RECEIPTS_SORT_KEYS = [
@@ -49,9 +49,6 @@ exports.toBulkUploadResultsTab = toBulkUploadResultsTab;
49
49
  const MISSING_RECEIPTS_TABS = ['missing', 'completed', 'unmatched'];
50
50
  const toMissingReceiptsTab = (v) => (0, stringToUnion_1.stringToUnion)(v.trim().toLowerCase(), MISSING_RECEIPTS_TABS);
51
51
  exports.toMissingReceiptsTab = toMissingReceiptsTab;
52
- const COMPLETED_SUB_TABS = ['all', 'ai_accountant', 'manual'];
53
- const toCompletedSubTab = (v) => (0, stringToUnion_1.stringToUnion)(v.trim().toLowerCase(), COMPLETED_SUB_TABS);
54
- exports.toCompletedSubTab = toCompletedSubTab;
55
52
  const MATCH_SOURCES = ['ai', 'manual'];
56
53
  const toMatchSource = (v) => (0, stringToUnion_1.stringToUnion)(v.trim().toLowerCase(), MATCH_SOURCES);
57
54
  exports.toMatchSource = toMatchSource;
@@ -1,5 +1,5 @@
1
1
  import { Amount } from '../../../commonStateTypes/amount';
2
- import { FetchStateAndError, FetchedState, ID } from '../../../commonStateTypes/common';
2
+ import { FetchState, FetchStateAndError, FetchedState, ID } from '../../../commonStateTypes/common';
3
3
  import { Recommendation, RecommendationWithCOT } from '../../../commonStateTypes/recommendationBase';
4
4
  import { SortOrder } from '../../../commonStateTypes/selectorTypes/sortOrderTypes';
5
5
  import { MonthYearPeriodId } from '../../../commonStateTypes/timePeriod';
@@ -13,10 +13,11 @@ import { TransactionID } from '../../../entity/transaction/stateTypes/transactio
13
13
  import { BillableStatus, CategorizationStatusType, PlatformLineDetailType, ProductOrService, TransactionLineBase } from '../../../entity/transaction/stateTypes/transactionLine';
14
14
  import { TransactionCategory, TransactionType } from '../../../entity/transaction/stateTypes/transactionType';
15
15
  import { VendorBase } from '../../../entity/vendor/vendorState';
16
+ import { ZeniAPIStatus } from '../../../responsePayload';
16
17
  import { ZeniDate } from '../../../zeniDayJS';
17
18
  import { EntityRecommendationKey } from '../../recommendation/recommendationState';
18
- import { TransactionFilters } from '../transactionFilterHelpers';
19
19
  import { TransactionDetailKey } from '../../transactionDetail/transactionDetailState';
20
+ import { CompletedSubTab } from './completedSubTab';
20
21
  export declare const toTransactionsSortKey: (v: string) => "date" | "amount" | "vendor" | "project" | "category" | "class" | "payment_account" | "transaction_type" | "memo_and_receipt";
21
22
  export type TransactionsSortKey = ReturnType<typeof toTransactionsSortKey>;
22
23
  export declare const TRANSACTIONS_TABS: readonly ["review", "autoCategorized"];
@@ -92,7 +93,6 @@ export interface SupportedTransactionCategorization {
92
93
  }
93
94
  export declare const initialSupportedTransactionCategorization: SupportedTransactionCategorization;
94
95
  export interface TransactionsTabViewState extends FetchedState {
95
- filters: TransactionFilters;
96
96
  markAsNotMiscategorizedStatus: FetchStateAndError;
97
97
  refreshStatus: FetchStateAndError;
98
98
  saveStatus: FetchStateAndError;
@@ -105,7 +105,39 @@ export interface TransactionsTabViewState extends FetchedState {
105
105
  selectedTransactionId?: ID;
106
106
  selectedTransactionLineId?: ID;
107
107
  }
108
+ /**
109
+ * Snapshot of the autoCategorized tab's paginated dataset for a single
110
+ * Completed sub-tab. Stored in {@link TransactionsViewState.autoCategorizedSubTabCache}
111
+ * so revisiting an already-loaded sub-tab can short-circuit the fetch epic
112
+ * (mirrors parent-tab caching). The snapshot is period-spanning — both the
113
+ * `totalCount` map and `transactionIdsBySelectedPeriod` map preserve every
114
+ * period the user has paged through under that sub-tab.
115
+ */
116
+ export interface AutoCategorizedSubTabSnapshot {
117
+ error: ZeniAPIStatus | undefined;
118
+ fetchState: FetchState;
119
+ pageToken: PageToken;
120
+ totalCount: Record<MonthYearPeriodId, number>;
121
+ transactionIdsBySelectedPeriod: Record<MonthYearPeriodId, ID[]>;
122
+ }
108
123
  export type TransactionsViewState = {
124
+ /**
125
+ * Per-sub-tab snapshot cache for the Completed (autoCategorized) tab. Keyed
126
+ * by {@link CompletedSubTab}. Populated as the user navigates between
127
+ * sub-tabs and consulted on every switch — the active autoCategorized slot
128
+ * is restored from here when a snapshot exists, otherwise it is reset and
129
+ * the fetch epic loads page 1 fresh.
130
+ */
131
+ autoCategorizedSubTabCache: Partial<Record<CompletedSubTab, AutoCategorizedSubTabSnapshot>>;
132
+ /**
133
+ * Period-keyed parent tab counts, scoped per {@link TransactionsTab}.
134
+ * Sourced from the listing response's `parent_tab_total_count` and used
135
+ * exclusively to drive the parent tab badges on the UI — every other
136
+ * count consumer (pagination, sub-tab chips, in-tab "showing X of Y")
137
+ * keeps reading from {@link TransactionsViewUIState.totalCount}.
138
+ */
139
+ parentTotalCountByTab: Record<TransactionsTab, Record<MonthYearPeriodId, number>>;
140
+ selectedTransactionCategorizationCompletedSubTab: CompletedSubTab;
109
141
  selectedTransactionCategorizationTab: TransactionsTab;
110
142
  transactionCategorizationView: Record<TransactionsTab, TransactionsTabViewState>;
111
143
  };
@@ -14,8 +14,6 @@ const helpers_1 = require("./helpers");
14
14
  const remiListSelector_1 = require("./reimbursement/remiListView/remiListSelector");
15
15
  const remiListState_1 = require("./reimbursement/remiListView/remiListState");
16
16
  //filters items against filter values representing a range. ex: date (from-to), amount(1k<-->5k)
17
- // Spend Management uses only equal/not-equal — TC amount operators
18
- // (inBetween, lessThan, greaterThan) live in the TC filter pipeline.
19
17
  const filterItemOnRangeCategoryType = (valueForItem, currentFilter) => {
20
18
  let doesItemFallInValueRange = false;
21
19
  const filterField = currentFilter.field;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.0.64-betaAR2",
3
+ "version": "5.0.64-betaSS1",
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",