@zeniai/client-epic-state 4.19.53-betaAR1 → 4.19.53
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/entity/account/accountSelector.d.ts +0 -18
- package/lib/entity/account/accountSelector.js +1 -31
- package/lib/entity/account/accountState.d.ts +0 -5
- package/lib/entity/account/accountState.js +4 -11
- package/lib/entity/class/classSelector.d.ts +0 -5
- package/lib/entity/class/classSelector.js +0 -8
- package/lib/esm/entity/account/accountSelector.js +1 -29
- package/lib/esm/entity/account/accountState.js +1 -7
- package/lib/esm/entity/class/classSelector.js +0 -7
- package/lib/esm/index.js +6 -7
- package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +1 -11
- package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +8 -57
- package/lib/esm/view/spendManagement/spendManagementFilterHelpers.js +15 -198
- package/lib/index.d.ts +9 -9
- package/lib/index.js +30 -37
- package/lib/tsconfig.typecheck.tsbuildinfo +1 -1
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +1 -5
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +2 -12
- package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.d.ts +1 -4
- package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +8 -59
- package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +0 -2
- package/lib/view/spendManagement/spendManagementFilterHelpers.d.ts +4 -45
- package/lib/view/spendManagement/spendManagementFilterHelpers.js +16 -199
- package/package.json +1 -1
|
@@ -13,7 +13,6 @@ import { ZeniAPIStatus } from '../../../responsePayload';
|
|
|
13
13
|
import { UncategorizedAccounts } from '../../accountList/accountListSelector';
|
|
14
14
|
import { UpdateTransactionCategorizationResponsePayload } from '../payload/transactionCategorizationPayload';
|
|
15
15
|
import { SupportedTransactionCategorization, TransactionSaveUpdates, TransactionsTab, TransactionsTabViewState, TransactionsViewState, TransactionsViewUIState } from '../types/transactionsViewState';
|
|
16
|
-
import { TransactionFilters } from '../../spendManagement/spendManagementFilterHelpers';
|
|
17
16
|
export declare const initialTransactionTabViewState: TransactionsTabViewState;
|
|
18
17
|
export declare const initialState: TransactionsViewState;
|
|
19
18
|
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], {
|
|
@@ -29,10 +28,7 @@ export declare const fetchTransactionCategorization: import("@reduxjs/toolkit").
|
|
|
29
28
|
}, "expenseAutomationTransactionsView/fetchTransactionCategorization", never, never>, updateTransactionCategorizationUIState: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
30
29
|
selectedTab: TransactionsTab;
|
|
31
30
|
uiState: Partial<TransactionsViewUIState>;
|
|
32
|
-
}, "expenseAutomationTransactionsView/updateTransactionCategorizationUIState">,
|
|
33
|
-
filters: TransactionFilters;
|
|
34
|
-
selectedTab: TransactionsTab;
|
|
35
|
-
}, "expenseAutomationTransactionsView/updateTransactionFilters">, initializeTransactionCategorizationViewLocalData: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[selectedTab: "review" | "autoCategorized", transactionIds: string[], selectedPeriod: MonthYearPeriod, keepExistingListItems: any, pageToken: PageToken, totalCount: number, lineItemsByTransactionIds: Record<string, string[]>, refreshViewInBackground?: any, isUncategorizedExpenseCategoryEnabled?: boolean | undefined], {
|
|
31
|
+
}, "expenseAutomationTransactionsView/updateTransactionCategorizationUIState">, initializeTransactionCategorizationViewLocalData: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[selectedTab: "review" | "autoCategorized", transactionIds: string[], selectedPeriod: MonthYearPeriod, keepExistingListItems: any, pageToken: PageToken, totalCount: number, lineItemsByTransactionIds: Record<string, string[]>, refreshViewInBackground?: any, isUncategorizedExpenseCategoryEnabled?: boolean | undefined], {
|
|
36
32
|
selectedTab: "review" | "autoCategorized";
|
|
37
33
|
transactionIds: string[];
|
|
38
34
|
selectedPeriod: MonthYearPeriod;
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
var _a;
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.backgroundRefetchReviewTab = exports.syncTransactionCategorizationFromDetailSave = exports.updateSelectedTransactionId = exports.setEntityRecommendationForLineIdsForCategorization = exports.clearExpenseAutomationTransactionsView = exports.clearExpenseAutomationTransactionsViewPerTabView = exports.updateSelectedCheckboxTransactionIds = exports.fetchTransactionCategorizationView = exports.resetOtherTabsFetchState = exports.fetchTransactionCategorizationSuccess = exports.updateTotalCountForTransactionCategorization = exports.setAllItemsToCategoryClassInLocalDataForCategorization = exports.updateSelectedCustomerForTransaction = exports.updateSelectedVendorForTransaction = exports.updateStatusForTransactionNotMiscategorizedUpdateForCategorization = exports.markTransactionAsNotMiscategorized = exports.updateTransactionCategorizationSaveStatus = exports.updateCurrentSelectedTransactionCategorizationTab = exports.updateTransactionCategorization = exports.saveTransactionCategorization = exports.fetchTransactionCategorizationFailure = exports.saveTransactionCategorizationLocalData = exports.initializeTransactionCategorizationViewLocalData = exports.
|
|
7
|
+
exports.backgroundRefetchReviewTab = exports.syncTransactionCategorizationFromDetailSave = exports.updateSelectedTransactionId = exports.setEntityRecommendationForLineIdsForCategorization = exports.clearExpenseAutomationTransactionsView = exports.clearExpenseAutomationTransactionsViewPerTabView = exports.updateSelectedCheckboxTransactionIds = exports.fetchTransactionCategorizationView = exports.resetOtherTabsFetchState = exports.fetchTransactionCategorizationSuccess = exports.updateTotalCountForTransactionCategorization = exports.setAllItemsToCategoryClassInLocalDataForCategorization = exports.updateSelectedCustomerForTransaction = exports.updateSelectedVendorForTransaction = exports.updateStatusForTransactionNotMiscategorizedUpdateForCategorization = exports.markTransactionAsNotMiscategorized = exports.updateTransactionCategorizationSaveStatus = exports.updateCurrentSelectedTransactionCategorizationTab = exports.updateTransactionCategorization = exports.saveTransactionCategorization = exports.fetchTransactionCategorizationFailure = exports.saveTransactionCategorizationLocalData = exports.initializeTransactionCategorizationViewLocalData = exports.updateTransactionCategorizationUIState = exports.fetchTransactionCategorization = exports.initialState = exports.initialTransactionTabViewState = void 0;
|
|
8
8
|
const toolkit_1 = require("@reduxjs/toolkit");
|
|
9
9
|
const get_1 = __importDefault(require("lodash/get"));
|
|
10
10
|
const uniq_1 = __importDefault(require("lodash/uniq"));
|
|
@@ -34,10 +34,6 @@ exports.initialTransactionTabViewState = {
|
|
|
34
34
|
totalCount: {},
|
|
35
35
|
limit: 10,
|
|
36
36
|
},
|
|
37
|
-
filters: {
|
|
38
|
-
categoryCombinationOperator: 'AND',
|
|
39
|
-
categories: [],
|
|
40
|
-
},
|
|
41
37
|
fetchState: 'Not-Started',
|
|
42
38
|
error: undefined,
|
|
43
39
|
hasValidState() {
|
|
@@ -246,12 +242,6 @@ const expenseAutomationTransactionsView = (0, toolkit_1.createSlice)({
|
|
|
246
242
|
uiState.totalCount;
|
|
247
243
|
}
|
|
248
244
|
},
|
|
249
|
-
updateTransactionFilters(draft, action) {
|
|
250
|
-
const { selectedTab, filters } = action.payload;
|
|
251
|
-
if (filters != null) {
|
|
252
|
-
draft.transactionCategorizationView[selectedTab].filters = filters;
|
|
253
|
-
}
|
|
254
|
-
},
|
|
255
245
|
saveTransactionCategorization: {
|
|
256
246
|
prepare(selectedTab, transactionIds, cotTrackingByTransactionId, isUncategorizedExpenseCategoryEnabled) {
|
|
257
247
|
return {
|
|
@@ -787,5 +777,5 @@ const expenseAutomationTransactionsView = (0, toolkit_1.createSlice)({
|
|
|
787
777
|
},
|
|
788
778
|
},
|
|
789
779
|
});
|
|
790
|
-
_a = expenseAutomationTransactionsView.actions, exports.fetchTransactionCategorization = _a.fetchTransactionCategorization, exports.updateTransactionCategorizationUIState = _a.updateTransactionCategorizationUIState, exports.
|
|
780
|
+
_a = expenseAutomationTransactionsView.actions, exports.fetchTransactionCategorization = _a.fetchTransactionCategorization, exports.updateTransactionCategorizationUIState = _a.updateTransactionCategorizationUIState, exports.initializeTransactionCategorizationViewLocalData = _a.initializeTransactionCategorizationViewLocalData, exports.saveTransactionCategorizationLocalData = _a.saveTransactionCategorizationLocalData, exports.fetchTransactionCategorizationFailure = _a.fetchTransactionCategorizationFailure, exports.saveTransactionCategorization = _a.saveTransactionCategorization, exports.updateTransactionCategorization = _a.updateTransactionCategorization, exports.updateCurrentSelectedTransactionCategorizationTab = _a.updateCurrentSelectedTransactionCategorizationTab, exports.updateTransactionCategorizationSaveStatus = _a.updateTransactionCategorizationSaveStatus, exports.markTransactionAsNotMiscategorized = _a.markTransactionAsNotMiscategorized, exports.updateStatusForTransactionNotMiscategorizedUpdateForCategorization = _a.updateStatusForTransactionNotMiscategorizedUpdateForCategorization, exports.updateSelectedVendorForTransaction = _a.updateSelectedVendorForTransaction, exports.updateSelectedCustomerForTransaction = _a.updateSelectedCustomerForTransaction, exports.setAllItemsToCategoryClassInLocalDataForCategorization = _a.setAllItemsToCategoryClassInLocalDataForCategorization, exports.updateTotalCountForTransactionCategorization = _a.updateTotalCountForTransactionCategorization, exports.fetchTransactionCategorizationSuccess = _a.fetchTransactionCategorizationSuccess, exports.resetOtherTabsFetchState = _a.resetOtherTabsFetchState, exports.fetchTransactionCategorizationView = _a.fetchTransactionCategorizationView, exports.updateSelectedCheckboxTransactionIds = _a.updateSelectedCheckboxTransactionIds, exports.clearExpenseAutomationTransactionsViewPerTabView = _a.clearExpenseAutomationTransactionsViewPerTabView, exports.clearExpenseAutomationTransactionsView = _a.clearExpenseAutomationTransactionsView, exports.setEntityRecommendationForLineIdsForCategorization = _a.setEntityRecommendationForLineIdsForCategorization, exports.updateSelectedTransactionId = _a.updateSelectedTransactionId, exports.syncTransactionCategorizationFromDetailSave = _a.syncTransactionCategorizationFromDetailSave, exports.backgroundRefetchReviewTab = _a.backgroundRefetchReviewTab;
|
|
791
781
|
exports.default = expenseAutomationTransactionsView.reducer;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { TransactionWithCOT } from '../../../entity/transaction/stateTypes/transaction';
|
|
2
1
|
import { RootState } from '../../../reducer';
|
|
3
|
-
import {
|
|
4
|
-
import { ExpenseAutomationTransactionViewSelector, TransactionReviewLocalDataSelectorView } from '../selectorTypes/transactionsViewSelectorTypes';
|
|
5
|
-
export declare const toTransactionView: (transaction: TransactionWithCOT, transactionLocalData?: TransactionReviewLocalDataSelectorView) => TransactionView;
|
|
2
|
+
import { ExpenseAutomationTransactionViewSelector } from '../selectorTypes/transactionsViewSelectorTypes';
|
|
6
3
|
export declare function getExpenseAutomationTransactionView(state: RootState): ExpenseAutomationTransactionViewSelector;
|
|
@@ -3,7 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.toTransactionView = void 0;
|
|
7
6
|
exports.getExpenseAutomationTransactionView = getExpenseAutomationTransactionView;
|
|
8
7
|
const omit_1 = __importDefault(require("lodash/omit"));
|
|
9
8
|
const reduceFetchState_1 = require("../../../commonStateTypes/reduceFetchState");
|
|
@@ -11,33 +10,13 @@ const timePeriod_1 = require("../../../commonStateTypes/timePeriod");
|
|
|
11
10
|
const tenantSelector_1 = require("../../../entity/tenant/tenantSelector");
|
|
12
11
|
const transactionHelper_1 = require("../../../entity/transaction/transactionHelper");
|
|
13
12
|
const transactionSelector_1 = require("../../../entity/transaction/transactionSelector");
|
|
14
|
-
const spendManagementFilterHelpers_1 = require("../../spendManagement/spendManagementFilterHelpers");
|
|
15
13
|
const accountListSelector_1 = require("../../accountList/accountListSelector");
|
|
16
14
|
const classListSelector_1 = require("../../classList/classListSelector");
|
|
17
15
|
const expenseAutomationViewSelectorTypes_1 = require("../selectorTypes/expenseAutomationViewSelectorTypes");
|
|
18
|
-
const toTransactionView = (transaction, transactionLocalData) => {
|
|
19
|
-
return {
|
|
20
|
-
id: transaction.id,
|
|
21
|
-
date: transaction.date,
|
|
22
|
-
amount: transaction.amount,
|
|
23
|
-
vendorName: transaction.vendorName,
|
|
24
|
-
customerName: transaction.customerName,
|
|
25
|
-
vendorId: transaction.vendorId,
|
|
26
|
-
customerId: transaction.customerId,
|
|
27
|
-
description: transaction.description,
|
|
28
|
-
memo: transaction.memo,
|
|
29
|
-
type: transaction.type,
|
|
30
|
-
typeName: transaction.typeName,
|
|
31
|
-
createTime: transaction.createTime,
|
|
32
|
-
transaction: transaction,
|
|
33
|
-
transactionLocalData,
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
exports.toTransactionView = toTransactionView;
|
|
37
16
|
function getExpenseAutomationTransactionView(state) {
|
|
38
17
|
const { accountState, classState, classListState, accountListState, expenseAutomationTransactionsViewState, expenseAutomationViewState, transactionState, monthEndCloseChecksState, } = state;
|
|
39
18
|
const { selectedTransactionCategorizationTab } = expenseAutomationTransactionsViewState;
|
|
40
|
-
const { uiState, refreshStatus, saveStatus, markAsNotMiscategorizedStatus, transactionIdsBySelectedPeriod, transactionReviewLocalDataById, selectedCheckBoxTransactionIds, transactionIdsWithUnsavedData, selectedTransactionId, selectedTransactionLineId,
|
|
19
|
+
const { uiState, refreshStatus, saveStatus, markAsNotMiscategorizedStatus, transactionIdsBySelectedPeriod, transactionReviewLocalDataById, selectedCheckBoxTransactionIds, transactionIdsWithUnsavedData, selectedTransactionId, selectedTransactionLineId, } = expenseAutomationTransactionsViewState.transactionCategorizationView[selectedTransactionCategorizationTab];
|
|
41
20
|
const uncategorizedIncomeExpense = (0, accountListSelector_1.getUncategorizedAccounts)(accountState, accountListState, 'accountList');
|
|
42
21
|
const accountList = (0, accountListSelector_1.getAccountList)(accountState, accountListState, 'accountList');
|
|
43
22
|
const classList = (0, classListSelector_1.getClassList)(classState, classListState);
|
|
@@ -54,42 +33,10 @@ function getExpenseAutomationTransactionView(state) {
|
|
|
54
33
|
? transactionIdsBySelectedPeriod[monthYearPeriodId]
|
|
55
34
|
: null;
|
|
56
35
|
const transactionIds = transactionIdsForSelectedPeriod ?? [];
|
|
57
|
-
const
|
|
58
|
-
const transactionsWithCOT = transactions.map((transaction) => (0, transactionHelper_1.getTransactionWithCOT)(transaction));
|
|
59
|
-
const transactionLocalDataMap = new Map();
|
|
60
|
-
transactionIds.forEach((transactionId) => {
|
|
61
|
-
const transactionData = transactionReviewLocalDataById[transactionId];
|
|
62
|
-
if (transactionData != null) {
|
|
63
|
-
transactionLocalDataMap.set(transactionId, {
|
|
64
|
-
transactionId,
|
|
65
|
-
transactionReviewLocalData: transactionData.transactionReviewLocalData,
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
// Step 2: Convert to TransactionView and apply advanced filters
|
|
70
|
-
const transactionViews = transactionsWithCOT.map((transaction) => {
|
|
71
|
-
const localData = transactionLocalDataMap.get(transaction.id);
|
|
72
|
-
return (0, exports.toTransactionView)(transaction, localData);
|
|
73
|
-
});
|
|
74
|
-
// Apply advanced filters if they exist
|
|
75
|
-
const filteredTransactionViews = (0, spendManagementFilterHelpers_1.applyAdvancedFiltersOnList)('transaction_categorization', transactionViews, filters);
|
|
76
|
-
// Convert back to TransactionWithCOT for return
|
|
77
|
-
const filteredTransactionsWithCOT = filteredTransactionViews.map((view) => view.transaction);
|
|
78
|
-
// Get transactionLocalData for filtered transactions
|
|
79
|
-
// Also include transactionLocalData for transactions that don't exist in transactionState
|
|
80
|
-
// but have local data (to match original behavior)
|
|
81
|
-
const filteredTransactionIds = new Set(filteredTransactionViews.map((view) => view.id));
|
|
82
|
-
const filteredTransactionLocalData = transactionIds
|
|
36
|
+
const transactionLocalData = transactionIds
|
|
83
37
|
.map((transactionId) => {
|
|
84
38
|
const transactionData = transactionReviewLocalDataById[transactionId];
|
|
85
|
-
if (transactionData
|
|
86
|
-
return null;
|
|
87
|
-
}
|
|
88
|
-
// Include if transaction is in filtered results, or if transaction doesn't exist in state
|
|
89
|
-
// (to maintain backward compatibility with tests)
|
|
90
|
-
const transactionExists = transactions.some((t) => t.id === transactionId);
|
|
91
|
-
if (filteredTransactionIds.has(transactionId) ||
|
|
92
|
-
!transactionExists) {
|
|
39
|
+
if (transactionData != null) {
|
|
93
40
|
return {
|
|
94
41
|
transactionId,
|
|
95
42
|
transactionReviewLocalData: transactionData.transactionReviewLocalData,
|
|
@@ -97,7 +44,9 @@ function getExpenseAutomationTransactionView(state) {
|
|
|
97
44
|
}
|
|
98
45
|
return null;
|
|
99
46
|
})
|
|
100
|
-
.filter((
|
|
47
|
+
.filter((transaction) => transaction != null);
|
|
48
|
+
const transactions = (0, transactionSelector_1.getSupportedTransactionsByIds)(transactionState, transactionIds);
|
|
49
|
+
const transactionsWithCOT = transactions.map((transaction) => (0, transactionHelper_1.getTransactionWithCOT)(transaction));
|
|
101
50
|
const fetchStatus = (0, reduceFetchState_1.reduceAllFetchState)([
|
|
102
51
|
accountList,
|
|
103
52
|
classList,
|
|
@@ -134,7 +83,7 @@ function getExpenseAutomationTransactionView(state) {
|
|
|
134
83
|
version: 0,
|
|
135
84
|
fetchState: fetchStatus.fetchState,
|
|
136
85
|
error: fetchStatus.error,
|
|
137
|
-
transactions:
|
|
86
|
+
transactions: transactionsWithCOT,
|
|
138
87
|
selectedCheckBoxTransactionIds,
|
|
139
88
|
transactionIdsWithUnsavedData,
|
|
140
89
|
uncategorizedAccounts: uncategorizedIncomeExpense,
|
|
@@ -143,7 +92,7 @@ function getExpenseAutomationTransactionView(state) {
|
|
|
143
92
|
classList: allClasses,
|
|
144
93
|
accountsHierarchyList,
|
|
145
94
|
classHierarchyList,
|
|
146
|
-
transactionLocalData
|
|
95
|
+
transactionLocalData,
|
|
147
96
|
uiState,
|
|
148
97
|
refreshStatus,
|
|
149
98
|
saveStatus,
|
|
@@ -14,7 +14,6 @@ import { TransactionCategory, TransactionType } from '../../../entity/transactio
|
|
|
14
14
|
import { VendorBase } from '../../../entity/vendor/vendorState';
|
|
15
15
|
import { ZeniDate } from '../../../zeniDayJS';
|
|
16
16
|
import { EntityRecommendationKey } from '../../recommendation/recommendationState';
|
|
17
|
-
import { TransactionFilters } from '../../spendManagement/spendManagementFilterHelpers';
|
|
18
17
|
import { TransactionDetailKey } from '../../transactionDetail/transactionDetailState';
|
|
19
18
|
export declare const toTransactionsSortKey: (v: string) => "date" | "amount" | "vendor" | "category" | "class" | "memo" | "transaction_type";
|
|
20
19
|
export type TransactionsSortKey = ReturnType<typeof toTransactionsSortKey>;
|
|
@@ -90,7 +89,6 @@ export interface SupportedTransactionCategorization {
|
|
|
90
89
|
}
|
|
91
90
|
export declare const initialSupportedTransactionCategorization: SupportedTransactionCategorization;
|
|
92
91
|
export interface TransactionsTabViewState extends FetchedState {
|
|
93
|
-
filters: TransactionFilters;
|
|
94
92
|
markAsNotMiscategorizedStatus: FetchStateAndError;
|
|
95
93
|
refreshStatus: FetchStateAndError;
|
|
96
94
|
saveStatus: FetchStateAndError;
|
|
@@ -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,28 @@ 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
|
-
// For amount: supports new transaction_categorization operators (inBetween, lessThan, greaterThan) and
|
|
26
|
-
// backward compatibility for old format values: ["1000<->5000"] with matchingOperator "equal".
|
|
27
|
-
// Other entities (bill_pay, reimbursement, etc.) use only equal/not-equal and are unchanged.
|
|
28
17
|
const filterItemOnRangeCategoryType = (valueForItem, currentFilter) => {
|
|
29
18
|
let doesItemFallInValueRange = false;
|
|
30
19
|
const filterField = currentFilter.field;
|
|
31
20
|
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
|
-
}
|
|
21
|
+
for (const filterValue of currentFilter.values) {
|
|
22
|
+
const currentValue = parseInt(valueForItem.toString());
|
|
23
|
+
const lowerValue = parseInt(filterValue?.toString()?.split('<->')[0] ?? '');
|
|
24
|
+
const higherValue = parseInt(filterValue?.toString()?.split('<->')[1] ?? '');
|
|
25
|
+
if (currentValue >= lowerValue && currentValue <= higherValue) {
|
|
26
|
+
doesItemFallInValueRange = true;
|
|
78
27
|
}
|
|
79
28
|
}
|
|
80
|
-
return op === 'not-equal'
|
|
81
|
-
? !doesItemFallInValueRange
|
|
82
|
-
: doesItemFallInValueRange;
|
|
83
29
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
30
|
+
else {
|
|
31
|
+
const currentValue = valueForItem;
|
|
32
|
+
const lowerValue = currentFilter.values[0];
|
|
33
|
+
const higherValue = currentFilter.values[1];
|
|
34
|
+
if (currentValue.isSameOrAfter(lowerValue) &&
|
|
35
|
+
currentValue.isSameOrBefore(higherValue)) {
|
|
36
|
+
doesItemFallInValueRange = true;
|
|
37
|
+
}
|
|
91
38
|
}
|
|
92
39
|
return currentFilter.matchingOperator === 'equal'
|
|
93
40
|
? doesItemFallInValueRange
|
|
@@ -172,11 +119,7 @@ const applyAdvancedFiltersOnList = (entity, allItems, filters, filteredItems = [
|
|
|
172
119
|
? getCategoryValueForReimbursement(key, item)
|
|
173
120
|
: entity === 'task_management'
|
|
174
121
|
? getCategoryValueForTaskList(key, item)
|
|
175
|
-
:
|
|
176
|
-
? getCategoryValueForTransaction(key, item)
|
|
177
|
-
: entity === 'charge_card_payment_history'
|
|
178
|
-
? getCategoryValueForPaymentHistory(key, item)
|
|
179
|
-
: undefined;
|
|
122
|
+
: getCategoryValueForPaymentHistory(key, item);
|
|
180
123
|
if (categoryValue == null) {
|
|
181
124
|
if (currentFilter.matchingOperator === 'not-equal') {
|
|
182
125
|
return true;
|
|
@@ -298,132 +241,6 @@ const getCategoryValueForReimbursement = (key, reimbursement) => {
|
|
|
298
241
|
return undefined;
|
|
299
242
|
}
|
|
300
243
|
};
|
|
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
|
-
// Get from transaction.account or from lines
|
|
343
|
-
if (transaction.transaction.account?.accountName) {
|
|
344
|
-
return transaction.transaction.account.accountName;
|
|
345
|
-
}
|
|
346
|
-
// Get from first line's account
|
|
347
|
-
const firstLine = transaction.transaction.lines?.[0];
|
|
348
|
-
if (firstLine?.type === 'transaction_with_account_and_class_line' ||
|
|
349
|
-
firstLine?.type === 'transaction_with_product_or_service_line' ||
|
|
350
|
-
firstLine?.type === 'journal_entry_transaction_line') {
|
|
351
|
-
const accountLine = firstLine;
|
|
352
|
-
return accountLine.account?.accountName;
|
|
353
|
-
}
|
|
354
|
-
return undefined;
|
|
355
|
-
}
|
|
356
|
-
case 'payment_account_type': {
|
|
357
|
-
// Similar to payment_account_name but for type
|
|
358
|
-
if (transaction.transaction.account?.accountType) {
|
|
359
|
-
return transaction.transaction.account.accountType;
|
|
360
|
-
}
|
|
361
|
-
const firstLineForType = transaction.transaction.lines?.[0];
|
|
362
|
-
if (firstLineForType?.type === 'transaction_with_account_and_class_line' ||
|
|
363
|
-
firstLineForType?.type === 'transaction_with_product_or_service_line' ||
|
|
364
|
-
firstLineForType?.type === 'journal_entry_transaction_line') {
|
|
365
|
-
const accountLineForType = firstLineForType;
|
|
366
|
-
return accountLineForType.account?.accountType;
|
|
367
|
-
}
|
|
368
|
-
return undefined;
|
|
369
|
-
}
|
|
370
|
-
case 'category': {
|
|
371
|
-
// Get from transactionLocalData (preferred) or from transaction lines
|
|
372
|
-
const localDataForCategory = transaction.transactionLocalData?.transactionReviewLocalData;
|
|
373
|
-
if (localDataForCategory) {
|
|
374
|
-
// Get category from first line item or most common
|
|
375
|
-
const firstLineItem = Object.values(localDataForCategory.lineItemById)[0];
|
|
376
|
-
if (firstLineItem?.account?.accountId) {
|
|
377
|
-
return firstLineItem.account.accountId;
|
|
378
|
-
}
|
|
379
|
-
if (firstLineItem?.account?.qboId) {
|
|
380
|
-
return firstLineItem.account.qboId;
|
|
381
|
-
}
|
|
382
|
-
if (firstLineItem?.account?.accountName) {
|
|
383
|
-
return firstLineItem.account.accountName;
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
// Fallback to transaction lines
|
|
387
|
-
const firstLineForCategory = transaction.transaction.lines?.[0];
|
|
388
|
-
if (firstLineForCategory?.type ===
|
|
389
|
-
'transaction_with_account_and_class_line' ||
|
|
390
|
-
firstLineForCategory?.type ===
|
|
391
|
-
'transaction_with_product_or_service_line' ||
|
|
392
|
-
firstLineForCategory?.type === 'journal_entry_transaction_line') {
|
|
393
|
-
const account = firstLineForCategory.account;
|
|
394
|
-
return account?.accountId ?? account?.qboId ?? account?.accountName;
|
|
395
|
-
}
|
|
396
|
-
return undefined;
|
|
397
|
-
}
|
|
398
|
-
case 'class': {
|
|
399
|
-
// Similar to category but for class
|
|
400
|
-
const localDataForClass = transaction.transactionLocalData?.transactionReviewLocalData;
|
|
401
|
-
if (localDataForClass) {
|
|
402
|
-
const firstLineItemForClass = Object.values(localDataForClass.lineItemById)[0];
|
|
403
|
-
if (firstLineItemForClass?.class?.classId) {
|
|
404
|
-
return firstLineItemForClass.class.classId;
|
|
405
|
-
}
|
|
406
|
-
if (firstLineItemForClass?.class?.qboId) {
|
|
407
|
-
return firstLineItemForClass.class.qboId;
|
|
408
|
-
}
|
|
409
|
-
if (firstLineItemForClass?.class?.className) {
|
|
410
|
-
return firstLineItemForClass.class.className;
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
const firstLineForClass = transaction.transaction.lines?.[0];
|
|
414
|
-
if (firstLineForClass?.type === 'transaction_with_account_and_class_line' ||
|
|
415
|
-
firstLineForClass?.type ===
|
|
416
|
-
'transaction_with_product_or_service_line' ||
|
|
417
|
-
firstLineForClass?.type === 'journal_entry_transaction_line') {
|
|
418
|
-
const classData = firstLineForClass.class;
|
|
419
|
-
return classData?.classId ?? classData?.qboId ?? classData?.className;
|
|
420
|
-
}
|
|
421
|
-
return undefined;
|
|
422
|
-
}
|
|
423
|
-
default:
|
|
424
|
-
return undefined;
|
|
425
|
-
}
|
|
426
|
-
};
|
|
427
244
|
const getCategoryValueForPaymentHistory = (key, repayment) => {
|
|
428
245
|
switch (key) {
|
|
429
246
|
case 'repaymentDate':
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "4.19.53
|
|
3
|
+
"version": "4.19.53",
|
|
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",
|