@zeniai/client-epic-state 5.0.70 → 5.0.71-betaAK1
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/commonStateTypes/amount.d.ts +1 -0
- package/lib/commonStateTypes/amount.js +3 -1
- package/lib/commonStateTypes/cacheOverrideFetchReducer.d.ts +17 -0
- package/lib/commonStateTypes/cacheOverrideFetchReducer.js +20 -0
- package/lib/commonStateTypes/pusherActions.d.ts +11 -0
- package/lib/commonStateTypes/pusherActions.js +6 -0
- package/lib/coreEpics.js +1 -1
- package/lib/entity/account/accountSelector.d.ts +1 -1
- package/lib/entity/account/accountState.d.ts +1 -1
- package/lib/entity/account/subAccountSelector.d.ts +1 -1
- package/lib/entity/aiAccountantCustomer/aiAccountantCustomerPayload.js +1 -3
- package/lib/entity/aiAccountantCustomer/aiAccountantCustomerReducer.js +1 -2
- package/lib/entity/aiAccountantCustomer/aiAccountantCustomerSelector.d.ts +1 -1
- package/lib/entity/chargeCard/chargeCardReducer.d.ts +19 -2
- package/lib/entity/chargeCard/chargeCardReducer.js +35 -2
- package/lib/entity/chargeCardTransaction/chargeCardTransactionReducer.d.ts +14 -1
- package/lib/entity/chargeCardTransaction/chargeCardTransactionReducer.js +36 -2
- package/lib/entity/sectionProjectView/sectionProjectViewReducer.d.ts +1 -1
- package/lib/entity/sectionProjectView/sectionProjectViewSelector.js +1 -1
- package/lib/entity/tenant/SessionManager.js +6 -3
- package/lib/entity/tenant/clearAllEpic.d.ts +2 -2
- package/lib/entity/tenant/clearAllEpic.js +2 -2
- package/lib/entity/tenant/epic/saveAPIKeyConnectionEpic.js +6 -2
- package/lib/entity/tenant/epic/saveOAuthConnectionEpic.js +6 -2
- package/lib/entity/tenant/tenantReducer.js +6 -1
- package/lib/entity/transaction/payloadTypes/transactionLinePayload.js +3 -1
- package/lib/entity/upcomingPaymentEvent/upcomingPaymentEventPayload.d.ts +11 -0
- package/lib/entity/upcomingPaymentEvent/upcomingPaymentEventPayload.js +23 -0
- package/lib/entity/upcomingPaymentEvent/upcomingPaymentEventReducer.d.ts +6 -0
- package/lib/entity/upcomingPaymentEvent/upcomingPaymentEventReducer.js +31 -0
- package/lib/entity/upcomingPaymentEvent/upcomingPaymentEventSelector.d.ts +4 -0
- package/lib/entity/upcomingPaymentEvent/upcomingPaymentEventSelector.js +16 -0
- package/lib/entity/upcomingPaymentEvent/upcomingPaymentEventState.d.ts +13 -0
- package/lib/entity/upcomingPaymentEvent/upcomingPaymentEventState.js +2 -0
- package/lib/epic.d.ts +13 -10
- package/lib/epic.js +14 -11
- package/lib/esm/commonStateTypes/amount.js +1 -0
- package/lib/esm/commonStateTypes/cacheOverrideFetchReducer.js +16 -0
- package/lib/esm/commonStateTypes/pusherActions.js +3 -0
- package/lib/esm/coreEpics.js +1 -1
- package/lib/esm/entity/aiAccountantCustomer/aiAccountantCustomerPayload.js +1 -3
- package/lib/esm/entity/aiAccountantCustomer/aiAccountantCustomerReducer.js +1 -2
- package/lib/esm/entity/chargeCard/chargeCardReducer.js +34 -1
- package/lib/esm/entity/chargeCardTransaction/chargeCardTransactionReducer.js +35 -1
- package/lib/esm/entity/sectionProjectView/sectionProjectViewSelector.js +1 -1
- package/lib/esm/entity/tenant/SessionManager.js +4 -1
- package/lib/esm/entity/tenant/clearAllEpic.js +2 -2
- package/lib/esm/entity/tenant/epic/saveAPIKeyConnectionEpic.js +6 -2
- package/lib/esm/entity/tenant/epic/saveOAuthConnectionEpic.js +6 -2
- package/lib/esm/entity/tenant/tenantReducer.js +6 -1
- package/lib/esm/entity/transaction/payloadTypes/transactionLinePayload.js +3 -1
- package/lib/esm/entity/upcomingPaymentEvent/upcomingPaymentEventPayload.js +19 -0
- package/lib/esm/entity/upcomingPaymentEvent/upcomingPaymentEventReducer.js +27 -0
- package/lib/esm/entity/upcomingPaymentEvent/upcomingPaymentEventSelector.js +11 -0
- package/lib/esm/entity/upcomingPaymentEvent/upcomingPaymentEventState.js +1 -0
- package/lib/esm/epic.js +14 -11
- package/lib/esm/index.js +19 -13
- package/lib/esm/reducer.js +8 -2
- package/lib/esm/view/aiAccountantView/epics/fetchAiAccountantCustomersEpic.js +2 -5
- package/lib/esm/view/aiAccountantView/epics/fetchAiAccountantJobsEpic.js +2 -5
- package/lib/esm/view/aiAccountantView/epics/triggerAiAccountantJobEpic.js +4 -1
- package/lib/esm/view/companyTaskManagerView/companyTaskManagerViewSelector.js +1 -1
- package/lib/esm/view/companyTaskManagerView/epics/fetchTaskManagerMetricsEpic.js +1 -1
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +2 -2
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +2 -1
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/restoreBulkUploadAutomatchingOnMountEpic.js +8 -6
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +7 -1
- package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.js +11 -1
- package/lib/esm/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +2 -1
- package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +127 -1
- package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +20 -1
- package/lib/esm/view/expenseAutomationView/types/completedSubTab.js +17 -0
- package/lib/esm/view/expenseAutomationView/types/missingReceiptsViewState.js +0 -2
- package/lib/esm/view/financeStatement/financeStatementSelector.js +1 -1
- package/lib/esm/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewPayload.js +1 -0
- package/lib/esm/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewReducer.js +82 -0
- package/lib/esm/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewSelector.js +93 -0
- package/lib/esm/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewState.js +14 -0
- package/lib/esm/view/spendManagement/cashManagement/cashManagementOverview/epics/fetchCashManagementBannerEpic.js +6 -0
- package/lib/esm/view/spendManagement/cashManagement/cashManagementOverview/epics/fetchCashManagementOverviewPageEpic.js +42 -0
- package/lib/esm/view/spendManagement/cashManagement/cashManagementOverview/epics/fetchUpcomingPaymentEventsEpic.js +22 -0
- package/lib/esm/view/spendManagement/chargeCards/cashbackDetail/cashbackDetailReducer.js +3 -2
- package/lib/esm/view/spendManagement/chargeCards/chargeCardConfig/chargeCardConfigReducer.js +3 -2
- package/lib/esm/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailReducer.js +55 -18
- package/lib/esm/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardDetailEpic.js +16 -2
- package/lib/esm/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardDetailPageEpic.js +5 -4
- package/lib/esm/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.js +26 -9
- package/lib/esm/view/spendManagement/chargeCards/chargeCardList/fetchChargeCardListPageEpic.js +9 -6
- package/lib/esm/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryReducer.js +3 -2
- package/lib/esm/view/spendManagement/chargeCards/chargeCardPaymentHistory/fetchChargeCardPaymentPageEpic.js +1 -1
- package/lib/esm/view/spendManagement/chargeCards/chargeCardRepaymentDetail/chargeCardRepaymentDetailReducer.js +7 -3
- package/lib/esm/view/spendManagement/commonHistoryView/commonHistoryPayload.js +1 -0
- 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/transactionDetail/transactionDetailSelector.js +7 -1
- package/lib/index.d.ts +22 -15
- package/lib/index.js +77 -58
- package/lib/reducer.d.ts +8 -2
- package/lib/reducer.js +8 -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 +2 -5
- package/lib/view/aiAccountantView/epics/fetchAiAccountantJobsEpic.js +2 -5
- package/lib/view/aiAccountantView/epics/triggerAiAccountantJobEpic.js +4 -1
- package/lib/view/companyTaskManagerView/companyTaskManagerViewSelector.d.ts +1 -1
- package/lib/view/companyTaskManagerView/companyTaskManagerViewSelector.js +1 -1
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +2 -2
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +2 -1
- package/lib/view/expenseAutomationView/epics/missingReceipts/restoreBulkUploadAutomatchingOnMountEpic.js +8 -6
- package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +7 -1
- package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.d.ts +2 -2
- package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.js +10 -0
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
- package/lib/view/expenseAutomationView/payload/transactionCategorizationPayload.d.ts +21 -0
- package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +2 -1
- package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +2 -1
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +9 -3
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +128 -2
- package/lib/view/expenseAutomationView/selectorTypes/missingReceiptsSelectorTypes.d.ts +2 -1
- package/lib/view/expenseAutomationView/selectorTypes/transactionsViewSelectorTypes.d.ts +14 -0
- package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +20 -1
- package/lib/view/expenseAutomationView/types/completedSubTab.d.ts +10 -0
- package/lib/view/expenseAutomationView/types/completedSubTab.js +21 -0
- package/lib/view/expenseAutomationView/types/missingReceiptsViewState.d.ts +1 -2
- package/lib/view/expenseAutomationView/types/missingReceiptsViewState.js +1 -4
- package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +41 -2
- package/lib/view/financeStatement/financeStatementSelector.js +1 -1
- package/lib/view/profitAndLossProjectView/profitAndLossProjectViewSelectorTypes.d.ts +1 -1
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewPayload.d.ts +10 -0
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewPayload.js +2 -0
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewReducer.d.ts +20 -0
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewReducer.js +86 -0
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewSelector.d.ts +20 -0
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewSelector.js +98 -0
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewState.d.ts +21 -0
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/cashManagementOverviewState.js +17 -0
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/epics/fetchCashManagementBannerEpic.d.ts +5 -0
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/epics/fetchCashManagementBannerEpic.js +10 -0
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/epics/fetchCashManagementOverviewPageEpic.d.ts +9 -0
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/epics/fetchCashManagementOverviewPageEpic.js +46 -0
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/epics/fetchUpcomingPaymentEventsEpic.d.ts +8 -0
- package/lib/view/spendManagement/cashManagement/cashManagementOverview/epics/fetchUpcomingPaymentEventsEpic.js +26 -0
- package/lib/view/spendManagement/chargeCards/cashbackDetail/cashbackDetailReducer.d.ts +3 -1
- package/lib/view/spendManagement/chargeCards/cashbackDetail/cashbackDetailReducer.js +3 -2
- package/lib/view/spendManagement/chargeCards/chargeCardConfig/chargeCardConfigReducer.d.ts +3 -1
- package/lib/view/spendManagement/chargeCards/chargeCardConfig/chargeCardConfigReducer.js +3 -2
- package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailReducer.js +55 -18
- package/lib/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardDetailEpic.js +16 -2
- package/lib/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardDetailPageEpic.js +5 -4
- package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.d.ts +18 -3
- package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.js +27 -10
- package/lib/view/spendManagement/chargeCards/chargeCardList/fetchChargeCardListPageEpic.js +9 -6
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryReducer.d.ts +3 -1
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryReducer.js +3 -2
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/fetchChargeCardPaymentPageEpic.js +1 -1
- package/lib/view/spendManagement/chargeCards/chargeCardRepaymentDetail/chargeCardRepaymentDetailReducer.d.ts +3 -1
- package/lib/view/spendManagement/chargeCards/chargeCardRepaymentDetail/chargeCardRepaymentDetailReducer.js +7 -3
- package/lib/view/spendManagement/commonHistoryView/commonHistory.d.ts +1 -0
- package/lib/view/spendManagement/commonHistoryView/commonHistoryPayload.d.ts +1 -0
- package/lib/view/spendManagement/commonHistoryView/commonHistoryPayload.js +1 -0
- package/lib/view/transactionDetail/transactionDetailSelector.js +7 -1
- package/lib/view/zeniOAuthView/zeniOAuthSelector.d.ts +1 -1
- package/package.json +9 -4
|
@@ -4,6 +4,7 @@ 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';
|
|
7
8
|
export const initialTransactionTabViewState = {
|
|
8
9
|
saveStatus: {
|
|
9
10
|
fetchState: 'Not-Started',
|
|
@@ -41,12 +42,74 @@ export const initialTransactionTabViewState = {
|
|
|
41
42
|
selectedTransactionLineId: undefined,
|
|
42
43
|
};
|
|
43
44
|
export const initialState = {
|
|
45
|
+
autoCategorizedSubTabCache: {},
|
|
46
|
+
parentTotalCountByTab: {
|
|
47
|
+
review: {},
|
|
48
|
+
autoCategorized: {},
|
|
49
|
+
},
|
|
44
50
|
selectedTransactionCategorizationTab: 'review',
|
|
51
|
+
selectedTransactionCategorizationCompletedSubTab: DEFAULT_COMPLETED_SUB_TAB,
|
|
45
52
|
transactionCategorizationView: {
|
|
46
53
|
review: { ...initialTransactionTabViewState },
|
|
47
54
|
autoCategorized: { ...initialTransactionTabViewState },
|
|
48
55
|
},
|
|
49
56
|
};
|
|
57
|
+
/**
|
|
58
|
+
* Capture the autoCategorized tab's current paginated dataset for a sub-tab.
|
|
59
|
+
* The mid-flight `'In-Progress'` state is normalised to `'Completed'` because
|
|
60
|
+
* the in-flight request is cancelled by `switchMap` in the fetch epic when the
|
|
61
|
+
* sub-tab changes — restoring `'In-Progress'` later would leave the UI stuck
|
|
62
|
+
* showing a phantom loading state with no fetch actually running. Length-zero
|
|
63
|
+
* datasets degrade to `'Not-Started'` so the next visit triggers a fresh
|
|
64
|
+
* fetch from page 1 instead of short-circuiting on stale empty caches.
|
|
65
|
+
*
|
|
66
|
+
* Snapshot scope (deliberately narrow):
|
|
67
|
+
* - Captured: `pageToken`, `totalCount`, `transactionIdsBySelectedPeriod`,
|
|
68
|
+
* `fetchState`, `error`, `scrollPosition`. The first five are the keys the
|
|
69
|
+
* fetch epic's cache check reads to decide whether to short-circuit a
|
|
70
|
+
* sub-tab revisit; `scrollPosition` is captured per sub-tab so revisiting
|
|
71
|
+
* restores the user's last offset and switching to a never-visited sub-tab
|
|
72
|
+
* starts at the top instead of inheriting the outgoing sub-tab's offset
|
|
73
|
+
* (which would land the user at a meaningless row index against a
|
|
74
|
+
* completely different list).
|
|
75
|
+
* - Intentionally NOT captured (left in place on `autoCat` and inherited by
|
|
76
|
+
* the incoming sub-tab):
|
|
77
|
+
* - `uiState.searchString`, `uiState.sortKey`, `uiState.sortOrder`,
|
|
78
|
+
* `uiState.nodeCollapseState`, `uiState.limit` — search and sort are
|
|
79
|
+
* user-applied preferences that persist across sub-tabs by design (a
|
|
80
|
+
* search query stays active when the user toggles between Manual / AI
|
|
81
|
+
* Accountant).
|
|
82
|
+
* - `selectedCheckBoxTransactionIds` — selection state is intentionally
|
|
83
|
+
* cleared at the action source (the fetch epic / save flow), not
|
|
84
|
+
* by the snapshot path. Carrying selection across sub-tabs is safe
|
|
85
|
+
* because every sub-tab change goes through a fetch round-trip that
|
|
86
|
+
* reconciles selection against the new row IDs.
|
|
87
|
+
* - `transactionReviewLocalDataById`, `transactionIdsWithUnsavedData`,
|
|
88
|
+
* `uploadReceiptStatusById`, `saveStatus`, `refreshStatus`,
|
|
89
|
+
* `markAsNotMiscategorizedStatus` — these are per-row / per-flight
|
|
90
|
+
* caches that are write-through global state, not sub-tab-scoped.
|
|
91
|
+
*
|
|
92
|
+
* If the contract changes (e.g. selection should reset on every sub-tab
|
|
93
|
+
* switch), update both this comment and the snapshot return shape together.
|
|
94
|
+
*/
|
|
95
|
+
function snapshotAutoCategorizedTab(autoCat) {
|
|
96
|
+
const transactionIdsBySelectedPeriod = {
|
|
97
|
+
...autoCat.transactionIdsBySelectedPeriod,
|
|
98
|
+
};
|
|
99
|
+
const hasAnyLoadedRows = Object.values(transactionIdsBySelectedPeriod).some((ids) => ids.length > 0);
|
|
100
|
+
let normalisedFetchState = autoCat.fetchState;
|
|
101
|
+
if (normalisedFetchState === 'In-Progress') {
|
|
102
|
+
normalisedFetchState = hasAnyLoadedRows ? 'Completed' : 'Not-Started';
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
error: autoCat.error,
|
|
106
|
+
fetchState: normalisedFetchState,
|
|
107
|
+
pageToken: autoCat.uiState.pageToken,
|
|
108
|
+
scrollPosition: autoCat.uiState.scrollPosition,
|
|
109
|
+
totalCount: { ...autoCat.uiState.totalCount },
|
|
110
|
+
transactionIdsBySelectedPeriod,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
50
113
|
const expenseAutomationTransactionsView = createSlice({
|
|
51
114
|
name: 'expenseAutomationTransactionsView',
|
|
52
115
|
initialState,
|
|
@@ -260,6 +323,55 @@ const expenseAutomationTransactionsView = createSlice({
|
|
|
260
323
|
return { payload: { newSelectedTab } };
|
|
261
324
|
},
|
|
262
325
|
},
|
|
326
|
+
updateTransactionCategorizationCompletedSubTab: {
|
|
327
|
+
reducer(draft, action) {
|
|
328
|
+
const { newSubTab } = action.payload;
|
|
329
|
+
const previousSubTab = draft.selectedTransactionCategorizationCompletedSubTab;
|
|
330
|
+
if (previousSubTab === newSubTab) {
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
const autoCat = draft.transactionCategorizationView.autoCategorized;
|
|
334
|
+
// Snapshot the outgoing sub-tab so a future revisit can short-circuit
|
|
335
|
+
// the fetch epic (mirrors the parent-tab "don't refetch what's
|
|
336
|
+
// already cached" behaviour). Period-scoped data is preserved as-is
|
|
337
|
+
// because the snapshot itself is keyed only by sub-tab; the active
|
|
338
|
+
// tab's per-period maps remain the source of truth while live.
|
|
339
|
+
draft.autoCategorizedSubTabCache[previousSubTab] =
|
|
340
|
+
snapshotAutoCategorizedTab(autoCat);
|
|
341
|
+
const cached = draft.autoCategorizedSubTabCache[newSubTab];
|
|
342
|
+
if (cached != null) {
|
|
343
|
+
autoCat.uiState.pageToken = cached.pageToken;
|
|
344
|
+
autoCat.uiState.totalCount = { ...cached.totalCount };
|
|
345
|
+
autoCat.uiState.scrollPosition = cached.scrollPosition;
|
|
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. `scrollPosition` is reset to the top
|
|
357
|
+
// so the incoming list isn't anchored to the outgoing sub-tab's
|
|
358
|
+
// offset (different rows → previous offset is meaningless).
|
|
359
|
+
autoCat.uiState.pageToken = null;
|
|
360
|
+
autoCat.uiState.totalCount = {};
|
|
361
|
+
autoCat.uiState.scrollPosition = {
|
|
362
|
+
scrollTop: 0,
|
|
363
|
+
scrollLeft: undefined,
|
|
364
|
+
};
|
|
365
|
+
autoCat.transactionIdsBySelectedPeriod = {};
|
|
366
|
+
autoCat.fetchState = 'Not-Started';
|
|
367
|
+
autoCat.error = undefined;
|
|
368
|
+
}
|
|
369
|
+
draft.selectedTransactionCategorizationCompletedSubTab = newSubTab;
|
|
370
|
+
},
|
|
371
|
+
prepare(newSubTab) {
|
|
372
|
+
return { payload: { newSubTab } };
|
|
373
|
+
},
|
|
374
|
+
},
|
|
263
375
|
updateTransactionCategorization: {
|
|
264
376
|
reducer(draft, action) {
|
|
265
377
|
const selectedTab = action.payload.selectedTab;
|
|
@@ -697,6 +809,10 @@ const expenseAutomationTransactionsView = createSlice({
|
|
|
697
809
|
const { selectedTab, selectedPeriod, totalCount } = action.payload;
|
|
698
810
|
draft.transactionCategorizationView[selectedTab].uiState.totalCount[toMonthYearPeriodId(selectedPeriod)] = totalCount;
|
|
699
811
|
},
|
|
812
|
+
updateParentTotalCountForTab(draft, action) {
|
|
813
|
+
const { selectedTab, selectedPeriod, parentTotalCount } = action.payload;
|
|
814
|
+
draft.parentTotalCountByTab[selectedTab][toMonthYearPeriodId(selectedPeriod)] = parentTotalCount;
|
|
815
|
+
},
|
|
700
816
|
updateSelectedCheckboxTransactionIds(draft, action) {
|
|
701
817
|
const selectedTab = action.payload.selectedTab;
|
|
702
818
|
const transactionIds = action.payload.transactionIds;
|
|
@@ -707,6 +823,16 @@ const expenseAutomationTransactionsView = createSlice({
|
|
|
707
823
|
draft.transactionCategorizationView[selectedTab] = {
|
|
708
824
|
...initialTransactionTabViewState,
|
|
709
825
|
};
|
|
826
|
+
draft.parentTotalCountByTab[selectedTab] = {};
|
|
827
|
+
// The per-sub-tab snapshot cache lives at the slice root and is
|
|
828
|
+
// exclusively populated by the autoCategorized tab's sub-tab switching
|
|
829
|
+
// (see updateTransactionCategorizationCompletedSubTab). When that tab
|
|
830
|
+
// is reset, leaving stale snapshots behind would short-circuit the
|
|
831
|
+
// next sub-tab visit with phantom row IDs / page tokens that no longer
|
|
832
|
+
// correspond to anything in state — drop them in lockstep.
|
|
833
|
+
if (selectedTab === 'autoCategorized') {
|
|
834
|
+
draft.autoCategorizedSubTabCache = {};
|
|
835
|
+
}
|
|
710
836
|
},
|
|
711
837
|
clearExpenseAutomationTransactionsView(draft) {
|
|
712
838
|
Object.assign(draft, initialState);
|
|
@@ -803,5 +929,5 @@ const expenseAutomationTransactionsView = createSlice({
|
|
|
803
929
|
},
|
|
804
930
|
},
|
|
805
931
|
});
|
|
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;
|
|
932
|
+
export const { fetchTransactionCategorization, updateTransactionCategorizationUIState, initializeTransactionCategorizationViewLocalData, saveTransactionCategorizationLocalData, fetchTransactionCategorizationFailure, saveTransactionCategorization, updateTransactionCategorization, updateCurrentSelectedTransactionCategorizationTab, updateTransactionCategorizationCompletedSubTab, updateTransactionCategorizationSaveStatus, markTransactionAsNotMiscategorized, updateStatusForTransactionNotMiscategorizedUpdateForCategorization, updateSelectedVendorForTransaction, updateSelectedCustomerForTransaction, setAllItemsToCategoryClassInLocalDataForCategorization, updateTotalCountForTransactionCategorization, updateParentTotalCountForTab, fetchTransactionCategorizationSuccess, resetOtherTabsFetchState, fetchTransactionCategorizationView, updateSelectedCheckboxTransactionIds, clearExpenseAutomationTransactionsViewPerTabView, clearExpenseAutomationTransactionsView, setEntityRecommendationForLineIdsForCategorization, updateSelectedTransactionId, syncTransactionCategorizationFromDetailSave, backgroundRefetchReviewTab, updateTransactionCategorizationUploadReceiptState, uploadTransactionCategorizationReceiptSuccess, } = expenseAutomationTransactionsView.actions;
|
|
807
933
|
export default expenseAutomationTransactionsView.reducer;
|
|
@@ -10,7 +10,7 @@ import { getProjectList } from '../../projectList/projectListSelector';
|
|
|
10
10
|
import { getAllSteps } from '../selectorTypes/expenseAutomationViewSelectorTypes';
|
|
11
11
|
export function getExpenseAutomationTransactionView(state) {
|
|
12
12
|
const { accountState, classState, classListState, accountListState, expenseAutomationTransactionsViewState, expenseAutomationViewState, projectState, projectListState, transactionState, monthEndCloseChecksState, monthEndCloseChecksViewState, } = state;
|
|
13
|
-
const { selectedTransactionCategorizationTab } = expenseAutomationTransactionsViewState;
|
|
13
|
+
const { selectedTransactionCategorizationCompletedSubTab, selectedTransactionCategorizationTab, } = expenseAutomationTransactionsViewState;
|
|
14
14
|
const { uiState, refreshStatus, saveStatus, markAsNotMiscategorizedStatus, transactionIdsBySelectedPeriod, transactionReviewLocalDataById, selectedCheckBoxTransactionIds, transactionIdsWithUnsavedData, uploadReceiptStatusById, selectedTransactionId, selectedTransactionLineId, } = expenseAutomationTransactionsViewState.transactionCategorizationView[selectedTransactionCategorizationTab];
|
|
15
15
|
const uncategorizedIncomeExpense = getUncategorizedAccounts(accountState, accountListState, 'accountList');
|
|
16
16
|
const accountList = getAccountList(accountState, accountListState, 'accountList');
|
|
@@ -63,10 +63,27 @@ export function getExpenseAutomationTransactionView(state) {
|
|
|
63
63
|
.uiState.totalCount;
|
|
64
64
|
const totalCountByAutoCat = expenseAutomationTransactionsViewState.transactionCategorizationView
|
|
65
65
|
.autoCategorized.uiState.totalCount;
|
|
66
|
+
// Per-(sub-)tab counts powering pagination, in-list "showing X of Y", and
|
|
67
|
+
// any save/refresh round-trips. Sourced from `uiState.totalCount` which
|
|
68
|
+
// mirrors the response's `total_count` for whatever tab/sub-tab the user is
|
|
69
|
+
// viewing (e.g. only the Manual sub-tab rows for Completed → Manual).
|
|
66
70
|
const totalCountByTab = {
|
|
67
71
|
review: monthYearPeriodId != null ? totalCountByReview[monthYearPeriodId] : 0,
|
|
68
72
|
autoCategorized: monthYearPeriodId != null ? totalCountByAutoCat[monthYearPeriodId] : 0,
|
|
69
73
|
};
|
|
74
|
+
// Parent-tab badge counts. Sourced from `parent_tab_total_count` in the
|
|
75
|
+
// listing response and used exclusively by the navbar / tab strip badges.
|
|
76
|
+
// Independent of which Completed sub-tab is active so the badge stays
|
|
77
|
+
// stable across sub-tab switches.
|
|
78
|
+
const parentTotalCountByTab = expenseAutomationTransactionsViewState.parentTotalCountByTab;
|
|
79
|
+
const parentTabTotalCountByTab = {
|
|
80
|
+
review: monthYearPeriodId != null
|
|
81
|
+
? (parentTotalCountByTab.review[monthYearPeriodId] ?? 0)
|
|
82
|
+
: 0,
|
|
83
|
+
autoCategorized: monthYearPeriodId != null
|
|
84
|
+
? (parentTotalCountByTab.autoCategorized[monthYearPeriodId] ?? 0)
|
|
85
|
+
: 0,
|
|
86
|
+
};
|
|
70
87
|
const fetchStateByTab = {
|
|
71
88
|
review: {
|
|
72
89
|
fetchState: expenseAutomationTransactionsViewState.transactionCategorizationView
|
|
@@ -108,9 +125,11 @@ export function getExpenseAutomationTransactionView(state) {
|
|
|
108
125
|
markAsNotMiscategorizedStatus,
|
|
109
126
|
completionStatus,
|
|
110
127
|
totalCountByTab,
|
|
128
|
+
parentTabTotalCountByTab,
|
|
111
129
|
fetchStateByTransactionTabs: fetchStateByTab,
|
|
112
130
|
uploadReceiptStatusById,
|
|
113
131
|
selectedTransactionId,
|
|
114
132
|
selectedTransactionLineId,
|
|
133
|
+
selectedTransactionCategorizationCompletedSubTab,
|
|
115
134
|
};
|
|
116
135
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { stringToUnion } from '../../../commonStateTypes/stringToUnion';
|
|
2
|
+
/**
|
|
3
|
+
* Sub-tabs that can appear under any "Completed" tab in the Expense Automation
|
|
4
|
+
* surface (Transaction Categorization Completed and Missing Receipts Completed
|
|
5
|
+
* both use this exact union). Forwarded verbatim to listing APIs as `sub_tab`
|
|
6
|
+
* / `match_type`. `'all'` preserves parent-tab semantics on the backend.
|
|
7
|
+
*/
|
|
8
|
+
const COMPLETED_SUB_TABS = ['all', 'ai_accountant', 'manual'];
|
|
9
|
+
export const toCompletedSubTab = (v) => stringToUnion(v.trim().toLowerCase(), COMPLETED_SUB_TABS);
|
|
10
|
+
/**
|
|
11
|
+
* "No sub-tab filter" sentinel — single source of truth for the default
|
|
12
|
+
* value of {@link CompletedSubTab}. Use this constant in initial slice
|
|
13
|
+
* state and at any call site that needs to fall back to the parent-tab
|
|
14
|
+
* listing semantics (review tab requests, manual-search overrides, etc.)
|
|
15
|
+
* so a future rename of the union doesn't require chasing literals.
|
|
16
|
+
*/
|
|
17
|
+
export const DEFAULT_COMPLETED_SUB_TAB = 'all';
|
|
@@ -39,8 +39,6 @@ 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);
|
|
44
42
|
const MATCH_SOURCES = ['ai', 'manual'];
|
|
45
43
|
export const toMatchSource = (v) => stringToUnion(v.trim().toLowerCase(), MATCH_SOURCES);
|
|
46
44
|
const BULK_UPLOAD_SORT_KEYS = [
|
|
@@ -2,6 +2,7 @@ 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';
|
|
5
6
|
import { getNumberOfPeriods, } from '../../commonStateTypes/dataAvailable';
|
|
6
7
|
import { reduceAnyCompletedFetchState } from '../../commonStateTypes/reduceFetchState';
|
|
7
8
|
import { toTimeframeTick, } from '../../commonStateTypes/timeframeTick';
|
|
@@ -9,7 +10,6 @@ import { extractThisPeriod } from '../../commonStateTypes/viewAndReport/thisPeri
|
|
|
9
10
|
import { getBalanceSheet } from '../balanceSheet/balanceSheetSelector';
|
|
10
11
|
import { getCashFlow } from '../cashFlow/cashFlowSelector';
|
|
11
12
|
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';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { createSlice } from '@reduxjs/toolkit';
|
|
2
|
+
import { initialCashManagementBannerState, initialUpcomingPaymentEventsListState, } from './cashManagementOverviewState';
|
|
3
|
+
export const initialState = {
|
|
4
|
+
banner: initialCashManagementBannerState,
|
|
5
|
+
upcomingPaymentEvents: initialUpcomingPaymentEventsListState,
|
|
6
|
+
fetchState: 'Not-Started',
|
|
7
|
+
error: undefined,
|
|
8
|
+
hasValidState() {
|
|
9
|
+
return this.fetchState == 'Completed';
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
const cashManagementOverview = createSlice({
|
|
13
|
+
name: 'cashManagementOverview',
|
|
14
|
+
initialState,
|
|
15
|
+
reducers: {
|
|
16
|
+
fetchCashManagementOverviewPage: {
|
|
17
|
+
reducer() { },
|
|
18
|
+
prepare(cacheOverride) {
|
|
19
|
+
return { payload: { cacheOverride } };
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
fetchUpcomingPaymentEvents(draft) {
|
|
23
|
+
draft.upcomingPaymentEvents = {
|
|
24
|
+
...draft.upcomingPaymentEvents,
|
|
25
|
+
fetchState: 'In-Progress',
|
|
26
|
+
error: undefined,
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
updateUpcomingPaymentEventsList(draft, action) {
|
|
30
|
+
const { data } = action.payload;
|
|
31
|
+
const eventIds = [];
|
|
32
|
+
data.events.forEach((payload) => {
|
|
33
|
+
if (payload.id != null) {
|
|
34
|
+
eventIds.push(payload.id);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
draft.upcomingPaymentEvents = {
|
|
38
|
+
fetchState: 'Completed',
|
|
39
|
+
error: undefined,
|
|
40
|
+
billStages: (data.bill_stages ?? []),
|
|
41
|
+
eventIds,
|
|
42
|
+
horizonDays: data.horizon_days,
|
|
43
|
+
reimbursementStages: (data.reimbursement_stages ??
|
|
44
|
+
[]),
|
|
45
|
+
tenantNamespace: data.tenant_namespace,
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
updateUpcomingPaymentEventsListFetchStatus(draft, action) {
|
|
49
|
+
draft.upcomingPaymentEvents = {
|
|
50
|
+
...draft.upcomingPaymentEvents,
|
|
51
|
+
fetchState: action.payload.fetchState,
|
|
52
|
+
error: action.payload.error,
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
fetchCashManagementBanner(draft) {
|
|
56
|
+
draft.banner = {
|
|
57
|
+
...initialCashManagementBannerState,
|
|
58
|
+
fetchState: 'In-Progress',
|
|
59
|
+
error: undefined,
|
|
60
|
+
};
|
|
61
|
+
},
|
|
62
|
+
updateCashManagementBanner(draft, action) {
|
|
63
|
+
draft.banner = {
|
|
64
|
+
fetchState: 'Completed',
|
|
65
|
+
error: undefined,
|
|
66
|
+
data: action.payload.data,
|
|
67
|
+
};
|
|
68
|
+
},
|
|
69
|
+
updateCashManagementBannerFetchStatus(draft, action) {
|
|
70
|
+
draft.banner = {
|
|
71
|
+
...draft.banner,
|
|
72
|
+
fetchState: action.payload.fetchState,
|
|
73
|
+
error: action.payload.error,
|
|
74
|
+
};
|
|
75
|
+
},
|
|
76
|
+
clearCashManagementOverview(draft) {
|
|
77
|
+
Object.assign(draft, initialState);
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
export const { fetchCashManagementOverviewPage, fetchUpcomingPaymentEvents, updateUpcomingPaymentEventsList, updateUpcomingPaymentEventsListFetchStatus, fetchCashManagementBanner, updateCashManagementBanner, updateCashManagementBannerFetchStatus, clearCashManagementOverview, } = cashManagementOverview.actions;
|
|
82
|
+
export default cashManagementOverview.reducer;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { zeroAmount } from '../../../../commonStateTypes/amount';
|
|
2
|
+
import { reduceAllFetchState } from '../../../../commonStateTypes/reduceFetchState';
|
|
3
|
+
import { getUpcomingPaymentEventsByIds } from '../../../../entity/upcomingPaymentEvent/upcomingPaymentEventSelector';
|
|
4
|
+
export const getCashManagementOverviewBanner = (state) => {
|
|
5
|
+
const { banner } = state.cashManagementOverviewState;
|
|
6
|
+
return {
|
|
7
|
+
fetchState: banner.fetchState,
|
|
8
|
+
error: banner.error,
|
|
9
|
+
data: banner.data,
|
|
10
|
+
version: 0,
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export const getCashManagementOverview = (state) => {
|
|
14
|
+
const { cashManagementOverviewState, depositAccountListState, depositAccountState, paymentAccountListState, paymentAccountState, treasuryDetailState, } = state;
|
|
15
|
+
const outflowEventsFetchState = {
|
|
16
|
+
fetchState: cashManagementOverviewState.upcomingPaymentEvents.fetchState,
|
|
17
|
+
error: cashManagementOverviewState.upcomingPaymentEvents.error,
|
|
18
|
+
};
|
|
19
|
+
const bannerFetchState = {
|
|
20
|
+
fetchState: cashManagementOverviewState.banner.fetchState,
|
|
21
|
+
error: cashManagementOverviewState.banner.error,
|
|
22
|
+
};
|
|
23
|
+
const aggregate = reduceAllFetchState([
|
|
24
|
+
{
|
|
25
|
+
fetchState: paymentAccountListState.fetchState,
|
|
26
|
+
error: paymentAccountListState.error,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
fetchState: depositAccountListState.fetchState,
|
|
30
|
+
error: depositAccountListState.error,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
fetchState: treasuryDetailState.fetchState,
|
|
34
|
+
error: treasuryDetailState.error,
|
|
35
|
+
},
|
|
36
|
+
outflowEventsFetchState,
|
|
37
|
+
bannerFetchState,
|
|
38
|
+
]);
|
|
39
|
+
const treasuryBalance = treasuryDetailState.accountSummary?.totalBalance ?? zeroAmount();
|
|
40
|
+
const cashBalance = sumCashBalances(paymentAccountListState.paymentAccountIds, paymentAccountState, depositAccountListState.accountIds, depositAccountState);
|
|
41
|
+
const totalCash = addAmounts(treasuryBalance, cashBalance);
|
|
42
|
+
return {
|
|
43
|
+
bannerFetchState,
|
|
44
|
+
cashBalance,
|
|
45
|
+
horizonDays: cashManagementOverviewState.upcomingPaymentEvents.horizonDays,
|
|
46
|
+
outflowEvents: getUpcomingPaymentEventsByIds(state.upcomingPaymentEventState, cashManagementOverviewState.upcomingPaymentEvents.eventIds),
|
|
47
|
+
outflowEventsFetchState,
|
|
48
|
+
totalCash,
|
|
49
|
+
treasuryBalance,
|
|
50
|
+
fetchState: aggregate.fetchState,
|
|
51
|
+
error: aggregate.error,
|
|
52
|
+
version: 0,
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
const isZeroAmount = (a) => a.amount === 0 && a.currencyCode === 'USD' && a.currencySymbol === '$';
|
|
56
|
+
/**
|
|
57
|
+
* Adds two Amounts. Currencies must match (the seeded zeroAmount() counts as
|
|
58
|
+
* "no currency yet" and adopts `b`'s currency). Mismatches return `a`
|
|
59
|
+
* unchanged and warn — mixing currencies in a total is a bug, not silent
|
|
60
|
+
* conversion.
|
|
61
|
+
*/
|
|
62
|
+
const addAmounts = (a, b) => {
|
|
63
|
+
if (isZeroAmount(a)) {
|
|
64
|
+
return { ...b };
|
|
65
|
+
}
|
|
66
|
+
if (a.currencyCode !== b.currencyCode ||
|
|
67
|
+
a.currencySymbol !== b.currencySymbol) {
|
|
68
|
+
console.warn(`cashManagementOverview: skipping balance with mismatched currency. Expected ${a.currencyCode} (${a.currencySymbol}), got ${b.currencyCode} (${b.currencySymbol}).`);
|
|
69
|
+
return a;
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
amount: a.amount + b.amount,
|
|
73
|
+
currencyCode: a.currencyCode,
|
|
74
|
+
currencySymbol: a.currencySymbol,
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
const sumCashBalances = (paymentAccountIds, paymentAccountState, depositAccountIds, depositAccountState) => {
|
|
78
|
+
let total = zeroAmount();
|
|
79
|
+
paymentAccountIds.forEach((id) => {
|
|
80
|
+
const balance = paymentAccountState.paymentAccountByID[id]?.balances
|
|
81
|
+
?.available;
|
|
82
|
+
if (balance != null) {
|
|
83
|
+
total = addAmounts(total, balance);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
depositAccountIds.forEach((id) => {
|
|
87
|
+
const balance = depositAccountState.depositAccountByID[id]?.accountBalance?.available;
|
|
88
|
+
if (balance != null) {
|
|
89
|
+
total = addAmounts(total, balance);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
return total;
|
|
93
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const initialCashManagementBannerState = {
|
|
2
|
+
fetchState: 'Not-Started',
|
|
3
|
+
error: undefined,
|
|
4
|
+
data: undefined,
|
|
5
|
+
};
|
|
6
|
+
export const initialUpcomingPaymentEventsListState = {
|
|
7
|
+
fetchState: 'Not-Started',
|
|
8
|
+
error: undefined,
|
|
9
|
+
billStages: [],
|
|
10
|
+
eventIds: [],
|
|
11
|
+
horizonDays: 0,
|
|
12
|
+
reimbursementStages: [],
|
|
13
|
+
tenantNamespace: undefined,
|
|
14
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { EMPTY } from 'rxjs';
|
|
2
|
+
import { filter, mergeMap } from 'rxjs/operators';
|
|
3
|
+
import { fetchCashManagementBanner, } from '../cashManagementOverviewReducer';
|
|
4
|
+
// TODO: replace EMPTY with an actual API call once the banner endpoint is finalized.
|
|
5
|
+
// Figma: https://www.figma.com/design/FUg2pv7edRAidx9X56VnZT/Cash-Management?node-id=2265-63443
|
|
6
|
+
export const fetchCashManagementBannerEpic = (actions$) => actions$.pipe(filter(fetchCashManagementBanner.match), mergeMap(() => EMPTY));
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { concat, from } from 'rxjs';
|
|
2
|
+
import { filter, mergeMap } from 'rxjs/operators';
|
|
3
|
+
import { fetchAutoTransferRules } from '../../../autotransferRules/autoTransferRulesReducer';
|
|
4
|
+
import { fetchTreasuryOverviewDetail } from '../../../treasury/treasuryList/treasuryDetailReducer';
|
|
5
|
+
import { fetchZeniAccountList } from '../../../zeniAccounts/zeniAccountList/zeniAccountListReducer';
|
|
6
|
+
import { fetchCashManagementBanner, fetchCashManagementOverviewPage, fetchUpcomingPaymentEvents, } from '../cashManagementOverviewReducer';
|
|
7
|
+
export const fetchCashManagementOverviewPageEpic = (actions$, state$) => actions$.pipe(filter(fetchCashManagementOverviewPage.match), mergeMap((action) => {
|
|
8
|
+
const { cacheOverride } = action.payload;
|
|
9
|
+
const state = state$.value;
|
|
10
|
+
const pageActions = [];
|
|
11
|
+
if (cacheOverride === true) {
|
|
12
|
+
pageActions.push(fetchTreasuryOverviewDetail(true));
|
|
13
|
+
pageActions.push(fetchZeniAccountList(true));
|
|
14
|
+
pageActions.push(fetchUpcomingPaymentEvents());
|
|
15
|
+
pageActions.push(fetchCashManagementBanner());
|
|
16
|
+
pageActions.push(fetchAutoTransferRules(true));
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
const treasuryDetailState = state.treasuryDetailState;
|
|
20
|
+
if (treasuryDetailState.hasValidState() === false &&
|
|
21
|
+
treasuryDetailState.fetchState !== 'In-Progress') {
|
|
22
|
+
pageActions.push(fetchTreasuryOverviewDetail(false));
|
|
23
|
+
}
|
|
24
|
+
pageActions.push(fetchZeniAccountList(false));
|
|
25
|
+
const upcomingEvents = state.cashManagementOverviewState.upcomingPaymentEvents;
|
|
26
|
+
if (upcomingEvents.fetchState !== 'Completed' &&
|
|
27
|
+
upcomingEvents.fetchState !== 'In-Progress') {
|
|
28
|
+
pageActions.push(fetchUpcomingPaymentEvents());
|
|
29
|
+
}
|
|
30
|
+
const banner = state.cashManagementOverviewState.banner;
|
|
31
|
+
if (banner.fetchState !== 'Completed' &&
|
|
32
|
+
banner.fetchState !== 'In-Progress') {
|
|
33
|
+
pageActions.push(fetchCashManagementBanner());
|
|
34
|
+
}
|
|
35
|
+
const autoTransferRules = state.autotransferRulesState;
|
|
36
|
+
if (autoTransferRules.fetchState !== 'Completed' &&
|
|
37
|
+
autoTransferRules.fetchState !== 'In-Progress') {
|
|
38
|
+
pageActions.push(fetchAutoTransferRules(false));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return concat(from(pageActions));
|
|
42
|
+
}));
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { of } from 'rxjs';
|
|
2
|
+
import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
|
|
3
|
+
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../../responsePayload';
|
|
4
|
+
import { updateUpcomingPaymentEvents } from '../../../../../entity/upcomingPaymentEvent/upcomingPaymentEventReducer';
|
|
5
|
+
import { fetchUpcomingPaymentEvents, updateUpcomingPaymentEventsList, updateUpcomingPaymentEventsListFetchStatus, } from '../cashManagementOverviewReducer';
|
|
6
|
+
export const fetchUpcomingPaymentEventsEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(fetchUpcomingPaymentEvents.match), switchMap(() => zeniAPI
|
|
7
|
+
.getJSON(
|
|
8
|
+
// TODO: drop /rajat/ once the prod endpoint lands. `${zeniAPI.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/upcoming-payment-events`
|
|
9
|
+
`https://dev.api.zeni.ai/version/spend-management/rajat/1.0/upcoming-payment-events`)
|
|
10
|
+
.pipe(mergeMap((response) => {
|
|
11
|
+
if (isSuccessResponse(response) && response.data != null) {
|
|
12
|
+
return of(updateUpcomingPaymentEvents(response.data.events), updateUpcomingPaymentEventsList({ data: response.data }));
|
|
13
|
+
}
|
|
14
|
+
return of(updateUpcomingPaymentEventsListFetchStatus({
|
|
15
|
+
fetchState: 'Error',
|
|
16
|
+
error: response.status,
|
|
17
|
+
}));
|
|
18
|
+
}), catchError((error) => of(updateUpcomingPaymentEventsListFetchStatus({
|
|
19
|
+
fetchState: 'Error',
|
|
20
|
+
error: createZeniAPIStatus('Unexpected Error', 'Fetch upcoming payment events REST API call errored out' +
|
|
21
|
+
JSON.stringify(error)),
|
|
22
|
+
}))))));
|
|
@@ -1,6 +1,7 @@
|
|
|
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';
|
|
4
5
|
import { initialCashbackAnalytics, } from './cashbackDetailState';
|
|
5
6
|
export const initialState = {
|
|
6
7
|
fetchState: 'Not-Started',
|
|
@@ -27,10 +28,10 @@ const cashbackDetail = createSlice({
|
|
|
27
28
|
name: 'cashbackDetail',
|
|
28
29
|
initialState,
|
|
29
30
|
reducers: {
|
|
30
|
-
fetchCashbackDetail(draft) {
|
|
31
|
+
fetchCashbackDetail: createCacheOverrideFetchReducer((draft) => {
|
|
31
32
|
draft.fetchState = 'In-Progress';
|
|
32
33
|
draft.error = undefined;
|
|
33
|
-
},
|
|
34
|
+
}),
|
|
34
35
|
updateCashbackDetail(draft, action) {
|
|
35
36
|
draft.cashbackByPeriod = toCashbackByPeriod(action.payload);
|
|
36
37
|
draft.cashbackSummary = toCashbackSummary(action.payload);
|
package/lib/esm/view/spendManagement/chargeCards/chargeCardConfig/chargeCardConfigReducer.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createSlice } from '@reduxjs/toolkit';
|
|
2
2
|
import { toAmount } from '../../../../commonStateTypes/amount';
|
|
3
|
+
import { createCacheOverrideFetchReducer } from '../../../../commonStateTypes/cacheOverrideFetchReducer';
|
|
3
4
|
import { toCreditLimitFrequencyCodeType } from '../../../../entity/chargeCard/chargeCard';
|
|
4
5
|
import { toCreditTerm, toRePaymentInfo, } from './chargeCardConfigPayload';
|
|
5
6
|
export const initialState = {
|
|
@@ -30,10 +31,10 @@ const chargeCardConfig = createSlice({
|
|
|
30
31
|
name: 'chargeCardConfig',
|
|
31
32
|
initialState,
|
|
32
33
|
reducers: {
|
|
33
|
-
fetchChargeCardConfig(draft) {
|
|
34
|
+
fetchChargeCardConfig: createCacheOverrideFetchReducer((draft) => {
|
|
34
35
|
draft.fetchState = 'In-Progress';
|
|
35
36
|
draft.error = undefined;
|
|
36
|
-
},
|
|
37
|
+
}),
|
|
37
38
|
updateChargeCardConfig(draft, action) {
|
|
38
39
|
const { payload } = action;
|
|
39
40
|
draft.creditLimitFrequency =
|