@zeniai/client-epic-state 5.0.74 → 5.0.76
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/coreEpics.js +1 -1
- package/lib/entity/account/accountSelector.d.ts +1 -27
- package/lib/entity/account/accountSelector.js +1 -47
- package/lib/entity/account/accountState.d.ts +1 -6
- package/lib/entity/account/accountState.js +4 -11
- package/lib/entity/account/subAccountSelector.d.ts +1 -1
- package/lib/entity/aiAccountantCustomer/aiAccountantCustomerPayload.js +3 -1
- package/lib/entity/aiAccountantCustomer/aiAccountantCustomerReducer.js +2 -1
- package/lib/entity/aiAccountantCustomer/aiAccountantCustomerSelector.d.ts +1 -1
- package/lib/entity/chargeCard/chargeCardReducer.d.ts +2 -19
- package/lib/entity/chargeCard/chargeCardReducer.js +2 -35
- package/lib/entity/chargeCardTransaction/chargeCardTransactionReducer.d.ts +1 -14
- package/lib/entity/chargeCardTransaction/chargeCardTransactionReducer.js +2 -36
- package/lib/entity/class/classSelector.d.ts +0 -35
- package/lib/entity/class/classSelector.js +0 -50
- package/lib/entity/sectionProjectView/sectionProjectViewReducer.d.ts +1 -1
- package/lib/entity/sectionProjectView/sectionProjectViewSelector.js +1 -1
- package/lib/entity/tenant/SessionManager.js +3 -6
- package/lib/entity/tenant/clearAllEpic.d.ts +2 -2
- package/lib/entity/tenant/clearAllEpic.js +2 -2
- package/lib/entity/tenant/epic/saveAPIKeyConnectionEpic.js +2 -6
- package/lib/entity/tenant/epic/saveOAuthConnectionEpic.js +2 -6
- package/lib/entity/tenant/tenantReducer.js +1 -6
- package/lib/entity/transaction/payloadTypes/transactionLinePayload.js +1 -3
- package/lib/epic.d.ts +9 -9
- package/lib/epic.js +10 -10
- package/lib/esm/coreEpics.js +1 -1
- package/lib/esm/entity/account/accountSelector.js +1 -46
- package/lib/esm/entity/account/accountState.js +1 -7
- package/lib/esm/entity/aiAccountantCustomer/aiAccountantCustomerPayload.js +3 -1
- package/lib/esm/entity/aiAccountantCustomer/aiAccountantCustomerReducer.js +2 -1
- package/lib/esm/entity/chargeCard/chargeCardReducer.js +1 -34
- package/lib/esm/entity/chargeCardTransaction/chargeCardTransactionReducer.js +1 -35
- package/lib/esm/entity/class/classSelector.js +0 -48
- package/lib/esm/entity/sectionProjectView/sectionProjectViewSelector.js +1 -1
- package/lib/esm/entity/tenant/SessionManager.js +1 -4
- package/lib/esm/entity/tenant/clearAllEpic.js +2 -2
- package/lib/esm/entity/tenant/epic/saveAPIKeyConnectionEpic.js +2 -6
- package/lib/esm/entity/tenant/epic/saveOAuthConnectionEpic.js +2 -6
- package/lib/esm/entity/tenant/tenantReducer.js +1 -6
- package/lib/esm/entity/transaction/payloadTypes/transactionLinePayload.js +1 -3
- package/lib/esm/epic.js +10 -10
- package/lib/esm/index.js +16 -26
- package/lib/esm/reducer.js +2 -2
- package/lib/esm/view/aiAccountantView/epics/fetchAiAccountantCustomersEpic.js +5 -2
- package/lib/esm/view/aiAccountantView/epics/fetchAiAccountantJobsEpic.js +5 -2
- package/lib/esm/view/aiAccountantView/epics/triggerAiAccountantJobEpic.js +1 -4
- package/lib/esm/view/companyHealthMetricView/companyHealthMetricViewSelector.js +1 -1
- package/lib/esm/view/companyTaskManagerView/companyTaskManagerViewSelector.js +1 -1
- package/lib/esm/view/companyTaskManagerView/epics/fetchTaskManagerMetricsEpic.js +1 -1
- package/lib/esm/view/companyView/helpers/cockpitHelpers.js +1 -1
- package/lib/esm/view/companyView/selector/companyManagementViewSelector.js +1 -1
- package/lib/esm/view/companyView/selector/companyPortfolioViewSelector.js +1 -1
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +2 -2
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +1 -2
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/restoreBulkUploadAutomatchingOnMountEpic.js +6 -8
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +1 -7
- package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.js +1 -11
- package/lib/esm/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +1 -2
- package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +1 -137
- package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +13 -89
- package/lib/esm/view/expenseAutomationView/types/missingReceiptsViewState.js +2 -0
- package/lib/esm/view/financeStatement/financeStatementSelector.js +1 -1
- package/lib/esm/view/spendManagement/chargeCards/cashbackDetail/cashbackDetailReducer.js +2 -3
- package/lib/esm/view/spendManagement/chargeCards/chargeCardConfig/chargeCardConfigReducer.js +2 -3
- package/lib/esm/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailReducer.js +18 -55
- package/lib/esm/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardDetailEpic.js +2 -16
- package/lib/esm/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardDetailPageEpic.js +4 -5
- package/lib/esm/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.js +9 -26
- package/lib/esm/view/spendManagement/chargeCards/chargeCardList/fetchChargeCardListPageEpic.js +6 -9
- package/lib/esm/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryReducer.js +2 -3
- package/lib/esm/view/spendManagement/chargeCards/chargeCardPaymentHistory/fetchChargeCardPaymentPageEpic.js +1 -1
- package/lib/esm/view/spendManagement/chargeCards/chargeCardRepaymentDetail/chargeCardRepaymentDetailReducer.js +3 -7
- package/lib/esm/view/spendManagement/spendManagementFilterHelpers.js +2 -4
- package/lib/esm/view/subscriptionView/subscriptionViewSelector.js +1 -1
- package/lib/esm/view/taskManager/cannedResponsesView/epics/fetchCannedResponsesEpic.js +1 -1
- package/lib/esm/view/taskManager/cannedResponsesView/epics/saveCannedResponseEpic.js +1 -1
- package/lib/esm/view/taskManager/taskDetailView/epics/unsnoozeTaskEpic.js +1 -1
- package/lib/esm/view/taskManager/taskListView/taskListReducer.js +1 -1
- package/lib/esm/view/transactionDetail/transactionDetailSelector.js +1 -7
- package/lib/index.d.ts +19 -25
- package/lib/index.js +58 -81
- package/lib/reducer.d.ts +2 -2
- package/lib/reducer.js +2 -2
- package/lib/view/aiAccountantView/aiAccountantViewPayload.d.ts +2 -2
- package/lib/view/aiAccountantView/aiAccountantViewReducer.d.ts +1 -1
- package/lib/view/aiAccountantView/epics/fetchAiAccountantCustomersEpic.js +5 -2
- package/lib/view/aiAccountantView/epics/fetchAiAccountantJobsEpic.js +5 -2
- package/lib/view/aiAccountantView/epics/triggerAiAccountantJobEpic.js +1 -4
- package/lib/view/companyHealthMetricView/companyHealthMetricViewSelector.js +1 -1
- package/lib/view/companyTaskManagerView/companyTaskManagerViewSelector.d.ts +1 -1
- package/lib/view/companyTaskManagerView/companyTaskManagerViewSelector.js +1 -1
- package/lib/view/companyView/helpers/cockpitHelpers.js +1 -1
- package/lib/view/companyView/selector/companyManagementViewSelector.js +1 -1
- package/lib/view/companyView/selector/companyPortfolioViewSelector.js +1 -1
- package/lib/view/companyView/types/cockpitTypes.d.ts +1 -1
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +2 -2
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +1 -2
- package/lib/view/expenseAutomationView/epics/missingReceipts/restoreBulkUploadAutomatchingOnMountEpic.js +6 -8
- package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +1 -7
- package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.d.ts +2 -2
- package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.js +0 -10
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
- package/lib/view/expenseAutomationView/payload/transactionCategorizationPayload.d.ts +0 -21
- package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +1 -2
- package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +1 -2
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +4 -14
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +2 -138
- package/lib/view/expenseAutomationView/selectorTypes/missingReceiptsSelectorTypes.d.ts +1 -2
- package/lib/view/expenseAutomationView/selectorTypes/transactionsViewSelectorTypes.d.ts +0 -14
- package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.d.ts +1 -4
- package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +13 -91
- package/lib/view/expenseAutomationView/types/missingReceiptsViewState.d.ts +2 -1
- package/lib/view/expenseAutomationView/types/missingReceiptsViewState.js +4 -1
- package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +2 -43
- package/lib/view/financeStatement/financeStatementSelector.js +1 -1
- package/lib/view/profitAndLossProjectView/profitAndLossProjectViewSelectorTypes.d.ts +1 -1
- package/lib/view/spendManagement/billPay/billList/billListState.d.ts +1 -1
- package/lib/view/spendManagement/chargeCards/cashbackDetail/cashbackDetailReducer.d.ts +1 -3
- package/lib/view/spendManagement/chargeCards/cashbackDetail/cashbackDetailReducer.js +2 -3
- package/lib/view/spendManagement/chargeCards/chargeCardConfig/chargeCardConfigReducer.d.ts +1 -3
- package/lib/view/spendManagement/chargeCards/chargeCardConfig/chargeCardConfigReducer.js +2 -3
- package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailReducer.js +18 -55
- package/lib/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardDetailEpic.js +2 -16
- package/lib/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardDetailPageEpic.js +4 -5
- package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.d.ts +3 -18
- package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.js +10 -27
- package/lib/view/spendManagement/chargeCards/chargeCardList/fetchChargeCardListPageEpic.js +6 -9
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistory.d.ts +1 -1
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryReducer.d.ts +1 -3
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryReducer.js +2 -3
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/fetchChargeCardPaymentPageEpic.js +1 -1
- package/lib/view/spendManagement/chargeCards/chargeCardRepaymentDetail/chargeCardRepaymentDetailReducer.d.ts +1 -3
- package/lib/view/spendManagement/chargeCards/chargeCardRepaymentDetail/chargeCardRepaymentDetailReducer.js +3 -7
- package/lib/view/spendManagement/reimbursement/remiListView/remiListState.d.ts +1 -1
- package/lib/view/spendManagement/spendManagementFilterHelpers.d.ts +3 -12
- package/lib/view/spendManagement/spendManagementFilterHelpers.js +2 -4
- package/lib/view/subscriptionView/subscriptionViewSelector.js +1 -1
- package/lib/view/taskManager/taskListView/taskList.d.ts +1 -1
- package/lib/view/taskManager/taskListView/taskListReducer.js +1 -1
- package/lib/view/transactionDetail/transactionDetailSelector.js +1 -7
- package/lib/view/zeniOAuthView/zeniOAuthSelector.d.ts +1 -1
- package/package.json +4 -9
- package/lib/commonStateTypes/cacheOverrideFetchReducer.d.ts +0 -17
- package/lib/commonStateTypes/cacheOverrideFetchReducer.js +0 -20
- package/lib/commonStateTypes/filterPrimitives.d.ts +0 -23
- package/lib/commonStateTypes/filterPrimitives.js +0 -21
- package/lib/commonStateTypes/pusherActions.d.ts +0 -11
- package/lib/commonStateTypes/pusherActions.js +0 -6
- package/lib/esm/commonStateTypes/cacheOverrideFetchReducer.js +0 -16
- package/lib/esm/commonStateTypes/filterPrimitives.js +0 -20
- package/lib/esm/commonStateTypes/pusherActions.js +0 -3
- package/lib/esm/view/expenseAutomationView/transactionFilterHelpers.js +0 -258
- package/lib/esm/view/expenseAutomationView/types/completedSubTab.js +0 -17
- package/lib/view/expenseAutomationView/transactionFilterHelpers.d.ts +0 -66
- package/lib/view/expenseAutomationView/transactionFilterHelpers.js +0 -262
- package/lib/view/expenseAutomationView/types/completedSubTab.d.ts +0 -10
- package/lib/view/expenseAutomationView/types/completedSubTab.js +0 -21
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { createAction, createSlice } from '@reduxjs/toolkit';
|
|
2
2
|
import { toMonthYearPeriodId } from '../../../commonStateTypes/timePeriod';
|
|
3
|
-
import { DEFAULT_COMPLETED_SUB_TAB, } from '../types/completedSubTab';
|
|
4
3
|
import { MIN_MANUAL_TRANSACTION_SEARCH_LENGTH, } from '../types/missingReceiptsViewState';
|
|
5
4
|
export const getCompletedTransactionsCacheKey = (periodId, sortKey, sortOrder, subTab) => {
|
|
6
5
|
const sortKeyPart = sortKey ?? 'none';
|
|
@@ -13,7 +12,7 @@ export const initialBulkUploadState = {
|
|
|
13
12
|
batchListByPeriod: {},
|
|
14
13
|
batchListFetchState: { fetchState: 'Not-Started', error: undefined },
|
|
15
14
|
batchStatusById: {},
|
|
16
|
-
completedSubTab:
|
|
15
|
+
completedSubTab: 'all',
|
|
17
16
|
completedTransactionsByPeriod: {},
|
|
18
17
|
confirmMatchStatus: { fetchState: 'Not-Started', error: undefined },
|
|
19
18
|
currentBatchId: undefined,
|
|
@@ -4,7 +4,6 @@ import uniq from 'lodash/uniq';
|
|
|
4
4
|
import { toMonthYearPeriodId, } from '../../../commonStateTypes/timePeriod';
|
|
5
5
|
import { isVendorTransaction } from '../../../entity/transaction/stateTypes/vendorTransaction';
|
|
6
6
|
import { MAX_SELECTION_LIMIT, checkIfAllLineItemsAreCategoryClassFilled, filterAutoTabLineItems, mergeTabSpecificLineItems, removeTransactionFromTabView, setEntityRecommendationForLineIdInLocalData, toSetAllLineItemsToCategoryClass, toTransactionDetailLocalData, } from '../helpers/transactionCategorizationLocalDataHelper';
|
|
7
|
-
import { DEFAULT_COMPLETED_SUB_TAB, } from '../types/completedSubTab';
|
|
8
7
|
export const initialTransactionTabViewState = {
|
|
9
8
|
saveStatus: {
|
|
10
9
|
fetchState: 'Not-Started',
|
|
@@ -28,10 +27,6 @@ export const initialTransactionTabViewState = {
|
|
|
28
27
|
totalCount: {},
|
|
29
28
|
limit: 10,
|
|
30
29
|
},
|
|
31
|
-
filters: {
|
|
32
|
-
categoryCombinationOperator: 'AND',
|
|
33
|
-
categories: [],
|
|
34
|
-
},
|
|
35
30
|
fetchState: 'Not-Started',
|
|
36
31
|
error: undefined,
|
|
37
32
|
hasValidState() {
|
|
@@ -46,74 +41,12 @@ export const initialTransactionTabViewState = {
|
|
|
46
41
|
selectedTransactionLineId: undefined,
|
|
47
42
|
};
|
|
48
43
|
export const initialState = {
|
|
49
|
-
autoCategorizedSubTabCache: {},
|
|
50
|
-
parentTotalCountByTab: {
|
|
51
|
-
review: {},
|
|
52
|
-
autoCategorized: {},
|
|
53
|
-
},
|
|
54
44
|
selectedTransactionCategorizationTab: 'review',
|
|
55
|
-
selectedTransactionCategorizationCompletedSubTab: DEFAULT_COMPLETED_SUB_TAB,
|
|
56
45
|
transactionCategorizationView: {
|
|
57
46
|
review: { ...initialTransactionTabViewState },
|
|
58
47
|
autoCategorized: { ...initialTransactionTabViewState },
|
|
59
48
|
},
|
|
60
49
|
};
|
|
61
|
-
/**
|
|
62
|
-
* Capture the autoCategorized tab's current paginated dataset for a sub-tab.
|
|
63
|
-
* The mid-flight `'In-Progress'` state is normalised to `'Completed'` because
|
|
64
|
-
* the in-flight request is cancelled by `switchMap` in the fetch epic when the
|
|
65
|
-
* sub-tab changes — restoring `'In-Progress'` later would leave the UI stuck
|
|
66
|
-
* showing a phantom loading state with no fetch actually running. Length-zero
|
|
67
|
-
* datasets degrade to `'Not-Started'` so the next visit triggers a fresh
|
|
68
|
-
* fetch from page 1 instead of short-circuiting on stale empty caches.
|
|
69
|
-
*
|
|
70
|
-
* Snapshot scope (deliberately narrow):
|
|
71
|
-
* - Captured: `pageToken`, `totalCount`, `transactionIdsBySelectedPeriod`,
|
|
72
|
-
* `fetchState`, `error`, `scrollPosition`. The first five are the keys the
|
|
73
|
-
* fetch epic's cache check reads to decide whether to short-circuit a
|
|
74
|
-
* sub-tab revisit; `scrollPosition` is captured per sub-tab so revisiting
|
|
75
|
-
* restores the user's last offset and switching to a never-visited sub-tab
|
|
76
|
-
* starts at the top instead of inheriting the outgoing sub-tab's offset
|
|
77
|
-
* (which would land the user at a meaningless row index against a
|
|
78
|
-
* completely different list).
|
|
79
|
-
* - Intentionally NOT captured (left in place on `autoCat` and inherited by
|
|
80
|
-
* the incoming sub-tab):
|
|
81
|
-
* - `uiState.searchString`, `uiState.sortKey`, `uiState.sortOrder`,
|
|
82
|
-
* `uiState.nodeCollapseState`, `uiState.limit` — search and sort are
|
|
83
|
-
* user-applied preferences that persist across sub-tabs by design (a
|
|
84
|
-
* search query stays active when the user toggles between Manual / AI
|
|
85
|
-
* Accountant).
|
|
86
|
-
* - `selectedCheckBoxTransactionIds` — selection state is intentionally
|
|
87
|
-
* cleared at the action source (the fetch epic / save flow), not
|
|
88
|
-
* by the snapshot path. Carrying selection across sub-tabs is safe
|
|
89
|
-
* because every sub-tab change goes through a fetch round-trip that
|
|
90
|
-
* reconciles selection against the new row IDs.
|
|
91
|
-
* - `transactionReviewLocalDataById`, `transactionIdsWithUnsavedData`,
|
|
92
|
-
* `uploadReceiptStatusById`, `saveStatus`, `refreshStatus`,
|
|
93
|
-
* `markAsNotMiscategorizedStatus` — these are per-row / per-flight
|
|
94
|
-
* caches that are write-through global state, not sub-tab-scoped.
|
|
95
|
-
*
|
|
96
|
-
* If the contract changes (e.g. selection should reset on every sub-tab
|
|
97
|
-
* switch), update both this comment and the snapshot return shape together.
|
|
98
|
-
*/
|
|
99
|
-
function snapshotAutoCategorizedTab(autoCat) {
|
|
100
|
-
const transactionIdsBySelectedPeriod = {
|
|
101
|
-
...autoCat.transactionIdsBySelectedPeriod,
|
|
102
|
-
};
|
|
103
|
-
const hasAnyLoadedRows = Object.values(transactionIdsBySelectedPeriod).some((ids) => ids.length > 0);
|
|
104
|
-
let normalisedFetchState = autoCat.fetchState;
|
|
105
|
-
if (normalisedFetchState === 'In-Progress') {
|
|
106
|
-
normalisedFetchState = hasAnyLoadedRows ? 'Completed' : 'Not-Started';
|
|
107
|
-
}
|
|
108
|
-
return {
|
|
109
|
-
error: autoCat.error,
|
|
110
|
-
fetchState: normalisedFetchState,
|
|
111
|
-
pageToken: autoCat.uiState.pageToken,
|
|
112
|
-
scrollPosition: autoCat.uiState.scrollPosition,
|
|
113
|
-
totalCount: { ...autoCat.uiState.totalCount },
|
|
114
|
-
transactionIdsBySelectedPeriod,
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
50
|
const expenseAutomationTransactionsView = createSlice({
|
|
118
51
|
name: 'expenseAutomationTransactionsView',
|
|
119
52
|
initialState,
|
|
@@ -303,12 +236,6 @@ const expenseAutomationTransactionsView = createSlice({
|
|
|
303
236
|
uiState.totalCount;
|
|
304
237
|
}
|
|
305
238
|
},
|
|
306
|
-
updateTransactionFilters(draft, action) {
|
|
307
|
-
const { selectedTab, filters } = action.payload;
|
|
308
|
-
// `filters` is non-nullable per the payload type, so no runtime
|
|
309
|
-
// null-check is needed — dropping it removes a dead defensive branch.
|
|
310
|
-
draft.transactionCategorizationView[selectedTab].filters = filters;
|
|
311
|
-
},
|
|
312
239
|
saveTransactionCategorization: {
|
|
313
240
|
prepare(selectedTab, transactionIds, cotTrackingByTransactionId, isUncategorizedExpenseCategoryEnabled) {
|
|
314
241
|
return {
|
|
@@ -333,55 +260,6 @@ const expenseAutomationTransactionsView = createSlice({
|
|
|
333
260
|
return { payload: { newSelectedTab } };
|
|
334
261
|
},
|
|
335
262
|
},
|
|
336
|
-
updateTransactionCategorizationCompletedSubTab: {
|
|
337
|
-
reducer(draft, action) {
|
|
338
|
-
const { newSubTab } = action.payload;
|
|
339
|
-
const previousSubTab = draft.selectedTransactionCategorizationCompletedSubTab;
|
|
340
|
-
if (previousSubTab === newSubTab) {
|
|
341
|
-
return;
|
|
342
|
-
}
|
|
343
|
-
const autoCat = draft.transactionCategorizationView.autoCategorized;
|
|
344
|
-
// Snapshot the outgoing sub-tab so a future revisit can short-circuit
|
|
345
|
-
// the fetch epic (mirrors the parent-tab "don't refetch what's
|
|
346
|
-
// already cached" behaviour). Period-scoped data is preserved as-is
|
|
347
|
-
// because the snapshot itself is keyed only by sub-tab; the active
|
|
348
|
-
// tab's per-period maps remain the source of truth while live.
|
|
349
|
-
draft.autoCategorizedSubTabCache[previousSubTab] =
|
|
350
|
-
snapshotAutoCategorizedTab(autoCat);
|
|
351
|
-
const cached = draft.autoCategorizedSubTabCache[newSubTab];
|
|
352
|
-
if (cached != null) {
|
|
353
|
-
autoCat.uiState.pageToken = cached.pageToken;
|
|
354
|
-
autoCat.uiState.totalCount = { ...cached.totalCount };
|
|
355
|
-
autoCat.uiState.scrollPosition = cached.scrollPosition;
|
|
356
|
-
autoCat.transactionIdsBySelectedPeriod = {
|
|
357
|
-
...cached.transactionIdsBySelectedPeriod,
|
|
358
|
-
};
|
|
359
|
-
autoCat.fetchState = cached.fetchState;
|
|
360
|
-
autoCat.error = cached.error;
|
|
361
|
-
}
|
|
362
|
-
else {
|
|
363
|
-
// Sub-tab has never been visited — clear the active slot so the
|
|
364
|
-
// view-epic's `fetchState === 'Not-Started' || transactionIds.length
|
|
365
|
-
// === 0` cache check falls through and triggers a fresh page-1
|
|
366
|
-
// fetch for the new dataset. `scrollPosition` is reset to the top
|
|
367
|
-
// so the incoming list isn't anchored to the outgoing sub-tab's
|
|
368
|
-
// offset (different rows → previous offset is meaningless).
|
|
369
|
-
autoCat.uiState.pageToken = null;
|
|
370
|
-
autoCat.uiState.totalCount = {};
|
|
371
|
-
autoCat.uiState.scrollPosition = {
|
|
372
|
-
scrollTop: 0,
|
|
373
|
-
scrollLeft: undefined,
|
|
374
|
-
};
|
|
375
|
-
autoCat.transactionIdsBySelectedPeriod = {};
|
|
376
|
-
autoCat.fetchState = 'Not-Started';
|
|
377
|
-
autoCat.error = undefined;
|
|
378
|
-
}
|
|
379
|
-
draft.selectedTransactionCategorizationCompletedSubTab = newSubTab;
|
|
380
|
-
},
|
|
381
|
-
prepare(newSubTab) {
|
|
382
|
-
return { payload: { newSubTab } };
|
|
383
|
-
},
|
|
384
|
-
},
|
|
385
263
|
updateTransactionCategorization: {
|
|
386
264
|
reducer(draft, action) {
|
|
387
265
|
const selectedTab = action.payload.selectedTab;
|
|
@@ -819,10 +697,6 @@ const expenseAutomationTransactionsView = createSlice({
|
|
|
819
697
|
const { selectedTab, selectedPeriod, totalCount } = action.payload;
|
|
820
698
|
draft.transactionCategorizationView[selectedTab].uiState.totalCount[toMonthYearPeriodId(selectedPeriod)] = totalCount;
|
|
821
699
|
},
|
|
822
|
-
updateParentTotalCountForTab(draft, action) {
|
|
823
|
-
const { selectedTab, selectedPeriod, parentTotalCount } = action.payload;
|
|
824
|
-
draft.parentTotalCountByTab[selectedTab][toMonthYearPeriodId(selectedPeriod)] = parentTotalCount;
|
|
825
|
-
},
|
|
826
700
|
updateSelectedCheckboxTransactionIds(draft, action) {
|
|
827
701
|
const selectedTab = action.payload.selectedTab;
|
|
828
702
|
const transactionIds = action.payload.transactionIds;
|
|
@@ -833,16 +707,6 @@ const expenseAutomationTransactionsView = createSlice({
|
|
|
833
707
|
draft.transactionCategorizationView[selectedTab] = {
|
|
834
708
|
...initialTransactionTabViewState,
|
|
835
709
|
};
|
|
836
|
-
draft.parentTotalCountByTab[selectedTab] = {};
|
|
837
|
-
// The per-sub-tab snapshot cache lives at the slice root and is
|
|
838
|
-
// exclusively populated by the autoCategorized tab's sub-tab switching
|
|
839
|
-
// (see updateTransactionCategorizationCompletedSubTab). When that tab
|
|
840
|
-
// is reset, leaving stale snapshots behind would short-circuit the
|
|
841
|
-
// next sub-tab visit with phantom row IDs / page tokens that no longer
|
|
842
|
-
// correspond to anything in state — drop them in lockstep.
|
|
843
|
-
if (selectedTab === 'autoCategorized') {
|
|
844
|
-
draft.autoCategorizedSubTabCache = {};
|
|
845
|
-
}
|
|
846
710
|
},
|
|
847
711
|
clearExpenseAutomationTransactionsView(draft) {
|
|
848
712
|
Object.assign(draft, initialState);
|
|
@@ -939,5 +803,5 @@ const expenseAutomationTransactionsView = createSlice({
|
|
|
939
803
|
},
|
|
940
804
|
},
|
|
941
805
|
});
|
|
942
|
-
export const { fetchTransactionCategorization, updateTransactionCategorizationUIState,
|
|
806
|
+
export const { fetchTransactionCategorization, updateTransactionCategorizationUIState, initializeTransactionCategorizationViewLocalData, saveTransactionCategorizationLocalData, fetchTransactionCategorizationFailure, saveTransactionCategorization, updateTransactionCategorization, updateCurrentSelectedTransactionCategorizationTab, updateTransactionCategorizationSaveStatus, markTransactionAsNotMiscategorized, updateStatusForTransactionNotMiscategorizedUpdateForCategorization, updateSelectedVendorForTransaction, updateSelectedCustomerForTransaction, setAllItemsToCategoryClassInLocalDataForCategorization, updateTotalCountForTransactionCategorization, fetchTransactionCategorizationSuccess, resetOtherTabsFetchState, fetchTransactionCategorizationView, updateSelectedCheckboxTransactionIds, clearExpenseAutomationTransactionsViewPerTabView, clearExpenseAutomationTransactionsView, setEntityRecommendationForLineIdsForCategorization, updateSelectedTransactionId, syncTransactionCategorizationFromDetailSave, backgroundRefetchReviewTab, updateTransactionCategorizationUploadReceiptState, uploadTransactionCategorizationReceiptSuccess, } = expenseAutomationTransactionsView.actions;
|
|
943
807
|
export default expenseAutomationTransactionsView.reducer;
|
|
@@ -4,33 +4,14 @@ import { toMonthYearPeriodId } from '../../../commonStateTypes/timePeriod';
|
|
|
4
4
|
import { getCurrentTenant, getIsAccountingClassesEnabled, getIsAccountingProjectsEnabled, } from '../../../entity/tenant/tenantSelector';
|
|
5
5
|
import { getTransactionWithCOT } from '../../../entity/transaction/transactionHelper';
|
|
6
6
|
import { getSupportedTransactionsByIds } from '../../../entity/transaction/transactionSelector';
|
|
7
|
-
import { applyTransactionFilters, } from '../transactionFilterHelpers';
|
|
8
7
|
import { getAccountList, getNestedAccountListHierarchy, getUncategorizedAccounts, } from '../../accountList/accountListSelector';
|
|
9
8
|
import { getClassList, getNestedClassListHierarchy, } from '../../classList/classListSelector';
|
|
10
9
|
import { getProjectList } from '../../projectList/projectListSelector';
|
|
11
10
|
import { getAllSteps } from '../selectorTypes/expenseAutomationViewSelectorTypes';
|
|
12
|
-
export const toTransactionView = (transaction, transactionLocalData) => {
|
|
13
|
-
return {
|
|
14
|
-
id: transaction.id,
|
|
15
|
-
date: transaction.date,
|
|
16
|
-
amount: transaction.amount,
|
|
17
|
-
vendorName: transaction.vendorName,
|
|
18
|
-
customerName: transaction.customerName,
|
|
19
|
-
vendorId: transaction.vendorId,
|
|
20
|
-
customerId: transaction.customerId,
|
|
21
|
-
description: transaction.description,
|
|
22
|
-
memo: transaction.memo,
|
|
23
|
-
type: transaction.type,
|
|
24
|
-
typeName: transaction.typeName,
|
|
25
|
-
createTime: transaction.createTime,
|
|
26
|
-
transaction: transaction,
|
|
27
|
-
transactionLocalData,
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
11
|
export function getExpenseAutomationTransactionView(state) {
|
|
31
12
|
const { accountState, classState, classListState, accountListState, expenseAutomationTransactionsViewState, expenseAutomationViewState, projectState, projectListState, transactionState, monthEndCloseChecksState, monthEndCloseChecksViewState, } = state;
|
|
32
|
-
const {
|
|
33
|
-
const { uiState, refreshStatus, saveStatus, markAsNotMiscategorizedStatus, transactionIdsBySelectedPeriod, transactionReviewLocalDataById, selectedCheckBoxTransactionIds, transactionIdsWithUnsavedData, uploadReceiptStatusById, selectedTransactionId, selectedTransactionLineId,
|
|
13
|
+
const { selectedTransactionCategorizationTab } = expenseAutomationTransactionsViewState;
|
|
14
|
+
const { uiState, refreshStatus, saveStatus, markAsNotMiscategorizedStatus, transactionIdsBySelectedPeriod, transactionReviewLocalDataById, selectedCheckBoxTransactionIds, transactionIdsWithUnsavedData, uploadReceiptStatusById, selectedTransactionId, selectedTransactionLineId, } = expenseAutomationTransactionsViewState.transactionCategorizationView[selectedTransactionCategorizationTab];
|
|
34
15
|
const uncategorizedIncomeExpense = getUncategorizedAccounts(accountState, accountListState, 'accountList');
|
|
35
16
|
const accountList = getAccountList(accountState, accountListState, 'accountList');
|
|
36
17
|
const classList = getClassList(classState, classListState);
|
|
@@ -49,58 +30,20 @@ export function getExpenseAutomationTransactionView(state) {
|
|
|
49
30
|
? transactionIdsBySelectedPeriod[monthYearPeriodId]
|
|
50
31
|
: null;
|
|
51
32
|
const transactionIds = transactionIdsForSelectedPeriod ?? [];
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
const transactionLocalDataMap = new Map();
|
|
55
|
-
transactionIds.forEach((transactionId) => {
|
|
33
|
+
const transactionLocalData = transactionIds
|
|
34
|
+
.map((transactionId) => {
|
|
56
35
|
const transactionData = transactionReviewLocalDataById[transactionId];
|
|
57
36
|
if (transactionData != null) {
|
|
58
|
-
|
|
37
|
+
return {
|
|
59
38
|
transactionId,
|
|
60
39
|
transactionReviewLocalData: transactionData.transactionReviewLocalData,
|
|
61
|
-
}
|
|
40
|
+
};
|
|
62
41
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
});
|
|
69
|
-
// Apply TC-specific filters (lives under expenseAutomationView, independent
|
|
70
|
-
// of the Spend Management filter pipeline).
|
|
71
|
-
const filteredTransactionViews = applyTransactionFilters(transactionViews, filters);
|
|
72
|
-
// Convert back to TransactionWithCOT for return
|
|
73
|
-
const filteredTransactionsWithCOT = filteredTransactionViews.map((view) => view.transaction);
|
|
74
|
-
// Get transactionLocalData for filtered transactions
|
|
75
|
-
// Also include transactionLocalData for transactions that don't exist in transactionState
|
|
76
|
-
// but have local data (to match original behavior)
|
|
77
|
-
const filteredTransactionIds = new Set(filteredTransactionViews.map((view) => view.id));
|
|
78
|
-
// Pre-compute the membership set once. The previous implementation called
|
|
79
|
-
// `transactions.some(t => t.id === transactionId)` inside the per-id loop,
|
|
80
|
-
// turning the pipeline into O(n × m) — measurable on tenants with large
|
|
81
|
-
// transaction lists since this selector runs on every Redux dispatch.
|
|
82
|
-
const transactionExistsById = new Set(transactions.map((t) => t.id));
|
|
83
|
-
// `.flatMap` returns `X[]` directly when the callback returns `[]` for the
|
|
84
|
-
// skip case, so we don't need the trailing `.filter((d): d is X => …)` type
|
|
85
|
-
// predicate that the previous `map → filter` pipeline required.
|
|
86
|
-
const filteredTransactionLocalData = transactionIds.flatMap((transactionId) => {
|
|
87
|
-
const transactionData = transactionReviewLocalDataById[transactionId];
|
|
88
|
-
if (transactionData == null) {
|
|
89
|
-
return [];
|
|
90
|
-
}
|
|
91
|
-
// Include if transaction is in filtered results, or if transaction doesn't exist in state
|
|
92
|
-
// (to maintain backward compatibility with tests)
|
|
93
|
-
const transactionExists = transactionExistsById.has(transactionId);
|
|
94
|
-
if (filteredTransactionIds.has(transactionId) || !transactionExists) {
|
|
95
|
-
return [
|
|
96
|
-
{
|
|
97
|
-
transactionId,
|
|
98
|
-
transactionReviewLocalData: transactionData.transactionReviewLocalData,
|
|
99
|
-
},
|
|
100
|
-
];
|
|
101
|
-
}
|
|
102
|
-
return [];
|
|
103
|
-
});
|
|
42
|
+
return null;
|
|
43
|
+
})
|
|
44
|
+
.filter((transaction) => transaction != null);
|
|
45
|
+
const transactions = getSupportedTransactionsByIds(transactionState, transactionIds);
|
|
46
|
+
const transactionsWithCOT = transactions.map((transaction) => getTransactionWithCOT(transaction));
|
|
104
47
|
const monthEndFetchState = monthYearPeriodId != null
|
|
105
48
|
? (monthEndCloseChecksViewState.monthEndCloseChecksViewByTenantId[currentTenant.tenantId]?.[monthYearPeriodId] ?? { fetchState: 'Not-Started', error: undefined })
|
|
106
49
|
: { fetchState: 'Not-Started', error: undefined };
|
|
@@ -120,27 +63,10 @@ export function getExpenseAutomationTransactionView(state) {
|
|
|
120
63
|
.uiState.totalCount;
|
|
121
64
|
const totalCountByAutoCat = expenseAutomationTransactionsViewState.transactionCategorizationView
|
|
122
65
|
.autoCategorized.uiState.totalCount;
|
|
123
|
-
// Per-(sub-)tab counts powering pagination, in-list "showing X of Y", and
|
|
124
|
-
// any save/refresh round-trips. Sourced from `uiState.totalCount` which
|
|
125
|
-
// mirrors the response's `total_count` for whatever tab/sub-tab the user is
|
|
126
|
-
// viewing (e.g. only the Manual sub-tab rows for Completed → Manual).
|
|
127
66
|
const totalCountByTab = {
|
|
128
67
|
review: monthYearPeriodId != null ? totalCountByReview[monthYearPeriodId] : 0,
|
|
129
68
|
autoCategorized: monthYearPeriodId != null ? totalCountByAutoCat[monthYearPeriodId] : 0,
|
|
130
69
|
};
|
|
131
|
-
// Parent-tab badge counts. Sourced from `parent_tab_total_count` in the
|
|
132
|
-
// listing response and used exclusively by the navbar / tab strip badges.
|
|
133
|
-
// Independent of which Completed sub-tab is active so the badge stays
|
|
134
|
-
// stable across sub-tab switches.
|
|
135
|
-
const parentTotalCountByTab = expenseAutomationTransactionsViewState.parentTotalCountByTab;
|
|
136
|
-
const parentTabTotalCountByTab = {
|
|
137
|
-
review: monthYearPeriodId != null
|
|
138
|
-
? (parentTotalCountByTab.review[monthYearPeriodId] ?? 0)
|
|
139
|
-
: 0,
|
|
140
|
-
autoCategorized: monthYearPeriodId != null
|
|
141
|
-
? (parentTotalCountByTab.autoCategorized[monthYearPeriodId] ?? 0)
|
|
142
|
-
: 0,
|
|
143
|
-
};
|
|
144
70
|
const fetchStateByTab = {
|
|
145
71
|
review: {
|
|
146
72
|
fetchState: expenseAutomationTransactionsViewState.transactionCategorizationView
|
|
@@ -164,7 +90,7 @@ export function getExpenseAutomationTransactionView(state) {
|
|
|
164
90
|
version: 0,
|
|
165
91
|
fetchState: fetchStatus.fetchState,
|
|
166
92
|
error: fetchStatus.error,
|
|
167
|
-
transactions:
|
|
93
|
+
transactions: transactionsWithCOT,
|
|
168
94
|
selectedCheckBoxTransactionIds,
|
|
169
95
|
transactionIdsWithUnsavedData,
|
|
170
96
|
uncategorizedAccounts: uncategorizedIncomeExpense,
|
|
@@ -175,18 +101,16 @@ export function getExpenseAutomationTransactionView(state) {
|
|
|
175
101
|
classHierarchyList,
|
|
176
102
|
isAccountingProjectsEnabled,
|
|
177
103
|
projectList,
|
|
178
|
-
transactionLocalData
|
|
104
|
+
transactionLocalData,
|
|
179
105
|
uiState,
|
|
180
106
|
refreshStatus,
|
|
181
107
|
saveStatus,
|
|
182
108
|
markAsNotMiscategorizedStatus,
|
|
183
109
|
completionStatus,
|
|
184
110
|
totalCountByTab,
|
|
185
|
-
parentTabTotalCountByTab,
|
|
186
111
|
fetchStateByTransactionTabs: fetchStateByTab,
|
|
187
112
|
uploadReceiptStatusById,
|
|
188
113
|
selectedTransactionId,
|
|
189
114
|
selectedTransactionLineId,
|
|
190
|
-
selectedTransactionCategorizationCompletedSubTab,
|
|
191
115
|
};
|
|
192
116
|
}
|
|
@@ -39,6 +39,8 @@ const BULK_UPLOAD_RESULTS_TABS = ['completed', 'unmatched'];
|
|
|
39
39
|
export const toBulkUploadResultsTab = (v) => stringToUnion(v.trim().toLowerCase(), BULK_UPLOAD_RESULTS_TABS);
|
|
40
40
|
const MISSING_RECEIPTS_TABS = ['missing', 'completed', 'unmatched'];
|
|
41
41
|
export const toMissingReceiptsTab = (v) => stringToUnion(v.trim().toLowerCase(), MISSING_RECEIPTS_TABS);
|
|
42
|
+
const COMPLETED_SUB_TABS = ['all', 'ai_accountant', 'manual'];
|
|
43
|
+
export const toCompletedSubTab = (v) => stringToUnion(v.trim().toLowerCase(), COMPLETED_SUB_TABS);
|
|
42
44
|
const MATCH_SOURCES = ['ai', 'manual'];
|
|
43
45
|
export const toMatchSource = (v) => stringToUnion(v.trim().toLowerCase(), MATCH_SOURCES);
|
|
44
46
|
const BULK_UPLOAD_SORT_KEYS = [
|
|
@@ -2,7 +2,6 @@ import { createSelector } from '@reduxjs/toolkit';
|
|
|
2
2
|
import { stripCompareAdditionalBalanceTypes } from '../../commonStateTypes/coaBalance/coaBalanceType';
|
|
3
3
|
import { newBalancesFilter, newBalancesFilterForDateRange, } from '../../commonStateTypes/coaBalance/coaBalancesFilter';
|
|
4
4
|
import { newBalancesFilterClassesView } from '../../commonStateTypes/coaBalance/coaBalancesFilterClassesView';
|
|
5
|
-
import { newBalancesFilterProjectView } from '../../commonStateTypes/coaBalance/coaBalancesFilterProjectView';
|
|
6
5
|
import { getNumberOfPeriods, } from '../../commonStateTypes/dataAvailable';
|
|
7
6
|
import { reduceAnyCompletedFetchState } from '../../commonStateTypes/reduceFetchState';
|
|
8
7
|
import { toTimeframeTick, } from '../../commonStateTypes/timeframeTick';
|
|
@@ -10,6 +9,7 @@ import { extractThisPeriod } from '../../commonStateTypes/viewAndReport/thisPeri
|
|
|
10
9
|
import { getBalanceSheet } from '../balanceSheet/balanceSheetSelector';
|
|
11
10
|
import { getCashFlow } from '../cashFlow/cashFlowSelector';
|
|
12
11
|
import { getProfitAndLossReport, } from '../profitAndLoss/profitAndLossSelector';
|
|
12
|
+
import { newBalancesFilterProjectView } from '../../commonStateTypes/coaBalance/coaBalancesFilterProjectView';
|
|
13
13
|
import { getProfitAndLossClassesHorizontalView } from '../profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector';
|
|
14
14
|
import { getProfitAndLossClassesView } from '../profitAndLossClassesView/profitAndLossClassesViewSelector';
|
|
15
15
|
import { getProfitAndLossProjectView } from '../profitAndLossProjectView/profitAndLossProjectViewSelector';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { createSlice } from '@reduxjs/toolkit';
|
|
2
2
|
import { mapCurrencyPayloadToCurrency } from '../../../../commonPayloadTypes/v2/viewAndReportPayloadv2';
|
|
3
3
|
import { toAmount } from '../../../../commonStateTypes/amount';
|
|
4
|
-
import { createCacheOverrideFetchReducer } from '../../../../commonStateTypes/cacheOverrideFetchReducer';
|
|
5
4
|
import { initialCashbackAnalytics, } from './cashbackDetailState';
|
|
6
5
|
export const initialState = {
|
|
7
6
|
fetchState: 'Not-Started',
|
|
@@ -28,10 +27,10 @@ const cashbackDetail = createSlice({
|
|
|
28
27
|
name: 'cashbackDetail',
|
|
29
28
|
initialState,
|
|
30
29
|
reducers: {
|
|
31
|
-
fetchCashbackDetail
|
|
30
|
+
fetchCashbackDetail(draft) {
|
|
32
31
|
draft.fetchState = 'In-Progress';
|
|
33
32
|
draft.error = undefined;
|
|
34
|
-
}
|
|
33
|
+
},
|
|
35
34
|
updateCashbackDetail(draft, action) {
|
|
36
35
|
draft.cashbackByPeriod = toCashbackByPeriod(action.payload);
|
|
37
36
|
draft.cashbackSummary = toCashbackSummary(action.payload);
|
package/lib/esm/view/spendManagement/chargeCards/chargeCardConfig/chargeCardConfigReducer.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { createSlice } from '@reduxjs/toolkit';
|
|
2
2
|
import { toAmount } from '../../../../commonStateTypes/amount';
|
|
3
|
-
import { createCacheOverrideFetchReducer } from '../../../../commonStateTypes/cacheOverrideFetchReducer';
|
|
4
3
|
import { toCreditLimitFrequencyCodeType } from '../../../../entity/chargeCard/chargeCard';
|
|
5
4
|
import { toCreditTerm, toRePaymentInfo, } from './chargeCardConfigPayload';
|
|
6
5
|
export const initialState = {
|
|
@@ -31,10 +30,10 @@ const chargeCardConfig = createSlice({
|
|
|
31
30
|
name: 'chargeCardConfig',
|
|
32
31
|
initialState,
|
|
33
32
|
reducers: {
|
|
34
|
-
fetchChargeCardConfig
|
|
33
|
+
fetchChargeCardConfig(draft) {
|
|
35
34
|
draft.fetchState = 'In-Progress';
|
|
36
35
|
draft.error = undefined;
|
|
37
|
-
}
|
|
36
|
+
},
|
|
38
37
|
updateChargeCardConfig(draft, action) {
|
|
39
38
|
const { payload } = action;
|
|
40
39
|
draft.creditLimitFrequency =
|
package/lib/esm/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailReducer.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { createSlice } from '@reduxjs/toolkit';
|
|
2
2
|
import { mapSortOrderPayloadToSortOrder, } from '../../../../commonPayloadTypes/sortOrderPayload';
|
|
3
|
-
import { addChargeCardTransactionFromPusher, addDeclinedChargeCardTransactionFromPusher, } from '../../../../commonStateTypes/pusherActions';
|
|
4
3
|
import { toAttachment, } from '../../../../entity/transaction/payloadTypes/attachmentPayload';
|
|
5
4
|
import { emptyChargeCardDetail, mapChargeCardTransactionStatisticsPayloadToChargeCardTransactionStatistics, toChargeCardTransactionSortKeyType, } from './chargeCardDetail';
|
|
6
5
|
export const initialState = {
|
|
@@ -65,30 +64,19 @@ const chargeCardDetail = createSlice({
|
|
|
65
64
|
},
|
|
66
65
|
fetchChargeCardTransactionList: {
|
|
67
66
|
reducer(draft, action) {
|
|
68
|
-
const { chargeCardId, pageToken, pageTokenType
|
|
67
|
+
const { chargeCardId, pageToken, pageTokenType } = action.payload;
|
|
69
68
|
const existingCardDetail = draft.detailById[chargeCardId] ?? emptyChargeCardDetail;
|
|
70
|
-
const existingUi = existingCardDetail.transactionList.uiState;
|
|
71
|
-
// cacheOverride=true (Pusher): preserve fetchState, error, and scroll
|
|
72
|
-
// to avoid skeleton flash. Normal fetches reset as before.
|
|
73
69
|
draft.detailById[chargeCardId] = {
|
|
74
70
|
...existingCardDetail,
|
|
75
71
|
transactionList: {
|
|
76
72
|
...existingCardDetail.transactionList,
|
|
77
|
-
fetchState:
|
|
78
|
-
|
|
79
|
-
: 'In-Progress',
|
|
80
|
-
error: cacheOverride
|
|
81
|
-
? existingCardDetail.transactionList.error
|
|
82
|
-
: undefined,
|
|
73
|
+
fetchState: 'In-Progress',
|
|
74
|
+
error: undefined,
|
|
83
75
|
uiState: {
|
|
84
|
-
...
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
? existingUi.scrollYOffset
|
|
89
|
-
: existingUi.pageToken === null
|
|
90
|
-
? 0
|
|
91
|
-
: existingUi.scrollYOffset,
|
|
76
|
+
...existingCardDetail.transactionList.uiState,
|
|
77
|
+
scrollYOffset: existingCardDetail.transactionList.uiState.pageToken === null
|
|
78
|
+
? 0
|
|
79
|
+
: existingCardDetail.transactionList.uiState.scrollYOffset,
|
|
92
80
|
pageToken: pageToken,
|
|
93
81
|
pageTokenType: pageTokenType,
|
|
94
82
|
},
|
|
@@ -105,24 +93,18 @@ const chargeCardDetail = createSlice({
|
|
|
105
93
|
const { chargeCardId, data, cacheOverride } = action.payload;
|
|
106
94
|
const existingCardDetail = draft.detailById[chargeCardId] ?? emptyChargeCardDetail;
|
|
107
95
|
const newTransactionIds = data.transactions.map((tran) => tran.transaction_id);
|
|
108
|
-
const existingIds = existingCardDetail.transactionList.transactionIds;
|
|
109
|
-
// cacheOverride (Pusher): refresh page 1 but keep page 2+ IDs.
|
|
110
|
-
// Normal pagination: append new page, deduped.
|
|
111
|
-
const newIdSet = new Set(newTransactionIds);
|
|
112
|
-
const mergedTransactionIds = cacheOverride
|
|
113
|
-
? [
|
|
114
|
-
...newTransactionIds,
|
|
115
|
-
...existingIds.filter((id) => !newIdSet.has(id)),
|
|
116
|
-
]
|
|
117
|
-
: [
|
|
118
|
-
...existingIds,
|
|
119
|
-
...newTransactionIds.filter((id) => !existingIds.includes(id)),
|
|
120
|
-
];
|
|
121
96
|
draft.detailById[chargeCardId] = {
|
|
122
97
|
...existingCardDetail,
|
|
123
98
|
transactionList: {
|
|
124
99
|
...existingCardDetail.transactionList,
|
|
125
|
-
transactionIds:
|
|
100
|
+
transactionIds: [
|
|
101
|
+
...new Set([
|
|
102
|
+
...(cacheOverride
|
|
103
|
+
? []
|
|
104
|
+
: existingCardDetail.transactionList.transactionIds),
|
|
105
|
+
...newTransactionIds,
|
|
106
|
+
]),
|
|
107
|
+
],
|
|
126
108
|
fetchState: 'Completed',
|
|
127
109
|
error: undefined,
|
|
128
110
|
uiState: {
|
|
@@ -134,12 +116,9 @@ const chargeCardDetail = createSlice({
|
|
|
134
116
|
limit: data.query.limit,
|
|
135
117
|
pageToken: data.query.page_token,
|
|
136
118
|
pageTokenType: data.query.page_token_type,
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
: existingCardDetail.transactionList.uiState.pageToken === null
|
|
141
|
-
? 0
|
|
142
|
-
: existingCardDetail.transactionList.uiState.scrollYOffset,
|
|
119
|
+
scrollYOffset: existingCardDetail.transactionList.uiState.pageToken === null
|
|
120
|
+
? 0
|
|
121
|
+
: existingCardDetail.transactionList.uiState.scrollYOffset,
|
|
143
122
|
},
|
|
144
123
|
},
|
|
145
124
|
};
|
|
@@ -653,22 +632,6 @@ const chargeCardDetail = createSlice({
|
|
|
653
632
|
Object.assign(draft, initialState);
|
|
654
633
|
},
|
|
655
634
|
},
|
|
656
|
-
extraReducers: (builder) => {
|
|
657
|
-
const prependTransaction = (draft, cardId, txId) => {
|
|
658
|
-
const detail = draft.detailById[cardId];
|
|
659
|
-
if (detail != null &&
|
|
660
|
-
!detail.transactionList.transactionIds.includes(txId)) {
|
|
661
|
-
detail.transactionList.transactionIds.unshift(txId);
|
|
662
|
-
}
|
|
663
|
-
};
|
|
664
|
-
builder
|
|
665
|
-
.addCase(addChargeCardTransactionFromPusher, (draft, action) => {
|
|
666
|
-
prependTransaction(draft, action.payload.cardId, action.payload.transaction.transaction_id);
|
|
667
|
-
})
|
|
668
|
-
.addCase(addDeclinedChargeCardTransactionFromPusher, (draft, action) => {
|
|
669
|
-
prependTransaction(draft, action.payload.cardId, action.payload.transaction.transaction_id);
|
|
670
|
-
});
|
|
671
|
-
},
|
|
672
635
|
});
|
|
673
636
|
export const { fetchChargeCardDetailPage, fetchChargeCardDetail, updateChargeCardDetailFetchState, fetchChargeCardTransactionList, updateChargeCardDetailUIState, updateChargeCardTransactionList, updateChargeCardTransactionUploadReceiptsFetchStatus, fetchChargeCardTransactionAttachments, updateChargeCardTransactionIsViewReceiptClicked, updateChargeCardTransactionAttachmentsFailure, updatePhysicalChargeCardAttemptSuccessOrFailure, updatePhysicalChargeCardAttempt, updateDebitCardPinAttempt, updateDebitCardPinAttemptSuccessOrFailure, updateChargeCardTransactionReceiptsShowTickFetchStatus, updateChargeCardTransactionAttachmentsInCardDetail, updateChargeCardTransactionListFailure, updateChargeCardDetail, startCVVActivationWait, completeCVVActivationWait, startDebitCardSetPinWait, completeDebitCardSetPinWait, updateChargeCardDetailUpdateStatus, updateChargeCardSpendLimit, updateChargeCardSpendLimitSuccessOrFailure, updateChargeCardName, updateChargeCardNameSuccessOrFailure, lockChargeCard, lockChargeCardSuccessOrFailure, unlockChargeCard, unlockChargeCardSuccessOrFailure, closeChargeCard, closeChargeCardSuccessOrFailure, fetchDepositAccountLimit, updateDepositAccountLimitFetchStatus, fetchChargeCardTransactionStatistics, updateChargeCardTransactionStatistics, updateChargeCardTransactionStatisticsFetchState, fetchChargeCardsRecurringExpenses, updateChargeCardsRecurringExpenses, updateChargeCardsRecurringExpensesFetchState, sendOtpCardHolder, resendOtpCardHolder, sendOtpCardHolderSuccess, sendOtpCardHolderFailure, verifyOtpCardHolder, verifyOtpCardHolderSuccess, verifyOtpCardHolderFailure, clearChargeCardDetail, } = chargeCardDetail.actions;
|
|
674
637
|
export default chargeCardDetail.reducer;
|
package/lib/esm/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardDetailEpic.js
CHANGED
|
@@ -13,24 +13,13 @@ export const fetchChargeCardDetailEpic = (actions$, state$, zeniAPI) => actions$
|
|
|
13
13
|
const chargeCardAction = [];
|
|
14
14
|
const state = state$.value;
|
|
15
15
|
const chargeCardDetail = recordGet(state.chargeCardDetailState.detailById, chargeCardId, undefined);
|
|
16
|
-
// Skip if a user-triggered fetch is already in-flight (not applicable
|
|
17
|
-
// to cacheOverride/Pusher refreshes, which always proceed).
|
|
18
16
|
if (cacheOverride === true ||
|
|
19
17
|
chargeCardDetail == null ||
|
|
20
18
|
chargeCardDetail.fetchState !== 'In-Progress') {
|
|
21
|
-
// Silent refresh: preserve fetchState to avoid skeleton flash.
|
|
22
|
-
// Discriminate via fetchState (not null-check) because the reducer
|
|
23
|
-
// always creates an entry before the epic runs.
|
|
24
|
-
const isSilentRefresh = cacheOverride === true &&
|
|
25
|
-
chargeCardDetail != null &&
|
|
26
|
-
chargeCardDetail.fetchState !== 'Not-Started';
|
|
27
19
|
chargeCardAction.push(updateChargeCardDetailFetchState({
|
|
28
20
|
chargeCardId,
|
|
29
|
-
isRefreshingViewInBackground:
|
|
30
|
-
fetchState:
|
|
31
|
-
? chargeCardDetail.fetchState
|
|
32
|
-
: 'In-Progress',
|
|
33
|
-
error: isSilentRefresh ? chargeCardDetail.error : undefined,
|
|
21
|
+
isRefreshingViewInBackground: cacheOverride,
|
|
22
|
+
fetchState: 'In-Progress',
|
|
34
23
|
}));
|
|
35
24
|
const query = {
|
|
36
25
|
is_include_card_activation_events: true,
|
|
@@ -48,8 +37,6 @@ export const fetchChargeCardDetailEpic = (actions$, state$, zeniAPI) => actions$
|
|
|
48
37
|
}));
|
|
49
38
|
}
|
|
50
39
|
else {
|
|
51
|
-
// Surface errors even on silent refresh so the user
|
|
52
|
-
// knows data is stale (follow-up: consider toast instead).
|
|
53
40
|
return of(updateChargeCardDetailFetchState({
|
|
54
41
|
chargeCardId,
|
|
55
42
|
fetchState: 'Error',
|
|
@@ -58,7 +45,6 @@ export const fetchChargeCardDetailEpic = (actions$, state$, zeniAPI) => actions$
|
|
|
58
45
|
}));
|
|
59
46
|
}
|
|
60
47
|
}), catchError((error) => {
|
|
61
|
-
// Surface network failures even on silent refresh.
|
|
62
48
|
return of(updateChargeCardDetailFetchState({
|
|
63
49
|
chargeCardId,
|
|
64
50
|
fetchState: 'Error',
|
package/lib/esm/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardDetailPageEpic.js
CHANGED
|
@@ -15,16 +15,15 @@ export const fetchChargeCardDetailPageEpic = (actions$, state$) => actions$.pipe
|
|
|
15
15
|
? exsitingChargeCardDetail.transactionList.uiState.pageTokenType
|
|
16
16
|
: null;
|
|
17
17
|
if (cacheOverride === true) {
|
|
18
|
-
// Forward cacheOverride to all sub-fetches to prevent skeleton flash.
|
|
19
18
|
chargeCardTransactionListAction.push(fetchChargeCardDetail(chargeCardId, cacheOverride));
|
|
20
19
|
//latest transactions need to be fetched hence removing pageToken and pageTokenType
|
|
21
|
-
chargeCardTransactionListAction.push(fetchChargeCardTransactionList(chargeCardId, null, null
|
|
22
|
-
chargeCardTransactionListAction.push(fetchChargeCardConfig(
|
|
20
|
+
chargeCardTransactionListAction.push(fetchChargeCardTransactionList(chargeCardId, null, null));
|
|
21
|
+
chargeCardTransactionListAction.push(fetchChargeCardConfig());
|
|
23
22
|
if (doFetchCreditAccounts && isCreditCardEnabled) {
|
|
24
|
-
chargeCardTransactionListAction.push(fetchCreditAccount(
|
|
23
|
+
chargeCardTransactionListAction.push(fetchCreditAccount());
|
|
25
24
|
}
|
|
26
25
|
if (doFetchCreditAccounts && isCreditCardEnabled) {
|
|
27
|
-
chargeCardTransactionListAction.push(fetchCreditAccountRepayment(
|
|
26
|
+
chargeCardTransactionListAction.push(fetchCreditAccountRepayment());
|
|
28
27
|
}
|
|
29
28
|
}
|
|
30
29
|
else {
|