@zeniai/client-epic-state 5.0.64-betaAR2 → 5.0.64-betaSS1

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 (45) hide show
  1. package/lib/entity/account/accountSelector.d.ts +1 -20
  2. package/lib/entity/account/accountSelector.js +1 -35
  3. package/lib/entity/account/accountState.d.ts +0 -5
  4. package/lib/entity/account/accountState.js +4 -11
  5. package/lib/entity/class/classSelector.d.ts +0 -5
  6. package/lib/entity/class/classSelector.js +0 -8
  7. package/lib/esm/entity/account/accountSelector.js +1 -33
  8. package/lib/esm/entity/account/accountState.js +1 -7
  9. package/lib/esm/entity/class/classSelector.js +0 -7
  10. package/lib/esm/index.js +7 -12
  11. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +2 -1
  12. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +6 -0
  13. package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.js +11 -1
  14. package/lib/esm/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +2 -1
  15. package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +114 -11
  16. package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +28 -59
  17. package/lib/esm/view/expenseAutomationView/types/completedSubTab.js +17 -0
  18. package/lib/esm/view/expenseAutomationView/types/missingReceiptsViewState.js +0 -2
  19. package/lib/esm/view/spendManagement/spendManagementFilterHelpers.js +0 -2
  20. package/lib/index.d.ts +8 -9
  21. package/lib/index.js +39 -44
  22. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +2 -1
  23. package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +6 -0
  24. package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.d.ts +2 -2
  25. package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.js +10 -0
  26. package/lib/view/expenseAutomationView/payload/transactionCategorizationPayload.d.ts +21 -0
  27. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +2 -1
  28. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +2 -1
  29. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +9 -7
  30. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +115 -12
  31. package/lib/view/expenseAutomationView/selectorTypes/missingReceiptsSelectorTypes.d.ts +2 -1
  32. package/lib/view/expenseAutomationView/selectorTypes/transactionsViewSelectorTypes.d.ts +14 -0
  33. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.d.ts +1 -4
  34. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +28 -61
  35. package/lib/view/expenseAutomationView/types/completedSubTab.d.ts +10 -0
  36. package/lib/view/expenseAutomationView/types/completedSubTab.js +21 -0
  37. package/lib/view/expenseAutomationView/types/missingReceiptsViewState.d.ts +1 -2
  38. package/lib/view/expenseAutomationView/types/missingReceiptsViewState.js +1 -4
  39. package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +35 -3
  40. package/lib/view/spendManagement/spendManagementFilterHelpers.js +0 -2
  41. package/package.json +1 -1
  42. package/lib/esm/view/expenseAutomationView/transactionFilterHelpers.js +0 -186
  43. package/lib/tsconfig.typecheck.tsbuildinfo +0 -1
  44. package/lib/view/expenseAutomationView/transactionFilterHelpers.d.ts +0 -65
  45. package/lib/view/expenseAutomationView/transactionFilterHelpers.js +0 -190
