@zeniai/client-epic-state 5.0.55-betaAR4 → 5.0.55-betaAR5
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/esm/index.js +7 -2
- package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +4 -3
- package/lib/esm/view/expenseAutomationView/transactionFilterHelpers.js +186 -0
- package/lib/esm/view/spendManagement/spendManagementFilterHelpers.js +17 -185
- package/lib/index.d.ts +4 -2
- package/lib/index.js +20 -18
- package/lib/tsconfig.typecheck.tsbuildinfo +1 -1
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +1 -1
- package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.d.ts +1 -1
- package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +4 -3
- package/lib/view/expenseAutomationView/transactionFilterHelpers.d.ts +64 -0
- package/lib/view/expenseAutomationView/transactionFilterHelpers.js +190 -0
- package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +1 -1
- package/lib/view/spendManagement/spendManagementFilterHelpers.d.ts +4 -45
- package/lib/view/spendManagement/spendManagementFilterHelpers.js +18 -186
- package/package.json +1 -1
|
@@ -14,7 +14,7 @@ import { ZeniAPIStatus } from '../../../responsePayload';
|
|
|
14
14
|
import { UncategorizedAccounts } from '../../accountList/accountListSelector';
|
|
15
15
|
import { UpdateTransactionCategorizationResponsePayload } from '../payload/transactionCategorizationPayload';
|
|
16
16
|
import { SupportedTransactionCategorization, TransactionSaveUpdates, TransactionsTab, TransactionsTabViewState, TransactionsViewState, TransactionsViewUIState } from '../types/transactionsViewState';
|
|
17
|
-
import { TransactionFilters } from '
|
|
17
|
+
import { TransactionFilters } from '../transactionFilterHelpers';
|
|
18
18
|
export declare const initialTransactionTabViewState: TransactionsTabViewState;
|
|
19
19
|
export declare const initialState: TransactionsViewState;
|
|
20
20
|
export declare const fetchTransactionCategorization: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[selectedTab: "review" | "autoCategorized", period: TimePeriod, cacheOverride?: any, keepExistingListItems?: any, searchString?: string | undefined, pageToken?: PageToken | undefined, refreshViewInBackground?: any, resetListItems?: boolean | undefined, isUncategorizedExpenseCategoryEnabled?: boolean | undefined], {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TransactionWithCOT } from '../../../entity/transaction/stateTypes/transaction';
|
|
2
2
|
import { RootState } from '../../../reducer';
|
|
3
|
-
import { TransactionView } from '
|
|
3
|
+
import { TransactionView } from '../transactionFilterHelpers';
|
|
4
4
|
import { ExpenseAutomationTransactionViewSelector, TransactionReviewLocalDataSelectorView } from '../selectorTypes/transactionsViewSelectorTypes';
|
|
5
5
|
export declare const toTransactionView: (transaction: TransactionWithCOT, transactionLocalData?: TransactionReviewLocalDataSelectorView) => TransactionView;
|
|
6
6
|
export declare function getExpenseAutomationTransactionView(state: RootState): ExpenseAutomationTransactionViewSelector;
|
|
@@ -11,7 +11,7 @@ const timePeriod_1 = require("../../../commonStateTypes/timePeriod");
|
|
|
11
11
|
const tenantSelector_1 = require("../../../entity/tenant/tenantSelector");
|
|
12
12
|
const transactionHelper_1 = require("../../../entity/transaction/transactionHelper");
|
|
13
13
|
const transactionSelector_1 = require("../../../entity/transaction/transactionSelector");
|
|
14
|
-
const
|
|
14
|
+
const transactionFilterHelpers_1 = require("../transactionFilterHelpers");
|
|
15
15
|
const accountListSelector_1 = require("../../accountList/accountListSelector");
|
|
16
16
|
const classListSelector_1 = require("../../classList/classListSelector");
|
|
17
17
|
const projectListSelector_1 = require("../../projectList/projectListSelector");
|
|
@@ -74,8 +74,9 @@ function getExpenseAutomationTransactionView(state) {
|
|
|
74
74
|
const localData = transactionLocalDataMap.get(transaction.id);
|
|
75
75
|
return (0, exports.toTransactionView)(transaction, localData);
|
|
76
76
|
});
|
|
77
|
-
// Apply
|
|
78
|
-
|
|
77
|
+
// Apply TC-specific filters (lives under expenseAutomationView, independent
|
|
78
|
+
// of the Spend Management filter pipeline).
|
|
79
|
+
const filteredTransactionViews = (0, transactionFilterHelpers_1.applyTransactionFilters)(transactionViews, filters);
|
|
79
80
|
// Convert back to TransactionWithCOT for return
|
|
80
81
|
const filteredTransactionsWithCOT = filteredTransactionViews.map((view) => view.transaction);
|
|
81
82
|
// Get transactionLocalData for filtered transactions
|
|
@@ -0,0 +1,64 @@
|
|
|
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. Generic primitives (`CategoryCombinationOperator`,
|
|
6
|
+
* `FilterCategoryType`) are redeclared locally rather than imported across the
|
|
7
|
+
* feature boundary; their definitions happen to coincide with the
|
|
8
|
+
* spend-management equivalents, which is fine — they're the same primitive
|
|
9
|
+
* concept used independently by both feature groups.
|
|
10
|
+
*/
|
|
11
|
+
import { Amount } from '../../commonStateTypes/amount';
|
|
12
|
+
import { ID } from '../../commonStateTypes/common';
|
|
13
|
+
import { TransactionType } from '../../entity/transaction/stateTypes/transactionType';
|
|
14
|
+
import { SupportedTransactionWithCOT } from '../../entity/transaction/transactionState';
|
|
15
|
+
import { TransactionReviewLocalDataSelectorView } from './selectorTypes/transactionsViewSelectorTypes';
|
|
16
|
+
/** Local copy of the generic combination operator — independent of SM. */
|
|
17
|
+
export type CategoryCombinationOperator = 'AND' | 'OR';
|
|
18
|
+
/** Local copy of the generic filter category-input type — independent of SM. */
|
|
19
|
+
export type FilterCategoryType = 'searchAutocomplete' | 'user' | 'dateRange' | 'numberRange' | 'dropdown';
|
|
20
|
+
export type TransactionFilterEntityType = 'transaction_categorization' | 'customer' | 'vendor' | 'merchant';
|
|
21
|
+
export type TransactionFilterCategoryField = 'payment_account_name' | 'payment_account_type' | 'payee' | 'category' | 'class' | 'amount';
|
|
22
|
+
export interface TransactionFilterCategoryDropdownOption {
|
|
23
|
+
value: TransactionFilterCategoryField;
|
|
24
|
+
multiple?: boolean;
|
|
25
|
+
type?: FilterCategoryType;
|
|
26
|
+
}
|
|
27
|
+
export declare const TRANSACTION_FILTER_CATEGORIES: TransactionFilterCategoryDropdownOption[];
|
|
28
|
+
/** Amount filter operators for transaction_categorization. */
|
|
29
|
+
export type TransactionFilterAmountMatchingOperator = 'equal' | 'not-equal' | 'lessThan' | 'greaterThan' | 'inBetween';
|
|
30
|
+
export interface TransactionFilterCategory {
|
|
31
|
+
field: TransactionFilterCategoryField;
|
|
32
|
+
matchingOperator: TransactionFilterAmountMatchingOperator;
|
|
33
|
+
values: (string | number)[];
|
|
34
|
+
valuesCombinationOperator: 'ANY';
|
|
35
|
+
}
|
|
36
|
+
export interface TransactionFilters {
|
|
37
|
+
categories: TransactionFilterCategory[];
|
|
38
|
+
categoryCombinationOperator: CategoryCombinationOperator;
|
|
39
|
+
}
|
|
40
|
+
export interface TransactionView {
|
|
41
|
+
amount: Amount;
|
|
42
|
+
createTime: import('../../zeniDayJS').ZeniDate;
|
|
43
|
+
date: import('../../zeniDayJS').ZeniDate;
|
|
44
|
+
description: string;
|
|
45
|
+
id: ID;
|
|
46
|
+
memo: string;
|
|
47
|
+
transaction: SupportedTransactionWithCOT;
|
|
48
|
+
type: TransactionType;
|
|
49
|
+
customerId?: ID;
|
|
50
|
+
customerName?: string;
|
|
51
|
+
transactionLocalData?: TransactionReviewLocalDataSelectorView;
|
|
52
|
+
typeName?: string;
|
|
53
|
+
vendorId?: ID;
|
|
54
|
+
vendorName?: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* TC-only equivalent of `applyAdvancedFiltersOnList`. Filters a list of
|
|
58
|
+
* `TransactionView` items against a `TransactionFilters` object using the
|
|
59
|
+
* AND/OR combination semantics from `categoryCombinationOperator`.
|
|
60
|
+
*
|
|
61
|
+
* Independent of `view/spendManagement` — keeps the TC filter pipeline cleanly
|
|
62
|
+
* inside the Expense Automation feature group.
|
|
63
|
+
*/
|
|
64
|
+
export declare const applyTransactionFilters: (transactions: TransactionView[], filters?: TransactionFilters) => TransactionView[];
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.applyTransactionFilters = exports.TRANSACTION_FILTER_CATEGORIES = void 0;
|
|
4
|
+
exports.TRANSACTION_FILTER_CATEGORIES = [
|
|
5
|
+
{ value: 'payment_account_name', type: 'dropdown' },
|
|
6
|
+
{ value: 'payment_account_type', type: 'dropdown' },
|
|
7
|
+
{ value: 'payee', type: 'searchAutocomplete' },
|
|
8
|
+
{ value: 'category', type: 'dropdown' },
|
|
9
|
+
{ value: 'class', type: 'dropdown' },
|
|
10
|
+
{ value: 'amount', type: 'numberRange' },
|
|
11
|
+
];
|
|
12
|
+
/**
|
|
13
|
+
* Resolve the comparable value for a transaction against a given filter field.
|
|
14
|
+
* Returns undefined when the transaction doesn't carry the field — callers
|
|
15
|
+
* decide whether absence counts as a match (for 'not-equal' it does).
|
|
16
|
+
*/
|
|
17
|
+
const getCategoryValueForTransaction = (key, transaction) => {
|
|
18
|
+
switch (key) {
|
|
19
|
+
case 'amount': {
|
|
20
|
+
// Prefer transactionLocalData line items (sum). Fall back to lines on
|
|
21
|
+
// the transaction itself. Final fallback: transaction-level amount.
|
|
22
|
+
const localDataForAmount = transaction.transactionLocalData?.transactionReviewLocalData;
|
|
23
|
+
if (localDataForAmount?.lineItemById) {
|
|
24
|
+
const lineItems = Object.values(localDataForAmount.lineItemById);
|
|
25
|
+
if (lineItems.length > 0) {
|
|
26
|
+
return lineItems.reduce((sum, lineItem) => sum + (lineItem.amount?.amount ?? 0), 0);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (transaction.transaction.lines &&
|
|
30
|
+
transaction.transaction.lines.length > 0) {
|
|
31
|
+
return transaction.transaction.lines.reduce((sum, line) => sum + (line.amount?.amount ?? 0), 0);
|
|
32
|
+
}
|
|
33
|
+
return transaction.amount.amount;
|
|
34
|
+
}
|
|
35
|
+
case 'payee': {
|
|
36
|
+
if (transaction.vendorName) {
|
|
37
|
+
return transaction.vendorName;
|
|
38
|
+
}
|
|
39
|
+
if (transaction.customerName) {
|
|
40
|
+
return transaction.customerName;
|
|
41
|
+
}
|
|
42
|
+
const localData = transaction.transactionLocalData?.transactionReviewLocalData;
|
|
43
|
+
if (localData?.vendor?.name) {
|
|
44
|
+
return localData.vendor.name;
|
|
45
|
+
}
|
|
46
|
+
if (localData?.customer?.name) {
|
|
47
|
+
return localData.customer.name;
|
|
48
|
+
}
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
case 'payment_account_name': {
|
|
52
|
+
// Match what TransactionCategorizationListRow renders for the cell.
|
|
53
|
+
return transaction.transaction.account?.accountName;
|
|
54
|
+
}
|
|
55
|
+
case 'payment_account_type': {
|
|
56
|
+
// Raw `paymentType` enum ("credit_card" / "check" / "cash"). Dropdown
|
|
57
|
+
// option values use the same enum; row uses `paymentTypeName` for the
|
|
58
|
+
// human label.
|
|
59
|
+
return transaction.transaction.paymentType;
|
|
60
|
+
}
|
|
61
|
+
case 'category': {
|
|
62
|
+
const localDataForCategory = transaction.transactionLocalData?.transactionReviewLocalData;
|
|
63
|
+
if (localDataForCategory) {
|
|
64
|
+
const firstLineItem = Object.values(localDataForCategory.lineItemById)[0];
|
|
65
|
+
if (firstLineItem?.account?.accountId) {
|
|
66
|
+
return firstLineItem.account.accountId;
|
|
67
|
+
}
|
|
68
|
+
if (firstLineItem?.account?.qboId) {
|
|
69
|
+
return firstLineItem.account.qboId;
|
|
70
|
+
}
|
|
71
|
+
if (firstLineItem?.account?.accountName) {
|
|
72
|
+
return firstLineItem.account.accountName;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const firstLineForCategory = transaction.transaction.lines?.[0];
|
|
76
|
+
if (firstLineForCategory?.type ===
|
|
77
|
+
'transaction_with_account_and_class_line' ||
|
|
78
|
+
firstLineForCategory?.type ===
|
|
79
|
+
'transaction_with_product_or_service_line' ||
|
|
80
|
+
firstLineForCategory?.type === 'journal_entry_transaction_line') {
|
|
81
|
+
const account = firstLineForCategory.account;
|
|
82
|
+
return account?.accountId ?? account?.qboId ?? account?.accountName;
|
|
83
|
+
}
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
case 'class': {
|
|
87
|
+
const localDataForClass = transaction.transactionLocalData?.transactionReviewLocalData;
|
|
88
|
+
if (localDataForClass) {
|
|
89
|
+
const firstLineItemForClass = Object.values(localDataForClass.lineItemById)[0];
|
|
90
|
+
if (firstLineItemForClass?.class?.classId) {
|
|
91
|
+
return firstLineItemForClass.class.classId;
|
|
92
|
+
}
|
|
93
|
+
if (firstLineItemForClass?.class?.qboId) {
|
|
94
|
+
return firstLineItemForClass.class.qboId;
|
|
95
|
+
}
|
|
96
|
+
if (firstLineItemForClass?.class?.className) {
|
|
97
|
+
return firstLineItemForClass.class.className;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const firstLineForClass = transaction.transaction.lines?.[0];
|
|
101
|
+
if (firstLineForClass?.type === 'transaction_with_account_and_class_line' ||
|
|
102
|
+
firstLineForClass?.type ===
|
|
103
|
+
'transaction_with_product_or_service_line' ||
|
|
104
|
+
firstLineForClass?.type === 'journal_entry_transaction_line') {
|
|
105
|
+
const classData = firstLineForClass.class;
|
|
106
|
+
return classData?.classId ?? classData?.qboId ?? classData?.className;
|
|
107
|
+
}
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
default:
|
|
111
|
+
return undefined;
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* TC-only amount matcher. Supports all five operators TC defines, including
|
|
116
|
+
* the legacy "1000<->5000" range-string form (kept for backward compatibility
|
|
117
|
+
* with persisted filter state that may still contain that encoding).
|
|
118
|
+
*/
|
|
119
|
+
const matchAmount = (amount, category) => {
|
|
120
|
+
const op = category.matchingOperator;
|
|
121
|
+
const values = category.values;
|
|
122
|
+
let matched = false;
|
|
123
|
+
if (op === 'inBetween') {
|
|
124
|
+
if (values.length >= 2) {
|
|
125
|
+
const min = Number(values[0]);
|
|
126
|
+
const max = Number(values[1]);
|
|
127
|
+
matched = amount >= min && amount <= max;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
else if (op === 'lessThan') {
|
|
131
|
+
if (values.length >= 1) {
|
|
132
|
+
matched = amount < Number(values[0]);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
else if (op === 'greaterThan') {
|
|
136
|
+
if (values.length >= 1) {
|
|
137
|
+
matched = amount > Number(values[0]);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
else if (op === 'equal' &&
|
|
141
|
+
values.length === 1 &&
|
|
142
|
+
String(values[0]).includes('<->')) {
|
|
143
|
+
// Backward compatibility: ["1000<->5000"] with matchingOperator "equal".
|
|
144
|
+
const parts = String(values[0]).split('<->');
|
|
145
|
+
matched =
|
|
146
|
+
amount >= Number(parts[0] ?? '') && amount <= Number(parts[1] ?? '');
|
|
147
|
+
}
|
|
148
|
+
else if (op === 'equal' && values.length === 1) {
|
|
149
|
+
matched = amount === Number(values[0]);
|
|
150
|
+
}
|
|
151
|
+
return op === 'not-equal' ? !matched : matched;
|
|
152
|
+
};
|
|
153
|
+
const transactionMatchesCategory = (transaction, category) => {
|
|
154
|
+
const value = getCategoryValueForTransaction(category.field, transaction);
|
|
155
|
+
if (value == null) {
|
|
156
|
+
// Absent values count as a match only under 'not-equal'.
|
|
157
|
+
return category.matchingOperator === 'not-equal';
|
|
158
|
+
}
|
|
159
|
+
if (category.field === 'amount') {
|
|
160
|
+
return matchAmount(Number(value), category);
|
|
161
|
+
}
|
|
162
|
+
const valueStr = value.toString();
|
|
163
|
+
const valueInList = category.values.some((v) => v.toString() === valueStr);
|
|
164
|
+
return category.matchingOperator === 'not-equal' ? !valueInList : valueInList;
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* TC-only equivalent of `applyAdvancedFiltersOnList`. Filters a list of
|
|
168
|
+
* `TransactionView` items against a `TransactionFilters` object using the
|
|
169
|
+
* AND/OR combination semantics from `categoryCombinationOperator`.
|
|
170
|
+
*
|
|
171
|
+
* Independent of `view/spendManagement` — keeps the TC filter pipeline cleanly
|
|
172
|
+
* inside the Expense Automation feature group.
|
|
173
|
+
*/
|
|
174
|
+
const applyTransactionFilters = (transactions, filters) => {
|
|
175
|
+
if (filters?.categories == null || filters.categories.length === 0) {
|
|
176
|
+
return transactions;
|
|
177
|
+
}
|
|
178
|
+
const activeCategories = filters.categories.filter((c) => c.field != null && c.values.length > 0);
|
|
179
|
+
if (activeCategories.length === 0) {
|
|
180
|
+
return transactions;
|
|
181
|
+
}
|
|
182
|
+
const op = filters.categoryCombinationOperator;
|
|
183
|
+
return transactions.filter((txn) => {
|
|
184
|
+
if (op === 'AND') {
|
|
185
|
+
return activeCategories.every((cat) => transactionMatchesCategory(txn, cat));
|
|
186
|
+
}
|
|
187
|
+
return activeCategories.some((cat) => transactionMatchesCategory(txn, cat));
|
|
188
|
+
});
|
|
189
|
+
};
|
|
190
|
+
exports.applyTransactionFilters = applyTransactionFilters;
|
|
@@ -15,7 +15,7 @@ import { TransactionCategory, TransactionType } from '../../../entity/transactio
|
|
|
15
15
|
import { VendorBase } from '../../../entity/vendor/vendorState';
|
|
16
16
|
import { ZeniDate } from '../../../zeniDayJS';
|
|
17
17
|
import { EntityRecommendationKey } from '../../recommendation/recommendationState';
|
|
18
|
-
import { TransactionFilters } from '
|
|
18
|
+
import { TransactionFilters } from '../transactionFilterHelpers';
|
|
19
19
|
import { TransactionDetailKey } from '../../transactionDetail/transactionDetailState';
|
|
20
20
|
export declare const toTransactionsSortKey: (v: string) => "date" | "amount" | "vendor" | "project" | "category" | "class" | "payment_account" | "transaction_type" | "memo_and_receipt";
|
|
21
21
|
export type TransactionsSortKey = ReturnType<typeof toTransactionsSortKey>;
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import { Amount } from '../../commonStateTypes/amount';
|
|
2
|
-
import { ID } from '../../commonStateTypes/common';
|
|
3
1
|
import { TimePeriod } from '../../commonStateTypes/timePeriod';
|
|
4
|
-
import { TransactionType } from '../../entity/transaction/stateTypes/transactionType';
|
|
5
|
-
import { SupportedTransactionWithCOT } from '../../entity/transaction/transactionState';
|
|
6
2
|
import { UserRoleType } from '../../entity/userRole/userRoleType';
|
|
7
3
|
import { RootState } from '../../reducer';
|
|
8
4
|
import { ZeniDate } from '../../zeniDayJS';
|
|
9
|
-
import { TransactionReviewLocalDataSelectorView } from '../expenseAutomationView/selectorTypes/transactionsViewSelectorTypes';
|
|
10
5
|
import { TaskListFilterCategoryField, TaskListFilters } from '../taskManager/taskListView/taskList';
|
|
11
6
|
import { TaskWithUserDetails } from '../taskManager/taskListView/taskListSelector';
|
|
12
7
|
import { BillTransactionView } from './billPay/billList/billListSelector';
|
|
@@ -15,8 +10,8 @@ import { PaymentHistoryFilterCategoryDropdownOption, PaymentHistoryFilters } fro
|
|
|
15
10
|
import { ChargeCardRepaymentWithUser } from './chargeCards/chargeCardPaymentHistory/chargeCardPaymentHistorySelector';
|
|
16
11
|
import { ReimbursementView } from './reimbursement/remiListView/remiListSelector';
|
|
17
12
|
import { ReimbursementFilters, RemiListViewFilterCategoryField } from './reimbursement/remiListView/remiListState';
|
|
18
|
-
export type SpendManagementFiltersType = BillPayFilters | ReimbursementFilters | TaskListFilters |
|
|
19
|
-
export type SpendManagementFilterEntityType = 'bill_pay' | 'reimbursement' | 'task_management' | '
|
|
13
|
+
export type SpendManagementFiltersType = BillPayFilters | ReimbursementFilters | TaskListFilters | PaymentHistoryFilters;
|
|
14
|
+
export type SpendManagementFilterEntityType = 'bill_pay' | 'reimbursement' | 'task_management' | 'charge_card_payment_history';
|
|
20
15
|
export type FilterCategoryType = 'searchAutocomplete' | 'user' | 'dateRange' | 'numberRange' | 'dropdown';
|
|
21
16
|
export interface MatchingOperatorDropdownOption {
|
|
22
17
|
label: 'is' | 'is not';
|
|
@@ -38,45 +33,9 @@ export interface TaskFilterCategoryDropdownOption {
|
|
|
38
33
|
multiple?: boolean;
|
|
39
34
|
type?: FilterCategoryType;
|
|
40
35
|
}
|
|
41
|
-
export type SpendManagementFilterCategoryDropdownOption = BillPayFilterCategoryDropdownOption | ReimbursementFilterCategoryDropdownOption | TaskFilterCategoryDropdownOption |
|
|
42
|
-
export interface TransactionFilterCategoryDropdownOption {
|
|
43
|
-
value: TransactionFilterCategoryField;
|
|
44
|
-
multiple?: boolean;
|
|
45
|
-
type?: FilterCategoryType;
|
|
46
|
-
}
|
|
47
|
-
export type TransactionFilterEntityType = 'transaction_categorization' | 'customer' | 'vendor' | 'merchant';
|
|
48
|
-
export type TransactionFilterCategoryField = 'payment_account_name' | 'payment_account_type' | 'payee' | 'category' | 'class' | 'amount';
|
|
49
|
-
export declare const TRANSACTION_FILTER_CATEGORIES: TransactionFilterCategoryDropdownOption[];
|
|
50
|
-
export interface TransactionFilters {
|
|
51
|
-
categories: TransactionFilterCategory[];
|
|
52
|
-
categoryCombinationOperator: CategoryCombinationOperator;
|
|
53
|
-
}
|
|
54
|
-
/** Amount filter operators for transaction_categorization (expense automation). Other entities use only equal/not-equal. */
|
|
55
|
-
export type TransactionFilterAmountMatchingOperator = 'equal' | 'not-equal' | 'lessThan' | 'greaterThan' | 'inBetween';
|
|
56
|
-
export interface TransactionFilterCategory {
|
|
57
|
-
field: TransactionFilterCategoryField;
|
|
58
|
-
matchingOperator: TransactionFilterAmountMatchingOperator;
|
|
59
|
-
values: (string | ZeniDate)[];
|
|
60
|
-
valuesCombinationOperator: 'ANY';
|
|
61
|
-
}
|
|
62
|
-
export interface TransactionView {
|
|
63
|
-
amount: Amount;
|
|
64
|
-
createTime: ZeniDate;
|
|
65
|
-
date: ZeniDate;
|
|
66
|
-
description: string;
|
|
67
|
-
id: ID;
|
|
68
|
-
memo: string;
|
|
69
|
-
transaction: SupportedTransactionWithCOT;
|
|
70
|
-
type: TransactionType;
|
|
71
|
-
customerId?: ID;
|
|
72
|
-
customerName?: string;
|
|
73
|
-
transactionLocalData?: TransactionReviewLocalDataSelectorView;
|
|
74
|
-
typeName?: string;
|
|
75
|
-
vendorId?: ID;
|
|
76
|
-
vendorName?: string;
|
|
77
|
-
}
|
|
36
|
+
export type SpendManagementFilterCategoryDropdownOption = BillPayFilterCategoryDropdownOption | ReimbursementFilterCategoryDropdownOption | TaskFilterCategoryDropdownOption | PaymentHistoryFilterCategoryDropdownOption;
|
|
78
37
|
export type FilterCategoryValueType = string | number | ZeniDate;
|
|
79
|
-
export declare const applyAdvancedFiltersOnList: (entity: SpendManagementFilterEntityType, allItems: BillTransactionView[] | ReimbursementView[] | TaskWithUserDetails[] |
|
|
38
|
+
export declare const applyAdvancedFiltersOnList: (entity: SpendManagementFilterEntityType, allItems: BillTransactionView[] | ReimbursementView[] | TaskWithUserDetails[] | ChargeCardRepaymentWithUser[], filters?: BillPayFilters | ReimbursementFilters | TaskListFilters | PaymentHistoryFilters, filteredItems?: (BillTransactionView | ReimbursementView | TaskWithUserDetails | ChargeCardRepaymentWithUser)[], index?: number) => (BillTransactionView | ReimbursementView | TaskWithUserDetails | ChargeCardRepaymentWithUser)[];
|
|
80
39
|
export declare const isBillListDownloadable: (state: RootState, currentTimePeriod: TimePeriod) => boolean;
|
|
81
40
|
export declare const isRemiListDownloadable: (state: RootState, currentTimePeriod: TimePeriod) => boolean;
|
|
82
41
|
export declare const hideCreatedByFilter: (userRole: UserRoleType[]) => boolean;
|
|
@@ -3,7 +3,7 @@ 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.hideCreatedByFilter = exports.isRemiListDownloadable = exports.isBillListDownloadable = exports.applyAdvancedFiltersOnList =
|
|
6
|
+
exports.hideCreatedByFilter = exports.isRemiListDownloadable = exports.isBillListDownloadable = exports.applyAdvancedFiltersOnList = void 0;
|
|
7
7
|
const get_1 = __importDefault(require("lodash/get"));
|
|
8
8
|
const userSelector_1 = require("../../entity/user/userSelector");
|
|
9
9
|
const userRoleType_1 = require("../../entity/userRole/userRoleType");
|
|
@@ -13,81 +13,30 @@ const billListState_1 = require("./billPay/billList/billListState");
|
|
|
13
13
|
const helpers_1 = require("./helpers");
|
|
14
14
|
const remiListSelector_1 = require("./reimbursement/remiListView/remiListSelector");
|
|
15
15
|
const remiListState_1 = require("./reimbursement/remiListView/remiListState");
|
|
16
|
-
exports.TRANSACTION_FILTER_CATEGORIES = [
|
|
17
|
-
{ value: 'payment_account_name', type: 'dropdown' },
|
|
18
|
-
{ value: 'payment_account_type', type: 'dropdown' },
|
|
19
|
-
{ value: 'payee', type: 'searchAutocomplete' },
|
|
20
|
-
{ value: 'category', type: 'dropdown' },
|
|
21
|
-
{ value: 'class', type: 'dropdown' },
|
|
22
|
-
{ value: 'amount', type: 'numberRange' },
|
|
23
|
-
];
|
|
24
16
|
//filters items against filter values representing a range. ex: date (from-to), amount(1k<-->5k)
|
|
25
|
-
//
|
|
26
|
-
//
|
|
27
|
-
// Other entities (bill_pay, reimbursement, etc.) use only equal/not-equal and are unchanged.
|
|
17
|
+
// Spend Management uses only equal/not-equal — TC amount operators
|
|
18
|
+
// (inBetween, lessThan, greaterThan) live in the TC filter pipeline.
|
|
28
19
|
const filterItemOnRangeCategoryType = (valueForItem, currentFilter) => {
|
|
29
20
|
let doesItemFallInValueRange = false;
|
|
30
21
|
const filterField = currentFilter.field;
|
|
31
22
|
if (filterField === 'amount') {
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const min = Number(values[0]);
|
|
39
|
-
const max = Number(values[1]);
|
|
40
|
-
doesItemFallInValueRange = currentValue >= min && currentValue <= max;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
else if (op === 'lessThan') {
|
|
44
|
-
if (values.length >= 1) {
|
|
45
|
-
const threshold = Number(values[0]);
|
|
46
|
-
doesItemFallInValueRange = currentValue < threshold;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
else if (op === 'greaterThan') {
|
|
50
|
-
if (values.length >= 1) {
|
|
51
|
-
const threshold = Number(values[0]);
|
|
52
|
-
doesItemFallInValueRange = currentValue > threshold;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
else if (op === 'equal' &&
|
|
56
|
-
values.length === 1 &&
|
|
57
|
-
String(values[0]).includes('<->')) {
|
|
58
|
-
// Backward compatibility: old format ["1000<->5000"] with matchingOperator "equal"
|
|
59
|
-
const parts = String(values[0]).split('<->');
|
|
60
|
-
const lowerValue = Number(parts[0] ?? '');
|
|
61
|
-
const higherValue = Number(parts[1] ?? '');
|
|
62
|
-
doesItemFallInValueRange =
|
|
63
|
-
currentValue >= lowerValue && currentValue <= higherValue;
|
|
64
|
-
}
|
|
65
|
-
else if (op === 'equal' && values.length === 1) {
|
|
66
|
-
// New format: exact match on single value (expense automation)
|
|
67
|
-
const val = Number(values[0]);
|
|
68
|
-
doesItemFallInValueRange = currentValue === val;
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
// Existing logic for equal/not-equal (bill_pay, reimbursement, etc. or multiple range values)
|
|
72
|
-
for (const filterValue of values) {
|
|
73
|
-
const lowerValue = Number.parseInt(filterValue?.toString()?.split('<->')[0] ?? '', 10);
|
|
74
|
-
const higherValue = Number.parseInt(filterValue?.toString()?.split('<->')[1] ?? '', 10);
|
|
75
|
-
if (currentValue >= lowerValue && currentValue <= higherValue) {
|
|
76
|
-
doesItemFallInValueRange = true;
|
|
77
|
-
}
|
|
23
|
+
for (const filterValue of currentFilter.values) {
|
|
24
|
+
const currentValue = parseInt(valueForItem.toString());
|
|
25
|
+
const lowerValue = parseInt(filterValue?.toString()?.split('<->')[0] ?? '');
|
|
26
|
+
const higherValue = parseInt(filterValue?.toString()?.split('<->')[1] ?? '');
|
|
27
|
+
if (currentValue >= lowerValue && currentValue <= higherValue) {
|
|
28
|
+
doesItemFallInValueRange = true;
|
|
78
29
|
}
|
|
79
30
|
}
|
|
80
|
-
return op === 'not-equal'
|
|
81
|
-
? !doesItemFallInValueRange
|
|
82
|
-
: doesItemFallInValueRange;
|
|
83
31
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
32
|
+
else {
|
|
33
|
+
const currentValue = valueForItem;
|
|
34
|
+
const lowerValue = currentFilter.values[0];
|
|
35
|
+
const higherValue = currentFilter.values[1];
|
|
36
|
+
if (currentValue.isSameOrAfter(lowerValue) &&
|
|
37
|
+
currentValue.isSameOrBefore(higherValue)) {
|
|
38
|
+
doesItemFallInValueRange = true;
|
|
39
|
+
}
|
|
91
40
|
}
|
|
92
41
|
return currentFilter.matchingOperator === 'equal'
|
|
93
42
|
? doesItemFallInValueRange
|
|
@@ -172,11 +121,7 @@ const applyAdvancedFiltersOnList = (entity, allItems, filters, filteredItems = [
|
|
|
172
121
|
? getCategoryValueForReimbursement(key, item)
|
|
173
122
|
: entity === 'task_management'
|
|
174
123
|
? getCategoryValueForTaskList(key, item)
|
|
175
|
-
:
|
|
176
|
-
? getCategoryValueForTransaction(key, item)
|
|
177
|
-
: entity === 'charge_card_payment_history'
|
|
178
|
-
? getCategoryValueForPaymentHistory(key, item)
|
|
179
|
-
: undefined;
|
|
124
|
+
: getCategoryValueForPaymentHistory(key, item);
|
|
180
125
|
if (categoryValue == null) {
|
|
181
126
|
if (currentFilter.matchingOperator === 'not-equal') {
|
|
182
127
|
return true;
|
|
@@ -298,119 +243,6 @@ const getCategoryValueForReimbursement = (key, reimbursement) => {
|
|
|
298
243
|
return undefined;
|
|
299
244
|
}
|
|
300
245
|
};
|
|
301
|
-
const getCategoryValueForTransaction = (key, transaction) => {
|
|
302
|
-
switch (key) {
|
|
303
|
-
case 'amount': {
|
|
304
|
-
// Get from transactionLocalData line items (preferred) - sum all line item amounts
|
|
305
|
-
const localDataForAmount = transaction.transactionLocalData?.transactionReviewLocalData;
|
|
306
|
-
if (localDataForAmount?.lineItemById) {
|
|
307
|
-
const lineItems = Object.values(localDataForAmount.lineItemById);
|
|
308
|
-
if (lineItems.length > 0) {
|
|
309
|
-
// Sum all line item amounts
|
|
310
|
-
const totalAmount = lineItems.reduce((sum, lineItem) => sum + (lineItem.amount?.amount ?? 0), 0);
|
|
311
|
-
return totalAmount;
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
// Fallback to transaction-level amount or sum from transaction lines
|
|
315
|
-
if (transaction.transaction.lines &&
|
|
316
|
-
transaction.transaction.lines.length > 0) {
|
|
317
|
-
const totalAmount = transaction.transaction.lines.reduce((sum, line) => sum + (line.amount?.amount ?? 0), 0);
|
|
318
|
-
return totalAmount;
|
|
319
|
-
}
|
|
320
|
-
// Final fallback to transaction amount
|
|
321
|
-
return transaction.amount.amount;
|
|
322
|
-
}
|
|
323
|
-
case 'payee': {
|
|
324
|
-
// Priority: vendorName > customerName > from transactionLocalData
|
|
325
|
-
if (transaction.vendorName) {
|
|
326
|
-
return transaction.vendorName;
|
|
327
|
-
}
|
|
328
|
-
if (transaction.customerName) {
|
|
329
|
-
return transaction.customerName;
|
|
330
|
-
}
|
|
331
|
-
// Check transactionLocalData for vendor/customer
|
|
332
|
-
const localData = transaction.transactionLocalData?.transactionReviewLocalData;
|
|
333
|
-
if (localData?.vendor?.name) {
|
|
334
|
-
return localData.vendor.name;
|
|
335
|
-
}
|
|
336
|
-
if (localData?.customer?.name) {
|
|
337
|
-
return localData.customer.name;
|
|
338
|
-
}
|
|
339
|
-
return undefined;
|
|
340
|
-
}
|
|
341
|
-
case 'payment_account_name': {
|
|
342
|
-
// Match the value the row renders: TransactionCategorizationListRow reads
|
|
343
|
-
// `currentTransaction?.account?.accountName` for the Payment Account Name
|
|
344
|
-
// column. Returning the same field here keeps filter-match parity with the
|
|
345
|
-
// visible cell, so any row a user can see is also a row the filter can match.
|
|
346
|
-
return transaction.transaction.account?.accountName;
|
|
347
|
-
}
|
|
348
|
-
case 'payment_account_type': {
|
|
349
|
-
// Compare against the raw `paymentType` enum (e.g. "credit_card", "check",
|
|
350
|
-
// "cash"). The same enum is what TransactionCategorizationListRow uses for
|
|
351
|
-
// its icon switch on line ~1675, and it's what the dropdown options emit
|
|
352
|
-
// as `value`. Display labels come from each account's `paymentTypeName`
|
|
353
|
-
// field (populated by mapAccountBasePayloadToAccountBase from the backend
|
|
354
|
-
// payload) — no client-side label map required.
|
|
355
|
-
return transaction.transaction.paymentType;
|
|
356
|
-
}
|
|
357
|
-
case 'category': {
|
|
358
|
-
// Get from transactionLocalData (preferred) or from transaction lines
|
|
359
|
-
const localDataForCategory = transaction.transactionLocalData?.transactionReviewLocalData;
|
|
360
|
-
if (localDataForCategory) {
|
|
361
|
-
// Get category from first line item or most common
|
|
362
|
-
const firstLineItem = Object.values(localDataForCategory.lineItemById)[0];
|
|
363
|
-
if (firstLineItem?.account?.accountId) {
|
|
364
|
-
return firstLineItem.account.accountId;
|
|
365
|
-
}
|
|
366
|
-
if (firstLineItem?.account?.qboId) {
|
|
367
|
-
return firstLineItem.account.qboId;
|
|
368
|
-
}
|
|
369
|
-
if (firstLineItem?.account?.accountName) {
|
|
370
|
-
return firstLineItem.account.accountName;
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
// Fallback to transaction lines
|
|
374
|
-
const firstLineForCategory = transaction.transaction.lines?.[0];
|
|
375
|
-
if (firstLineForCategory?.type ===
|
|
376
|
-
'transaction_with_account_and_class_line' ||
|
|
377
|
-
firstLineForCategory?.type ===
|
|
378
|
-
'transaction_with_product_or_service_line' ||
|
|
379
|
-
firstLineForCategory?.type === 'journal_entry_transaction_line') {
|
|
380
|
-
const account = firstLineForCategory.account;
|
|
381
|
-
return account?.accountId ?? account?.qboId ?? account?.accountName;
|
|
382
|
-
}
|
|
383
|
-
return undefined;
|
|
384
|
-
}
|
|
385
|
-
case 'class': {
|
|
386
|
-
// Similar to category but for class
|
|
387
|
-
const localDataForClass = transaction.transactionLocalData?.transactionReviewLocalData;
|
|
388
|
-
if (localDataForClass) {
|
|
389
|
-
const firstLineItemForClass = Object.values(localDataForClass.lineItemById)[0];
|
|
390
|
-
if (firstLineItemForClass?.class?.classId) {
|
|
391
|
-
return firstLineItemForClass.class.classId;
|
|
392
|
-
}
|
|
393
|
-
if (firstLineItemForClass?.class?.qboId) {
|
|
394
|
-
return firstLineItemForClass.class.qboId;
|
|
395
|
-
}
|
|
396
|
-
if (firstLineItemForClass?.class?.className) {
|
|
397
|
-
return firstLineItemForClass.class.className;
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
const firstLineForClass = transaction.transaction.lines?.[0];
|
|
401
|
-
if (firstLineForClass?.type === 'transaction_with_account_and_class_line' ||
|
|
402
|
-
firstLineForClass?.type ===
|
|
403
|
-
'transaction_with_product_or_service_line' ||
|
|
404
|
-
firstLineForClass?.type === 'journal_entry_transaction_line') {
|
|
405
|
-
const classData = firstLineForClass.class;
|
|
406
|
-
return classData?.classId ?? classData?.qboId ?? classData?.className;
|
|
407
|
-
}
|
|
408
|
-
return undefined;
|
|
409
|
-
}
|
|
410
|
-
default:
|
|
411
|
-
return undefined;
|
|
412
|
-
}
|
|
413
|
-
};
|
|
414
246
|
const getCategoryValueForPaymentHistory = (key, repayment) => {
|
|
415
247
|
switch (key) {
|
|
416
248
|
case 'repaymentDate':
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "5.0.55-
|
|
3
|
+
"version": "5.0.55-betaAR5",
|
|
4
4
|
"description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/esm/index.js",
|