@zeniai/client-epic-state 5.0.69-betaML7 → 5.0.69-betaRR07
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 +1 -2
- package/lib/epic.js +1 -2
- package/lib/esm/epic.js +1 -2
- package/lib/esm/index.js +6 -6
- package/lib/esm/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +1 -21
- package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +14 -117
- package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +0 -31
- package/lib/esm/view/recommendation/recommendationHelper.js +0 -29
- package/lib/esm/view/recommendation/recommendationReducer.js +1 -36
- package/lib/esm/view/transactionDetail/transactionDetailReducer.js +1 -94
- package/lib/esm/view/transactionDetail/transactionDetailSelector.js +0 -22
- package/lib/index.d.ts +6 -7
- package/lib/index.js +32 -35
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +0 -1
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +2 -23
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +1 -14
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +14 -117
- package/lib/view/expenseAutomationView/selectorTypes/transactionsViewSelectorTypes.d.ts +0 -2
- package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.d.ts +0 -3
- package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +0 -32
- package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +0 -1
- package/lib/view/recommendation/recommendationHelper.d.ts +0 -9
- package/lib/view/recommendation/recommendationHelper.js +1 -31
- package/lib/view/recommendation/recommendationReducer.d.ts +1 -18
- package/lib/view/recommendation/recommendationReducer.js +2 -37
- package/lib/view/transactionDetail/transactionDetailReducer.d.ts +1 -11
- package/lib/view/transactionDetail/transactionDetailReducer.js +2 -95
- package/lib/view/transactionDetail/transactionDetailSelector.d.ts +0 -2
- package/lib/view/transactionDetail/transactionDetailSelector.js +1 -24
- package/lib/view/transactionDetail/transactionDetailTypes.d.ts +0 -1
- package/package.json +1 -1
- package/lib/esm/view/recommendation/fetchEntityRecommendationsForLineUpdateEpic.js +0 -83
- package/lib/view/recommendation/fetchEntityRecommendationsForLineUpdateEpic.d.ts +0 -9
- package/lib/view/recommendation/fetchEntityRecommendationsForLineUpdateEpic.js +0 -87
|
@@ -3,7 +3,7 @@ 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.getInitialUpdatablePeriodsForTransactionRecommendations = exports.getTransactionDetail =
|
|
6
|
+
exports.getInitialUpdatablePeriodsForTransactionRecommendations = exports.getTransactionDetail = void 0;
|
|
7
7
|
exports.getTransactionDetailForTransaction = getTransactionDetailForTransaction;
|
|
8
8
|
const get_1 = __importDefault(require("lodash/get"));
|
|
9
9
|
const reduceFetchState_1 = require("../../commonStateTypes/reduceFetchState");
|
|
@@ -17,27 +17,6 @@ const accountListSelector_1 = require("../accountList/accountListSelector");
|
|
|
17
17
|
const classListSelector_1 = require("../classList/classListSelector");
|
|
18
18
|
const projectListSelector_1 = require("../projectList/projectListSelector");
|
|
19
19
|
const transactionDetailState_1 = require("./transactionDetailState");
|
|
20
|
-
// "Any line on this transaction is fetching category/class recommendations?"
|
|
21
|
-
// Inlined as a plain function because the upstream selector
|
|
22
|
-
// `getTransactionDetail` is also un-memoized and the iteration is O(lines)
|
|
23
|
-
// — typically <10. Exported standalone so consumers that only need the
|
|
24
|
-
// flag (e.g. footer save-disable) can avoid materializing the whole
|
|
25
|
-
// detail report.
|
|
26
|
-
const getDetailInFlightRecommendations = (state, transactionId) => {
|
|
27
|
-
const detailKey = (0, transactionDetailState_1.getTransactionDetailKey)(transactionId);
|
|
28
|
-
const detail = (0, get_1.default)(state.transactionDetailState.transactionDetailById, detailKey, undefined);
|
|
29
|
-
if (detail == null) {
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
for (const lineItem of Object.values(detail.transactionDetailLocalData.lineItemById)) {
|
|
33
|
-
if (lineItem.categoryClassRecommendationsFetchState?.fetchState ===
|
|
34
|
-
'In-Progress') {
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return false;
|
|
39
|
-
};
|
|
40
|
-
exports.getDetailInFlightRecommendations = getDetailInFlightRecommendations;
|
|
41
20
|
const getTransactionDetail = (state, transactionId, fetchLinkedTransactions = true) => {
|
|
42
21
|
const { transactionDetailState, transactionState, vendorState, vendorListState, accountState, classState, classListState, accountListState, projectState, projectListState, } = state;
|
|
43
22
|
const detailKey = (0, transactionDetailState_1.getTransactionDetailKey)(transactionId);
|
|
@@ -106,7 +85,6 @@ const getTransactionDetail = (state, transactionId, fetchLinkedTransactions = tr
|
|
|
106
85
|
: [];
|
|
107
86
|
const transactionDetailAnyUpdateStatus = reduceUpdateFetchStates(transactionDetail);
|
|
108
87
|
const vendors = (0, vendorSelector_1.getVendorsByVendorIds)(vendorState, vendorListState.vendorIds);
|
|
109
|
-
const hasInFlightCategoryClassRecommendations = (0, exports.getDetailInFlightRecommendations)(state, transactionId);
|
|
110
88
|
return {
|
|
111
89
|
reportId: 'transaction_detail',
|
|
112
90
|
reportTitle: 'Transaction Detail',
|
|
@@ -122,7 +100,6 @@ const getTransactionDetail = (state, transactionId, fetchLinkedTransactions = tr
|
|
|
122
100
|
classHierarchyList,
|
|
123
101
|
accountsHierarchyList,
|
|
124
102
|
classList: classList,
|
|
125
|
-
hasInFlightCategoryClassRecommendations,
|
|
126
103
|
isAccountingClassesEnabled,
|
|
127
104
|
isAccountingProjectsEnabled,
|
|
128
105
|
projectList,
|
|
@@ -14,7 +14,6 @@ export interface TransactionDetailLineItemData extends TransactionLineBase {
|
|
|
14
14
|
isClassMiscategorized: boolean;
|
|
15
15
|
account?: AccountBase;
|
|
16
16
|
billable?: BillableStatus;
|
|
17
|
-
categoryClassRecommendationsFetchState?: FetchStateAndError;
|
|
18
17
|
class?: ClassBase;
|
|
19
18
|
customer?: CustomerBase;
|
|
20
19
|
isCategoryUpdateSelected?: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "5.0.69-
|
|
3
|
+
"version": "5.0.69-betaRR07",
|
|
4
4
|
"description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/esm/index.js",
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { concat, of, timer } from 'rxjs';
|
|
2
|
-
import { catchError, debounce, filter, groupBy, mergeMap, switchMap, } from 'rxjs/operators';
|
|
3
|
-
import { getIsAccountingClassesEnabled } from '../../entity/tenant/tenantSelector';
|
|
4
|
-
import { getTransactionWithCOT, getTransactionWithCOTFromRecommendations, } from '../../entity/transaction/transactionHelper';
|
|
5
|
-
import { createZeniAPIStatus, isSuccessResponse } from '../../responsePayload';
|
|
6
|
-
import { getUncategorizedAccounts } from '../accountList/accountListSelector';
|
|
7
|
-
import { markCategoryClassRecommendationsCompletedForCategorization, markCategoryClassRecommendationsFailureForCategorization, markCategoryClassRecommendationsInProgressForCategorization, setEntityRecommendationForLineIdsForCategorization, } from '../expenseAutomationView/reducers/transactionsViewReducer';
|
|
8
|
-
import { markCategoryClassRecommendationsCompletedForTransactionDetail, markCategoryClassRecommendationsFailureForTransactionDetail, markCategoryClassRecommendationsInProgressForTransactionDetail, setEntityRecommendationForLineIdsForTransactionDetail, } from '../transactionDetail/transactionDetailReducer';
|
|
9
|
-
import { buildRecommendationUrl, getRecommendationByLineIdWithCOTFromRecommendationPayloadWithCOT, } from './recommendationHelper';
|
|
10
|
-
import { fetchEntityRecommendationsForLineUpdate } from './recommendationReducer';
|
|
11
|
-
// Close the per-target groupBy bucket after this much idle time so inactive
|
|
12
|
-
// groups don't accumulate forever (each group holds a Subject + a chain of
|
|
13
|
-
// active subscribers; without a duration selector groupBy retains them for
|
|
14
|
-
// the lifetime of the source observable, which is the lifetime of the app).
|
|
15
|
-
// Picked at 60s to leave a generous window for re-fetches on the same
|
|
16
|
-
// payee/transaction/line target while still bounding memory.
|
|
17
|
-
const GROUP_INACTIVITY_TIMEOUT_MS = 60000;
|
|
18
|
-
// Build the groupBy key. Same flow + same transaction + same line set
|
|
19
|
-
// share a target so switchMap can cancel an in-flight prior fetch. Use
|
|
20
|
-
// NUL (\u0000) as separator because it can never appear in transaction
|
|
21
|
-
// or line ids (vs the `|` used in an earlier WIP which collides with
|
|
22
|
-
// pipe-delimited synthetic ids).
|
|
23
|
-
const SEPARATOR = '\u0000';
|
|
24
|
-
const toGroupKey = (flowType, transactionId, lineIds) => `${flowType}${SEPARATOR}${transactionId}${SEPARATOR}${[...lineIds]
|
|
25
|
-
.sort((a, b) => a.localeCompare(b))
|
|
26
|
-
.join(SEPARATOR)}`;
|
|
27
|
-
// Targeted recommendations fetch that drives the per-line skeleton, the
|
|
28
|
-
// list-page row-checkbox uncheck/recheck, and the page-level Save
|
|
29
|
-
// disable.
|
|
30
|
-
//
|
|
31
|
-
// Concurrency model:
|
|
32
|
-
// - groupBy by (flowType, transactionId, sorted lineIds) so distinct
|
|
33
|
-
// targets run in parallel.
|
|
34
|
-
// - inside each group, switchMap so a re-fetch on the SAME target
|
|
35
|
-
// cancels any prior in-flight request for that target.
|
|
36
|
-
// - groupBy duration selector closes idle groups to bound memory.
|
|
37
|
-
export const fetchEntityRecommendationsForLineUpdateEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(fetchEntityRecommendationsForLineUpdate.match), groupBy((action) => toGroupKey(action.payload.flowType, action.payload.transactionDetails.transactionId.id, action.payload.transactionDetails.lineIds), undefined, (group$) => group$.pipe(debounce(() => timer(GROUP_INACTIVITY_TIMEOUT_MS)))), mergeMap((group$) => group$.pipe(switchMap((action) => {
|
|
38
|
-
const { entity, amount, transactionDetails, flowType, selectedTab, isFetchCOT, isUncategorizedExpenseCategoryEnabled, } = action.payload;
|
|
39
|
-
const { transactionId, transaction, lineIds } = transactionDetails;
|
|
40
|
-
// Synchronously emit the start arm so the per-line skeleton +
|
|
41
|
-
// row uncheck happen before the HTTP request begins.
|
|
42
|
-
const startAction = flowType === 'categorization' && selectedTab != null
|
|
43
|
-
? markCategoryClassRecommendationsInProgressForCategorization(selectedTab, transactionId, lineIds)
|
|
44
|
-
: markCategoryClassRecommendationsInProgressForTransactionDetail(transactionId, lineIds);
|
|
45
|
-
const url = buildRecommendationUrl(zeniAPI.apiEndPoints.accountMicroServiceBaseUrl, entity, amount, transactionDetails, isFetchCOT === true);
|
|
46
|
-
const httpStream$ = zeniAPI
|
|
47
|
-
.getJSON(url)
|
|
48
|
-
.pipe(mergeMap((response) => {
|
|
49
|
-
if (!isSuccessResponse(response) || response.data == null) {
|
|
50
|
-
return of(flowType === 'categorization' && selectedTab != null
|
|
51
|
-
? markCategoryClassRecommendationsFailureForCategorization(selectedTab, transactionId, lineIds, response.status)
|
|
52
|
-
: markCategoryClassRecommendationsFailureForTransactionDetail(transactionId, lineIds, response.status));
|
|
53
|
-
}
|
|
54
|
-
const recommendationWithCOTByLineId = getRecommendationByLineIdWithCOTFromRecommendationPayloadWithCOT(response.data.recommendations, lineIds);
|
|
55
|
-
// HTTP 200 with no per-line recommendations: NOT an error.
|
|
56
|
-
// Flip lines to Completed so the skeleton resolves and
|
|
57
|
-
// downstream UI can treat this as "we tried, nothing to
|
|
58
|
-
// apply".
|
|
59
|
-
if (recommendationWithCOTByLineId == null) {
|
|
60
|
-
return of(flowType === 'categorization' && selectedTab != null
|
|
61
|
-
? markCategoryClassRecommendationsCompletedForCategorization(selectedTab, transactionId, lineIds)
|
|
62
|
-
: markCategoryClassRecommendationsCompletedForTransactionDetail(transactionId, lineIds));
|
|
63
|
-
}
|
|
64
|
-
const transactionWithCOT = isFetchCOT === true
|
|
65
|
-
? getTransactionWithCOTFromRecommendations(transaction, recommendationWithCOTByLineId)
|
|
66
|
-
: getTransactionWithCOT(transaction);
|
|
67
|
-
const uncategorizedIncomeExpense = getUncategorizedAccounts(state$.value.accountState, state$.value.accountListState, 'accountList');
|
|
68
|
-
if (flowType === 'categorization' && selectedTab != null) {
|
|
69
|
-
return of(setEntityRecommendationForLineIdsForCategorization(selectedTab, transactionId, transactionWithCOT, lineIds, entity, amount, recommendationWithCOTByLineId, uncategorizedIncomeExpense, isUncategorizedExpenseCategoryEnabled, getIsAccountingClassesEnabled(state$.value)));
|
|
70
|
-
}
|
|
71
|
-
return of(setEntityRecommendationForLineIdsForTransactionDetail(transactionId, transactionWithCOT, lineIds, entity, amount, recommendationWithCOTByLineId, uncategorizedIncomeExpense));
|
|
72
|
-
}), catchError((error) => {
|
|
73
|
-
const errorMessage = 'fetchEntityRecommendationsForLineUpdate failed: ' +
|
|
74
|
-
(error instanceof Error
|
|
75
|
-
? error.message
|
|
76
|
-
: JSON.stringify(error));
|
|
77
|
-
const status = createZeniAPIStatus('Unexpected Error', errorMessage);
|
|
78
|
-
return of(flowType === 'categorization' && selectedTab != null
|
|
79
|
-
? markCategoryClassRecommendationsFailureForCategorization(selectedTab, transactionId, lineIds, status)
|
|
80
|
-
: markCategoryClassRecommendationsFailureForTransactionDetail(transactionId, lineIds, status));
|
|
81
|
-
}));
|
|
82
|
-
return concat(of(startAction), httpStream$);
|
|
83
|
-
}))));
|
|
@@ -1,9 +0,0 @@
|
|
|
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>;
|
|
@@ -1,87 +0,0 @@
|
|
|
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) => {
|
|
76
|
-
const errorMessage = 'fetchEntityRecommendationsForLineUpdate failed: ' +
|
|
77
|
-
(error instanceof Error
|
|
78
|
-
? error.message
|
|
79
|
-
: JSON.stringify(error));
|
|
80
|
-
const status = (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', errorMessage);
|
|
81
|
-
return (0, rxjs_1.of)(flowType === 'categorization' && selectedTab != null
|
|
82
|
-
? (0, transactionsViewReducer_1.markCategoryClassRecommendationsFailureForCategorization)(selectedTab, transactionId, lineIds, status)
|
|
83
|
-
: (0, transactionDetailReducer_1.markCategoryClassRecommendationsFailureForTransactionDetail)(transactionId, lineIds, status));
|
|
84
|
-
}));
|
|
85
|
-
return (0, rxjs_1.concat)((0, rxjs_1.of)(startAction), httpStream$);
|
|
86
|
-
}))));
|
|
87
|
-
exports.fetchEntityRecommendationsForLineUpdateEpic = fetchEntityRecommendationsForLineUpdateEpic;
|