@zeniai/client-epic-state 5.0.69-betaML31 → 5.0.69-betaML51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/lib/epic.d.ts +1 -2
  2. package/lib/epic.js +1 -2
  3. package/lib/esm/epic.js +1 -2
  4. package/lib/esm/index.js +6 -6
  5. package/lib/esm/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +1 -21
  6. package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +14 -117
  7. package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +0 -58
  8. package/lib/esm/view/recommendation/recommendationHelper.js +0 -29
  9. package/lib/esm/view/recommendation/recommendationReducer.js +1 -36
  10. package/lib/esm/view/transactionDetail/transactionDetailReducer.js +6 -121
  11. package/lib/esm/view/transactionDetail/transactionDetailSelector.js +0 -22
  12. package/lib/index.d.ts +6 -7
  13. package/lib/index.js +32 -35
  14. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +0 -1
  15. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +2 -23
  16. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +1 -14
  17. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +14 -117
  18. package/lib/view/expenseAutomationView/selectorTypes/transactionsViewSelectorTypes.d.ts +0 -2
  19. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.d.ts +0 -3
  20. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +0 -60
  21. package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +0 -1
  22. package/lib/view/recommendation/recommendationHelper.d.ts +0 -9
  23. package/lib/view/recommendation/recommendationHelper.js +1 -31
  24. package/lib/view/recommendation/recommendationReducer.d.ts +1 -18
  25. package/lib/view/recommendation/recommendationReducer.js +2 -37
  26. package/lib/view/transactionDetail/transactionDetailReducer.d.ts +1 -11
  27. package/lib/view/transactionDetail/transactionDetailReducer.js +7 -122
  28. package/lib/view/transactionDetail/transactionDetailSelector.d.ts +0 -2
  29. package/lib/view/transactionDetail/transactionDetailSelector.js +1 -24
  30. package/lib/view/transactionDetail/transactionDetailTypes.d.ts +0 -1
  31. package/package.json +1 -1
  32. package/lib/esm/view/recommendation/fetchEntityRecommendationsForLineUpdateEpic.js +0 -83
  33. package/lib/tsconfig.typecheck.tsbuildinfo +0 -1
  34. package/lib/view/recommendation/fetchEntityRecommendationsForLineUpdateEpic.d.ts +0 -9
  35. package/lib/view/recommendation/fetchEntityRecommendationsForLineUpdateEpic.js +0 -87
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  var _a;
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.setIsVendorUpdateAllChecked = exports.updateVendorBulkRecommendationsFetchStatus = exports.updateLatestSelectedEntity = exports.resetAllLineItemsToVendor = exports.updateVendorToAllLineItems = exports.updateLocalDataWithTransactionsUpdateWithVendorCheckbox = exports.resetSelectedCustomer = exports.resetVendor = exports.updateSelectedCustomer = exports.updateSelectedVendor = exports.removeEntityRecommendationForLineIdForTransactionDetail = exports.markCategoryClassRecommendationsFailureForTransactionDetail = exports.markCategoryClassRecommendationsCompletedForTransactionDetail = exports.markCategoryClassRecommendationsInProgressForTransactionDetail = exports.setEntityRecommendationForLineIdsForTransactionDetail = exports.setAllLineItemsLocalDataIsUpdateAllChecked = exports.setAllLineItemsToCategoryClassInLocalData = exports.resetLineItemsCategoryClassInLocalData = exports.clearTransactionDetailLocalData = exports.saveTransactionDetailLocalData = exports.initializeTransactionDetailLocalData = exports.saveTransactionDetail = exports.updateTransactionStateIfUpdateActionNotAllowed = exports.updateStatusConsolidatedSaveTransactionDetail = exports.updateStatusForTransactionNotMiscategorizedUpdate = exports.deleteTransactionAttachmentSuccess = exports.deleteTransactionAttachmentFailure = exports.deleteTransactionAttachment = exports.markTransactionAsNotMiscategorized = exports.clearTransactionDetailSaveStatus = exports.updateTransactionDetailSaveStatus = exports.updateTransactionDetail = exports.uploadMissingAttachmentSuccess = exports.clearTransactionDetail = exports.removeTransactionDetail = exports.updateTransactionDetailFetchState = exports.fetchTransactionDetail = exports.downloadAccountingProviderAttachmentFailure = exports.downloadAccountingProviderAttachmentSuccess = exports.downloadAccountingProviderAttachment = exports.initialState = void 0;
7
+ exports.setIsVendorUpdateAllChecked = exports.updateVendorBulkRecommendationsFetchStatus = exports.updateLatestSelectedEntity = exports.resetAllLineItemsToVendor = exports.updateVendorToAllLineItems = exports.updateLocalDataWithTransactionsUpdateWithVendorCheckbox = exports.resetSelectedCustomer = exports.resetVendor = exports.updateSelectedCustomer = exports.updateSelectedVendor = exports.removeEntityRecommendationForLineIdForTransactionDetail = exports.setEntityRecommendationForLineIdsForTransactionDetail = exports.setAllLineItemsLocalDataIsUpdateAllChecked = exports.setAllLineItemsToCategoryClassInLocalData = exports.resetLineItemsCategoryClassInLocalData = exports.clearTransactionDetailLocalData = exports.saveTransactionDetailLocalData = exports.initializeTransactionDetailLocalData = exports.saveTransactionDetail = exports.updateTransactionStateIfUpdateActionNotAllowed = exports.updateStatusConsolidatedSaveTransactionDetail = exports.updateStatusForTransactionNotMiscategorizedUpdate = exports.deleteTransactionAttachmentSuccess = exports.deleteTransactionAttachmentFailure = exports.deleteTransactionAttachment = exports.markTransactionAsNotMiscategorized = exports.clearTransactionDetailSaveStatus = exports.updateTransactionDetailSaveStatus = exports.updateTransactionDetail = exports.uploadMissingAttachmentSuccess = exports.clearTransactionDetail = exports.removeTransactionDetail = exports.updateTransactionDetailFetchState = exports.fetchTransactionDetail = exports.downloadAccountingProviderAttachmentFailure = exports.downloadAccountingProviderAttachmentSuccess = exports.downloadAccountingProviderAttachment = exports.initialState = void 0;
8
8
  const toolkit_1 = require("@reduxjs/toolkit");