@@ -1,186 +0,0 @@
1
- export const TRANSACTION_FILTER_CATEGORIES = [
2
- { value: 'payment_account_name', type: 'dropdown' },
3
- { value: 'payment_account_type', type: 'dropdown' },
4
- { value: 'payee', type: 'searchAutocomplete' },
5
- { value: 'category', type: 'dropdown' },
6
- { value: 'class', type: 'dropdown' },
7
- { value: 'amount', type: 'numberRange' },
8
- ];
9
- /**
10
- * Resolve the comparable value for a transaction against a given filter field.
11
- * Returns undefined when the transaction doesn't carry the field — callers
12
- * decide whether absence counts as a match (for 'not-equal' it does).
13
- */
14
- const getCategoryValueForTransaction = (key, transaction) => {
15
- switch (key) {
16
- case 'amount': {
17
- // Prefer transactionLocalData line items (sum). Fall back to lines on
18
- // the transaction itself. Final fallback: transaction-level amount.
19
- const localDataForAmount = transaction.transactionLocalData?.transactionReviewLocalData;
20
- if (localDataForAmount?.lineItemById) {
21
- const lineItems = Object.values(localDataForAmount.lineItemById);
22
- if (lineItems.length > 0) {
23
- return lineItems.reduce((sum, lineItem) => sum + (lineItem.amount?.amount ?? 0), 0);
24
- }
25
- }
26
- if (transaction.transaction.lines &&
27
- transaction.transaction.lines.length > 0) {
28
- return transaction.transaction.lines.reduce((sum, line) => sum + (line.amount?.amount ?? 0), 0);
29
- }
30
- return transaction.amount.amount;
31
- }
32
- case 'payee': {
33
- if (transaction.vendorName) {
34
- return transaction.vendorName;
35
- }
36
- if (transaction.customerName) {
37
- return transaction.customerName;
38
- }
39
- const localData = transaction.transactionLocalData?.transactionReviewLocalData;
40
- if (localData?.vendor?.name) {
41
- return localData.vendor.name;
42
- }
43
- if (localData?.customer?.name) {
44
- return localData.customer.name;
45
- }
46
- return undefined;
47
- }
48
- case 'payment_account_name': {
49
- // Match what TransactionCategorizationListRow renders for the cell.
50
- return transaction.transaction.account?.accountName;
51
- }
52
- case 'payment_account_type': {
53
- // Raw `paymentType` enum ("credit_card" / "check" / "cash"). Dropdown
54
- // option values use the same enum; row uses `paymentTypeName` for the
55
- // human label.
56
- return transaction.transaction.paymentType;
57
- }
58
- case 'category': {
59
- const localDataForCategory = transaction.transactionLocalData?.transactionReviewLocalData;
60
- if (localDataForCategory) {
61
- const firstLineItem = Object.values(localDataForCategory.lineItemById)[0];
62
- if (firstLineItem?.account?.accountId) {
63
- return firstLineItem.account.accountId;
64
- }
65
- if (firstLineItem?.account?.qboId) {
66
- return firstLineItem.account.qboId;
67
- }
68
- if (firstLineItem?.account?.accountName) {
69
- return firstLineItem.account.accountName;
70
- }
71
- }
72
- const firstLineForCategory = transaction.transaction.lines?.[0];
73
- if (firstLineForCategory?.type ===
74
- 'transaction_with_account_and_class_line' ||
75
- firstLineForCategory?.type ===
76
- 'transaction_with_product_or_service_line' ||
77
- firstLineForCategory?.type === 'journal_entry_transaction_line') {
78
- const account = firstLineForCategory.account;
79
- return account?.accountId ?? account?.qboId ?? account?.accountName;
80
- }
81
- return undefined;
82
- }
83
- case 'class': {
84
- const localDataForClass = transaction.transactionLocalData?.transactionReviewLocalData;
85
- if (localDataForClass) {
86
- const firstLineItemForClass = Object.values(localDataForClass.lineItemById)[0];
87
- if (firstLineItemForClass?.class?.classId) {
88
- return firstLineItemForClass.class.classId;
89
- }
90
- if (firstLineItemForClass?.class?.qboId) {
91
- return firstLineItemForClass.class.qboId;
92
- }
93
- if (firstLineItemForClass?.class?.className) {
94
- return firstLineItemForClass.class.className;
95
- }
96
- }
97
- const firstLineForClass = transaction.transaction.lines?.[0];
98
- if (firstLineForClass?.type === 'transaction_with_account_and_class_line' ||
99
- firstLineForClass?.type ===
100
- 'transaction_with_product_or_service_line' ||
101
- firstLineForClass?.type === 'journal_entry_transaction_line') {
102
- const classData = firstLineForClass.class;
103
- return classData?.classId ?? classData?.qboId ?? classData?.className;
104
- }
105
- return undefined;
106
- }
107
- default:
108
- return undefined;
109
- }
110
- };
111
- /**
112
- * TC-only amount matcher. Supports all five operators TC defines, including
113
- * the legacy "1000<->5000" range-string form (kept for backward compatibility
114
- * with persisted filter state that may still contain that encoding).
115
- */
116
- const matchAmount = (amount, category) => {
117
- const op = category.matchingOperator;
118
- const values = category.values;
119
- let matched = false;
120
- if (op === 'in_between') {
121
- if (values.length >= 2) {
122
- const min = Number(values[0]);
123
- const max = Number(values[1]);
124
- matched = amount >= min && amount <= max;
125
- }
126
- }
127
- else if (op === 'less_than') {
128
- if (values.length >= 1) {
129
- matched = amount < Number(values[0]);
130
- }
131
- }
132
- else if (op === 'greater_than') {
133
- if (values.length >= 1) {
134
- matched = amount > Number(values[0]);
135
- }
136
- }
137
- else if (op === 'equal' &&
138
- values.length === 1 &&
139
- String(values[0]).includes('<->')) {
140
- // Backward compatibility: ["1000<->5000"] with matchingOperator "equal".
141
- const parts = String(values[0]).split('<->');
142
- matched =
143
- amount >= Number(parts[0] ?? '') && amount <= Number(parts[1] ?? '');
144
- }
145
- else if (op === 'equal' && values.length === 1) {
146
- matched = amount === Number(values[0]);
147
- }
148
- return op === 'not-equal' ? !matched : matched;
149
- };
150
- const transactionMatchesCategory = (transaction, category) => {
151
- const value = getCategoryValueForTransaction(category.field, transaction);
152
- if (value == null) {
153
- // Absent values count as a match only under 'not-equal'.
154
- return category.matchingOperator === 'not-equal';
155
- }
156
- if (category.field === 'amount') {
157
- return matchAmount(Number(value), category);
158
- }
159
- const valueStr = value.toString();
160
- const valueInList = category.values.some((v) => v.toString() === valueStr);
161
- return category.matchingOperator === 'not-equal' ? !valueInList : valueInList;
162
- };
163
- /**
164
- * TC-only equivalent of `applyAdvancedFiltersOnList`. Filters a list of
165
- * `TransactionView` items against a `TransactionFilters` object using the
166
- * AND/OR combination semantics from `categoryCombinationOperator`.
167
- *
168
- * Independent of `view/spendManagement` — keeps the TC filter pipeline cleanly
169
- * inside the Expense Automation feature group.
170
- */
171
- export const applyTransactionFilters = (transactions, filters) => {
172
- if (filters?.categories == null || filters.categories.length === 0) {
173
- return transactions;
174
- }
175
- const activeCategories = filters.categories.filter((c) => c.field != null && c.values.length > 0);
176
- if (activeCategories.length === 0) {
177
- return transactions;
178
- }
179
- const op = filters.categoryCombinationOperator;
180
- return transactions.filter((txn) => {
181
- if (op === 'AND') {
182
- return activeCategories.every((cat) => transactionMatchesCategory(txn, cat));
183
- }
184
- return activeCategories.some((cat) => transactionMatchesCategory(txn, cat));
185
- });
186
- };