@zeniai/client-epic-state 5.0.78 → 5.0.79

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 (190) hide show
  1. package/lib/commonStateTypes/cacheOverrideFetchReducer.d.ts +17 -0
  2. package/lib/commonStateTypes/cacheOverrideFetchReducer.js +20 -0
  3. package/lib/commonStateTypes/filterPrimitives.d.ts +23 -0
  4. package/lib/commonStateTypes/filterPrimitives.js +21 -0
  5. package/lib/commonStateTypes/pusherActions.d.ts +11 -0
  6. package/lib/commonStateTypes/pusherActions.js +6 -0
  7. package/lib/coreEpics.js +1 -1
  8. package/lib/entity/account/accountSelector.d.ts +27 -1
  9. package/lib/entity/account/accountSelector.js +47 -1
  10. package/lib/entity/account/accountState.d.ts +6 -1
  11. package/lib/entity/account/accountState.js +11 -4
  12. package/lib/entity/account/subAccountSelector.d.ts +1 -1
  13. package/lib/entity/aiAccountantCustomer/aiAccountantCustomerPayload.js +1 -3
  14. package/lib/entity/aiAccountantCustomer/aiAccountantCustomerReducer.js +1 -2
  15. package/lib/entity/aiAccountantCustomer/aiAccountantCustomerSelector.d.ts +1 -1
  16. package/lib/entity/chargeCard/chargeCardReducer.d.ts +19 -2
  17. package/lib/entity/chargeCard/chargeCardReducer.js +35 -2
  18. package/lib/entity/chargeCardTransaction/chargeCardTransactionReducer.d.ts +14 -1
  19. package/lib/entity/chargeCardTransaction/chargeCardTransactionReducer.js +36 -2
  20. package/lib/entity/class/classSelector.d.ts +35 -0
  21. package/lib/entity/class/classSelector.js +50 -0
  22. package/lib/entity/sectionProjectView/sectionProjectViewReducer.d.ts +1 -1
  23. package/lib/entity/sectionProjectView/sectionProjectViewSelector.js +1 -1
  24. package/lib/entity/tenant/SessionManager.js +6 -3
  25. package/lib/entity/tenant/clearAllEpic.d.ts +2 -2
  26. package/lib/entity/tenant/clearAllEpic.js +2 -2
  27. package/lib/entity/tenant/epic/saveAPIKeyConnectionEpic.js +6 -2
  28. package/lib/entity/tenant/epic/saveOAuthConnectionEpic.js +6 -2
  29. package/lib/entity/tenant/tenantReducer.js +6 -1
  30. package/lib/entity/transaction/payloadTypes/transactionLinePayload.js +3 -1
  31. package/lib/epic.d.ts +11 -11
  32. package/lib/epic.js +12 -12
  33. package/lib/esm/commonStateTypes/cacheOverrideFetchReducer.js +16 -0
  34. package/lib/esm/commonStateTypes/filterPrimitives.js +20 -0
  35. package/lib/esm/commonStateTypes/pusherActions.js +3 -0
  36. package/lib/esm/coreEpics.js +1 -1
  37. package/lib/esm/entity/account/accountSelector.js +46 -1
  38. package/lib/esm/entity/account/accountState.js +7 -1
  39. package/lib/esm/entity/aiAccountantCustomer/aiAccountantCustomerPayload.js +1 -3
  40. package/lib/esm/entity/aiAccountantCustomer/aiAccountantCustomerReducer.js +1 -2
  41. package/lib/esm/entity/chargeCard/chargeCardReducer.js +34 -1
  42. package/lib/esm/entity/chargeCardTransaction/chargeCardTransactionReducer.js +35 -1
  43. package/lib/esm/entity/class/classSelector.js +48 -0
  44. package/lib/esm/entity/sectionProjectView/sectionProjectViewSelector.js +1 -1
  45. package/lib/esm/entity/tenant/SessionManager.js +4 -1
  46. package/lib/esm/entity/tenant/clearAllEpic.js +2 -2
  47. package/lib/esm/entity/tenant/epic/saveAPIKeyConnectionEpic.js +6 -2
  48. package/lib/esm/entity/tenant/epic/saveOAuthConnectionEpic.js +6 -2
  49. package/lib/esm/entity/tenant/tenantReducer.js +6 -1
  50. package/lib/esm/entity/transaction/payloadTypes/transactionLinePayload.js +3 -1
  51. package/lib/esm/epic.js +12 -12
  52. package/lib/esm/index.js +31 -21
  53. package/lib/esm/reducer.js +2 -2
  54. package/lib/esm/view/aiAccountantView/epics/fetchAiAccountantCustomersEpic.js +2 -5
  55. package/lib/esm/view/aiAccountantView/epics/fetchAiAccountantJobsEpic.js +2 -5
  56. package/lib/esm/view/aiAccountantView/epics/triggerAiAccountantJobEpic.js +4 -1
  57. package/lib/esm/view/companyHealthMetricView/companyHealthMetricViewSelector.js +1 -1
  58. package/lib/esm/view/companyTaskManagerView/companyTaskManagerViewSelector.js +1 -1
  59. package/lib/esm/view/companyTaskManagerView/epics/fetchTaskManagerMetricsEpic.js +1 -1
  60. package/lib/esm/view/companyView/helpers/cockpitHelpers.js +1 -1
  61. package/lib/esm/view/companyView/selector/companyManagementViewSelector.js +1 -1
  62. package/lib/esm/view/companyView/selector/companyPortfolioViewSelector.js +1 -1
  63. package/lib/esm/view/creditAgentView/creditAgentViewReducer.js +1 -16
  64. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +2 -2
  65. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +2 -1
  66. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/restoreBulkUploadAutomatchingOnMountEpic.js +8 -6
  67. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +7 -1
  68. package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.js +11 -1
  69. package/lib/esm/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +21 -1
  70. package/lib/esm/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +2 -1
  71. package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +253 -14
  72. package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +147 -13
  73. package/lib/esm/view/expenseAutomationView/transactionFilterHelpers.js +258 -0
  74. package/lib/esm/view/expenseAutomationView/types/completedSubTab.js +17 -0
  75. package/lib/esm/view/expenseAutomationView/types/missingReceiptsViewState.js +0 -2
  76. package/lib/esm/view/financeStatement/financeStatementSelector.js +1 -1
  77. package/lib/esm/view/recommendation/fetchEntityRecommendationsForLineUpdateEpic.js +87 -0
  78. package/lib/esm/view/recommendation/recommendationHelper.js +29 -0
  79. package/lib/esm/view/recommendation/recommendationReducer.js +26 -1
  80. package/lib/esm/view/spendManagement/chargeCards/cashbackDetail/cashbackDetailReducer.js +3 -2
  81. package/lib/esm/view/spendManagement/chargeCards/chargeCardConfig/chargeCardConfigReducer.js +3 -2
  82. package/lib/esm/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailReducer.js +55 -18
  83. package/lib/esm/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardDetailEpic.js +16 -2
  84. package/lib/esm/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardDetailPageEpic.js +5 -4
  85. package/lib/esm/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.js +26 -9
  86. package/lib/esm/view/spendManagement/chargeCards/chargeCardList/fetchChargeCardListPageEpic.js +9 -6
  87. package/lib/esm/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryReducer.js +3 -2
  88. package/lib/esm/view/spendManagement/chargeCards/chargeCardPaymentHistory/fetchChargeCardPaymentPageEpic.js +1 -1
  89. package/lib/esm/view/spendManagement/chargeCards/chargeCardRepaymentDetail/chargeCardRepaymentDetailReducer.js +7 -3
  90. package/lib/esm/view/spendManagement/commonHistoryView/commonHistoryPayload.js +8 -3
  91. package/lib/esm/view/spendManagement/commonHistoryView/commonHistoryReducer.js +3 -2
  92. package/lib/esm/view/spendManagement/commonHistoryView/fetchEntityHistoryEpic.js +2 -0
  93. package/lib/esm/view/spendManagement/spendManagementFilterHelpers.js +4 -2
  94. package/lib/esm/view/subscriptionView/subscriptionViewSelector.js +1 -1
  95. package/lib/esm/view/taskManager/cannedResponsesView/epics/fetchCannedResponsesEpic.js +1 -1
  96. package/lib/esm/view/taskManager/cannedResponsesView/epics/saveCannedResponseEpic.js +1 -1
  97. package/lib/esm/view/taskManager/taskDetailView/epics/unsnoozeTaskEpic.js +1 -1
  98. package/lib/esm/view/taskManager/taskListView/taskListReducer.js +1 -1
  99. package/lib/esm/view/transactionDetail/transactionDetailReducer.js +121 -6
  100. package/lib/esm/view/transactionDetail/transactionDetailSelector.js +29 -1
  101. package/lib/index.d.ts +31 -24
  102. package/lib/index.js +84 -60
  103. package/lib/reducer.d.ts +2 -2
  104. package/lib/reducer.js +2 -2
  105. package/lib/view/aiAccountantView/aiAccountantViewPayload.d.ts +2 -2
  106. package/lib/view/aiAccountantView/aiAccountantViewReducer.d.ts +1 -1
  107. package/lib/view/aiAccountantView/epics/fetchAiAccountantCustomersEpic.js +2 -5
  108. package/lib/view/aiAccountantView/epics/fetchAiAccountantJobsEpic.js +2 -5
  109. package/lib/view/aiAccountantView/epics/triggerAiAccountantJobEpic.js +4 -1
  110. package/lib/view/companyHealthMetricView/companyHealthMetricViewSelector.js +1 -1
  111. package/lib/view/companyTaskManagerView/companyTaskManagerViewSelector.d.ts +1 -1
  112. package/lib/view/companyTaskManagerView/companyTaskManagerViewSelector.js +1 -1
  113. package/lib/view/companyView/helpers/cockpitHelpers.js +1 -1
  114. package/lib/view/companyView/selector/companyManagementViewSelector.js +1 -1
  115. package/lib/view/companyView/selector/companyPortfolioViewSelector.js +1 -1
  116. package/lib/view/companyView/types/cockpitTypes.d.ts +1 -1
  117. package/lib/view/creditAgentView/creditAgentViewPayload.d.ts +0 -3
  118. package/lib/view/creditAgentView/creditAgentViewReducer.d.ts +1 -1
  119. package/lib/view/creditAgentView/creditAgentViewReducer.js +2 -17
  120. package/lib/view/creditAgentView/creditAgentViewState.d.ts +0 -5
  121. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +2 -2
  122. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +2 -1
  123. package/lib/view/expenseAutomationView/epics/missingReceipts/restoreBulkUploadAutomatchingOnMountEpic.js +8 -6
  124. package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +7 -1
  125. package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.d.ts +2 -2
  126. package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.js +10 -0
  127. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +2 -1
  128. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +23 -2
  129. package/lib/view/expenseAutomationView/payload/transactionCategorizationPayload.d.ts +21 -0
  130. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +2 -1
  131. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +2 -1
  132. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +28 -5
  133. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +253 -14
  134. package/lib/view/expenseAutomationView/selectorTypes/missingReceiptsSelectorTypes.d.ts +2 -1
  135. package/lib/view/expenseAutomationView/selectorTypes/transactionsViewSelectorTypes.d.ts +16 -0
  136. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.d.ts +7 -1
  137. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +150 -13
  138. package/lib/view/expenseAutomationView/transactionFilterHelpers.d.ts +66 -0
  139. package/lib/view/expenseAutomationView/transactionFilterHelpers.js +262 -0
  140. package/lib/view/expenseAutomationView/types/completedSubTab.d.ts +10 -0
  141. package/lib/view/expenseAutomationView/types/completedSubTab.js +21 -0
  142. package/lib/view/expenseAutomationView/types/missingReceiptsViewState.d.ts +1 -2
  143. package/lib/view/expenseAutomationView/types/missingReceiptsViewState.js +1 -4
  144. package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +44 -2
  145. package/lib/view/financeStatement/financeStatementSelector.js +1 -1
  146. package/lib/view/profitAndLossProjectView/profitAndLossProjectViewSelectorTypes.d.ts +1 -1
  147. package/lib/view/recommendation/fetchEntityRecommendationsForLineUpdateEpic.d.ts +9 -0
  148. package/lib/view/recommendation/fetchEntityRecommendationsForLineUpdateEpic.js +91 -0
  149. package/lib/view/recommendation/recommendationHelper.d.ts +9 -0
  150. package/lib/view/recommendation/recommendationHelper.js +31 -1
  151. package/lib/view/recommendation/recommendationReducer.d.ts +20 -1
  152. package/lib/view/recommendation/recommendationReducer.js +27 -2
  153. package/lib/view/spendManagement/billPay/billList/billListState.d.ts +1 -1
  154. package/lib/view/spendManagement/chargeCards/cashbackDetail/cashbackDetailReducer.d.ts +3 -1
  155. package/lib/view/spendManagement/chargeCards/cashbackDetail/cashbackDetailReducer.js +3 -2
  156. package/lib/view/spendManagement/chargeCards/chargeCardConfig/chargeCardConfigReducer.d.ts +3 -1
  157. package/lib/view/spendManagement/chargeCards/chargeCardConfig/chargeCardConfigReducer.js +3 -2
  158. package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailReducer.js +55 -18
  159. package/lib/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardDetailEpic.js +16 -2
  160. package/lib/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardDetailPageEpic.js +5 -4
  161. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.d.ts +18 -3
  162. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.js +27 -10
  163. package/lib/view/spendManagement/chargeCards/chargeCardList/fetchChargeCardListPageEpic.js +9 -6
  164. package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistory.d.ts +1 -1
  165. package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryReducer.d.ts +3 -1
  166. package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryReducer.js +3 -2
  167. package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/fetchChargeCardPaymentPageEpic.js +1 -1
  168. package/lib/view/spendManagement/chargeCards/chargeCardRepaymentDetail/chargeCardRepaymentDetailReducer.d.ts +3 -1
  169. package/lib/view/spendManagement/chargeCards/chargeCardRepaymentDetail/chargeCardRepaymentDetailReducer.js +7 -3
  170. package/lib/view/spendManagement/commonHistoryView/commonHistoryPayload.d.ts +1 -1
  171. package/lib/view/spendManagement/commonHistoryView/commonHistoryPayload.js +7 -2
  172. package/lib/view/spendManagement/commonHistoryView/commonHistoryReducer.d.ts +1 -0
  173. package/lib/view/spendManagement/commonHistoryView/commonHistoryReducer.js +3 -2
  174. package/lib/view/spendManagement/commonHistoryView/fetchEntityHistoryEpic.js +2 -0
  175. package/lib/view/spendManagement/reimbursement/remiListView/remiListState.d.ts +1 -1
  176. package/lib/view/spendManagement/spendManagementFilterHelpers.d.ts +12 -3
  177. package/lib/view/spendManagement/spendManagementFilterHelpers.js +4 -2
  178. package/lib/view/subscriptionView/subscriptionViewSelector.js +1 -1
  179. package/lib/view/taskManager/taskListView/taskList.d.ts +1 -1
  180. package/lib/view/taskManager/taskListView/taskListReducer.js +1 -1
  181. package/lib/view/transactionDetail/transactionDetailReducer.d.ts +11 -1
  182. package/lib/view/transactionDetail/transactionDetailReducer.js +122 -7
  183. package/lib/view/transactionDetail/transactionDetailSelector.d.ts +2 -0
  184. package/lib/view/transactionDetail/transactionDetailSelector.js +31 -2
  185. package/lib/view/transactionDetail/transactionDetailTypes.d.ts +1 -0
  186. package/lib/view/zeniOAuthView/zeniOAuthSelector.d.ts +1 -1
  187. package/package.json +9 -4
  188. package/lib/esm/view/creditAgentView/epics/fetchCreditAgentAccessEpic.js +0 -13
  189. package/lib/view/creditAgentView/epics/fetchCreditAgentAccessEpic.d.ts +0 -11
  190. package/lib/view/creditAgentView/epics/fetchCreditAgentAccessEpic.js +0 -17