9
9
  const get_1 = __importDefault(require("lodash/get"));
10
10
  const entity_1 = require("../../entity/genericEntity/entity");
@@ -245,34 +245,12 @@ const transactionDetail = (0, toolkit_1.createSlice)({
245
245
  saveTransactionDetailLocalData(draft, action) {
246
246
  const key = (0, transactionDetailState_1.getTransactionDetailKey)(action.payload.transactionId);
247
247
  const detail = (0, get_1.default)(draft.transactionDetailById, key, undefined);
248
- if (detail == null) {
249
- return;
248
+ if (detail != null) {
249
+ draft.transactionDetailById[key] = {
250
+ ...detail,
251
+ transactionDetailLocalData: action.payload.transactionLocalData,
252
+ };
250
253
  }
251
- const incoming = action.payload.transactionLocalData;
252
- const prevById = detail.transactionDetailLocalData.lineItemById;
253
- // Per-line `categoryClassRecommendationsFetchState` is owned by the
254
- // recommendation epic/reducers (markInProgress / markCompleted /
255
- // markFailure / setEntityRecommendationForLineIdsForTransactionDetail).
256
- // Callers that rebuild `transactionLocalData` from a UI snapshot will
257
- // typically have an out-of-date copy of this field (e.g. payee-change
258
- // captures the snapshot before the epic's start arm runs and would
259
- // otherwise clobber In-Progress back to undefined). Treat the field as
260
- // sticky: only let the caller override it when they explicitly set it.
261
- const mergedLineItemById = {};
262
- Object.entries(incoming.lineItemById ?? {}).forEach(([lineId, line]) => {
263
- mergedLineItemById[lineId] = {
264
- ...line,
265
- categoryClassRecommendationsFetchState: line.categoryClassRecommendationsFetchState ??
266
- prevById?.[lineId]?.categoryClassRecommendationsFetchState,
267
- };
268
- });
269
- draft.transactionDetailById[key] = {
270
- ...detail,
271
- transactionDetailLocalData: {
272
- ...incoming,
273
- lineItemById: mergedLineItemById,
274
- },
275
- };
276
254
  },
277
255
  saveTransactionDetail(draft, action) {
278
256
  const key = (0, transactionDetailState_1.getTransactionDetailKey)(action.payload.transactionId);
@@ -394,21 +372,6 @@ const transactionDetail = (0, toolkit_1.createSlice)({
394
372
  const detail = (0, get_1.default)(draft.transactionDetailById, key, undefined);
395
373
  if (detail != null) {
396
374
  const newLocalData = (0, transactionDetailLocalDataHelper_1.setEntityRecommendationForLineIdInLocalData)(transaction, detail.transactionDetailLocalData, action.payload.entity, lineIds, uncategorizedIncomeExpense, recommendationWithCOTByLineId);
397
- // Release the per-line fetch flag for every line this fetch
398
- // covered so the inline skeleton resolves and the page-level
399
- // Save button can re-enable.
400
- lineIds.forEach((lineId) => {
401
- const lineItem = newLocalData.lineItemById[lineId];
402
- if (lineItem != null) {
403
- newLocalData.lineItemById[lineId] = {
404
- ...lineItem,
405
- categoryClassRecommendationsFetchState: {
406
- fetchState: 'Completed',
407
- error: undefined,
408
- },
409
- };
410
- }
411
- });
412
375
  draft.transactionDetailById[key] = {
413
376
  ...detail,
414
377
  transactionDetailLocalData: newLocalData,
@@ -429,84 +392,6 @@ const transactionDetail = (0, toolkit_1.createSlice)({
429
392
  };
430
393
  },
431
394
  },
432
- // Start arm of the line-update recommendations fetch for the detail
433
- // page. Flips covered lines to In-Progress; detail page has no
434
- // checkbox, so no auto-uncheck side effect.
435
- markCategoryClassRecommendationsInProgressForTransactionDetail: {
436
- reducer(draft, action) {
437
- const { transactionId, lineIds } = action.payload;
438
- const key = (0, transactionDetailState_1.getTransactionDetailKey)(transactionId);
439
- const detail = (0, get_1.default)(draft.transactionDetailById, key, undefined);
440
- if (detail != null) {
441
- lineIds.forEach((lineId) => {
442
- const lineItem = detail.transactionDetailLocalData.lineItemById[lineId];
443
- if (lineItem != null) {
444
- detail.transactionDetailLocalData.lineItemById[lineId] = {
445
- ...lineItem,
446
- categoryClassRecommendationsFetchState: {
447
- fetchState: 'In-Progress',
448
- error: undefined,
449
- },
450
- };
451
- }
452
- });
453
- }
454
- },
455
- prepare(transactionId, lineIds) {
456
- return { payload: { transactionId, lineIds } };
457
- },
458
- },
459
- // Completed arm. Used when the HTTP call succeeded but the server
460
- // returned no per-line recommendations — still need to release the
461
- // In-Progress flag.
462
- markCategoryClassRecommendationsCompletedForTransactionDetail: {
463
- reducer(draft, action) {
464
- const { transactionId, lineIds } = action.payload;
465
- const key = (0, transactionDetailState_1.getTransactionDetailKey)(transactionId);
466
- const detail = (0, get_1.default)(draft.transactionDetailById, key, undefined);
467
- if (detail != null) {
468
- lineIds.forEach((lineId) => {
469
- const lineItem = detail.transactionDetailLocalData.lineItemById[lineId];
470
- if (lineItem != null) {
471
- detail.transactionDetailLocalData.lineItemById[lineId] = {
472
- ...lineItem,
473
- categoryClassRecommendationsFetchState: {
474
- fetchState: 'Completed',
475
- error: undefined,
476
- },
477
- };
478
- }
479
- });
480
- }
481
- },
482
- prepare(transactionId, lineIds) {
483
- return { payload: { transactionId, lineIds } };
484
- },
485
- },
486
- markCategoryClassRecommendationsFailureForTransactionDetail: {
487
- reducer(draft, action) {
488
- const { transactionId, lineIds, error } = action.payload;
489
- const key = (0, transactionDetailState_1.getTransactionDetailKey)(transactionId);
490
- const detail = (0, get_1.default)(draft.transactionDetailById, key, undefined);
491
- if (detail != null) {
492
- lineIds.forEach((lineId) => {
493
- const lineItem = detail.transactionDetailLocalData.lineItemById[lineId];
494
- if (lineItem != null) {
495
- detail.transactionDetailLocalData.lineItemById[lineId] = {
496
- ...lineItem,
497
- categoryClassRecommendationsFetchState: {
498
- fetchState: 'Error',
499
- error,
500
- },
501
- };
502
- }
503
- });
504
- }
505
- },
506
- prepare(transactionId, lineIds, error) {
507
- return { payload: { transactionId, lineIds, error } };
508
- },
509
- },
510
395
  removeEntityRecommendationForLineIdForTransactionDetail: {
511
396
  reducer(draft, action) {
512
397
  const { transaction, lineId } = action.payload;
@@ -778,7 +663,7 @@ const transactionDetail = (0, toolkit_1.createSlice)({
778
663
  },
779
664
  },
780
665
  });
781
- _a = transactionDetail.actions, exports.downloadAccountingProviderAttachment = _a.downloadAccountingProviderAttachment, exports.downloadAccountingProviderAttachmentSuccess = _a.downloadAccountingProviderAttachmentSuccess, exports.downloadAccountingProviderAttachmentFailure = _a.downloadAccountingProviderAttachmentFailure, exports.fetchTransactionDetail = _a.fetchTransactionDetail, exports.updateTransactionDetailFetchState = _a.updateTransactionDetailFetchState, exports.removeTransactionDetail = _a.removeTransactionDetail, exports.clearTransactionDetail = _a.clearTransactionDetail, exports.uploadMissingAttachmentSuccess = _a.uploadMissingAttachmentSuccess, exports.updateTransactionDetail = _a.updateTransactionDetail, exports.updateTransactionDetailSaveStatus = _a.updateTransactionDetailSaveStatus, exports.clearTransactionDetailSaveStatus = _a.clearTransactionDetailSaveStatus, exports.markTransactionAsNotMiscategorized = _a.markTransactionAsNotMiscategorized, exports.deleteTransactionAttachment = _a.deleteTransactionAttachment, exports.deleteTransactionAttachmentFailure = _a.deleteTransactionAttachmentFailure, exports.deleteTransactionAttachmentSuccess = _a.deleteTransactionAttachmentSuccess, exports.updateStatusForTransactionNotMiscategorizedUpdate = _a.updateStatusForTransactionNotMiscategorizedUpdate, exports.updateStatusConsolidatedSaveTransactionDetail = _a.updateStatusConsolidatedSaveTransactionDetail, exports.updateTransactionStateIfUpdateActionNotAllowed = _a.updateTransactionStateIfUpdateActionNotAllowed, exports.saveTransactionDetail = _a.saveTransactionDetail, exports.initializeTransactionDetailLocalData = _a.initializeTransactionDetailLocalData, exports.saveTransactionDetailLocalData = _a.saveTransactionDetailLocalData, exports.clearTransactionDetailLocalData = _a.clearTransactionDetailLocalData, exports.resetLineItemsCategoryClassInLocalData = _a.resetLineItemsCategoryClassInLocalData, exports.setAllLineItemsToCategoryClassInLocalData = _a.setAllLineItemsToCategoryClassInLocalData, exports.setAllLineItemsLocalDataIsUpdateAllChecked = _a.setAllLineItemsLocalDataIsUpdateAllChecked, exports.setEntityRecommendationForLineIdsForTransactionDetail = _a.setEntityRecommendationForLineIdsForTransactionDetail, exports.markCategoryClassRecommendationsInProgressForTransactionDetail = _a.markCategoryClassRecommendationsInProgressForTransactionDetail, exports.markCategoryClassRecommendationsCompletedForTransactionDetail = _a.markCategoryClassRecommendationsCompletedForTransactionDetail, exports.markCategoryClassRecommendationsFailureForTransactionDetail = _a.markCategoryClassRecommendationsFailureForTransactionDetail, exports.removeEntityRecommendationForLineIdForTransactionDetail = _a.removeEntityRecommendationForLineIdForTransactionDetail, exports.updateSelectedVendor = _a.updateSelectedVendor, exports.updateSelectedCustomer = _a.updateSelectedCustomer, exports.resetVendor = _a.resetVendor, exports.resetSelectedCustomer = _a.resetSelectedCustomer, exports.updateLocalDataWithTransactionsUpdateWithVendorCheckbox = _a.updateLocalDataWithTransactionsUpdateWithVendorCheckbox, exports.updateVendorToAllLineItems = _a.updateVendorToAllLineItems, exports.resetAllLineItemsToVendor = _a.resetAllLineItemsToVendor, exports.updateLatestSelectedEntity = _a.updateLatestSelectedEntity, exports.updateVendorBulkRecommendationsFetchStatus = _a.updateVendorBulkRecommendationsFetchStatus, exports.setIsVendorUpdateAllChecked = _a.setIsVendorUpdateAllChecked;
666
+ _a = transactionDetail.actions, exports.downloadAccountingProviderAttachment = _a.downloadAccountingProviderAttachment, exports.downloadAccountingProviderAttachmentSuccess = _a.downloadAccountingProviderAttachmentSuccess, exports.downloadAccountingProviderAttachmentFailure = _a.downloadAccountingProviderAttachmentFailure, exports.fetchTransactionDetail = _a.fetchTransactionDetail, exports.updateTransactionDetailFetchState = _a.updateTransactionDetailFetchState, exports.removeTransactionDetail = _a.removeTransactionDetail, exports.clearTransactionDetail = _a.clearTransactionDetail, exports.uploadMissingAttachmentSuccess = _a.uploadMissingAttachmentSuccess, exports.updateTransactionDetail = _a.updateTransactionDetail, exports.updateTransactionDetailSaveStatus = _a.updateTransactionDetailSaveStatus, exports.clearTransactionDetailSaveStatus = _a.clearTransactionDetailSaveStatus, exports.markTransactionAsNotMiscategorized = _a.markTransactionAsNotMiscategorized, exports.deleteTransactionAttachment = _a.deleteTransactionAttachment, exports.deleteTransactionAttachmentFailure = _a.deleteTransactionAttachmentFailure, exports.deleteTransactionAttachmentSuccess = _a.deleteTransactionAttachmentSuccess, exports.updateStatusForTransactionNotMiscategorizedUpdate = _a.updateStatusForTransactionNotMiscategorizedUpdate, exports.updateStatusConsolidatedSaveTransactionDetail = _a.updateStatusConsolidatedSaveTransactionDetail, exports.updateTransactionStateIfUpdateActionNotAllowed = _a.updateTransactionStateIfUpdateActionNotAllowed, exports.saveTransactionDetail = _a.saveTransactionDetail, exports.initializeTransactionDetailLocalData = _a.initializeTransactionDetailLocalData, exports.saveTransactionDetailLocalData = _a.saveTransactionDetailLocalData, exports.clearTransactionDetailLocalData = _a.clearTransactionDetailLocalData, exports.resetLineItemsCategoryClassInLocalData = _a.resetLineItemsCategoryClassInLocalData, exports.setAllLineItemsToCategoryClassInLocalData = _a.setAllLineItemsToCategoryClassInLocalData, exports.setAllLineItemsLocalDataIsUpdateAllChecked = _a.setAllLineItemsLocalDataIsUpdateAllChecked, exports.setEntityRecommendationForLineIdsForTransactionDetail = _a.setEntityRecommendationForLineIdsForTransactionDetail, exports.removeEntityRecommendationForLineIdForTransactionDetail = _a.removeEntityRecommendationForLineIdForTransactionDetail, exports.updateSelectedVendor = _a.updateSelectedVendor, exports.updateSelectedCustomer = _a.updateSelectedCustomer, exports.resetVendor = _a.resetVendor, exports.resetSelectedCustomer = _a.resetSelectedCustomer, exports.updateLocalDataWithTransactionsUpdateWithVendorCheckbox = _a.updateLocalDataWithTransactionsUpdateWithVendorCheckbox, exports.updateVendorToAllLineItems = _a.updateVendorToAllLineItems, exports.resetAllLineItemsToVendor = _a.resetAllLineItemsToVendor, exports.updateLatestSelectedEntity = _a.updateLatestSelectedEntity, exports.updateVendorBulkRecommendationsFetchStatus = _a.updateVendorBulkRecommendationsFetchStatus, exports.setIsVendorUpdateAllChecked = _a.setIsVendorUpdateAllChecked;
782
667
  exports.default = transactionDetail.reducer;
783
668
  function getUpdatedEntityLocalData(detail, updates, entity, resetRecommendations, type) {
784
669
  const key = type === 'customer' ? 'customerUpdates' : 'vendorUpdates';
@@ -18,7 +18,6 @@ export interface TransactionDetailReport extends SelectorView {
18
18
  classHierarchyList: NestedClassHierarchyForReport[];
19
19
  classList: ClassListSelectorView;
20
20
  deleteStatusByAttachmentName: Record<string, FetchStateAndError>;
21
- hasInFlightCategoryClassRecommendations: boolean;
22
21
  isAccountingClassesEnabled: boolean;
23
22
  isAccountingProjectsEnabled: boolean;
24
23
  linkedTransactions: SupportedTransactionWithCOT[];
@@ -31,7 +30,6 @@ export interface TransactionDetailReport extends SelectorView {
31
30
  export interface VendorDetailsView extends SelectorView {
32
31
  vendors: Vendor[];
33
32
  }
34
- export declare const getDetailInFlightRecommendations: (state: RootState, transactionId: TransactionID) => boolean;
35
33
  export declare const getTransactionDetail: (state: RootState, transactionId: TransactionID, fetchLinkedTransactions?: boolean) => TransactionDetailReport;
36
34
  export declare function getTransactionDetailForTransaction(rootState: RootState, transactionId: TransactionID): TransactionDetailReport | undefined;
37
35
  export declare const getInitialUpdatablePeriodsForTransactionRecommendations: (companyIncorporationDate?: ZeniDate, bookCloseDate?: ZeniDate) => {
@@ -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 = exports.getDetailInFlightRecommendations = void 0;
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-betaML31",
3
+ "version": "5.0.69-betaML51",
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
- }))));