@zeniai/client-epic-state 5.0.64 → 5.0.65-betaML1
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/epic.d.ts +2 -1
- package/lib/epic.js +2 -1
- package/lib/esm/epic.js +2 -1
- package/lib/esm/index.js +9 -8
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +2 -1
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +6 -0
- package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.js +11 -1
- package/lib/esm/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +21 -1
- package/lib/esm/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +2 -1
- package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +243 -14
- package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +48 -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/recommendation/fetchEntityRecommendationsForLineUpdateEpic.js +78 -0
- package/lib/esm/view/recommendation/recommendationHelper.js +29 -0
- package/lib/esm/view/recommendation/recommendationReducer.js +36 -1
- package/lib/esm/view/transactionDetail/transactionDetailReducer.js +94 -1
- package/lib/esm/view/transactionDetail/transactionDetailSelector.js +22 -0
- package/lib/index.d.ts +10 -8
- package/lib/index.js +42 -36
- package/lib/tsconfig.typecheck.tsbuildinfo +1 -1
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +2 -1
- package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +6 -0
- 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 -0
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +23 -2
- 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 +22 -3
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +243 -14
- package/lib/view/expenseAutomationView/selectorTypes/missingReceiptsSelectorTypes.d.ts +2 -1
- package/lib/view/expenseAutomationView/selectorTypes/transactionsViewSelectorTypes.d.ts +16 -0
- package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.d.ts +3 -0
- package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +49 -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 -1
- package/lib/view/recommendation/fetchEntityRecommendationsForLineUpdateEpic.d.ts +9 -0
- package/lib/view/recommendation/fetchEntityRecommendationsForLineUpdateEpic.js +82 -0
- package/lib/view/recommendation/recommendationHelper.d.ts +9 -0
- package/lib/view/recommendation/recommendationHelper.js +31 -1
- package/lib/view/recommendation/recommendationReducer.d.ts +18 -1
- package/lib/view/recommendation/recommendationReducer.js +37 -2
- package/lib/view/transactionDetail/transactionDetailReducer.d.ts +11 -1
- package/lib/view/transactionDetail/transactionDetailReducer.js +95 -2
- package/lib/view/transactionDetail/transactionDetailSelector.d.ts +2 -0
- package/lib/view/transactionDetail/transactionDetailSelector.js +24 -1
- package/lib/view/transactionDetail/transactionDetailTypes.d.ts +1 -0
- package/package.json +1 -1
|
@@ -2,7 +2,8 @@ import { CompletionStatusType, FetchStateAndError, ID } from '../../../commonSta
|
|
|
2
2
|
import { SortOrder } from '../../../commonStateTypes/selectorTypes/sortOrderTypes';
|
|
3
3
|
import { SelectorView } from '../../../commonStateTypes/viewAndReport/viewAndReport';
|
|
4
4
|
import { SupportedTransaction } from '../../../entity/transaction/transactionState';
|
|
5
|
-
import type {
|
|
5
|
+
import type { CompletedSubTab } from '../types/completedSubTab';
|
|
6
|
+
import type { BatchFileStatus, BatchListItem, BatchStatus, BulkUploadPhase, BulkUploadResultsTab, BulkUploadSortKey, ManualSearchState, MatchSource, MissingReceiptsViewUIState } from '../types/missingReceiptsViewState';
|
|
6
7
|
export interface CompletedTransactionsSelectorData {
|
|
7
8
|
fetchState: FetchStateAndError;
|
|
8
9
|
nextPageToken: string | null;
|
|
@@ -7,6 +7,7 @@ import { ClassBase } from '../../../entity/class/classState';
|
|
|
7
7
|
import { SupportedTransactionWithCOT } from '../../../entity/transaction/transactionState';
|
|
8
8
|
import { UncategorizedAccounts } from '../../accountList/accountListSelector';
|
|
9
9
|
import { ProjectListSelectorView } from '../../projectList/projectListSelector';
|
|
10
|
+
import { CompletedSubTab } from '../types/completedSubTab';
|
|
10
11
|
import { TransactionReviewLocalData, TransactionsTab, TransactionsViewUIState } from '../types/transactionsViewState';
|
|
11
12
|
export interface TransactionReviewLocalDataSelectorView {
|
|
12
13
|
transactionId: ID;
|
|
@@ -19,12 +20,27 @@ export interface ExpenseAutomationTransactionViewSelector extends SelectorView {
|
|
|
19
20
|
classList: ClassBase[];
|
|
20
21
|
completionStatus: CompletionStatusType;
|
|
21
22
|
fetchStateByTransactionTabs: Record<TransactionsTab, FetchStateAndError>;
|
|
23
|
+
hasInFlightCategoryClassRecommendations: boolean;
|
|
24
|
+
inFlightCategoryClassRecommendationsByTransactionId: Record<ID, boolean>;
|
|
22
25
|
isAccountingProjectsEnabled: boolean;
|
|
23
26
|
markAsNotMiscategorizedStatus: FetchStateAndError;
|
|
27
|
+
/**
|
|
28
|
+
* Parent tab badge counts, sourced from the listing response's
|
|
29
|
+
* `parent_tab_total_count`. Used exclusively to drive the navbar / tab
|
|
30
|
+
* strip badge labels — every other count consumer (pagination, in-list
|
|
31
|
+
* "showing X of Y", save flows) keeps reading {@link totalCountByTab}.
|
|
32
|
+
*/
|
|
33
|
+
parentTabTotalCountByTab: Record<TransactionsTab, number>;
|
|
24
34
|
projectList: ProjectListSelectorView;
|
|
25
35
|
refreshStatus: FetchStateAndError;
|
|
26
36
|
saveStatus: FetchStateAndError;
|
|
27
37
|
selectedCheckBoxTransactionIds: ID[];
|
|
38
|
+
selectedTransactionCategorizationCompletedSubTab: CompletedSubTab;
|
|
39
|
+
/**
|
|
40
|
+
* Per-(sub-)tab counts mirroring `total_count` from the listing response.
|
|
41
|
+
* Powers pagination via `InfiniteLoader.itemCount`, in-list count copy,
|
|
42
|
+
* and the `resetTransactionCategorizationLocalData` round-trip.
|
|
43
|
+
*/
|
|
28
44
|
totalCountByTab: Record<TransactionsTab, number>;
|
|
29
45
|
transactionIdsWithUnsavedData: ID[];
|
|
30
46
|
transactionLocalData: TransactionReviewLocalDataSelectorView[];
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { ID } from '../../../commonStateTypes/common';
|
|
1
2
|
import { RootState } from '../../../reducer';
|
|
2
3
|
import { ExpenseAutomationTransactionViewSelector } from '../selectorTypes/transactionsViewSelectorTypes';
|
|
4
|
+
export declare const getCategorizationInFlightRecommendationsByTransactionId: (state: RootState) => Record<ID, boolean>;
|
|
5
|
+
export declare const getCategorizationHasInFlightRecommendations: (state: RootState) => boolean;
|
|
3
6
|
export declare function getExpenseAutomationTransactionView(state: RootState): ExpenseAutomationTransactionViewSelector;
|
|
@@ -3,7 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getCategorizationHasInFlightRecommendations = exports.getCategorizationInFlightRecommendationsByTransactionId = void 0;
|
|
6
7
|
exports.getExpenseAutomationTransactionView = getExpenseAutomationTransactionView;
|
|
8
|
+
const toolkit_1 = require("@reduxjs/toolkit");
|
|
7
9
|
const omit_1 = __importDefault(require("lodash/omit"));
|
|
8
10
|
const reduceFetchState_1 = require("../../../commonStateTypes/reduceFetchState");
|
|
9
11
|
const timePeriod_1 = require("../../../commonStateTypes/timePeriod");
|
|
@@ -14,9 +16,32 @@ const accountListSelector_1 = require("../../accountList/accountListSelector");
|
|
|
14
16
|
const classListSelector_1 = require("../../classList/classListSelector");
|
|
15
17
|
const projectListSelector_1 = require("../../projectList/projectListSelector");
|
|
16
18
|
const expenseAutomationViewSelectorTypes_1 = require("../selectorTypes/expenseAutomationViewSelectorTypes");
|
|
19
|
+
// Per-transaction "any line is fetching category/class recommendations?"
|
|
20
|
+
// map for the active categorization tab. Memoized on the active tab's
|
|
21
|
+
// transactionReviewLocalDataById reference, so steady state (no fetches
|
|
22
|
+
// in flight) recomputes only when local data changes — and the row-table
|
|
23
|
+
// can read a single map lookup per row instead of re-iterating the
|
|
24
|
+
// row's lineItemById in the render path.
|
|
25
|
+
exports.getCategorizationInFlightRecommendationsByTransactionId = (0, toolkit_1.createSelector)((state) => state.expenseAutomationTransactionsViewState
|
|
26
|
+
.selectedTransactionCategorizationTab, (state) => state.expenseAutomationTransactionsViewState
|
|
27
|
+
.transactionCategorizationView, (selectedTab, transactionCategorizationView) => {
|
|
28
|
+
const tab = transactionCategorizationView[selectedTab];
|
|
29
|
+
const result = {};
|
|
30
|
+
for (const [transactionId, data] of Object.entries(tab.transactionReviewLocalDataById)) {
|
|
31
|
+
const lineItems = Object.values(data.transactionReviewLocalData.lineItemById);
|
|
32
|
+
if (lineItems.some((lineItem) => lineItem.categoryClassRecommendationsFetchState?.fetchState ===
|
|
33
|
+
'In-Progress')) {
|
|
34
|
+
result[transactionId] = true;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
38
|
+
});
|
|
39
|
+
// Page-level "any line on the active tab is in flight?" flag. Drives the
|
|
40
|
+
// list-page Save disable.
|
|
41
|
+
exports.getCategorizationHasInFlightRecommendations = (0, toolkit_1.createSelector)(exports.getCategorizationInFlightRecommendationsByTransactionId, (inFlightByTransactionId) => Object.keys(inFlightByTransactionId).length > 0);
|
|
17
42
|
function getExpenseAutomationTransactionView(state) {
|
|
18
43
|
const { accountState, classState, classListState, accountListState, expenseAutomationTransactionsViewState, expenseAutomationViewState, projectState, projectListState, transactionState, monthEndCloseChecksState, monthEndCloseChecksViewState, } = state;
|
|
19
|
-
const { selectedTransactionCategorizationTab } = expenseAutomationTransactionsViewState;
|
|
44
|
+
const { selectedTransactionCategorizationCompletedSubTab, selectedTransactionCategorizationTab, } = expenseAutomationTransactionsViewState;
|
|
20
45
|
const { uiState, refreshStatus, saveStatus, markAsNotMiscategorizedStatus, transactionIdsBySelectedPeriod, transactionReviewLocalDataById, selectedCheckBoxTransactionIds, transactionIdsWithUnsavedData, uploadReceiptStatusById, selectedTransactionId, selectedTransactionLineId, } = expenseAutomationTransactionsViewState.transactionCategorizationView[selectedTransactionCategorizationTab];
|
|
21
46
|
const uncategorizedIncomeExpense = (0, accountListSelector_1.getUncategorizedAccounts)(accountState, accountListState, 'accountList');
|
|
22
47
|
const accountList = (0, accountListSelector_1.getAccountList)(accountState, accountListState, 'accountList');
|
|
@@ -69,10 +94,27 @@ function getExpenseAutomationTransactionView(state) {
|
|
|
69
94
|
.uiState.totalCount;
|
|
70
95
|
const totalCountByAutoCat = expenseAutomationTransactionsViewState.transactionCategorizationView
|
|
71
96
|
.autoCategorized.uiState.totalCount;
|
|
97
|
+
// Per-(sub-)tab counts powering pagination, in-list "showing X of Y", and
|
|
98
|
+
// any save/refresh round-trips. Sourced from `uiState.totalCount` which
|
|
99
|
+
// mirrors the response's `total_count` for whatever tab/sub-tab the user is
|
|
100
|
+
// viewing (e.g. only the Manual sub-tab rows for Completed → Manual).
|
|
72
101
|
const totalCountByTab = {
|
|
73
102
|
review: monthYearPeriodId != null ? totalCountByReview[monthYearPeriodId] : 0,
|
|
74
103
|
autoCategorized: monthYearPeriodId != null ? totalCountByAutoCat[monthYearPeriodId] : 0,
|
|
75
104
|
};
|
|
105
|
+
// Parent-tab badge counts. Sourced from `parent_tab_total_count` in the
|
|
106
|
+
// listing response and used exclusively by the navbar / tab strip badges.
|
|
107
|
+
// Independent of which Completed sub-tab is active so the badge stays
|
|
108
|
+
// stable across sub-tab switches.
|
|
109
|
+
const parentTotalCountByTab = expenseAutomationTransactionsViewState.parentTotalCountByTab;
|
|
110
|
+
const parentTabTotalCountByTab = {
|
|
111
|
+
review: monthYearPeriodId != null
|
|
112
|
+
? (parentTotalCountByTab.review[monthYearPeriodId] ?? 0)
|
|
113
|
+
: 0,
|
|
114
|
+
autoCategorized: monthYearPeriodId != null
|
|
115
|
+
? (parentTotalCountByTab.autoCategorized[monthYearPeriodId] ?? 0)
|
|
116
|
+
: 0,
|
|
117
|
+
};
|
|
76
118
|
const fetchStateByTab = {
|
|
77
119
|
review: {
|
|
78
120
|
fetchState: expenseAutomationTransactionsViewState.transactionCategorizationView
|
|
@@ -92,6 +134,8 @@ function getExpenseAutomationTransactionView(state) {
|
|
|
92
134
|
: [];
|
|
93
135
|
const transactionCompletionStatus = allSteps.find((step) => step.step === 'transaction_categorization')?.completionStatus;
|
|
94
136
|
const completionStatus = transactionCompletionStatus ?? 'incomplete';
|
|
137
|
+
const inFlightCategoryClassRecommendationsByTransactionId = (0, exports.getCategorizationInFlightRecommendationsByTransactionId)(state);
|
|
138
|
+
const hasInFlightCategoryClassRecommendations = (0, exports.getCategorizationHasInFlightRecommendations)(state);
|
|
95
139
|
return {
|
|
96
140
|
version: 0,
|
|
97
141
|
fetchState: fetchStatus.fetchState,
|
|
@@ -105,6 +149,8 @@ function getExpenseAutomationTransactionView(state) {
|
|
|
105
149
|
classList: allClasses,
|
|
106
150
|
accountsHierarchyList,
|
|
107
151
|
classHierarchyList,
|
|
152
|
+
hasInFlightCategoryClassRecommendations,
|
|
153
|
+
inFlightCategoryClassRecommendationsByTransactionId,
|
|
108
154
|
isAccountingProjectsEnabled,
|
|
109
155
|
projectList,
|
|
110
156
|
transactionLocalData,
|
|
@@ -114,9 +160,11 @@ function getExpenseAutomationTransactionView(state) {
|
|
|
114
160
|
markAsNotMiscategorizedStatus,
|
|
115
161
|
completionStatus,
|
|
116
162
|
totalCountByTab,
|
|
163
|
+
parentTabTotalCountByTab,
|
|
117
164
|
fetchStateByTransactionTabs: fetchStateByTab,
|
|
118
165
|
uploadReceiptStatusById,
|
|
119
166
|
selectedTransactionId,
|
|
120
167
|
selectedTransactionLineId,
|
|
168
|
+
selectedTransactionCategorizationCompletedSubTab,
|
|
121
169
|
};
|
|
122
170
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const toCompletedSubTab: (v: string) => "all" | "manual" | "ai_accountant";
|
|
2
|
+
export type CompletedSubTab = ReturnType<typeof toCompletedSubTab>;
|
|
3
|
+
/**
|
|
4
|
+
* "No sub-tab filter" sentinel — single source of truth for the default
|
|
5
|
+
* value of {@link CompletedSubTab}. Use this constant in initial slice
|
|
6
|
+
* state and at any call site that needs to fall back to the parent-tab
|
|
7
|
+
* listing semantics (review tab requests, manual-search overrides, etc.)
|
|
8
|
+
* so a future rename of the union doesn't require chasing literals.
|
|
9
|
+
*/
|
|
10
|
+
export declare const DEFAULT_COMPLETED_SUB_TAB: CompletedSubTab;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_COMPLETED_SUB_TAB = exports.toCompletedSubTab = void 0;
|
|
4
|
+
const stringToUnion_1 = require("../../../commonStateTypes/stringToUnion");
|
|
5
|
+
/**
|
|
6
|
+
* Sub-tabs that can appear under any "Completed" tab in the Expense Automation
|
|
7
|
+
* surface (Transaction Categorization Completed and Missing Receipts Completed
|
|
8
|
+
* both use this exact union). Forwarded verbatim to listing APIs as `sub_tab`
|
|
9
|
+
* / `match_type`. `'all'` preserves parent-tab semantics on the backend.
|
|
10
|
+
*/
|
|
11
|
+
const COMPLETED_SUB_TABS = ['all', 'ai_accountant', 'manual'];
|
|
12
|
+
const toCompletedSubTab = (v) => (0, stringToUnion_1.stringToUnion)(v.trim().toLowerCase(), COMPLETED_SUB_TABS);
|
|
13
|
+
exports.toCompletedSubTab = toCompletedSubTab;
|
|
14
|
+
/**
|
|
15
|
+
* "No sub-tab filter" sentinel — single source of truth for the default
|
|
16
|
+
* value of {@link CompletedSubTab}. Use this constant in initial slice
|
|
17
|
+
* state and at any call site that needs to fall back to the parent-tab
|
|
18
|
+
* listing semantics (review tab requests, manual-search overrides, etc.)
|
|
19
|
+
* so a future rename of the union doesn't require chasing literals.
|
|
20
|
+
*/
|
|
21
|
+
exports.DEFAULT_COMPLETED_SUB_TAB = 'all';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FetchStateAndError, FetchedState, ID } from '../../../commonStateTypes/common';
|
|
2
2
|
import { SortOrder } from '../../../commonStateTypes/selectorTypes/sortOrderTypes';
|
|
3
3
|
import { MonthYearPeriodId } from '../../../commonStateTypes/timePeriod';
|
|
4
|
+
import { CompletedSubTab } from './completedSubTab';
|
|
4
5
|
export declare const toMissingReceiptsSortKey: (v: string) => "date" | "amount" | "vendor" | "category" | "class";
|
|
5
6
|
export type MissingReceiptsSortKey = ReturnType<typeof toMissingReceiptsSortKey>;
|
|
6
7
|
export interface MissingReceiptsViewUIState {
|
|
@@ -31,8 +32,6 @@ export declare const toBulkUploadResultsTab: (v: string) => "completed" | "unmat
|
|
|
31
32
|
export type BulkUploadResultsTab = ReturnType<typeof toBulkUploadResultsTab>;
|
|
32
33
|
export declare const toMissingReceiptsTab: (v: string) => "completed" | "unmatched" | "missing";
|
|
33
34
|
export type MissingReceiptsTab = ReturnType<typeof toMissingReceiptsTab>;
|
|
34
|
-
export declare const toCompletedSubTab: (v: string) => "all" | "manual" | "ai_accountant";
|
|
35
|
-
export type CompletedSubTab = ReturnType<typeof toCompletedSubTab>;
|
|
36
35
|
export declare const toMatchSource: (v: string) => "manual" | "ai";
|
|
37
36
|
export type MatchSource = ReturnType<typeof toMatchSource>;
|
|
38
37
|
export declare const toBulkUploadSortKey: (v: string) => "date" | "amount" | "vendor" | "category" | "class";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toBulkUploadSortKey = exports.toMatchSource = exports.
|
|
3
|
+
exports.toBulkUploadSortKey = exports.toMatchSource = exports.toMissingReceiptsTab = exports.toBulkUploadResultsTab = exports.toBulkUploadPhase = exports.toBatchFileStatus = exports.BATCH_FILE_STATUSES = exports.toBatchStatusValue = exports.MIN_MANUAL_TRANSACTION_SEARCH_LENGTH = exports.toMissingReceiptsSortKey = void 0;
|
|
4
4
|
exports.isUnmatchedTabFileStatus = isUnmatchedTabFileStatus;
|
|
5
5
|
const stringToUnion_1 = require("../../../commonStateTypes/stringToUnion");
|
|
6
6
|
const MISSING_RECEIPTS_SORT_KEYS = [
|
|
@@ -49,9 +49,6 @@ exports.toBulkUploadResultsTab = toBulkUploadResultsTab;
|
|
|
49
49
|
const MISSING_RECEIPTS_TABS = ['missing', 'completed', 'unmatched'];
|
|
50
50
|
const toMissingReceiptsTab = (v) => (0, stringToUnion_1.stringToUnion)(v.trim().toLowerCase(), MISSING_RECEIPTS_TABS);
|
|
51
51
|
exports.toMissingReceiptsTab = toMissingReceiptsTab;
|
|
52
|
-
const COMPLETED_SUB_TABS = ['all', 'ai_accountant', 'manual'];
|
|
53
|
-
const toCompletedSubTab = (v) => (0, stringToUnion_1.stringToUnion)(v.trim().toLowerCase(), COMPLETED_SUB_TABS);
|
|
54
|
-
exports.toCompletedSubTab = toCompletedSubTab;
|
|
55
52
|
const MATCH_SOURCES = ['ai', 'manual'];
|
|
56
53
|
const toMatchSource = (v) => (0, stringToUnion_1.stringToUnion)(v.trim().toLowerCase(), MATCH_SOURCES);
|
|
57
54
|
exports.toMatchSource = toMatchSource;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Amount } from '../../../commonStateTypes/amount';
|
|
2
|
-
import { FetchStateAndError, FetchedState, ID } from '../../../commonStateTypes/common';
|
|
2
|
+
import { FetchState, FetchStateAndError, FetchedState, ID } from '../../../commonStateTypes/common';
|
|
3
3
|
import { Recommendation, RecommendationWithCOT } from '../../../commonStateTypes/recommendationBase';
|
|
4
4
|
import { SortOrder } from '../../../commonStateTypes/selectorTypes/sortOrderTypes';
|
|
5
5
|
import { MonthYearPeriodId } from '../../../commonStateTypes/timePeriod';
|
|
@@ -13,9 +13,11 @@ import { TransactionID } from '../../../entity/transaction/stateTypes/transactio
|
|
|
13
13
|
import { BillableStatus, CategorizationStatusType, PlatformLineDetailType, ProductOrService, TransactionLineBase } from '../../../entity/transaction/stateTypes/transactionLine';
|
|
14
14
|
import { TransactionCategory, TransactionType } from '../../../entity/transaction/stateTypes/transactionType';
|
|
15
15
|
import { VendorBase } from '../../../entity/vendor/vendorState';
|
|
16
|
+
import { ZeniAPIStatus } from '../../../responsePayload';
|
|
16
17
|
import { ZeniDate } from '../../../zeniDayJS';
|
|
17
18
|
import { EntityRecommendationKey } from '../../recommendation/recommendationState';
|
|
18
19
|
import { TransactionDetailKey } from '../../transactionDetail/transactionDetailState';
|
|
20
|
+
import { CompletedSubTab } from './completedSubTab';
|
|
19
21
|
export declare const toTransactionsSortKey: (v: string) => "date" | "amount" | "vendor" | "project" | "category" | "class" | "payment_account" | "transaction_type" | "memo_and_receipt";
|
|
20
22
|
export type TransactionsSortKey = ReturnType<typeof toTransactionsSortKey>;
|
|
21
23
|
export declare const TRANSACTIONS_TABS: readonly ["review", "autoCategorized"];
|
|
@@ -46,6 +48,7 @@ export interface TransactionCategorizationLineItemData extends TransactionLineBa
|
|
|
46
48
|
transactionId: ID;
|
|
47
49
|
account?: AccountBase;
|
|
48
50
|
categorizationStatus?: CategorizationStatusType;
|
|
51
|
+
categoryClassRecommendationsFetchState?: FetchStateAndError;
|
|
49
52
|
class?: ClassBase;
|
|
50
53
|
customer?: CustomerBase;
|
|
51
54
|
item?: ProductOrService;
|
|
@@ -103,7 +106,44 @@ export interface TransactionsTabViewState extends FetchedState {
|
|
|
103
106
|
selectedTransactionId?: ID;
|
|
104
107
|
selectedTransactionLineId?: ID;
|
|
105
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* Snapshot of the autoCategorized tab's paginated dataset for a single
|
|
111
|
+
* Completed sub-tab. Stored in {@link TransactionsViewState.autoCategorizedSubTabCache}
|
|
112
|
+
* so revisiting an already-loaded sub-tab can short-circuit the fetch epic
|
|
113
|
+
* (mirrors parent-tab caching). The snapshot is period-spanning — both the
|
|
114
|
+
* `totalCount` map and `transactionIdsBySelectedPeriod` map preserve every
|
|
115
|
+
* period the user has paged through under that sub-tab.
|
|
116
|
+
*
|
|
117
|
+
* `scrollPosition` is captured per sub-tab so revisiting a sub-tab restores
|
|
118
|
+
* the user's last scroll offset; switching to a fresh / never-visited sub-tab
|
|
119
|
+
* starts at the top instead of inheriting the previous sub-tab's offset.
|
|
120
|
+
*/
|
|
121
|
+
export interface AutoCategorizedSubTabSnapshot {
|
|
122
|
+
error: ZeniAPIStatus | undefined;
|
|
123
|
+
fetchState: FetchState;
|
|
124
|
+
pageToken: PageToken;
|
|
125
|
+
scrollPosition: TransactionsViewUIState['scrollPosition'];
|
|
126
|
+
totalCount: Record<MonthYearPeriodId, number>;
|
|
127
|
+
transactionIdsBySelectedPeriod: Record<MonthYearPeriodId, ID[]>;
|
|
128
|
+
}
|
|
106
129
|
export type TransactionsViewState = {
|
|
130
|
+
/**
|
|
131
|
+
* Per-sub-tab snapshot cache for the Completed (autoCategorized) tab. Keyed
|
|
132
|
+
* by {@link CompletedSubTab}. Populated as the user navigates between
|
|
133
|
+
* sub-tabs and consulted on every switch — the active autoCategorized slot
|
|
134
|
+
* is restored from here when a snapshot exists, otherwise it is reset and
|
|
135
|
+
* the fetch epic loads page 1 fresh.
|
|
136
|
+
*/
|
|
137
|
+
autoCategorizedSubTabCache: Partial<Record<CompletedSubTab, AutoCategorizedSubTabSnapshot>>;
|
|
138
|
+
/**
|
|
139
|
+
* Period-keyed parent tab counts, scoped per {@link TransactionsTab}.
|
|
140
|
+
* Sourced from the listing response's `parent_tab_total_count` and used
|
|
141
|
+
* exclusively to drive the parent tab badges on the UI — every other
|
|
142
|
+
* count consumer (pagination, sub-tab chips, in-tab "showing X of Y")
|
|
143
|
+
* keeps reading from {@link TransactionsViewUIState.totalCount}.
|
|
144
|
+
*/
|
|
145
|
+
parentTotalCountByTab: Record<TransactionsTab, Record<MonthYearPeriodId, number>>;
|
|
146
|
+
selectedTransactionCategorizationCompletedSubTab: CompletedSubTab;
|
|
107
147
|
selectedTransactionCategorizationTab: TransactionsTab;
|
|
108
148
|
transactionCategorizationView: Record<TransactionsTab, TransactionsTabViewState>;
|
|
109
149
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { RootState } from '../../reducer';
|
|
4
|
+
import { ZeniAPI } from '../../zeniAPI';
|
|
5
|
+
import { markCategoryClassRecommendationsCompletedForCategorization, markCategoryClassRecommendationsFailureForCategorization, markCategoryClassRecommendationsInProgressForCategorization, setEntityRecommendationForLineIdsForCategorization } from '../expenseAutomationView/reducers/transactionsViewReducer';
|
|
6
|
+
import { markCategoryClassRecommendationsCompletedForTransactionDetail, markCategoryClassRecommendationsFailureForTransactionDetail, markCategoryClassRecommendationsInProgressForTransactionDetail, setEntityRecommendationForLineIdsForTransactionDetail } from '../transactionDetail/transactionDetailReducer';
|
|
7
|
+
import { fetchEntityRecommendationsForLineUpdate } from './recommendationReducer';
|
|
8
|
+
export type ActionType = ReturnType<typeof fetchEntityRecommendationsForLineUpdate> | ReturnType<typeof markCategoryClassRecommendationsInProgressForCategorization> | ReturnType<typeof markCategoryClassRecommendationsCompletedForCategorization> | ReturnType<typeof markCategoryClassRecommendationsFailureForCategorization> | ReturnType<typeof markCategoryClassRecommendationsInProgressForTransactionDetail> | ReturnType<typeof markCategoryClassRecommendationsCompletedForTransactionDetail> | ReturnType<typeof markCategoryClassRecommendationsFailureForTransactionDetail> | ReturnType<typeof setEntityRecommendationForLineIdsForCategorization> | ReturnType<typeof setEntityRecommendationForLineIdsForTransactionDetail>;
|
|
9
|
+
export declare const fetchEntityRecommendationsForLineUpdateEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchEntityRecommendationsForLineUpdateEpic = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const operators_1 = require("rxjs/operators");
|
|
6
|
+
const tenantSelector_1 = require("../../entity/tenant/tenantSelector");
|
|
7
|
+
const transactionHelper_1 = require("../../entity/transaction/transactionHelper");
|
|
8
|
+
const responsePayload_1 = require("../../responsePayload");
|
|
9
|
+
const accountListSelector_1 = require("../accountList/accountListSelector");
|
|
10
|
+
const transactionsViewReducer_1 = require("../expenseAutomationView/reducers/transactionsViewReducer");
|
|
11
|
+
const transactionDetailReducer_1 = require("../transactionDetail/transactionDetailReducer");
|
|
12
|
+
const recommendationHelper_1 = require("./recommendationHelper");
|
|
13
|
+
const recommendationReducer_1 = require("./recommendationReducer");
|
|
14
|
+
// Close the per-target groupBy bucket after this much idle time so inactive
|
|
15
|
+
// groups don't accumulate forever (each group holds a Subject + a chain of
|
|
16
|
+
// active subscribers; without a duration selector groupBy retains them for
|
|
17
|
+
// the lifetime of the source observable, which is the lifetime of the app).
|
|
18
|
+
// Picked at 60s to leave a generous window for re-fetches on the same
|
|
19
|
+
// payee/transaction/line target while still bounding memory.
|
|
20
|
+
const GROUP_INACTIVITY_TIMEOUT_MS = 60000;
|
|
21
|
+
// Build the groupBy key. Same flow + same transaction + same line set
|
|
22
|
+
// share a target so switchMap can cancel an in-flight prior fetch. Use
|
|
23
|
+
// NUL (\u0000) as separator because it can never appear in transaction
|
|
24
|
+
// or line ids (vs the `|` used in an earlier WIP which collides with
|
|
25
|
+
// pipe-delimited synthetic ids).
|
|
26
|
+
const SEPARATOR = '\u0000';
|
|
27
|
+
const toGroupKey = (flowType, transactionId, lineIds) => `${flowType}${SEPARATOR}${transactionId}${SEPARATOR}${[...lineIds]
|
|
28
|
+
.sort((a, b) => a.localeCompare(b))
|
|
29
|
+
.join(SEPARATOR)}`;
|
|
30
|
+
// Targeted recommendations fetch that drives the per-line skeleton, the
|
|
31
|
+
// list-page row-checkbox uncheck/recheck, and the page-level Save
|
|
32
|
+
// disable.
|
|
33
|
+
//
|
|
34
|
+
// Concurrency model:
|
|
35
|
+
// - groupBy by (flowType, transactionId, sorted lineIds) so distinct
|
|
36
|
+
// targets run in parallel.
|
|
37
|
+
// - inside each group, switchMap so a re-fetch on the SAME target
|
|
38
|
+
// cancels any prior in-flight request for that target.
|
|
39
|
+
// - groupBy duration selector closes idle groups to bound memory.
|
|
40
|
+
const fetchEntityRecommendationsForLineUpdateEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(recommendationReducer_1.fetchEntityRecommendationsForLineUpdate.match), (0, operators_1.groupBy)((action) => toGroupKey(action.payload.flowType, action.payload.transactionDetails.transactionId.id, action.payload.transactionDetails.lineIds), undefined, (group$) => group$.pipe((0, operators_1.debounce)(() => (0, rxjs_1.timer)(GROUP_INACTIVITY_TIMEOUT_MS)))), (0, operators_1.mergeMap)((group$) => group$.pipe((0, operators_1.switchMap)((action) => {
|
|
41
|
+
const { entity, amount, transactionDetails, flowType, selectedTab, isFetchCOT, isUncategorizedExpenseCategoryEnabled, } = action.payload;
|
|
42
|
+
const { transactionId, transaction, lineIds } = transactionDetails;
|
|
43
|
+
// Synchronously emit the start arm so the per-line skeleton +
|
|
44
|
+
// row uncheck happen before the HTTP request begins.
|
|
45
|
+
const startAction = flowType === 'categorization' && selectedTab != null
|
|
46
|
+
? (0, transactionsViewReducer_1.markCategoryClassRecommendationsInProgressForCategorization)(selectedTab, transactionId, lineIds)
|
|
47
|
+
: (0, transactionDetailReducer_1.markCategoryClassRecommendationsInProgressForTransactionDetail)(transactionId, lineIds);
|
|
48
|
+
const url = (0, recommendationHelper_1.buildRecommendationUrl)(zeniAPI.apiEndPoints.accountMicroServiceBaseUrl, entity, amount, transactionDetails, isFetchCOT === true);
|
|
49
|
+
const httpStream$ = zeniAPI
|
|
50
|
+
.getJSON(url)
|
|
51
|
+
.pipe((0, operators_1.mergeMap)((response) => {
|
|
52
|
+
if (!(0, responsePayload_1.isSuccessResponse)(response) || response.data == null) {
|
|
53
|
+
return (0, rxjs_1.of)(flowType === 'categorization' && selectedTab != null
|
|
54
|
+
? (0, transactionsViewReducer_1.markCategoryClassRecommendationsFailureForCategorization)(selectedTab, transactionId, lineIds, response.status)
|
|
55
|
+
: (0, transactionDetailReducer_1.markCategoryClassRecommendationsFailureForTransactionDetail)(transactionId, lineIds, response.status));
|
|
56
|
+
}
|
|
57
|
+
const recommendationWithCOTByLineId = (0, recommendationHelper_1.getRecommendationByLineIdWithCOTFromRecommendationPayloadWithCOT)(response.data.recommendations, lineIds);
|
|
58
|
+
// HTTP 200 with no per-line recommendations: NOT an error.
|
|
59
|
+
// Flip lines to Completed so the skeleton resolves and
|
|
60
|
+
// downstream UI can treat this as "we tried, nothing to
|
|
61
|
+
// apply".
|
|
62
|
+
if (recommendationWithCOTByLineId == null) {
|
|
63
|
+
return (0, rxjs_1.of)(flowType === 'categorization' && selectedTab != null
|
|
64
|
+
? (0, transactionsViewReducer_1.markCategoryClassRecommendationsCompletedForCategorization)(selectedTab, transactionId, lineIds)
|
|
65
|
+
: (0, transactionDetailReducer_1.markCategoryClassRecommendationsCompletedForTransactionDetail)(transactionId, lineIds));
|
|
66
|
+
}
|
|
67
|
+
const transactionWithCOT = isFetchCOT === true
|
|
68
|
+
? (0, transactionHelper_1.getTransactionWithCOTFromRecommendations)(transaction, recommendationWithCOTByLineId)
|
|
69
|
+
: (0, transactionHelper_1.getTransactionWithCOT)(transaction);
|
|
70
|
+
const uncategorizedIncomeExpense = (0, accountListSelector_1.getUncategorizedAccounts)(state$.value.accountState, state$.value.accountListState, 'accountList');
|
|
71
|
+
if (flowType === 'categorization' && selectedTab != null) {
|
|
72
|
+
return (0, rxjs_1.of)((0, transactionsViewReducer_1.setEntityRecommendationForLineIdsForCategorization)(selectedTab, transactionId, transactionWithCOT, lineIds, entity, amount, recommendationWithCOTByLineId, uncategorizedIncomeExpense, isUncategorizedExpenseCategoryEnabled, (0, tenantSelector_1.getIsAccountingClassesEnabled)(state$.value)));
|
|
73
|
+
}
|
|
74
|
+
return (0, rxjs_1.of)((0, transactionDetailReducer_1.setEntityRecommendationForLineIdsForTransactionDetail)(transactionId, transactionWithCOT, lineIds, entity, amount, recommendationWithCOTByLineId, uncategorizedIncomeExpense));
|
|
75
|
+
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)(flowType === 'categorization' && selectedTab != null
|
|
76
|
+
? (0, transactionsViewReducer_1.markCategoryClassRecommendationsFailureForCategorization)(selectedTab, transactionId, lineIds, (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'fetchEntityRecommendationsForLineUpdate failed: ' +
|
|
77
|
+
JSON.stringify(error)))
|
|
78
|
+
: (0, transactionDetailReducer_1.markCategoryClassRecommendationsFailureForTransactionDetail)(transactionId, lineIds, (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'fetchEntityRecommendationsForLineUpdate failed: ' +
|
|
79
|
+
JSON.stringify(error))))));
|
|
80
|
+
return (0, rxjs_1.concat)((0, rxjs_1.of)(startAction), httpStream$);
|
|
81
|
+
}))));
|
|
82
|
+
exports.fetchEntityRecommendationsForLineUpdateEpic = fetchEntityRecommendationsForLineUpdateEpic;
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import { RecommendationPayload, RecommendationPayloadWithCOT } from '../../commonPayloadTypes/recommendationPayload';
|
|
2
2
|
import { ID } from '../../commonStateTypes/common';
|
|
3
3
|
import { Recommendation, RecommendationWithCOT } from '../../commonStateTypes/recommendationBase';
|
|
4
|
+
import { Entity } from '../../entity/genericEntity/entity';
|
|
4
5
|
import { RecommendationByLineId, RecommendationWithCOTByLineId } from '../../entity/transaction/stateTypes/transaction';
|
|
6
|
+
import { SupportedTransaction } from '../../entity/transaction/transactionState';
|
|
5
7
|
export declare const getRecommendationFromRecommendationPayload: (payload: RecommendationPayload[]) => Recommendation[] | undefined;
|
|
6
8
|
export declare const getRecommendationByLineIdFromRecommendationPayload: (recommendationPayload: RecommendationPayload[], lineIds: ID[]) => RecommendationByLineId | undefined;
|
|
7
9
|
export declare const getRecommendationWithCOTFromRecommendationPayloadWithCOT: (payload: RecommendationPayloadWithCOT[]) => RecommendationWithCOT[] | undefined;
|
|
10
|
+
export declare const buildRecommendationUrl: (accountMicroServiceBaseUrl: string, entity: Entity, amount: number, transactionDetails: {
|
|
11
|
+
lineIds: ID[];
|
|
12
|
+
transaction: SupportedTransaction;
|
|
13
|
+
transactionId: {
|
|
14
|
+
id: string;
|
|
15
|
+
};
|
|
16
|
+
}, isFetchCOT: boolean) => string;
|
|
8
17
|
export declare const getRecommendationByLineIdWithCOTFromRecommendationPayloadWithCOT: (recommendationPayload: RecommendationPayloadWithCOT[], lineIds: ID[]) => RecommendationWithCOTByLineId | undefined;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getRecommendationByLineIdWithCOTFromRecommendationPayloadWithCOT = exports.getRecommendationWithCOTFromRecommendationPayloadWithCOT = exports.getRecommendationByLineIdFromRecommendationPayload = exports.getRecommendationFromRecommendationPayload = void 0;
|
|
3
|
+
exports.getRecommendationByLineIdWithCOTFromRecommendationPayloadWithCOT = exports.buildRecommendationUrl = exports.getRecommendationWithCOTFromRecommendationPayloadWithCOT = exports.getRecommendationByLineIdFromRecommendationPayload = exports.getRecommendationFromRecommendationPayload = void 0;
|
|
4
4
|
const transactionPayload_1 = require("../../entity/transaction/payloadTypes/transactionPayload");
|
|
5
|
+
const transactionDetailState_1 = require("../transactionDetail/transactionDetailState");
|
|
5
6
|
const getRecommendationFromRecommendationPayload = (payload) => {
|
|
6
7
|
if (payload == null || payload.length === 0) {
|
|
7
8
|
return undefined;
|
|
@@ -43,6 +44,35 @@ const getRecommendationWithCOTFromRecommendationPayloadWithCOT = (payload) => {
|
|
|
43
44
|
return recommendations;
|
|
44
45
|
};
|
|
45
46
|
exports.getRecommendationWithCOTFromRecommendationPayloadWithCOT = getRecommendationWithCOTFromRecommendationPayloadWithCOT;
|
|
47
|
+
// Pluralized URL segment for entity types. Mirrors the legacy
|
|
48
|
+
// fetchEntityRecommendationsByTransactionIdEpic.toEntityTypeURL.
|
|
49
|
+
const toEntityTypeUrlSegment = (entityType) => `${entityType}s`;
|
|
50
|
+
// Build the recommendations URL for a single entity + transaction target.
|
|
51
|
+
// Centralizes the URL shape so the legacy
|
|
52
|
+
// fetchEntityRecommendationsByTransactionIdEpic and the new
|
|
53
|
+
// fetchEntityRecommendationsForLineUpdateEpic stay in lockstep.
|
|
54
|
+
const buildRecommendationUrl = (accountMicroServiceBaseUrl, entity, amount, transactionDetails, isFetchCOT) => {
|
|
55
|
+
const entityQuery = {
|
|
56
|
+
entity_name: entity.name,
|
|
57
|
+
entity_type: entity.type,
|
|
58
|
+
};
|
|
59
|
+
// Entity-id-null case: server expects entity_name / entity_type query
|
|
60
|
+
// instead of the {entityType}/{qboId}/recommendations path.
|
|
61
|
+
if (entity.qboId === entity.name) {
|
|
62
|
+
return `${accountMicroServiceBaseUrl}/1.0/recommendations?query=${encodeURIComponent(JSON.stringify(entityQuery))}`;
|
|
63
|
+
}
|
|
64
|
+
const query = {
|
|
65
|
+
amount,
|
|
66
|
+
transaction_id: (0, transactionDetailState_1.getActualTransactionID)(transactionDetails.transactionId.id),
|
|
67
|
+
transaction_type: transactionDetails.transaction.type,
|
|
68
|
+
line_ids: transactionDetails.lineIds,
|
|
69
|
+
};
|
|
70
|
+
if (isFetchCOT === true) {
|
|
71
|
+
query.include_cot = true;
|
|
72
|
+
}
|
|
73
|
+
return `${accountMicroServiceBaseUrl}/1.0/${toEntityTypeUrlSegment(entity.type)}/${entity.qboId}/recommendations?query=${encodeURIComponent(JSON.stringify(query))}`;
|
|
74
|
+
};
|
|
75
|
+
exports.buildRecommendationUrl = buildRecommendationUrl;
|
|
46
76
|
const getRecommendationByLineIdWithCOTFromRecommendationPayloadWithCOT = (recommendationPayload, lineIds) => {
|
|
47
77
|
if (recommendationPayload.length === 0) {
|
|
48
78
|
return undefined;
|
|
@@ -5,6 +5,7 @@ import { TransactionID } from '../../entity/transaction/stateTypes/transaction';
|
|
|
5
5
|
import { SupportedTransaction } from '../../entity/transaction/transactionState';
|
|
6
6
|
import { ZeniAPIStatus } from '../../responsePayload';
|
|
7
7
|
import { EntityRecommendationState } from './recommendationState';
|
|
8
|
+
export type RecommendationLineUpdateFlowType = 'categorization' | 'detail';
|
|
8
9
|
export declare const initialState: EntityRecommendationState;
|
|
9
10
|
export declare const fetchEntityRecommendationsByTransactionId: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[entity: Entity, amount: number, transactionDetails: {
|
|
10
11
|
lineIds: ID[];
|
|
@@ -22,7 +23,23 @@ export declare const fetchEntityRecommendationsByTransactionId: import("@reduxjs
|
|
|
22
23
|
isTransactionCategorizationFlow: any;
|
|
23
24
|
isFetchCOT: any;
|
|
24
25
|
isUncategorizedExpenseCategoryEnabled: boolean | undefined;
|
|
25
|
-
}, "recommendation/fetchEntityRecommendationsByTransactionId", never, never>,
|
|
26
|
+
}, "recommendation/fetchEntityRecommendationsByTransactionId", never, never>, fetchEntityRecommendationsForLineUpdate: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[entity: Entity, amount: number, transactionDetails: {
|
|
27
|
+
lineIds: ID[];
|
|
28
|
+
transaction: SupportedTransaction;
|
|
29
|
+
transactionId: TransactionID;
|
|
30
|
+
}, flowType: RecommendationLineUpdateFlowType, selectedTab?: "review" | "autoCategorized" | undefined, isFetchCOT?: any, isUncategorizedExpenseCategoryEnabled?: boolean | undefined], {
|
|
31
|
+
entity: Entity;
|
|
32
|
+
amount: number;
|
|
33
|
+
transactionDetails: {
|
|
34
|
+
lineIds: ID[];
|
|
35
|
+
transaction: SupportedTransaction;
|
|
36
|
+
transactionId: TransactionID;
|
|
37
|
+
};
|
|
38
|
+
flowType: RecommendationLineUpdateFlowType;
|
|
39
|
+
selectedTab: "review" | "autoCategorized" | undefined;
|
|
40
|
+
isFetchCOT: any;
|
|
41
|
+
isUncategorizedExpenseCategoryEnabled: boolean | undefined;
|
|
42
|
+
}, "recommendation/fetchEntityRecommendationsForLineUpdate", never, never>, fetchRecommendationByEntityName: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[entityName: string, entityType: EntityType], {
|
|
26
43
|
entityName: string;
|
|
27
44
|
entityType: EntityType;
|
|
28
45
|
}, "recommendation/fetchRecommendationByEntityName", never, never>, fetchRecommendationByEntityId: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[entityId: string, entityType: EntityType], {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.clearRecommendation = exports.indicateReadyToInitializeRecommendation = exports.updateRecommendationForEntityFailure = exports.updateRecommendationForEntity = exports.fetchRecommendationByEntityId = exports.fetchRecommendationByEntityName = exports.fetchEntityRecommendationsByTransactionId = exports.initialState = void 0;
|
|
4
|
+
exports.clearRecommendation = exports.indicateReadyToInitializeRecommendation = exports.updateRecommendationForEntityFailure = exports.updateRecommendationForEntity = exports.fetchRecommendationByEntityId = exports.fetchRecommendationByEntityName = exports.fetchEntityRecommendationsForLineUpdate = exports.fetchEntityRecommendationsByTransactionId = exports.initialState = void 0;
|
|
5
5
|
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
6
|
const recommendationState_1 = require("./recommendationState");
|
|
7
7
|
exports.initialState = {
|
|
@@ -37,6 +37,41 @@ const recommendation = (0, toolkit_1.createSlice)({
|
|
|
37
37
|
};
|
|
38
38
|
},
|
|
39
39
|
},
|
|
40
|
+
// Targeted recommendations fetch fired when the user changes the
|
|
41
|
+
// payee/customer on a single transaction line (or the JE sibling set
|
|
42
|
+
// for that change). Routed by `fetchEntityRecommendationsForLineUpdateEpic`
|
|
43
|
+
// which uses groupBy + switchMap to keep fetches for distinct targets
|
|
44
|
+
// running in parallel while same-target re-fetches still cancel each
|
|
45
|
+
// other. The flowType discriminator selects the categorization vs
|
|
46
|
+
// detail slice for the per-line In-Progress / Completed / Error state.
|
|
47
|
+
fetchEntityRecommendationsForLineUpdate: {
|
|
48
|
+
reducer(draft, action) {
|
|
49
|
+
const { entity } = action.payload;
|
|
50
|
+
const key = (0, recommendationState_1.getEntityRecommendationKey)(entity.type, entity.id);
|
|
51
|
+
// Unconditional flip to In-Progress; the previous variant only
|
|
52
|
+
// seeded when missing, which left stale fetchStates when a prior
|
|
53
|
+
// fetch had already populated the entity entry.
|
|
54
|
+
draft.recommendationByEntity[key] = {
|
|
55
|
+
...(draft.recommendationByEntity[key] ??
|
|
56
|
+
recommendationState_1.initialEntityRecommendationState),
|
|
57
|
+
fetchState: 'In-Progress',
|
|
58
|
+
error: undefined,
|
|
59
|
+
};
|
|
60
|
+
},
|
|
61
|
+
prepare(entity, amount, transactionDetails, flowType, selectedTab, isFetchCOT = false, isUncategorizedExpenseCategoryEnabled) {
|
|
62
|
+
return {
|
|
63
|
+
payload: {
|
|
64
|
+
entity,
|
|
65
|
+
amount,
|
|
66
|
+
transactionDetails,
|
|
67
|
+
flowType,
|
|
68
|
+
selectedTab,
|
|
69
|
+
isFetchCOT,
|
|
70
|
+
isUncategorizedExpenseCategoryEnabled,
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
},
|
|
74
|
+
},
|
|
40
75
|
fetchRecommendationByEntityName: {
|
|
41
76
|
reducer(draft, action) {
|
|
42
77
|
const { entityName, entityType } = action.payload;
|
|
@@ -115,7 +150,7 @@ const recommendation = (0, toolkit_1.createSlice)({
|
|
|
115
150
|
},
|
|
116
151
|
},
|
|
117
152
|
});
|
|
118
|
-
_a = recommendation.actions, exports.fetchEntityRecommendationsByTransactionId = _a.fetchEntityRecommendationsByTransactionId, exports.fetchRecommendationByEntityName = _a.fetchRecommendationByEntityName, exports.fetchRecommendationByEntityId = _a.fetchRecommendationByEntityId, exports.updateRecommendationForEntity = _a.updateRecommendationForEntity, exports.updateRecommendationForEntityFailure = _a.updateRecommendationForEntityFailure, exports.indicateReadyToInitializeRecommendation = _a.indicateReadyToInitializeRecommendation, exports.clearRecommendation = _a.clearRecommendation;
|
|
153
|
+
_a = recommendation.actions, exports.fetchEntityRecommendationsByTransactionId = _a.fetchEntityRecommendationsByTransactionId, exports.fetchEntityRecommendationsForLineUpdate = _a.fetchEntityRecommendationsForLineUpdate, exports.fetchRecommendationByEntityName = _a.fetchRecommendationByEntityName, exports.fetchRecommendationByEntityId = _a.fetchRecommendationByEntityId, exports.updateRecommendationForEntity = _a.updateRecommendationForEntity, exports.updateRecommendationForEntityFailure = _a.updateRecommendationForEntityFailure, exports.indicateReadyToInitializeRecommendation = _a.indicateReadyToInitializeRecommendation, exports.clearRecommendation = _a.clearRecommendation;
|
|
119
154
|
exports.default = recommendation.reducer;
|
|
120
155
|
const doUpdateRecommendationForEntity = (draft, entityId, entityType, payload) => {
|
|
121
156
|
const key = (0, recommendationState_1.getEntityRecommendationKey)(entityType, entityId);
|
|
@@ -115,7 +115,17 @@ export declare const downloadAccountingProviderAttachment: import("@reduxjs/tool
|
|
|
115
115
|
amount: number;
|
|
116
116
|
recommendationWithCOTByLineId: RecommendationWithCOTByLineId;
|
|
117
117
|
uncategorizedIncomeExpense: UncategorizedAccounts;
|
|
118
|
-
}, "transactionDetail/setEntityRecommendationForLineIdsForTransactionDetail", never, never>,
|
|
118
|
+
}, "transactionDetail/setEntityRecommendationForLineIdsForTransactionDetail", never, never>, markCategoryClassRecommendationsInProgressForTransactionDetail: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[transactionId: TransactionID, lineIds: string[]], {
|
|
119
|
+
transactionId: TransactionID;
|
|
120
|
+
lineIds: string[];
|
|
121
|
+
}, "transactionDetail/markCategoryClassRecommendationsInProgressForTransactionDetail", never, never>, markCategoryClassRecommendationsCompletedForTransactionDetail: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[transactionId: TransactionID, lineIds: string[]], {
|
|
122
|
+
transactionId: TransactionID;
|
|
123
|
+
lineIds: string[];
|
|
124
|
+
}, "transactionDetail/markCategoryClassRecommendationsCompletedForTransactionDetail", never, never>, markCategoryClassRecommendationsFailureForTransactionDetail: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[transactionId: TransactionID, lineIds: string[], error: ZeniAPIStatus<Record<string, unknown>>], {
|
|
125
|
+
transactionId: TransactionID;
|
|
126
|
+
lineIds: string[];
|
|
127
|
+
error: ZeniAPIStatus<Record<string, unknown>>;
|
|
128
|
+
}, "transactionDetail/markCategoryClassRecommendationsFailureForTransactionDetail", never, never>, removeEntityRecommendationForLineIdForTransactionDetail: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[transactionId: TransactionID, transaction: SupportedTransaction, lineId: string], {
|
|
119
129
|
transactionId: TransactionID;
|
|
120
130
|
transaction: SupportedTransaction;
|
|
121
131
|
lineId: string;
|