@@ -3,21 +3,97 @@ 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.toTransactionView = 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");
10
12
  const tenantSelector_1 = require("../../../entity/tenant/tenantSelector");
11
13
  const transactionHelper_1 = require("../../../entity/transaction/transactionHelper");
12
14
  const transactionSelector_1 = require("../../../entity/transaction/transactionSelector");
15
+ const transactionFilterHelpers_1 = require("../transactionFilterHelpers");
13
16
  const accountListSelector_1 = require("../../accountList/accountListSelector");
14
17
  const classListSelector_1 = require("../../classList/classListSelector");
15
18
  const projectListSelector_1 = require("../../projectList/projectListSelector");
16
19
  const expenseAutomationViewSelectorTypes_1 = require("../selectorTypes/expenseAutomationViewSelectorTypes");
20
+ // Walks the tab's transactionReviewLocalDataById map and returns
21
+ // `{ [transactionId]: true }` for every transaction that has at least
22
+ // one line whose targeted-fetch is In-Progress. Pulled out as a plain
23
+ // function so each tab's createSelector can share it.
24
+ const computeCategorizationInFlightRecommendations = (transactionReviewLocalDataById) => {
25
+ const result = {};
26
+ if (transactionReviewLocalDataById == null) {
27
+ return result;
28
+ }
29
+ for (const [transactionId, data] of Object.entries(transactionReviewLocalDataById)) {
30
+ const lineItems = Object.values(data.transactionReviewLocalData.lineItemById);
31
+ if (lineItems.some((lineItem) => lineItem.categoryClassRecommendationsFetchState?.fetchState ===
32
+ 'In-Progress')) {
33
+ result[transactionId] = true;
34
+ }
35
+ }
36
+ return result;
37
+ };
38
+ // Per-tab createSelector instances. Each one is memoized on its OWN tab's
39
+ // transactionReviewLocalDataById reference. Switching tabs A->B->A no
40
+ // longer busts the memo for tab A — the dispatcher below just returns
41
+ // whichever per-tab selector matches the active tab, and reselect keeps
42
+ // the prior result alive as long as the underlying slice ref is stable.
43
+ const getReviewInFlightRecommendationsByTransactionId = (0, toolkit_1.createSelector)((state) => state.expenseAutomationTransactionsViewState.transactionCategorizationView
44
+ .review.transactionReviewLocalDataById, computeCategorizationInFlightRecommendations);
45
+ const getAutoCategorizedInFlightRecommendationsByTransactionId = (0, toolkit_1.createSelector)((state) => state.expenseAutomationTransactionsViewState.transactionCategorizationView
46
+ .autoCategorized.transactionReviewLocalDataById, computeCategorizationInFlightRecommendations);
47
+ // Per-transaction "any line is fetching category/class recommendations?"
48
+ // map for the active categorization tab. Dispatches to the per-tab
49
+ // memoized selector above so steady state (no fetches in flight)
50
+ // recomputes only when the active tab's local data changes; tab switches
51
+ // are O(1) cache lookups.
52
+ //
53
+ // `default` guards against the union "lying" at runtime: `TransactionsTab`
54
+ // is produced via `stringToUnion`, which falls back to `s as StringUnion`
55
+ // for unrecognized strings, so an unexpected value can land in state. The
56
+ // downstream `getCategorizationHasInFlightRecommendations` calls
57
+ // `Object.keys` on this result, so we must always return an object.
58
+ const getCategorizationInFlightRecommendationsByTransactionId = (state) => {
59
+ const tab = state.expenseAutomationTransactionsViewState
60
+ .selectedTransactionCategorizationTab;
61
+ switch (tab) {
62
+ case 'review':
63
+ return getReviewInFlightRecommendationsByTransactionId(state);
64
+ case 'autoCategorized':
65
+ return getAutoCategorizedInFlightRecommendationsByTransactionId(state);
66
+ default:
67
+ return {};
68
+ }
69
+ };
70
+ exports.getCategorizationInFlightRecommendationsByTransactionId = getCategorizationInFlightRecommendationsByTransactionId;
71
+ // Page-level "any line on the active tab is in flight?" flag. Drives the
72
+ // list-page Save disable.
73
+ exports.getCategorizationHasInFlightRecommendations = (0, toolkit_1.createSelector)(exports.getCategorizationInFlightRecommendationsByTransactionId, (inFlightByTransactionId) => Object.keys(inFlightByTransactionId).length > 0);
74
+ const toTransactionView = (transaction, transactionLocalData) => {
75
+ return {
76
+ id: transaction.id,
77
+ date: transaction.date,
78
+ amount: transaction.amount,
79
+ vendorName: transaction.vendorName,
80
+ customerName: transaction.customerName,
81
+ vendorId: transaction.vendorId,
82
+ customerId: transaction.customerId,
83
+ description: transaction.description,
84
+ memo: transaction.memo,
85
+ type: transaction.type,
86
+ typeName: transaction.typeName,
87
+ createTime: transaction.createTime,
88
+ transaction: transaction,
89
+ transactionLocalData,
90
+ };
91
+ };
92
+ exports.toTransactionView = toTransactionView;
17
93
  function getExpenseAutomationTransactionView(state) {
18
94
  const { accountState, classState, classListState, accountListState, expenseAutomationTransactionsViewState, expenseAutomationViewState, projectState, projectListState, transactionState, monthEndCloseChecksState, monthEndCloseChecksViewState, } = state;
19
- const { selectedTransactionCategorizationTab } = expenseAutomationTransactionsViewState;
20
- const { uiState, refreshStatus, saveStatus, markAsNotMiscategorizedStatus, transactionIdsBySelectedPeriod, transactionReviewLocalDataById, selectedCheckBoxTransactionIds, transactionIdsWithUnsavedData, uploadReceiptStatusById, selectedTransactionId, selectedTransactionLineId, } = expenseAutomationTransactionsViewState.transactionCategorizationView[selectedTransactionCategorizationTab];
95
+ const { selectedTransactionCategorizationCompletedSubTab, selectedTransactionCategorizationTab, } = expenseAutomationTransactionsViewState;
96
+ const { uiState, refreshStatus, saveStatus, markAsNotMiscategorizedStatus, transactionIdsBySelectedPeriod, transactionReviewLocalDataById, selectedCheckBoxTransactionIds, transactionIdsWithUnsavedData, uploadReceiptStatusById, selectedTransactionId, selectedTransactionLineId, filters, } = expenseAutomationTransactionsViewState.transactionCategorizationView[selectedTransactionCategorizationTab];
21
97
  const uncategorizedIncomeExpense = (0, accountListSelector_1.getUncategorizedAccounts)(accountState, accountListState, 'accountList');
22
98
  const accountList = (0, accountListSelector_1.getAccountList)(accountState, accountListState, 'accountList');
23
99
  const classList = (0, classListSelector_1.getClassList)(classState, classListState);
@@ -36,20 +112,58 @@ function getExpenseAutomationTransactionView(state) {
36
112
  ? transactionIdsBySelectedPeriod[monthYearPeriodId]
37
113
  : null;
38
114
  const transactionIds = transactionIdsForSelectedPeriod ?? [];
39
- const transactionLocalData = transactionIds
40
- .map((transactionId) => {
115
+ const transactions = (0, transactionSelector_1.getSupportedTransactionsByIds)(transactionState, transactionIds);
116
+ const transactionsWithCOT = transactions.map((transaction) => (0, transactionHelper_1.getTransactionWithCOT)(transaction));
117
+ const transactionLocalDataMap = new Map();
118
+ transactionIds.forEach((transactionId) => {
41
119
  const transactionData = transactionReviewLocalDataById[transactionId];
42
120
  if (transactionData != null) {
43
- return {
121
+ transactionLocalDataMap.set(transactionId, {
44
122
  transactionId,
45
123
  transactionReviewLocalData: transactionData.transactionReviewLocalData,
46
- };
124
+ });
47
125
  }
48
- return null;
49
- })
50
- .filter((transaction) => transaction != null);
51
- const transactions = (0, transactionSelector_1.getSupportedTransactionsByIds)(transactionState, transactionIds);
52
- const transactionsWithCOT = transactions.map((transaction) => (0, transactionHelper_1.getTransactionWithCOT)(transaction));
126
+ });
127
+ // Step 2: Convert to TransactionView and apply advanced filters
128
+ const transactionViews = transactionsWithCOT.map((transaction) => {
129
+ const localData = transactionLocalDataMap.get(transaction.id);
130
+ return (0, exports.toTransactionView)(transaction, localData);
131
+ });
132
+ // Apply TC-specific filters (lives under expenseAutomationView, independent
133
+ // of the Spend Management filter pipeline).
134
+ const filteredTransactionViews = (0, transactionFilterHelpers_1.applyTransactionFilters)(transactionViews, filters);
135
+ // Convert back to TransactionWithCOT for return
136
+ const filteredTransactionsWithCOT = filteredTransactionViews.map((view) => view.transaction);
137
+ // Get transactionLocalData for filtered transactions
138
+ // Also include transactionLocalData for transactions that don't exist in transactionState
139
+ // but have local data (to match original behavior)
140
+ const filteredTransactionIds = new Set(filteredTransactionViews.map((view) => view.id));
141
+ // Pre-compute the membership set once. The previous implementation called
142
+ // `transactions.some(t => t.id === transactionId)` inside the per-id loop,
143
+ // turning the pipeline into O(n × m) — measurable on tenants with large
144
+ // transaction lists since this selector runs on every Redux dispatch.
145
+ const transactionExistsById = new Set(transactions.map((t) => t.id));
146
+ // `.flatMap` returns `X[]` directly when the callback returns `[]` for the
147
+ // skip case, so we don't need the trailing `.filter((d): d is X => …)` type
148
+ // predicate that the previous `map → filter` pipeline required.
149
+ const filteredTransactionLocalData = transactionIds.flatMap((transactionId) => {
150
+ const transactionData = transactionReviewLocalDataById[transactionId];
151
+ if (transactionData == null) {
152
+ return [];
153
+ }
154
+ // Include if transaction is in filtered results, or if transaction doesn't exist in state
155
+ // (to maintain backward compatibility with tests)
156
+ const transactionExists = transactionExistsById.has(transactionId);
157
+ if (filteredTransactionIds.has(transactionId) || !transactionExists) {
158
+ return [
159
+ {
160
+ transactionId,
161
+ transactionReviewLocalData: transactionData.transactionReviewLocalData,
162
+ },
163
+ ];
164
+ }
165
+ return [];
166
+ });
53
167
  const monthEndFetchState = monthYearPeriodId != null
54
168
  ? (monthEndCloseChecksViewState.monthEndCloseChecksViewByTenantId[currentTenant.tenantId]?.[monthYearPeriodId] ?? { fetchState: 'Not-Started', error: undefined })
55
169
  : { fetchState: 'Not-Started', error: undefined };
@@ -69,10 +183,27 @@ function getExpenseAutomationTransactionView(state) {
69
183
  .uiState.totalCount;
70
184
  const totalCountByAutoCat = expenseAutomationTransactionsViewState.transactionCategorizationView
71
185
  .autoCategorized.uiState.totalCount;
186
+ // Per-(sub-)tab counts powering pagination, in-list "showing X of Y", and
187
+ // any save/refresh round-trips. Sourced from `uiState.totalCount` which
188
+ // mirrors the response's `total_count` for whatever tab/sub-tab the user is
189
+ // viewing (e.g. only the Manual sub-tab rows for Completed → Manual).
72
190
  const totalCountByTab = {
73
191
  review: monthYearPeriodId != null ? totalCountByReview[monthYearPeriodId] : 0,
74
192
  autoCategorized: monthYearPeriodId != null ? totalCountByAutoCat[monthYearPeriodId] : 0,
75
193
  };
194
+ // Parent-tab badge counts. Sourced from `parent_tab_total_count` in the
195
+ // listing response and used exclusively by the navbar / tab strip badges.
196
+ // Independent of which Completed sub-tab is active so the badge stays
197
+ // stable across sub-tab switches.
198
+ const parentTotalCountByTab = expenseAutomationTransactionsViewState.parentTotalCountByTab;
199
+ const parentTabTotalCountByTab = {
200
+ review: monthYearPeriodId != null
201
+ ? (parentTotalCountByTab.review[monthYearPeriodId] ?? 0)
202
+ : 0,
203
+ autoCategorized: monthYearPeriodId != null
204
+ ? (parentTotalCountByTab.autoCategorized[monthYearPeriodId] ?? 0)
205
+ : 0,
206
+ };
76
207
  const fetchStateByTab = {
77
208
  review: {
78
209
  fetchState: expenseAutomationTransactionsViewState.transactionCategorizationView
@@ -92,11 +223,13 @@ function getExpenseAutomationTransactionView(state) {
92
223
  : [];
93
224
  const transactionCompletionStatus = allSteps.find((step) => step.step === 'transaction_categorization')?.completionStatus;
94
225
  const completionStatus = transactionCompletionStatus ?? 'incomplete';
226
+ const inFlightCategoryClassRecommendationsByTransactionId = (0, exports.getCategorizationInFlightRecommendationsByTransactionId)(state);
227
+ const hasInFlightCategoryClassRecommendations = (0, exports.getCategorizationHasInFlightRecommendations)(state);
95
228
  return {
96
229
  version: 0,
97
230
  fetchState: fetchStatus.fetchState,
98
231
  error: fetchStatus.error,
99
- transactions: transactionsWithCOT,
232
+ transactions: filteredTransactionsWithCOT,
100
233
  selectedCheckBoxTransactionIds,
101
234
  transactionIdsWithUnsavedData,
102
235
  uncategorizedAccounts: uncategorizedIncomeExpense,
@@ -105,18 +238,22 @@ function getExpenseAutomationTransactionView(state) {
105
238
  classList: allClasses,
106
239
  accountsHierarchyList,
107
240
  classHierarchyList,
241
+ hasInFlightCategoryClassRecommendations,
242
+ inFlightCategoryClassRecommendationsByTransactionId,
108
243
  isAccountingProjectsEnabled,
109
244
  projectList,
110
- transactionLocalData,
245
+ transactionLocalData: filteredTransactionLocalData,
111
246
  uiState,
112
247
  refreshStatus,
113
248
  saveStatus,
114
249
  markAsNotMiscategorizedStatus,
115
250
  completionStatus,
116
251
  totalCountByTab,
252
+ parentTabTotalCountByTab,
117
253
  fetchStateByTransactionTabs: fetchStateByTab,
118
254
  uploadReceiptStatusById,
119
255
  selectedTransactionId,
120
256
  selectedTransactionLineId,
257
+ selectedTransactionCategorizationCompletedSubTab,
121
258
  };
122
259
  }
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Filter machinery for the Transaction Categorization feature inside
3
+ * Expense Automation. Intentionally self-contained — does NOT import anything
4
+ * from `view/spendManagement/*`, because Transaction Categorization is not a
5
+ * Spend Management product. Shared primitives
6
+ * (`CategoryCombinationOperator`, `FilterCategoryType`) come from
7
+ * `commonStateTypes/filterPrimitives`, which both feature groups consume.
8
+ */
9
+ import { Amount } from '../../commonStateTypes/amount';
10
+ import { ID } from '../../commonStateTypes/common';
11
+ import { CategoryCombinationOperator, FilterCategoryType } from '../../commonStateTypes/filterPrimitives';
12
+ import { TransactionType } from '../../entity/transaction/stateTypes/transactionType';
13
+ import { SupportedTransactionWithCOT } from '../../entity/transaction/transactionState';
14
+ import { ZeniDate } from '../../zeniDayJS';
15
+ import { TransactionReviewLocalDataSelectorView } from './selectorTypes/transactionsViewSelectorTypes';
16
+ /**
17
+ * Re-exported here so the CES barrel can pull TC's primitives from the
18
+ * Expense Automation surface without reaching into `commonStateTypes`
19
+ * directly — keeps the barrel's existing import topology stable.
20
+ */
21
+ export type { CategoryCombinationOperator, FilterCategoryType };
22
+ export type TransactionFilterEntityType = 'transaction_categorization' | 'customer' | 'vendor' | 'merchant';
23
+ export type TransactionFilterCategoryField = 'payment_account_name' | 'payment_account_type' | 'payee' | 'category' | 'class' | 'amount';
24
+ export interface TransactionFilterCategoryDropdownOption {
25
+ value: TransactionFilterCategoryField;
26
+ multiple?: boolean;
27
+ type?: FilterCategoryType;
28
+ }
29
+ export declare const TRANSACTION_FILTER_CATEGORIES: TransactionFilterCategoryDropdownOption[];
30
+ /** Amount filter operators for transaction_categorization. */
31
+ export type TransactionFilterAmountMatchingOperator = 'equal' | 'not_equal' | 'less_than' | 'greater_than' | 'in_between';
32
+ export interface TransactionFilterCategory {
33
+ field: TransactionFilterCategoryField;
34
+ matchingOperator: TransactionFilterAmountMatchingOperator;
35
+ values: (string | number)[];
36
+ valuesCombinationOperator: 'ANY';
37
+ }
38
+ export interface TransactionFilters {
39
+ categories: TransactionFilterCategory[];
40
+ categoryCombinationOperator: CategoryCombinationOperator;
41
+ }
42
+ export interface TransactionView {
43
+ amount: Amount;
44
+ createTime: ZeniDate;
45
+ date: ZeniDate;
46
+ description: string;
47
+ id: ID;
48
+ memo: string;
49
+ transaction: SupportedTransactionWithCOT;
50
+ type: TransactionType;
51
+ customerId?: ID;
52
+ customerName?: string;
53
+ transactionLocalData?: TransactionReviewLocalDataSelectorView;
54
+ typeName?: string;
55
+ vendorId?: ID;
56
+ vendorName?: string;
57
+ }
58
+ /**
59
+ * TC-only equivalent of `applyAdvancedFiltersOnList`. Filters a list of
60
+ * `TransactionView` items against a `TransactionFilters` object using the
61
+ * AND/OR combination semantics from `categoryCombinationOperator`.
62
+ *
63
+ * Independent of `view/spendManagement` — keeps the TC filter pipeline cleanly
64
+ * inside the Expense Automation feature group.
65
+ */
66
+ export declare const applyTransactionFilters: (transactions: TransactionView[], filters?: TransactionFilters) => TransactionView[];
@@ -0,0 +1,262 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.applyTransactionFilters = exports.TRANSACTION_FILTER_CATEGORIES = void 0;
4
+ /**
5
+ * Narrowing type-guard for "has a non-empty string here". Used in place of
6
+ * raw `if (foo)` truthiness checks on `string | null | undefined` values so
7
+ * the `@typescript-eslint/strict-boolean-expressions` lint stays clean —
8
+ * empty strings should explicitly fall through to the next candidate
9
+ * (vendorName → customerName → localData.vendor.name → ...) rather than
10
+ * being implicitly coerced to falsy.
11
+ */
12
+ const isNonEmptyString = (s) => s != null && s !== '';
13
+ /**
14
+ * First line item in UI order. `lineItemById` is a Record whose iteration
15
+ * order is not guaranteed to match what the user sees; `sortedLineItems`
16
+ * is the canonical ordering used by the categorization list/detail views.
17
+ */
18
+ const getFirstLineItemFromReviewLocalData = (localData) => {
19
+ const { sortedLineItems, lineItemById } = localData;
20
+ if (sortedLineItems.length > 0) {
21
+ return lineItemById[sortedLineItems[0]];
22
+ }
23
+ const lineItems = Object.values(lineItemById);
24
+ return lineItems.length > 0 ? lineItems[0] : undefined;
25
+ };
26
+ exports.TRANSACTION_FILTER_CATEGORIES = [
27
+ { value: 'payment_account_name', type: 'dropdown' },
28
+ { value: 'payment_account_type', type: 'dropdown' },
29
+ { value: 'payee', type: 'searchAutocomplete' },
30
+ { value: 'category', type: 'dropdown' },
31
+ { value: 'class', type: 'dropdown' },
32
+ { value: 'amount', type: 'numberRange' },
33
+ ];
34
+ /**
35
+ * Resolve the comparable value for a transaction against a given filter field.
36
+ * Returns undefined when the transaction doesn't carry the field — callers
37
+ * decide whether absence counts as a match (for 'not_equal' it does).
38
+ */
39
+ const getCategoryValueForTransaction = (key, transaction) => {
40
+ switch (key) {
41
+ case 'amount': {
42
+ // Prefer transactionLocalData line items (sum). Fall back to lines on
43
+ // the transaction itself. Final fallback: transaction-level amount.
44
+ const localDataForAmount = transaction.transactionLocalData?.transactionReviewLocalData;
45
+ if (localDataForAmount?.lineItemById) {
46
+ const lineItems = Object.values(localDataForAmount.lineItemById);
47
+ if (lineItems.length > 0) {
48
+ return lineItems.reduce((sum, lineItem) => sum + (lineItem.amount?.amount ?? 0), 0);
49
+ }
50
+ }
51
+ if (transaction.transaction.lines &&
52
+ transaction.transaction.lines.length > 0) {
53
+ return transaction.transaction.lines.reduce((sum, line) => sum + (line.amount?.amount ?? 0), 0);
54
+ }
55
+ return transaction.amount.amount;
56
+ }
57
+ case 'payee': {
58
+ if (isNonEmptyString(transaction.vendorName)) {
59
+ return transaction.vendorName;
60
+ }
61
+ if (isNonEmptyString(transaction.customerName)) {
62
+ return transaction.customerName;
63
+ }
64
+ const localData = transaction.transactionLocalData?.transactionReviewLocalData;
65
+ const vendorName = localData?.vendor?.name;
66
+ if (isNonEmptyString(vendorName)) {
67
+ return vendorName;
68
+ }
69
+ const customerName = localData?.customer?.name;
70
+ if (isNonEmptyString(customerName)) {
71
+ return customerName;
72
+ }
73
+ return undefined;
74
+ }
75
+ case 'payment_account_name': {
76
+ // Match what TransactionCategorizationListRow renders for the cell.
77
+ return transaction.transaction.account?.accountName;
78
+ }
79
+ case 'payment_account_type': {
80
+ // Raw `paymentType` enum ("credit_card" / "check" / "cash"). Dropdown
81
+ // option values use the same enum; row uses `paymentTypeName` for the
82
+ // human label.
83
+ return transaction.transaction.paymentType;
84
+ }
85
+ case 'category': {
86
+ const localDataForCategory = transaction.transactionLocalData?.transactionReviewLocalData;
87
+ if (localDataForCategory != null) {
88
+ const firstLineItem = getFirstLineItemFromReviewLocalData(localDataForCategory);
89
+ const accountId = firstLineItem?.account?.accountId;
90
+ if (isNonEmptyString(accountId)) {
91
+ return accountId;
92
+ }
93
+ const qboId = firstLineItem?.account?.qboId;
94
+ if (isNonEmptyString(qboId)) {
95
+ return qboId;
96
+ }
97
+ const accountName = firstLineItem?.account?.accountName;
98
+ if (isNonEmptyString(accountName)) {
99
+ return accountName;
100
+ }
101
+ }
102
+ const firstLineForCategory = transaction.transaction.lines?.[0];
103
+ if (firstLineForCategory?.type ===
104
+ 'transaction_with_account_and_class_line' ||
105
+ firstLineForCategory?.type ===
106
+ 'transaction_with_product_or_service_line' ||
107
+ firstLineForCategory?.type === 'journal_entry_transaction_line') {
108
+ const account = firstLineForCategory.account;
109
+ return account?.accountId ?? account?.qboId ?? account?.accountName;
110
+ }
111
+ return undefined;
112
+ }
113
+ case 'class': {
114
+ const localDataForClass = transaction.transactionLocalData?.transactionReviewLocalData;
115
+ if (localDataForClass != null) {
116
+ const firstLineItemForClass = getFirstLineItemFromReviewLocalData(localDataForClass);
117
+ const classId = firstLineItemForClass?.class?.classId;
118
+ if (isNonEmptyString(classId)) {
119
+ return classId;
120
+ }
121
+ const qboId = firstLineItemForClass?.class?.qboId;
122
+ if (isNonEmptyString(qboId)) {
123
+ return qboId;
124
+ }
125
+ const className = firstLineItemForClass?.class?.className;
126
+ if (isNonEmptyString(className)) {
127
+ return className;
128
+ }
129
+ }
130
+ const firstLineForClass = transaction.transaction.lines?.[0];
131
+ if (firstLineForClass?.type === 'transaction_with_account_and_class_line' ||
132
+ firstLineForClass?.type ===
133
+ 'transaction_with_product_or_service_line' ||
134
+ firstLineForClass?.type === 'journal_entry_transaction_line') {
135
+ const classData = firstLineForClass.class;
136
+ return classData?.classId ?? classData?.qboId ?? classData?.className;
137
+ }
138
+ return undefined;
139
+ }
140
+ default:
141
+ return undefined;
142
+ }
143
+ };
144
+ /**
145
+ * TC-only amount matcher. Supports all five operators TC defines, including
146
+ * the legacy "1000<->5000" range-string form (kept for backward compatibility
147
+ * with persisted filter state that may still contain that encoding).
148
+ *
149
+ * The `'equal' | 'not_equal'` branch matches if `amount` equals ANY of the
150
+ * configured values (consistent with how non-amount filters interpret a
151
+ * multi-value `values` array). `.some()` over the values array also makes
152
+ * the empty-values case behave correctly — empty array → `matched = false`
153
+ * — though in practice `applyTransactionFilters` strips empty-values
154
+ * categories before they reach this matcher. The trailing
155
+ * `op === 'not_equal' ? !matched : matched` line inverts for `not_equal`.
156
+ */
157
+ const matchAmount = (amount, category) => {
158
+ const op = category.matchingOperator;
159
+ const values = category.values;
160
+ let matched = false;
161
+ if (op === 'in_between') {
162
+ if (values.length >= 2) {
163
+ const min = Number(values[0]);
164
+ const max = Number(values[1]);
165
+ matched = amount >= min && amount <= max;
166
+ }
167
+ }
168
+ else if (op === 'less_than') {
169
+ if (values.length >= 1) {
170
+ matched = amount < Number(values[0]);
171
+ }
172
+ }
173
+ else if (op === 'greater_than') {
174
+ if (values.length >= 1) {
175
+ matched = amount > Number(values[0]);
176
+ }
177
+ }
178
+ else if (op === 'equal' || op === 'not_equal') {
179
+ matched = values.some((v) => {
180
+ const s = String(v);
181
+ // Backward compatibility: legacy "low<->high" range-string form
182
+ // persisted under `matchingOperator: 'equal'`.
183
+ if (s.includes('<->')) {
184
+ const parts = s.split('<->');
185
+ return (amount >= Number(parts[0] ?? '') && amount <= Number(parts[1] ?? ''));
186
+ }
187
+ return amount === Number(v);
188
+ });
189
+ }
190
+ return op === 'not_equal' ? !matched : matched;
191
+ };
192
+ const transactionMatchesCategory = (transaction, category) => {
193
+ const value = getCategoryValueForTransaction(category.field, transaction);
194
+ if (value == null) {
195
+ // Absent-value semantics — pinning these down explicitly so the
196
+ // asymmetry isn't surprising:
197
+ //
198
+ // not_equal: a missing value IS NOT EQUAL to any candidate, so the
199
+ // transaction matches the filter (passes through).
200
+ // equal: a missing value is not equal to any candidate, so the
201
+ // transaction does NOT match (filtered out).
202
+ // less_than / greater_than: SQL-style three-valued logic — comparing
203
+ // against a missing value is "unknown", which we treat as
204
+ // "does not match" (filtered out). A user setting
205
+ // "amount < $1000" probably wants transactions with a
206
+ // concrete amount that satisfies the bound, not rows
207
+ // where the amount can't be determined.
208
+ // in_between: same as the single-sided comparators — missing values
209
+ // are filtered out.
210
+ //
211
+ // Only the `not_equal` branch returns `true` here; everything else
212
+ // falls through to the `false` below.
213
+ return category.matchingOperator === 'not_equal';
214
+ }
215
+ if (category.field === 'amount') {
216
+ return matchAmount(Number(value), category);
217
+ }
218
+ const valueStr = value.toString();
219
+ const valueInList = category.values.some((v) => v.toString() === valueStr);
220
+ return category.matchingOperator === 'not_equal' ? !valueInList : valueInList;
221
+ };
222
+ /**
223
+ * TC-only equivalent of `applyAdvancedFiltersOnList`. Filters a list of
224
+ * `TransactionView` items against a `TransactionFilters` object using the
225
+ * AND/OR combination semantics from `categoryCombinationOperator`.
226
+ *
227
+ * Independent of `view/spendManagement` — keeps the TC filter pipeline cleanly
228
+ * inside the Expense Automation feature group.
229
+ */
230
+ const applyTransactionFilters = (transactions, filters) => {
231
+ if (filters?.categories == null || filters.categories.length === 0) {
232
+ return transactions;
233
+ }
234
+ // Mirrors the predicate used by `getTransactionAppliedFiltersCount` on the
235
+ // webc side. A half-filled category — e.g. `in_between` with only the
236
+ // `min` typed — would otherwise survive the filter pass and produce zero
237
+ // matches because `Number("")` collapses to `0`, artificially emptying
238
+ // the list while editing. Skipping such categories keeps the filtered
239
+ // view stable while the user finishes typing.
240
+ const activeCategories = filters.categories.filter((c) => {
241
+ if (c.field == null || c.values.length === 0) {
242
+ return false;
243
+ }
244
+ if (c.field === 'amount' && c.matchingOperator === 'in_between') {
245
+ return (c.values.length >= 2 &&
246
+ String(c.values[0] ?? '').trim() !== '' &&
247
+ String(c.values[1] ?? '').trim() !== '');
248
+ }
249
+ return String(c.values[0] ?? '').trim() !== '';
250
+ });
251
+ if (activeCategories.length === 0) {
252
+ return transactions;
253
+ }
254
+ const op = filters.categoryCombinationOperator;
255
+ return transactions.filter((txn) => {
256
+ if (op === 'AND') {
257
+ return activeCategories.every((cat) => transactionMatchesCategory(txn, cat));
258
+ }
259
+ return activeCategories.some((cat) => transactionMatchesCategory(txn, cat));
260
+ });
261
+ };
262
+ exports.applyTransactionFilters = applyTransactionFilters;
@@ -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.toCompletedSubTab = exports.toMissingReceiptsTab = exports.toBulkUploadResultsTab = exports.toBulkUploadPhase = exports.toBatchFileStatus = exports.BATCH_FILE_STATUSES = exports.toBatchStatusValue = exports.MIN_MANUAL_TRANSACTION_SEARCH_LENGTH = exports.toMissingReceiptsSortKey = void 0;
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;