@zeniai/client-epic-state 5.0.79 → 5.0.80
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.
- package/lib/coreEpics.js +1 -1
- package/lib/entity/account/accountSelector.d.ts +1 -27
- package/lib/entity/account/accountSelector.js +1 -47
- package/lib/entity/account/accountState.d.ts +1 -6
- package/lib/entity/account/accountState.js +4 -11
- package/lib/entity/account/subAccountSelector.d.ts +1 -1
- package/lib/entity/aiAccountantCustomer/aiAccountantCustomerPayload.js +3 -1
- package/lib/entity/aiAccountantCustomer/aiAccountantCustomerReducer.js +2 -1
- package/lib/entity/aiAccountantCustomer/aiAccountantCustomerSelector.d.ts +1 -1
- package/lib/entity/chargeCard/chargeCardReducer.d.ts +2 -19
- package/lib/entity/chargeCard/chargeCardReducer.js +2 -35
- package/lib/entity/chargeCardTransaction/chargeCardTransactionReducer.d.ts +1 -14
- package/lib/entity/chargeCardTransaction/chargeCardTransactionReducer.js +2 -36
- package/lib/entity/class/classSelector.d.ts +0 -35
- package/lib/entity/class/classSelector.js +0 -50
- package/lib/entity/sectionProjectView/sectionProjectViewReducer.d.ts +1 -1
- package/lib/entity/sectionProjectView/sectionProjectViewSelector.js +1 -1
- package/lib/entity/tenant/SessionManager.js +3 -6
- package/lib/entity/tenant/clearAllEpic.d.ts +2 -2
- package/lib/entity/tenant/clearAllEpic.js +2 -2
- package/lib/entity/tenant/epic/saveAPIKeyConnectionEpic.js +2 -6
- package/lib/entity/tenant/epic/saveOAuthConnectionEpic.js +2 -6
- package/lib/entity/tenant/tenantReducer.js +1 -6
- package/lib/entity/transaction/payloadTypes/transactionLinePayload.js +1 -3
- package/lib/epic.d.ts +11 -11
- package/lib/epic.js +12 -12
- package/lib/esm/coreEpics.js +1 -1
- package/lib/esm/entity/account/accountSelector.js +1 -46
- package/lib/esm/entity/account/accountState.js +1 -7
- package/lib/esm/entity/aiAccountantCustomer/aiAccountantCustomerPayload.js +3 -1
- package/lib/esm/entity/aiAccountantCustomer/aiAccountantCustomerReducer.js +2 -1
- package/lib/esm/entity/chargeCard/chargeCardReducer.js +1 -34
- package/lib/esm/entity/chargeCardTransaction/chargeCardTransactionReducer.js +1 -35
- package/lib/esm/entity/class/classSelector.js +0 -48
- package/lib/esm/entity/sectionProjectView/sectionProjectViewSelector.js +1 -1
- package/lib/esm/entity/tenant/SessionManager.js +1 -4
- package/lib/esm/entity/tenant/clearAllEpic.js +2 -2
- package/lib/esm/entity/tenant/epic/saveAPIKeyConnectionEpic.js +2 -6
- package/lib/esm/entity/tenant/epic/saveOAuthConnectionEpic.js +2 -6
- package/lib/esm/entity/tenant/tenantReducer.js +1 -6
- package/lib/esm/entity/transaction/payloadTypes/transactionLinePayload.js +1 -3
- package/lib/esm/epic.js +12 -12
- package/lib/esm/index.js +21 -31
- package/lib/esm/reducer.js +2 -2
- package/lib/esm/view/aiAccountantView/epics/fetchAiAccountantCustomersEpic.js +5 -2
- package/lib/esm/view/aiAccountantView/epics/fetchAiAccountantJobsEpic.js +5 -2
- package/lib/esm/view/aiAccountantView/epics/triggerAiAccountantJobEpic.js +1 -4
- package/lib/esm/view/companyHealthMetricView/companyHealthMetricViewSelector.js +1 -1
- package/lib/esm/view/companyTaskManagerView/companyTaskManagerViewSelector.js +1 -1
- package/lib/esm/view/companyTaskManagerView/epics/fetchTaskManagerMetricsEpic.js +1 -1
- package/lib/esm/view/companyView/helpers/cockpitHelpers.js +1 -1
- package/lib/esm/view/companyView/selector/companyManagementViewSelector.js +1 -1
- package/lib/esm/view/companyView/selector/companyPortfolioViewSelector.js +1 -1
- package/lib/esm/view/creditAgentView/creditAgentViewReducer.js +16 -1
- package/lib/esm/view/creditAgentView/epics/fetchCreditAgentAccessEpic.js +13 -0
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +2 -2
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +1 -2
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/restoreBulkUploadAutomatchingOnMountEpic.js +6 -8
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +1 -7
- package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.js +1 -11
- package/lib/esm/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +1 -21
- package/lib/esm/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +1 -2
- package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +14 -253
- package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +13 -147
- package/lib/esm/view/expenseAutomationView/types/missingReceiptsViewState.js +2 -0
- package/lib/esm/view/financeStatement/financeStatementSelector.js +1 -1
- package/lib/esm/view/recommendation/recommendationHelper.js +0 -29
- package/lib/esm/view/recommendation/recommendationReducer.js +1 -26
- package/lib/esm/view/spendManagement/chargeCards/cashbackDetail/cashbackDetailReducer.js +2 -3
- package/lib/esm/view/spendManagement/chargeCards/chargeCardConfig/chargeCardConfigReducer.js +2 -3
- package/lib/esm/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailReducer.js +18 -55
- package/lib/esm/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardDetailEpic.js +2 -16
- package/lib/esm/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardDetailPageEpic.js +4 -5
- package/lib/esm/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.js +9 -26
- package/lib/esm/view/spendManagement/chargeCards/chargeCardList/fetchChargeCardListPageEpic.js +6 -9
- package/lib/esm/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryReducer.js +2 -3
- package/lib/esm/view/spendManagement/chargeCards/chargeCardPaymentHistory/fetchChargeCardPaymentPageEpic.js +1 -1
- package/lib/esm/view/spendManagement/chargeCards/chargeCardRepaymentDetail/chargeCardRepaymentDetailReducer.js +3 -7
- package/lib/esm/view/spendManagement/spendManagementFilterHelpers.js +2 -4
- package/lib/esm/view/subscriptionView/subscriptionViewSelector.js +1 -1
- package/lib/esm/view/taskManager/cannedResponsesView/epics/fetchCannedResponsesEpic.js +1 -1
- package/lib/esm/view/taskManager/cannedResponsesView/epics/saveCannedResponseEpic.js +1 -1
- package/lib/esm/view/taskManager/taskDetailView/epics/unsnoozeTaskEpic.js +1 -1
- package/lib/esm/view/taskManager/taskListView/taskListReducer.js +1 -1
- package/lib/esm/view/transactionDetail/transactionDetailReducer.js +6 -121
- package/lib/esm/view/transactionDetail/transactionDetailSelector.js +1 -29
- package/lib/index.d.ts +24 -31
- package/lib/index.js +60 -84
- package/lib/reducer.d.ts +2 -2
- package/lib/reducer.js +2 -2
- package/lib/tsconfig.typecheck.tsbuildinfo +1 -0
- package/lib/view/aiAccountantView/aiAccountantViewPayload.d.ts +2 -2
- package/lib/view/aiAccountantView/aiAccountantViewReducer.d.ts +1 -1
- package/lib/view/aiAccountantView/epics/fetchAiAccountantCustomersEpic.js +5 -2
- package/lib/view/aiAccountantView/epics/fetchAiAccountantJobsEpic.js +5 -2
- package/lib/view/aiAccountantView/epics/triggerAiAccountantJobEpic.js +1 -4
- package/lib/view/companyHealthMetricView/companyHealthMetricViewSelector.js +1 -1
- package/lib/view/companyTaskManagerView/companyTaskManagerViewSelector.d.ts +1 -1
- package/lib/view/companyTaskManagerView/companyTaskManagerViewSelector.js +1 -1
- package/lib/view/companyView/helpers/cockpitHelpers.js +1 -1
- package/lib/view/companyView/selector/companyManagementViewSelector.js +1 -1
- package/lib/view/companyView/selector/companyPortfolioViewSelector.js +1 -1
- package/lib/view/companyView/types/cockpitTypes.d.ts +1 -1
- package/lib/view/creditAgentView/creditAgentViewPayload.d.ts +3 -0
- package/lib/view/creditAgentView/creditAgentViewReducer.d.ts +1 -1
- package/lib/view/creditAgentView/creditAgentViewReducer.js +17 -2
- package/lib/view/creditAgentView/creditAgentViewState.d.ts +5 -0
- package/lib/view/creditAgentView/epics/fetchCreditAgentAccessEpic.d.ts +11 -0
- package/lib/view/creditAgentView/epics/fetchCreditAgentAccessEpic.js +17 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +2 -2
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +1 -2
- package/lib/view/expenseAutomationView/epics/missingReceipts/restoreBulkUploadAutomatchingOnMountEpic.js +6 -8
- package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +1 -7
- package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.d.ts +2 -2
- package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.js +0 -10
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -2
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +2 -23
- package/lib/view/expenseAutomationView/payload/transactionCategorizationPayload.d.ts +0 -21
- package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +1 -2
- package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +1 -2
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +5 -28
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +14 -253
- package/lib/view/expenseAutomationView/selectorTypes/missingReceiptsSelectorTypes.d.ts +1 -2
- package/lib/view/expenseAutomationView/selectorTypes/transactionsViewSelectorTypes.d.ts +0 -16
- package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.d.ts +1 -7
- package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +13 -150
- package/lib/view/expenseAutomationView/types/missingReceiptsViewState.d.ts +2 -1
- package/lib/view/expenseAutomationView/types/missingReceiptsViewState.js +4 -1
- package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +2 -44
- package/lib/view/financeStatement/financeStatementSelector.js +1 -1
- package/lib/view/profitAndLossProjectView/profitAndLossProjectViewSelectorTypes.d.ts +1 -1
- package/lib/view/recommendation/recommendationHelper.d.ts +0 -9
- package/lib/view/recommendation/recommendationHelper.js +1 -31
- package/lib/view/recommendation/recommendationReducer.d.ts +1 -20
- package/lib/view/recommendation/recommendationReducer.js +2 -27
- package/lib/view/spendManagement/billPay/billList/billListState.d.ts +1 -1
- package/lib/view/spendManagement/chargeCards/cashbackDetail/cashbackDetailReducer.d.ts +1 -3
- package/lib/view/spendManagement/chargeCards/cashbackDetail/cashbackDetailReducer.js +2 -3
- package/lib/view/spendManagement/chargeCards/chargeCardConfig/chargeCardConfigReducer.d.ts +1 -3
- package/lib/view/spendManagement/chargeCards/chargeCardConfig/chargeCardConfigReducer.js +2 -3
- package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailReducer.js +18 -55
- package/lib/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardDetailEpic.js +2 -16
- package/lib/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardDetailPageEpic.js +4 -5
- package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.d.ts +3 -18
- package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.js +10 -27
- package/lib/view/spendManagement/chargeCards/chargeCardList/fetchChargeCardListPageEpic.js +6 -9
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistory.d.ts +1 -1
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryReducer.d.ts +1 -3
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistoryReducer.js +2 -3
- package/lib/view/spendManagement/chargeCards/chargeCardPaymentHistory/fetchChargeCardPaymentPageEpic.js +1 -1
- package/lib/view/spendManagement/chargeCards/chargeCardRepaymentDetail/chargeCardRepaymentDetailReducer.d.ts +1 -3
- package/lib/view/spendManagement/chargeCards/chargeCardRepaymentDetail/chargeCardRepaymentDetailReducer.js +3 -7
- package/lib/view/spendManagement/reimbursement/remiListView/remiListState.d.ts +1 -1
- package/lib/view/spendManagement/spendManagementFilterHelpers.d.ts +3 -12
- package/lib/view/spendManagement/spendManagementFilterHelpers.js +2 -4
- package/lib/view/subscriptionView/subscriptionViewSelector.js +1 -1
- package/lib/view/taskManager/taskListView/taskList.d.ts +1 -1
- package/lib/view/taskManager/taskListView/taskListReducer.js +1 -1
- package/lib/view/transactionDetail/transactionDetailReducer.d.ts +1 -11
- package/lib/view/transactionDetail/transactionDetailReducer.js +7 -122
- package/lib/view/transactionDetail/transactionDetailSelector.d.ts +0 -2
- package/lib/view/transactionDetail/transactionDetailSelector.js +2 -31
- package/lib/view/transactionDetail/transactionDetailTypes.d.ts +0 -1
- package/lib/view/zeniOAuthView/zeniOAuthSelector.d.ts +1 -1
- package/package.json +4 -9
- package/lib/commonStateTypes/cacheOverrideFetchReducer.d.ts +0 -17
- package/lib/commonStateTypes/cacheOverrideFetchReducer.js +0 -20
- package/lib/commonStateTypes/filterPrimitives.d.ts +0 -23
- package/lib/commonStateTypes/filterPrimitives.js +0 -21
- package/lib/commonStateTypes/pusherActions.d.ts +0 -11
- package/lib/commonStateTypes/pusherActions.js +0 -6
- package/lib/esm/commonStateTypes/cacheOverrideFetchReducer.js +0 -16
- package/lib/esm/commonStateTypes/filterPrimitives.js +0 -20
- package/lib/esm/commonStateTypes/pusherActions.js +0 -3
- package/lib/esm/view/expenseAutomationView/transactionFilterHelpers.js +0 -258
- package/lib/esm/view/expenseAutomationView/types/completedSubTab.js +0 -17
- package/lib/esm/view/recommendation/fetchEntityRecommendationsForLineUpdateEpic.js +0 -87
- package/lib/view/expenseAutomationView/transactionFilterHelpers.d.ts +0 -66
- package/lib/view/expenseAutomationView/transactionFilterHelpers.js +0 -262
- package/lib/view/expenseAutomationView/types/completedSubTab.d.ts +0 -10
- package/lib/view/expenseAutomationView/types/completedSubTab.js +0 -21
- package/lib/view/recommendation/fetchEntityRecommendationsForLineUpdateEpic.d.ts +0 -9
- package/lib/view/recommendation/fetchEntityRecommendationsForLineUpdateEpic.js +0 -91
|
@@ -1,258 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Narrowing type-guard for "has a non-empty string here". Used in place of
|
|
3
|
-
* raw `if (foo)` truthiness checks on `string | null | undefined` values so
|
|
4
|
-
* the `@typescript-eslint/strict-boolean-expressions` lint stays clean —
|
|
5
|
-
* empty strings should explicitly fall through to the next candidate
|
|
6
|
-
* (vendorName → customerName → localData.vendor.name → ...) rather than
|
|
7
|
-
* being implicitly coerced to falsy.
|
|
8
|
-
*/
|
|
9
|
-
const isNonEmptyString = (s) => s != null && s !== '';
|
|
10
|
-
/**
|
|
11
|
-
* First line item in UI order. `lineItemById` is a Record whose iteration
|
|
12
|
-
* order is not guaranteed to match what the user sees; `sortedLineItems`
|
|
13
|
-
* is the canonical ordering used by the categorization list/detail views.
|
|
14
|
-
*/
|
|
15
|
-
const getFirstLineItemFromReviewLocalData = (localData) => {
|
|
16
|
-
const { sortedLineItems, lineItemById } = localData;
|
|
17
|
-
if (sortedLineItems.length > 0) {
|
|
18
|
-
return lineItemById[sortedLineItems[0]];
|
|
19
|
-
}
|
|
20
|
-
const lineItems = Object.values(lineItemById);
|
|
21
|
-
return lineItems.length > 0 ? lineItems[0] : undefined;
|
|
22
|
-
};
|
|
23
|
-
export const TRANSACTION_FILTER_CATEGORIES = [
|
|
24
|
-
{ value: 'payment_account_name', type: 'dropdown' },
|
|
25
|
-
{ value: 'payment_account_type', type: 'dropdown' },
|
|
26
|
-
{ value: 'payee', type: 'searchAutocomplete' },
|
|
27
|
-
{ value: 'category', type: 'dropdown' },
|
|
28
|
-
{ value: 'class', type: 'dropdown' },
|
|
29
|
-
{ value: 'amount', type: 'numberRange' },
|
|
30
|
-
];
|
|
31
|
-
/**
|
|
32
|
-
* Resolve the comparable value for a transaction against a given filter field.
|
|
33
|
-
* Returns undefined when the transaction doesn't carry the field — callers
|
|
34
|
-
* decide whether absence counts as a match (for 'not_equal' it does).
|
|
35
|
-
*/
|
|
36
|
-
const getCategoryValueForTransaction = (key, transaction) => {
|
|
37
|
-
switch (key) {
|
|
38
|
-
case 'amount': {
|
|
39
|
-
// Prefer transactionLocalData line items (sum). Fall back to lines on
|
|
40
|
-
// the transaction itself. Final fallback: transaction-level amount.
|
|
41
|
-
const localDataForAmount = transaction.transactionLocalData?.transactionReviewLocalData;
|
|
42
|
-
if (localDataForAmount?.lineItemById) {
|
|
43
|
-
const lineItems = Object.values(localDataForAmount.lineItemById);
|
|
44
|
-
if (lineItems.length > 0) {
|
|
45
|
-
return lineItems.reduce((sum, lineItem) => sum + (lineItem.amount?.amount ?? 0), 0);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
if (transaction.transaction.lines &&
|
|
49
|
-
transaction.transaction.lines.length > 0) {
|
|
50
|
-
return transaction.transaction.lines.reduce((sum, line) => sum + (line.amount?.amount ?? 0), 0);
|
|
51
|
-
}
|
|
52
|
-
return transaction.amount.amount;
|
|
53
|
-
}
|
|
54
|
-
case 'payee': {
|
|
55
|
-
if (isNonEmptyString(transaction.vendorName)) {
|
|
56
|
-
return transaction.vendorName;
|
|
57
|
-
}
|
|
58
|
-
if (isNonEmptyString(transaction.customerName)) {
|
|
59
|
-
return transaction.customerName;
|
|
60
|
-
}
|
|
61
|
-
const localData = transaction.transactionLocalData?.transactionReviewLocalData;
|
|
62
|
-
const vendorName = localData?.vendor?.name;
|
|
63
|
-
if (isNonEmptyString(vendorName)) {
|
|
64
|
-
return vendorName;
|
|
65
|
-
}
|
|
66
|
-
const customerName = localData?.customer?.name;
|
|
67
|
-
if (isNonEmptyString(customerName)) {
|
|
68
|
-
return customerName;
|
|
69
|
-
}
|
|
70
|
-
return undefined;
|
|
71
|
-
}
|
|
72
|
-
case 'payment_account_name': {
|
|
73
|
-
// Match what TransactionCategorizationListRow renders for the cell.
|
|
74
|
-
return transaction.transaction.account?.accountName;
|
|
75
|
-
}
|
|
76
|
-
case 'payment_account_type': {
|
|
77
|
-
// Raw `paymentType` enum ("credit_card" / "check" / "cash"). Dropdown
|
|
78
|
-
// option values use the same enum; row uses `paymentTypeName` for the
|
|
79
|
-
// human label.
|
|
80
|
-
return transaction.transaction.paymentType;
|
|
81
|
-
}
|
|
82
|
-
case 'category': {
|
|
83
|
-
const localDataForCategory = transaction.transactionLocalData?.transactionReviewLocalData;
|
|
84
|
-
if (localDataForCategory != null) {
|
|
85
|
-
const firstLineItem = getFirstLineItemFromReviewLocalData(localDataForCategory);
|
|
86
|
-
const accountId = firstLineItem?.account?.accountId;
|
|
87
|
-
if (isNonEmptyString(accountId)) {
|
|
88
|
-
return accountId;
|
|
89
|
-
}
|
|
90
|
-
const qboId = firstLineItem?.account?.qboId;
|
|
91
|
-
if (isNonEmptyString(qboId)) {
|
|
92
|
-
return qboId;
|
|
93
|
-
}
|
|
94
|
-
const accountName = firstLineItem?.account?.accountName;
|
|
95
|
-
if (isNonEmptyString(accountName)) {
|
|
96
|
-
return accountName;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
const firstLineForCategory = transaction.transaction.lines?.[0];
|
|
100
|
-
if (firstLineForCategory?.type ===
|
|
101
|
-
'transaction_with_account_and_class_line' ||
|
|
102
|
-
firstLineForCategory?.type ===
|
|
103
|
-
'transaction_with_product_or_service_line' ||
|
|
104
|
-
firstLineForCategory?.type === 'journal_entry_transaction_line') {
|
|
105
|
-
const account = firstLineForCategory.account;
|
|
106
|
-
return account?.accountId ?? account?.qboId ?? account?.accountName;
|
|
107
|
-
}
|
|
108
|
-
return undefined;
|
|
109
|
-
}
|
|
110
|
-
case 'class': {
|
|
111
|
-
const localDataForClass = transaction.transactionLocalData?.transactionReviewLocalData;
|
|
112
|
-
if (localDataForClass != null) {
|
|
113
|
-
const firstLineItemForClass = getFirstLineItemFromReviewLocalData(localDataForClass);
|
|
114
|
-
const classId = firstLineItemForClass?.class?.classId;
|
|
115
|
-
if (isNonEmptyString(classId)) {
|
|
116
|
-
return classId;
|
|
117
|
-
}
|
|
118
|
-
const qboId = firstLineItemForClass?.class?.qboId;
|
|
119
|
-
if (isNonEmptyString(qboId)) {
|
|
120
|
-
return qboId;
|
|
121
|
-
}
|
|
122
|
-
const className = firstLineItemForClass?.class?.className;
|
|
123
|
-
if (isNonEmptyString(className)) {
|
|
124
|
-
return className;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
const firstLineForClass = transaction.transaction.lines?.[0];
|
|
128
|
-
if (firstLineForClass?.type === 'transaction_with_account_and_class_line' ||
|
|
129
|
-
firstLineForClass?.type ===
|
|
130
|
-
'transaction_with_product_or_service_line' ||
|
|
131
|
-
firstLineForClass?.type === 'journal_entry_transaction_line') {
|
|
132
|
-
const classData = firstLineForClass.class;
|
|
133
|
-
return classData?.classId ?? classData?.qboId ?? classData?.className;
|
|
134
|
-
}
|
|
135
|
-
return undefined;
|
|
136
|
-
}
|
|
137
|
-
default:
|
|
138
|
-
return undefined;
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
/**
|
|
142
|
-
* TC-only amount matcher. Supports all five operators TC defines, including
|
|
143
|
-
* the legacy "1000<->5000" range-string form (kept for backward compatibility
|
|
144
|
-
* with persisted filter state that may still contain that encoding).
|
|
145
|
-
*
|
|
146
|
-
* The `'equal' | 'not_equal'` branch matches if `amount` equals ANY of the
|
|
147
|
-
* configured values (consistent with how non-amount filters interpret a
|
|
148
|
-
* multi-value `values` array). `.some()` over the values array also makes
|
|
149
|
-
* the empty-values case behave correctly — empty array → `matched = false`
|
|
150
|
-
* — though in practice `applyTransactionFilters` strips empty-values
|
|
151
|
-
* categories before they reach this matcher. The trailing
|
|
152
|
-
* `op === 'not_equal' ? !matched : matched` line inverts for `not_equal`.
|
|
153
|
-
*/
|
|
154
|
-
const matchAmount = (amount, category) => {
|
|
155
|
-
const op = category.matchingOperator;
|
|
156
|
-
const values = category.values;
|
|
157
|
-
let matched = false;
|
|
158
|
-
if (op === 'in_between') {
|
|
159
|
-
if (values.length >= 2) {
|
|
160
|
-
const min = Number(values[0]);
|
|
161
|
-
const max = Number(values[1]);
|
|
162
|
-
matched = amount >= min && amount <= max;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
else if (op === 'less_than') {
|
|
166
|
-
if (values.length >= 1) {
|
|
167
|
-
matched = amount < Number(values[0]);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
else if (op === 'greater_than') {
|
|
171
|
-
if (values.length >= 1) {
|
|
172
|
-
matched = amount > Number(values[0]);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
else if (op === 'equal' || op === 'not_equal') {
|
|
176
|
-
matched = values.some((v) => {
|
|
177
|
-
const s = String(v);
|
|
178
|
-
// Backward compatibility: legacy "low<->high" range-string form
|
|
179
|
-
// persisted under `matchingOperator: 'equal'`.
|
|
180
|
-
if (s.includes('<->')) {
|
|
181
|
-
const parts = s.split('<->');
|
|
182
|
-
return (amount >= Number(parts[0] ?? '') && amount <= Number(parts[1] ?? ''));
|
|
183
|
-
}
|
|
184
|
-
return amount === Number(v);
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
return op === 'not_equal' ? !matched : matched;
|
|
188
|
-
};
|
|
189
|
-
const transactionMatchesCategory = (transaction, category) => {
|
|
190
|
-
const value = getCategoryValueForTransaction(category.field, transaction);
|
|
191
|
-
if (value == null) {
|
|
192
|
-
// Absent-value semantics — pinning these down explicitly so the
|
|
193
|
-
// asymmetry isn't surprising:
|
|
194
|
-
//
|
|
195
|
-
// not_equal: a missing value IS NOT EQUAL to any candidate, so the
|
|
196
|
-
// transaction matches the filter (passes through).
|
|
197
|
-
// equal: a missing value is not equal to any candidate, so the
|
|
198
|
-
// transaction does NOT match (filtered out).
|
|
199
|
-
// less_than / greater_than: SQL-style three-valued logic — comparing
|
|
200
|
-
// against a missing value is "unknown", which we treat as
|
|
201
|
-
// "does not match" (filtered out). A user setting
|
|
202
|
-
// "amount < $1000" probably wants transactions with a
|
|
203
|
-
// concrete amount that satisfies the bound, not rows
|
|
204
|
-
// where the amount can't be determined.
|
|
205
|
-
// in_between: same as the single-sided comparators — missing values
|
|
206
|
-
// are filtered out.
|
|
207
|
-
//
|
|
208
|
-
// Only the `not_equal` branch returns `true` here; everything else
|
|
209
|
-
// falls through to the `false` below.
|
|
210
|
-
return category.matchingOperator === 'not_equal';
|
|
211
|
-
}
|
|
212
|
-
if (category.field === 'amount') {
|
|
213
|
-
return matchAmount(Number(value), category);
|
|
214
|
-
}
|
|
215
|
-
const valueStr = value.toString();
|
|
216
|
-
const valueInList = category.values.some((v) => v.toString() === valueStr);
|
|
217
|
-
return category.matchingOperator === 'not_equal' ? !valueInList : valueInList;
|
|
218
|
-
};
|
|
219
|
-
/**
|
|
220
|
-
* TC-only equivalent of `applyAdvancedFiltersOnList`. Filters a list of
|
|
221
|
-
* `TransactionView` items against a `TransactionFilters` object using the
|
|
222
|
-
* AND/OR combination semantics from `categoryCombinationOperator`.
|
|
223
|
-
*
|
|
224
|
-
* Independent of `view/spendManagement` — keeps the TC filter pipeline cleanly
|
|
225
|
-
* inside the Expense Automation feature group.
|
|
226
|
-
*/
|
|
227
|
-
export const applyTransactionFilters = (transactions, filters) => {
|
|
228
|
-
if (filters?.categories == null || filters.categories.length === 0) {
|
|
229
|
-
return transactions;
|
|
230
|
-
}
|
|
231
|
-
// Mirrors the predicate used by `getTransactionAppliedFiltersCount` on the
|
|
232
|
-
// webc side. A half-filled category — e.g. `in_between` with only the
|
|
233
|
-
// `min` typed — would otherwise survive the filter pass and produce zero
|
|
234
|
-
// matches because `Number("")` collapses to `0`, artificially emptying
|
|
235
|
-
// the list while editing. Skipping such categories keeps the filtered
|
|
236
|
-
// view stable while the user finishes typing.
|
|
237
|
-
const activeCategories = filters.categories.filter((c) => {
|
|
238
|
-
if (c.field == null || c.values.length === 0) {
|
|
239
|
-
return false;
|
|
240
|
-
}
|
|
241
|
-
if (c.field === 'amount' && c.matchingOperator === 'in_between') {
|
|
242
|
-
return (c.values.length >= 2 &&
|
|
243
|
-
String(c.values[0] ?? '').trim() !== '' &&
|
|
244
|
-
String(c.values[1] ?? '').trim() !== '');
|
|
245
|
-
}
|
|
246
|
-
return String(c.values[0] ?? '').trim() !== '';
|
|
247
|
-
});
|
|
248
|
-
if (activeCategories.length === 0) {
|
|
249
|
-
return transactions;
|
|
250
|
-
}
|
|
251
|
-
const op = filters.categoryCombinationOperator;
|
|
252
|
-
return transactions.filter((txn) => {
|
|
253
|
-
if (op === 'AND') {
|
|
254
|
-
return activeCategories.every((cat) => transactionMatchesCategory(txn, cat));
|
|
255
|
-
}
|
|
256
|
-
return activeCategories.some((cat) => transactionMatchesCategory(txn, cat));
|
|
257
|
-
});
|
|
258
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { stringToUnion } from '../../../commonStateTypes/stringToUnion';
|
|
2
|
-
/**
|
|
3
|
-
* Sub-tabs that can appear under any "Completed" tab in the Expense Automation
|
|
4
|
-
* surface (Transaction Categorization Completed and Missing Receipts Completed
|
|
5
|
-
* both use this exact union). Forwarded verbatim to listing APIs as `sub_tab`
|
|
6
|
-
* / `match_type`. `'all'` preserves parent-tab semantics on the backend.
|
|
7
|
-
*/
|
|
8
|
-
const COMPLETED_SUB_TABS = ['all', 'ai_accountant', 'manual'];
|
|
9
|
-
export const toCompletedSubTab = (v) => stringToUnion(v.trim().toLowerCase(), COMPLETED_SUB_TABS);
|
|
10
|
-
/**
|
|
11
|
-
* "No sub-tab filter" sentinel — single source of truth for the default
|
|
12
|
-
* value of {@link CompletedSubTab}. Use this constant in initial slice
|
|
13
|
-
* state and at any call site that needs to fall back to the parent-tab
|
|
14
|
-
* listing semantics (review tab requests, manual-search overrides, etc.)
|
|
15
|
-
* so a future rename of the union doesn't require chasing literals.
|
|
16
|
-
*/
|
|
17
|
-
export const DEFAULT_COMPLETED_SUB_TAB = 'all';
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { concat, of, timer } from 'rxjs';
|
|
2
|
-
import { catchError, debounce, filter, groupBy, mergeMap, switchMap, } from 'rxjs/operators';
|
|
3
|
-
import { getIsAccountingClassesEnabled } from '../../entity/tenant/tenantSelector';
|
|
4
|
-
import { getTransactionWithCOT, getTransactionWithCOTFromRecommendations, } from '../../entity/transaction/transactionHelper';
|
|
5
|
-
import { createZeniAPIStatus, isSuccessResponse } from '../../responsePayload';
|
|
6
|
-
import { getUncategorizedAccounts } from '../accountList/accountListSelector';
|
|
7
|
-
import { markCategoryClassRecommendationsCompletedForCategorization, markCategoryClassRecommendationsFailureForCategorization, markCategoryClassRecommendationsInProgressForCategorization, setEntityRecommendationForLineIdsForCategorization, } from '../expenseAutomationView/reducers/transactionsViewReducer';
|
|
8
|
-
import { markCategoryClassRecommendationsCompletedForTransactionDetail, markCategoryClassRecommendationsFailureForTransactionDetail, markCategoryClassRecommendationsInProgressForTransactionDetail, setEntityRecommendationForLineIdsForTransactionDetail, } from '../transactionDetail/transactionDetailReducer';
|
|
9
|
-
import { buildRecommendationUrl, getRecommendationByLineIdWithCOTFromRecommendationPayloadWithCOT, } from './recommendationHelper';
|
|
10
|
-
import { fetchEntityRecommendationsForLineUpdate } from './recommendationReducer';
|
|
11
|
-
// Close the per-target groupBy bucket after this much idle time so inactive
|
|
12
|
-
// groups don't accumulate forever (each group holds a Subject + a chain of
|
|
13
|
-
// active subscribers; without a duration selector groupBy retains them for
|
|
14
|
-
// the lifetime of the source observable, which is the lifetime of the app).
|
|
15
|
-
// Picked at 60s to leave a generous window for re-fetches on the same
|
|
16
|
-
// payee/transaction/line target while still bounding memory.
|
|
17
|
-
const GROUP_INACTIVITY_TIMEOUT_MS = 60000;
|
|
18
|
-
// Build the groupBy key. Same flow + same transaction + same line set
|
|
19
|
-
// share a target so switchMap can cancel an in-flight prior fetch. Use
|
|
20
|
-
// NUL (\u0000) as separator because it can never appear in transaction
|
|
21
|
-
// or line ids (vs the `|` used in an earlier WIP which collides with
|
|
22
|
-
// pipe-delimited synthetic ids).
|
|
23
|
-
const SEPARATOR = '\u0000';
|
|
24
|
-
const toGroupKey = (flowType, transactionId, lineIds) => `${flowType}${SEPARATOR}${transactionId}${SEPARATOR}${[...lineIds]
|
|
25
|
-
.sort((a, b) => a.localeCompare(b))
|
|
26
|
-
.join(SEPARATOR)}`;
|
|
27
|
-
// Targeted recommendations fetch that drives the per-line skeleton, the
|
|
28
|
-
// list-page row-checkbox uncheck/recheck, and the page-level Save
|
|
29
|
-
// disable.
|
|
30
|
-
//
|
|
31
|
-
// Concurrency model:
|
|
32
|
-
// - groupBy by (flowType, transactionId, sorted lineIds) so distinct
|
|
33
|
-
// targets run in parallel.
|
|
34
|
-
// - inside each group, switchMap so a re-fetch on the SAME target
|
|
35
|
-
// cancels any prior in-flight request for that target.
|
|
36
|
-
// - groupBy duration selector closes idle groups to bound memory.
|
|
37
|
-
export const fetchEntityRecommendationsForLineUpdateEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(fetchEntityRecommendationsForLineUpdate.match), groupBy((action) => toGroupKey(action.payload.flowType, action.payload.transactionDetails.transactionId.id, action.payload.transactionDetails.lineIds), undefined, (group$) => group$.pipe(debounce(() => timer(GROUP_INACTIVITY_TIMEOUT_MS)))), mergeMap((group$) => group$.pipe(switchMap((action) => {
|
|
38
|
-
const payload = action.payload;
|
|
39
|
-
const { transactionId, transaction, lineIds } = payload.transactionDetails;
|
|
40
|
-
const { entity, amount, isFetchCOT, isUncategorizedExpenseCategoryEnabled, } = payload;
|
|
41
|
-
// Synchronously emit the start arm so the per-line skeleton +
|
|
42
|
-
// row uncheck happen before the HTTP request begins. The
|
|
43
|
-
// discriminated-union payload narrows `payload.selectedTab` to
|
|
44
|
-
// a non-optional `TransactionsTab` inside the `'categorization'`
|
|
45
|
-
// branch, so no defensive fallthrough is needed.
|
|
46
|
-
const startAction = payload.flowType === 'categorization'
|
|
47
|
-
? markCategoryClassRecommendationsInProgressForCategorization(payload.selectedTab, transactionId, lineIds)
|
|
48
|
-
: markCategoryClassRecommendationsInProgressForTransactionDetail(transactionId, lineIds);
|
|
49
|
-
const url = buildRecommendationUrl(zeniAPI.apiEndPoints.accountMicroServiceBaseUrl, entity, amount, payload.transactionDetails, isFetchCOT === true);
|
|
50
|
-
const httpStream$ = zeniAPI
|
|
51
|
-
.getJSON(url)
|
|
52
|
-
.pipe(mergeMap((response) => {
|
|
53
|
-
if (!isSuccessResponse(response) || response.data == null) {
|
|
54
|
-
return of(payload.flowType === 'categorization'
|
|
55
|
-
? markCategoryClassRecommendationsFailureForCategorization(payload.selectedTab, transactionId, lineIds, response.status)
|
|
56
|
-
: markCategoryClassRecommendationsFailureForTransactionDetail(transactionId, lineIds, response.status));
|
|
57
|
-
}
|
|
58
|
-
const recommendationWithCOTByLineId = getRecommendationByLineIdWithCOTFromRecommendationPayloadWithCOT(response.data.recommendations, lineIds);
|
|
59
|
-
// HTTP 200 with no per-line recommendations: NOT an error.
|
|
60
|
-
// Flip lines to Completed so the skeleton resolves and
|
|
61
|
-
// downstream UI can treat this as "we tried, nothing to
|
|
62
|
-
// apply".
|
|
63
|
-
if (recommendationWithCOTByLineId == null) {
|
|
64
|
-
return of(payload.flowType === 'categorization'
|
|
65
|
-
? markCategoryClassRecommendationsCompletedForCategorization(payload.selectedTab, transactionId, lineIds)
|
|
66
|
-
: markCategoryClassRecommendationsCompletedForTransactionDetail(transactionId, lineIds));
|
|
67
|
-
}
|
|
68
|
-
const transactionWithCOT = isFetchCOT === true
|
|
69
|
-
? getTransactionWithCOTFromRecommendations(transaction, recommendationWithCOTByLineId)
|
|
70
|
-
: getTransactionWithCOT(transaction);
|
|
71
|
-
const uncategorizedIncomeExpense = getUncategorizedAccounts(state$.value.accountState, state$.value.accountListState, 'accountList');
|
|
72
|
-
if (payload.flowType === 'categorization') {
|
|
73
|
-
return of(setEntityRecommendationForLineIdsForCategorization(payload.selectedTab, transactionId, transactionWithCOT, lineIds, entity, amount, recommendationWithCOTByLineId, uncategorizedIncomeExpense, isUncategorizedExpenseCategoryEnabled, getIsAccountingClassesEnabled(state$.value)));
|
|
74
|
-
}
|
|
75
|
-
return of(setEntityRecommendationForLineIdsForTransactionDetail(transactionId, transactionWithCOT, lineIds, entity, amount, recommendationWithCOTByLineId, uncategorizedIncomeExpense));
|
|
76
|
-
}), catchError((error) => {
|
|
77
|
-
const errorMessage = 'fetchEntityRecommendationsForLineUpdate failed: ' +
|
|
78
|
-
(error instanceof Error
|
|
79
|
-
? error.message
|
|
80
|
-
: JSON.stringify(error));
|
|
81
|
-
const status = createZeniAPIStatus('Unexpected Error', errorMessage);
|
|
82
|
-
return of(payload.flowType === 'categorization'
|
|
83
|
-
? markCategoryClassRecommendationsFailureForCategorization(payload.selectedTab, transactionId, lineIds, status)
|
|
84
|
-
: markCategoryClassRecommendationsFailureForTransactionDetail(transactionId, lineIds, status));
|
|
85
|
-
}));
|
|
86
|
-
return concat(of(startAction), httpStream$);
|
|
87
|
-
}))));
|
|
@@ -1,66 +0,0 @@
|
|
|
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[];
|