@zeniai/client-epic-state 5.0.74 → 5.0.76

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 (158) hide show
  1. package/lib/coreEpics.js +1 -1
  2. package/lib/entity/account/accountSelector.d.ts +1 -27
  3. package/lib/entity/account/accountSelector.js +1 -47
  4. package/lib/entity/account/accountState.d.ts +1 -6
  5. package/lib/entity/account/accountState.js +4 -11
  6. package/lib/entity/account/subAccountSelector.d.ts +1 -1
  7. package/lib/entity/aiAccountantCustomer/aiAccountantCustomerPayload.js +3 -1
  8. package/lib/entity/aiAccountantCustomer/aiAccountantCustomerReducer.js +2 -1
  9. package/lib/entity/aiAccountantCustomer/aiAccountantCustomerSelector.d.ts +1 -1
  10. package/lib/entity/chargeCard/chargeCardReducer.d.ts +2 -19
  11. package/lib/entity/chargeCard/chargeCardReducer.js +2 -35
  12. package/lib/entity/chargeCardTransaction/chargeCardTransactionReducer.d.ts +1 -14
  13. package/lib/entity/chargeCardTransaction/chargeCardTransactionReducer.js +2 -36
  14. package/lib/entity/class/classSelector.d.ts +0 -35
  15. package/lib/entity/class/classSelector.js +0 -50
  16. package/lib/entity/sectionProjectView/sectionProjectViewReducer.d.ts +1 -1
  17. package/lib/entity/sectionProjectView/sectionProjectViewSelector.js +1 -1
  18. package/lib/entity/tenant/SessionManager.js +3 -6
  19. package/lib/entity/tenant/clearAllEpic.d.ts +2 -2
  20. package/lib/entity/tenant/clearAllEpic.js +2 -2
  21. package/lib/entity/tenant/epic/saveAPIKeyConnectionEpic.js +2 -6
  22. package/lib/entity/tenant/epic/saveOAuthConnectionEpic.js +2 -6
  23. package/lib/entity/tenant/tenantReducer.js +1 -6
  24. package/lib/entity/transaction/payloadTypes/transactionLinePayload.js +1 -3
  25. package/lib/epic.d.ts +9 -9
  26. package/lib/epic.js +10 -10
  27. package/lib/esm/coreEpics.js +1 -1
  28. package/lib/esm/entity/account/accountSelector.js +1 -46
  29. package/lib/esm/entity/account/accountState.js +1 -7
  30. package/lib/esm/entity/aiAccountantCustomer/aiAccountantCustomerPayload.js +3 -1
  31. package/lib/esm/entity/aiAccountantCustomer/aiAccountantCustomerReducer.js +2 -1
  32. package/lib/esm/entity/chargeCard/chargeCardReducer.js +1 -34
  33. package/lib/esm/entity/chargeCardTransaction/chargeCardTransactionReducer.js +1 -35
  34. package/lib/esm/entity/class/classSelector.js +0 -48
  35. package/lib/esm/entity/sectionProjectView/sectionProjectViewSelector.js +1 -1
  36. package/lib/esm/entity/tenant/SessionManager.js +1 -4
  37. package/lib/esm/entity/tenant/clearAllEpic.js +2 -2
  38. package/lib/esm/entity/tenant/epic/saveAPIKeyConnectionEpic.js +2 -6
  39. package/lib/esm/entity/tenant/epic/saveOAuthConnectionEpic.js +2 -6
  40. package/lib/esm/entity/tenant/tenantReducer.js +1 -6
  41. package/lib/esm/entity/transaction/payloadTypes/transactionLinePayload.js +1 -3
  42. package/lib/esm/epic.js +10 -10
  43. package/lib/esm/index.js +16 -26
  44. package/lib/esm/reducer.js +2 -2
  45. package/lib/esm/view/aiAccountantView/epics/fetchAiAccountantCustomersEpic.js +5 -2
  46. package/lib/esm/view/aiAccountantView/epics/fetchAiAccountantJobsEpic.js +5 -2
  47. package/lib/esm/view/aiAccountantView/epics/triggerAiAccountantJobEpic.js +1 -4
  48. package/lib/esm/view/companyHealthMetricView/companyHealthMetricViewSelector.js +1 -1
  49. package/lib/esm/view/companyTaskManagerView/companyTaskManagerViewSelector.js +1 -1
  50. package/lib/esm/view/companyTaskManagerView/epics/fetchTaskManagerMetricsEpic.js +1 -1
  51. package/lib/esm/view/companyView/helpers/cockpitHelpers.js +1 -1
  52. package/lib/esm/view/companyView/selector/companyManagementViewSelector.js +1 -1
  53. package/lib/esm/view/companyView/selector/companyPortfolioViewSelector.js +1 -1
  54. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +2 -2
  55. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +1 -2
  56. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/restoreBulkUploadAutomatchingOnMountEpic.js +6 -8
  57. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +1 -7
  58. package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.js +1 -11
  59. package/lib/esm/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +1 -2
  60. package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +1 -137
  61. package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +13 -89
  62. package/lib/esm/view/expenseAutomationView/types/missingReceiptsViewState.js +2 -0
  63. package/lib/esm/view/financeStatement/financeStatementSelector.js +1 -1
  64. package/lib/esm/view/spendManagement/chargeCards/cashbackDetail/cashbackDetailReducer.js +2 -3
  65. package/lib/esm/view/spendManagement/chargeCards/chargeCardConfig/chargeCardConfigReducer.js +2 -3
  66. package/lib/esm/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailReducer.js +18 -55
  67. package/lib/esm/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardDetailEpic.js +2 -16
  68. package/lib/esm/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardDetailPageEpic.js +4 -5
  69. package/lib/esm/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.js +9 -26
  70. package/lib/esm/view/spendManagement/chargeCards/chargeCardList/fetchChargeCardListPageEpic.js +6 -9
  71. package/lib/esm/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryReducer.js +2 -3
  72. package/lib/esm/view/spendManagement/chargeCards/chargeCardPaymentHistory/fetchChargeCardPaymentPageEpic.js +1 -1
  73. package/lib/esm/view/spendManagement/chargeCards/chargeCardRepaymentDetail/chargeCardRepaymentDetailReducer.js +3 -7
  74. package/lib/esm/view/spendManagement/spendManagementFilterHelpers.js +2 -4
  75. package/lib/esm/view/subscriptionView/subscriptionViewSelector.js +1 -1
  76. package/lib/esm/view/taskManager/cannedResponsesView/epics/fetchCannedResponsesEpic.js +1 -1
  77. package/lib/esm/view/taskManager/cannedResponsesView/epics/saveCannedResponseEpic.js +1 -1
  78. package/lib/esm/view/taskManager/taskDetailView/epics/unsnoozeTaskEpic.js +1 -1
  79. package/lib/esm/view/taskManager/taskListView/taskListReducer.js +1 -1
  80. package/lib/esm/view/transactionDetail/transactionDetailSelector.js +1 -7
  81. package/lib/index.d.ts +19 -25
  82. package/lib/index.js +58 -81
  83. package/lib/reducer.d.ts +2 -2
  84. package/lib/reducer.js +2 -2
  85. package/lib/view/aiAccountantView/aiAccountantViewPayload.d.ts +2 -2
  86. package/lib/view/aiAccountantView/aiAccountantViewReducer.d.ts +1 -1
  87. package/lib/view/aiAccountantView/epics/fetchAiAccountantCustomersEpic.js +5 -2
  88. package/lib/view/aiAccountantView/epics/fetchAiAccountantJobsEpic.js +5 -2
  89. package/lib/view/aiAccountantView/epics/triggerAiAccountantJobEpic.js +1 -4
  90. package/lib/view/companyHealthMetricView/companyHealthMetricViewSelector.js +1 -1
  91. package/lib/view/companyTaskManagerView/companyTaskManagerViewSelector.d.ts +1 -1
  92. package/lib/view/companyTaskManagerView/companyTaskManagerViewSelector.js +1 -1
  93. package/lib/view/companyView/helpers/cockpitHelpers.js +1 -1
  94. package/lib/view/companyView/selector/companyManagementViewSelector.js +1 -1
  95. package/lib/view/companyView/selector/companyPortfolioViewSelector.js +1 -1
  96. package/lib/view/companyView/types/cockpitTypes.d.ts +1 -1
  97. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +2 -2
  98. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +1 -2
  99. package/lib/view/expenseAutomationView/epics/missingReceipts/restoreBulkUploadAutomatchingOnMountEpic.js +6 -8
  100. package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +1 -7
  101. package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.d.ts +2 -2
  102. package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.js +0 -10
  103. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  104. package/lib/view/expenseAutomationView/payload/transactionCategorizationPayload.d.ts +0 -21
  105. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +1 -2
  106. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +1 -2
  107. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +4 -14
  108. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +2 -138
  109. package/lib/view/expenseAutomationView/selectorTypes/missingReceiptsSelectorTypes.d.ts +1 -2
  110. package/lib/view/expenseAutomationView/selectorTypes/transactionsViewSelectorTypes.d.ts +0 -14
  111. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.d.ts +1 -4
  112. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +13 -91
  113. package/lib/view/expenseAutomationView/types/missingReceiptsViewState.d.ts +2 -1
  114. package/lib/view/expenseAutomationView/types/missingReceiptsViewState.js +4 -1
  115. package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +2 -43
  116. package/lib/view/financeStatement/financeStatementSelector.js +1 -1
  117. package/lib/view/profitAndLossProjectView/profitAndLossProjectViewSelectorTypes.d.ts +1 -1
  118. package/lib/view/spendManagement/billPay/billList/billListState.d.ts +1 -1
  119. package/lib/view/spendManagement/chargeCards/cashbackDetail/cashbackDetailReducer.d.ts +1 -3
  120. package/lib/view/spendManagement/chargeCards/cashbackDetail/cashbackDetailReducer.js +2 -3
  121. package/lib/view/spendManagement/chargeCards/chargeCardConfig/chargeCardConfigReducer.d.ts +1 -3
  122. package/lib/view/spendManagement/chargeCards/chargeCardConfig/chargeCardConfigReducer.js +2 -3
  123. package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailReducer.js +18 -55
  124. package/lib/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardDetailEpic.js +2 -16
  125. package/lib/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardDetailPageEpic.js +4 -5
  126. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.d.ts +3 -18
  127. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.js +10 -27
  128. package/lib/view/spendManagement/chargeCards/chargeCardList/fetchChargeCardListPageEpic.js +6 -9
  129. package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistory.d.ts +1 -1
  130. package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryReducer.d.ts +1 -3
  131. package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryReducer.js +2 -3
  132. package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/fetchChargeCardPaymentPageEpic.js +1 -1
  133. package/lib/view/spendManagement/chargeCards/chargeCardRepaymentDetail/chargeCardRepaymentDetailReducer.d.ts +1 -3
  134. package/lib/view/spendManagement/chargeCards/chargeCardRepaymentDetail/chargeCardRepaymentDetailReducer.js +3 -7
  135. package/lib/view/spendManagement/reimbursement/remiListView/remiListState.d.ts +1 -1
  136. package/lib/view/spendManagement/spendManagementFilterHelpers.d.ts +3 -12
  137. package/lib/view/spendManagement/spendManagementFilterHelpers.js +2 -4
  138. package/lib/view/subscriptionView/subscriptionViewSelector.js +1 -1
  139. package/lib/view/taskManager/taskListView/taskList.d.ts +1 -1
  140. package/lib/view/taskManager/taskListView/taskListReducer.js +1 -1
  141. package/lib/view/transactionDetail/transactionDetailSelector.js +1 -7
  142. package/lib/view/zeniOAuthView/zeniOAuthSelector.d.ts +1 -1
  143. package/package.json +4 -9
  144. package/lib/commonStateTypes/cacheOverrideFetchReducer.d.ts +0 -17
  145. package/lib/commonStateTypes/cacheOverrideFetchReducer.js +0 -20
  146. package/lib/commonStateTypes/filterPrimitives.d.ts +0 -23
  147. package/lib/commonStateTypes/filterPrimitives.js +0 -21
  148. package/lib/commonStateTypes/pusherActions.d.ts +0 -11
  149. package/lib/commonStateTypes/pusherActions.js +0 -6
  150. package/lib/esm/commonStateTypes/cacheOverrideFetchReducer.js +0 -16
  151. package/lib/esm/commonStateTypes/filterPrimitives.js +0 -20
  152. package/lib/esm/commonStateTypes/pusherActions.js +0 -3
  153. package/lib/esm/view/expenseAutomationView/transactionFilterHelpers.js +0 -258
  154. package/lib/esm/view/expenseAutomationView/types/completedSubTab.js +0 -17
  155. package/lib/view/expenseAutomationView/transactionFilterHelpers.d.ts +0 -66
  156. package/lib/view/expenseAutomationView/transactionFilterHelpers.js +0 -262
  157. package/lib/view/expenseAutomationView/types/completedSubTab.d.ts +0 -10
  158. package/lib/view/expenseAutomationView/types/completedSubTab.js +0 -21
@@ -1,262 +0,0 @@
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;
@@ -1,10 +0,0 @@
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;
@@ -1,21 +0,0 @@
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';