@zeniai/client-epic-state 4.19.46 → 4.19.48

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.
@@ -18,6 +18,13 @@ export declare const getPendingReviewLineIdsFromTransaction: (transaction: Suppo
18
18
  * Intended for use within Immer reducer drafts (mutates in place).
19
19
  */
20
20
  export declare const removeTransactionFromTabView: (tabView: TransactionsTabViewState, transactionId: ID) => void;
21
+ /**
22
+ * Filters the autoCategorized tab's line items for a transaction, retaining only
23
+ * lines whose categorizationStatus is still `auto_reviewed` or `auto_categorized`.
24
+ * If no lines are retained, removes the transaction from the tab entirely.
25
+ * Intended for use within Immer reducer drafts (mutates in place).
26
+ */
27
+ export declare const filterAutoTabLineItems: (tabView: TransactionsTabViewState, transactionId: ID, updatedTransaction: SupportedTransactionWithCOT) => void;
21
28
  export declare const MAX_SELECTION_LIMIT = 5;
22
29
  export declare const toTransactionDetailLocalData: (transaction: SupportedTransactionWithCOT, selectedTab: TransactionsTab, lineItemsByTransactionIds: string[], uncategorizedIncomeExpense: UncategorizedAccounts, isUncategorizedExpenseCategoryEnabled?: boolean) => TransactionReviewLocalData;
23
30
  export declare const toSetAllLineItemsToCategoryClass: (draft: TransactionsTabViewState, transaction: SupportedTransactionWithCOT, transactionId: ID, transactionLineId: ID, transactionDetailLocalData: TransactionReviewLocalData, updatedItem: "category" | "class", uncategorizedAccounts: UncategorizedAccounts, selectedTab: TransactionsTab, vendorId?: ID, customerId?: ID, selectedAccount?: AccountBase, selectedClassBase?: ClassBase, isUncategorizedExpenseCategoryEnabled?: boolean) => {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hasTransactionLocalDataChanges = exports.isAnyItemWithUncategorizedExpenseAccount = exports.getSnackbarMessageForTransactionReview = exports.mergeTabSpecificLineItems = exports.getLineItemsByTransactionIdsFromLocalData = exports.getLineItemsByTransactionsIdsFromResponse = exports.checkIfAllLineItemsAreCategoryClassFilled = exports.setEntityRecommendationForLineIdInLocalData = exports.toSetAllLineItemsToCategoryClass = exports.toTransactionDetailLocalData = exports.MAX_SELECTION_LIMIT = exports.removeTransactionFromTabView = exports.getPendingReviewLineIdsFromTransaction = void 0;
3
+ exports.hasTransactionLocalDataChanges = exports.isAnyItemWithUncategorizedExpenseAccount = exports.getSnackbarMessageForTransactionReview = exports.mergeTabSpecificLineItems = exports.getLineItemsByTransactionIdsFromLocalData = exports.getLineItemsByTransactionsIdsFromResponse = exports.checkIfAllLineItemsAreCategoryClassFilled = exports.setEntityRecommendationForLineIdInLocalData = exports.toSetAllLineItemsToCategoryClass = exports.toTransactionDetailLocalData = exports.MAX_SELECTION_LIMIT = exports.filterAutoTabLineItems = exports.removeTransactionFromTabView = exports.getPendingReviewLineIdsFromTransaction = void 0;
4
4
  const vendorTransaction_1 = require("../../../entity/transaction/stateTypes/vendorTransaction");
5
5
  const transactionDetailLocalDataHelper_1 = require("../../transactionDetail/transactionDetailLocalDataHelper");
6
6
  const transactionDetailLocalDataHelper_2 = require("../../transactionDetail/transactionDetailLocalDataHelper");
@@ -35,6 +35,35 @@ const removeTransactionFromTabView = (tabView, transactionId) => {
35
35
  tabView.transactionIdsWithUnsavedData.filter((id) => id !== transactionId);
36
36
  };
37
37
  exports.removeTransactionFromTabView = removeTransactionFromTabView;
38
+ /**
39
+ * Filters the autoCategorized tab's line items for a transaction, retaining only
40
+ * lines whose categorizationStatus is still `auto_reviewed` or `auto_categorized`.
41
+ * If no lines are retained, removes the transaction from the tab entirely.
42
+ * Intended for use within Immer reducer drafts (mutates in place).
43
+ */
44
+ const filterAutoTabLineItems = (tabView, transactionId, updatedTransaction) => {
45
+ const localData = tabView.transactionReviewLocalDataById[transactionId];
46
+ if (localData == null) {
47
+ return;
48
+ }
49
+ const currentAutoLineIds = localData.transactionReviewLocalData.tabSpecificLineItems
50
+ .autoCategorized ?? [];
51
+ const linesById = new Map(updatedTransaction.lines?.map((l) => [l.id, l]));
52
+ const retainedLineIds = currentAutoLineIds.filter((lineId) => {
53
+ const line = linesById.get(lineId);
54
+ return (line?.categorizationStatus === 'auto_reviewed' ||
55
+ line?.categorizationStatus === 'auto_categorized');
56
+ });
57
+ if (retainedLineIds.length === 0) {
58
+ (0, exports.removeTransactionFromTabView)(tabView, transactionId);
59
+ }
60
+ else {
61
+ localData.transactionReviewLocalData.tabSpecificLineItems = {
62
+ autoCategorized: retainedLineIds,
63
+ };
64
+ }
65
+ };
66
+ exports.filterAutoTabLineItems = filterAutoTabLineItems;
38
67
  exports.MAX_SELECTION_LIMIT = 5;
39
68
  const toTransactionDetailLocalData = (transaction, selectedTab, lineItemsByTransactionIds, uncategorizedIncomeExpense, isUncategorizedExpenseCategoryEnabled) => {
40
69
  const transactionLocal = {
@@ -728,24 +728,18 @@ const expenseAutomationTransactionsView = (0, toolkit_1.createSlice)({
728
728
  if (!existsInReview && !existsInAuto) {
729
729
  return;
730
730
  }
731
+ // Auto tab: retain only lines still auto_reviewed or auto_categorized
732
+ if (existsInAuto) {
733
+ (0, transactionCategorizationLocalDataHelper_1.filterAutoTabLineItems)(autoTabView, txnId, updatedTransaction);
734
+ }
731
735
  const allReviewed = pendingReviewLineIds.length === 0;
732
736
  if (allReviewed) {
733
737
  if (existsInReview) {
734
738
  (0, transactionCategorizationLocalDataHelper_1.removeTransactionFromTabView)(reviewTabView, txnId);
735
739
  }
736
- if (existsInAuto) {
737
- (0, transactionCategorizationLocalDataHelper_1.removeTransactionFromTabView)(autoTabView, txnId);
738
- }
739
740
  return;
740
741
  }
741
- // Partially reviewed auto-only: remove transaction from auto tab entirely
742
- // since pending_review lines don't belong in auto tab and review_complete lines are done
743
- const isAutoOnly = existsInAuto && !existsInReview;
744
- if (isAutoOnly) {
745
- (0, transactionCategorizationLocalDataHelper_1.removeTransactionFromTabView)(autoTabView, txnId);
746
- return;
747
- }
748
- // Review-only or both-tabs: rebuild review tab local data with pending review lines
742
+ // Partially reviewed: rebuild review tab local data with pending review lines
749
743
  if (existsInReview) {
750
744
  const newLocalData = (0, transactionCategorizationLocalDataHelper_1.toTransactionDetailLocalData)(updatedTransaction, 'review', pendingReviewLineIds, uncategorizedIncomeExpense, isUncategorizedExpenseCategoryEnabled);
751
745
  reviewTabView.transactionReviewLocalDataById[txnId] = {
@@ -763,10 +757,6 @@ const expenseAutomationTransactionsView = (0, toolkit_1.createSlice)({
763
757
  reviewTabView.transactionIdsWithUnsavedData =
764
758
  reviewTabView.transactionIdsWithUnsavedData.filter((id) => id !== txnId);
765
759
  }
766
- // If both tabs, remove from auto tab entirely
767
- if (existsInAuto) {
768
- (0, transactionCategorizationLocalDataHelper_1.removeTransactionFromTabView)(autoTabView, txnId);
769
- }
770
760
  },
771
761
  },
772
762
  backgroundRefetchReviewTab: {
@@ -27,20 +27,35 @@ const markTransactionAsNotMiscategorizedEpic = (actions$, state$, zeniAPI) => ac
27
27
  const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state$.value);
28
28
  const { selectedPeriodByTenantId } = expenseAutomationViewState;
29
29
  const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
30
+ const txnId = action.payload.transactionId.id;
31
+ const autoTabLineItems = transactionCategorizationView.autoCategorized
32
+ .transactionReviewLocalDataById[txnId]
33
+ ?.transactionReviewLocalData.tabSpecificLineItems
34
+ .autoCategorized ?? [];
35
+ const hasAutoLines = autoTabLineItems.length > 0;
30
36
  const { uiState } = transactionCategorizationView[selectedTransactionCategorizationTab];
31
- const totalCountByPeriod = uiState.totalCount[(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)];
32
- const updatedTotalCount = totalCountByPeriod === 0
33
- ? totalCountByPeriod
34
- : totalCountByPeriod - 1;
35
- actions.push((0, transactionsViewReducer_1.updateStatusForTransactionNotMiscategorizedUpdateForCategorization)(selectedTransactionCategorizationTab, [action.payload.transactionId.id], [action.payload.transactionId.id], selectedPeriod, 'Completed'));
36
- actions.push((0, transactionReducer_1.removeTransactionCategorization)({
37
- transactionIds: [action.payload.transactionId.id],
38
- }));
39
- actions.push((0, transactionsViewReducer_1.updateTotalCountForTransactionCategorization)({
40
- selectedPeriod,
41
- selectedTab: selectedTransactionCategorizationTab,
42
- totalCount: updatedTotalCount,
43
- }));
37
+ const removeIdsFromPeriod = selectedTransactionCategorizationTab === 'review'
38
+ ? [txnId]
39
+ : hasAutoLines
40
+ ? []
41
+ : [txnId];
42
+ actions.push((0, transactionsViewReducer_1.updateStatusForTransactionNotMiscategorizedUpdateForCategorization)(selectedTransactionCategorizationTab, [txnId], removeIdsFromPeriod, selectedPeriod, 'Completed'));
43
+ if (!hasAutoLines) {
44
+ actions.push((0, transactionReducer_1.removeTransactionCategorization)({
45
+ transactionIds: [txnId],
46
+ }));
47
+ }
48
+ if (removeIdsFromPeriod.length > 0) {
49
+ const totalCountByPeriod = uiState.totalCount[(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)];
50
+ const updatedTotalCount = totalCountByPeriod === 0
51
+ ? totalCountByPeriod
52
+ : totalCountByPeriod - 1;
53
+ actions.push((0, transactionsViewReducer_1.updateTotalCountForTransactionCategorization)({
54
+ selectedPeriod,
55
+ selectedTab: selectedTransactionCategorizationTab,
56
+ totalCount: updatedTotalCount,
57
+ }));
58
+ }
44
59
  }
45
60
  actions.push((0, transactionDetailReducer_1.updateStatusConsolidatedSaveTransactionDetail)({
46
61
  transactionId: action.payload.transactionId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "4.19.46",
3
+ "version": "4.19.48",
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",