@zeniai/client-epic-state 4.19.24-betaAR11 → 4.19.24-betaAR13
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.
Potentially problematic release.
This version of @zeniai/client-epic-state might be problematic. Click here for more details.
- package/lib/index.d.ts +4 -4
- package/lib/index.js +30 -29
- package/lib/tsconfig.typecheck.tsbuildinfo +1 -1
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +5 -1
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +12 -2
- package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.d.ts +4 -1
- package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +90 -35
- package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +2 -0
- package/lib/view/spendManagement/spendManagementFilterHelpers.d.ts +22 -1
- package/lib/view/spendManagement/spendManagementFilterHelpers.js +114 -1
- package/package.json +1 -1
|
@@ -13,6 +13,7 @@ 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';
|
|
16
17
|
export declare const initialTransactionTabViewState: TransactionsTabViewState;
|
|
17
18
|
export declare const initialState: TransactionsViewState;
|
|
18
19
|
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], {
|
|
@@ -28,7 +29,10 @@ export declare const fetchTransactionCategorization: import("@reduxjs/toolkit").
|
|
|
28
29
|
}, "expenseAutomationTransactionsView/fetchTransactionCategorization", never, never>, updateTransactionCategorizationUIState: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
29
30
|
selectedTab: TransactionsTab;
|
|
30
31
|
uiState: Partial<TransactionsViewUIState>;
|
|
31
|
-
}, "expenseAutomationTransactionsView/updateTransactionCategorizationUIState">,
|
|
32
|
+
}, "expenseAutomationTransactionsView/updateTransactionCategorizationUIState">, updateTransactionFilters: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
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], {
|
|
32
36
|
selectedTab: "review" | "autoCategorized";
|
|
33
37
|
transactionIds: string[];
|
|
34
38
|
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.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;
|
|
7
|
+
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.updateTransactionFilters = 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,6 +34,10 @@ exports.initialTransactionTabViewState = {
|
|
|
34
34
|
totalCount: {},
|
|
35
35
|
limit: 10,
|
|
36
36
|
},
|
|
37
|
+
filters: {
|
|
38
|
+
categoryCombinationOperator: 'AND',
|
|
39
|
+
categories: [],
|
|
40
|
+
},
|
|
37
41
|
fetchState: 'Not-Started',
|
|
38
42
|
error: undefined,
|
|
39
43
|
hasValidState() {
|
|
@@ -230,6 +234,12 @@ const expenseAutomationTransactionsView = (0, toolkit_1.createSlice)({
|
|
|
230
234
|
uiState.totalCount;
|
|
231
235
|
}
|
|
232
236
|
},
|
|
237
|
+
updateTransactionFilters(draft, action) {
|
|
238
|
+
const { selectedTab, filters } = action.payload;
|
|
239
|
+
if (filters != null) {
|
|
240
|
+
draft.transactionCategorizationView[selectedTab].filters = filters;
|
|
241
|
+
}
|
|
242
|
+
},
|
|
233
243
|
saveTransactionCategorization: {
|
|
234
244
|
prepare(selectedTab, transactionIds, cotTrackingByTransactionId, isUncategorizedExpenseCategoryEnabled) {
|
|
235
245
|
return {
|
|
@@ -653,5 +663,5 @@ const expenseAutomationTransactionsView = (0, toolkit_1.createSlice)({
|
|
|
653
663
|
},
|
|
654
664
|
},
|
|
655
665
|
});
|
|
656
|
-
_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;
|
|
666
|
+
_a = expenseAutomationTransactionsView.actions, exports.fetchTransactionCategorization = _a.fetchTransactionCategorization, exports.updateTransactionCategorizationUIState = _a.updateTransactionCategorizationUIState, exports.updateTransactionFilters = _a.updateTransactionFilters, 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;
|
|
657
667
|
exports.default = expenseAutomationTransactionsView.reducer;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { TransactionWithCOT } from '../../../entity/transaction/stateTypes/transaction';
|
|
1
2
|
import { RootState } from '../../../reducer';
|
|
2
|
-
import {
|
|
3
|
+
import { TransactionView } from '../../spendManagement/spendManagementFilterHelpers';
|
|
4
|
+
import { ExpenseAutomationTransactionViewSelector, TransactionReviewLocalDataSelectorView } from '../selectorTypes/transactionsViewSelectorTypes';
|
|
5
|
+
export declare const toTransactionView: (transaction: TransactionWithCOT, transactionLocalData?: TransactionReviewLocalDataSelectorView) => TransactionView;
|
|
3
6
|
export declare function getExpenseAutomationTransactionView(state: RootState): ExpenseAutomationTransactionViewSelector;
|
|
@@ -3,6 +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.toTransactionView = void 0;
|
|
6
7
|
exports.getExpenseAutomationTransactionView = getExpenseAutomationTransactionView;
|
|
7
8
|
const omit_1 = __importDefault(require("lodash/omit"));
|
|
8
9
|
const reduceFetchState_1 = require("../../../commonStateTypes/reduceFetchState");
|
|
@@ -10,14 +11,34 @@ const timePeriod_1 = require("../../../commonStateTypes/timePeriod");
|
|
|
10
11
|
const tenantSelector_1 = require("../../../entity/tenant/tenantSelector");
|
|
11
12
|
const transactionHelper_1 = require("../../../entity/transaction/transactionHelper");
|
|
12
13
|
const transactionSelector_1 = require("../../../entity/transaction/transactionSelector");
|
|
14
|
+
const spendManagementFilterHelpers_1 = require("../../spendManagement/spendManagementFilterHelpers");
|
|
13
15
|
const accountListSelector_1 = require("../../accountList/accountListSelector");
|
|
14
16
|
const classListSelector_1 = require("../../classList/classListSelector");
|
|
15
17
|
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;
|
|
16
37
|
function getExpenseAutomationTransactionView(state) {
|
|
17
38
|
var _a, _b, _c;
|
|
18
39
|
const { accountState, classState, classListState, accountListState, expenseAutomationTransactionsViewState, expenseAutomationViewState, transactionState, monthEndCloseChecksState, } = state;
|
|
19
40
|
const { selectedTransactionCategorizationTab } = expenseAutomationTransactionsViewState;
|
|
20
|
-
const { uiState, refreshStatus, saveStatus, markAsNotMiscategorizedStatus, transactionIdsBySelectedPeriod, transactionReviewLocalDataById, selectedCheckBoxTransactionIds, transactionIdsWithUnsavedData, selectedTransactionId, selectedTransactionLineId, } = expenseAutomationTransactionsViewState.transactionCategorizationView[selectedTransactionCategorizationTab];
|
|
41
|
+
const { uiState, refreshStatus, saveStatus, markAsNotMiscategorizedStatus, transactionIdsBySelectedPeriod, transactionReviewLocalDataById, selectedCheckBoxTransactionIds, transactionIdsWithUnsavedData, selectedTransactionId, selectedTransactionLineId, filters, } = expenseAutomationTransactionsViewState.transactionCategorizationView[selectedTransactionCategorizationTab];
|
|
21
42
|
const uncategorizedIncomeExpense = (0, accountListSelector_1.getUncategorizedAccounts)(accountState, accountListState, 'accountList');
|
|
22
43
|
const accountList = (0, accountListSelector_1.getAccountList)(accountState, accountListState, 'accountList');
|
|
23
44
|
const classList = (0, classListSelector_1.getClassList)(classState, classListState);
|
|
@@ -34,48 +55,82 @@ function getExpenseAutomationTransactionView(state) {
|
|
|
34
55
|
? transactionIdsBySelectedPeriod[monthYearPeriodId]
|
|
35
56
|
: null;
|
|
36
57
|
const transactionIds = transactionIdsForSelectedPeriod !== null && transactionIdsForSelectedPeriod !== void 0 ? transactionIdsForSelectedPeriod : [];
|
|
58
|
+
const transactions = (0, transactionSelector_1.getSupportedTransactionsByIds)(transactionState, transactionIds);
|
|
59
|
+
const transactionsWithCOT = transactions.map((transaction) => (0, transactionHelper_1.getTransactionWithCOT)(transaction));
|
|
60
|
+
// Apply search first, then filters
|
|
61
|
+
// Step 1: Apply search filter
|
|
37
62
|
const searchString = (_b = (_a = uiState.searchString) === null || _a === void 0 ? void 0 : _a.trim().toLowerCase()) !== null && _b !== void 0 ? _b : '';
|
|
38
|
-
const
|
|
39
|
-
|
|
63
|
+
const transactionLocalDataMap = new Map();
|
|
64
|
+
transactionIds.forEach((transactionId) => {
|
|
40
65
|
const transactionData = transactionReviewLocalDataById[transactionId];
|
|
41
66
|
if (transactionData != null) {
|
|
42
|
-
|
|
67
|
+
transactionLocalDataMap.set(transactionId, {
|
|
43
68
|
transactionId,
|
|
44
69
|
transactionReviewLocalData: transactionData.transactionReviewLocalData,
|
|
45
|
-
};
|
|
70
|
+
});
|
|
46
71
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
72
|
+
});
|
|
73
|
+
// Filter transactions by search string
|
|
74
|
+
const transactionsAfterSearch = transactionsWithCOT.filter((transaction) => {
|
|
50
75
|
var _a, _b, _c, _d, _e;
|
|
51
|
-
if (
|
|
52
|
-
return
|
|
76
|
+
if (searchString === '') {
|
|
77
|
+
return true;
|
|
53
78
|
}
|
|
54
|
-
|
|
55
|
-
if (
|
|
56
|
-
|
|
57
|
-
// Check vendorDetails.name
|
|
58
|
-
const vendorNameMatch = (_c = (_b = (_a = transactionReviewLocalData.vendorDetails) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.toLowerCase().includes(searchString)) !== null && _c !== void 0 ? _c : false;
|
|
59
|
-
// Check memo
|
|
60
|
-
const memoMatch = (_e = (_d = transactionReviewLocalData.memo) === null || _d === void 0 ? void 0 : _d.toLowerCase().includes(searchString)) !== null && _e !== void 0 ? _e : false;
|
|
61
|
-
// Check lineItemById - iterate through all line items
|
|
62
|
-
const lineItemMatch = Object.values(transactionReviewLocalData.lineItemById).some((lineItem) => {
|
|
63
|
-
var _a, _b;
|
|
64
|
-
// Check amount (convert number to string)
|
|
65
|
-
const amountMatch = lineItem.amount.amount
|
|
66
|
-
.toString()
|
|
67
|
-
.toLowerCase()
|
|
68
|
-
.includes(searchString);
|
|
69
|
-
// Check transactionId
|
|
70
|
-
const transactionIdMatch = (_b = (_a = lineItem.transactionId) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes(searchString)) !== null && _b !== void 0 ? _b : false;
|
|
71
|
-
return amountMatch || transactionIdMatch;
|
|
72
|
-
});
|
|
73
|
-
return vendorNameMatch || memoMatch || lineItemMatch;
|
|
79
|
+
const localData = transactionLocalDataMap.get(transaction.id);
|
|
80
|
+
if (localData == null) {
|
|
81
|
+
return false;
|
|
74
82
|
}
|
|
75
|
-
|
|
83
|
+
const { transactionReviewLocalData } = localData;
|
|
84
|
+
// Check vendorDetails.name
|
|
85
|
+
const vendorNameMatch = (_c = (_b = (_a = transactionReviewLocalData.vendorDetails) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.toLowerCase().includes(searchString)) !== null && _c !== void 0 ? _c : false;
|
|
86
|
+
// Check memo
|
|
87
|
+
const memoMatch = (_e = (_d = transactionReviewLocalData.memo) === null || _d === void 0 ? void 0 : _d.toLowerCase().includes(searchString)) !== null && _e !== void 0 ? _e : false;
|
|
88
|
+
// Check lineItemById - iterate through all line items
|
|
89
|
+
const lineItemMatch = Object.values(transactionReviewLocalData.lineItemById).some((lineItem) => {
|
|
90
|
+
var _a, _b;
|
|
91
|
+
// Check amount (convert number to string)
|
|
92
|
+
const amountMatch = lineItem.amount.amount
|
|
93
|
+
.toString()
|
|
94
|
+
.toLowerCase()
|
|
95
|
+
.includes(searchString);
|
|
96
|
+
// Check transactionId
|
|
97
|
+
const transactionIdMatch = (_b = (_a = lineItem.transactionId) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes(searchString)) !== null && _b !== void 0 ? _b : false;
|
|
98
|
+
return amountMatch || transactionIdMatch;
|
|
99
|
+
});
|
|
100
|
+
return vendorNameMatch || memoMatch || lineItemMatch;
|
|
76
101
|
});
|
|
77
|
-
|
|
78
|
-
const
|
|
102
|
+
// Step 2: Convert to TransactionView and apply advanced filters
|
|
103
|
+
const transactionViews = transactionsAfterSearch.map((transaction) => {
|
|
104
|
+
const localData = transactionLocalDataMap.get(transaction.id);
|
|
105
|
+
return (0, exports.toTransactionView)(transaction, localData);
|
|
106
|
+
});
|
|
107
|
+
// Apply advanced filters if they exist
|
|
108
|
+
const filteredTransactionViews = (0, spendManagementFilterHelpers_1.applyAdvancedFiltersOnList)('transaction_categorization', transactionViews, filters);
|
|
109
|
+
// Convert back to TransactionWithCOT for return
|
|
110
|
+
const filteredTransactionsWithCOT = filteredTransactionViews.map((view) => view.transaction);
|
|
111
|
+
// Get transactionLocalData for filtered transactions
|
|
112
|
+
// Also include transactionLocalData for transactions that don't exist in transactionState
|
|
113
|
+
// but have local data (to match original behavior)
|
|
114
|
+
const filteredTransactionIds = new Set(filteredTransactionViews.map((view) => view.id));
|
|
115
|
+
const filteredTransactionLocalData = transactionIds
|
|
116
|
+
.map((transactionId) => {
|
|
117
|
+
const transactionData = transactionReviewLocalDataById[transactionId];
|
|
118
|
+
if (transactionData == null) {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
// Include if transaction is in filtered results, or if transaction doesn't exist in state
|
|
122
|
+
// (to maintain backward compatibility with tests)
|
|
123
|
+
const transactionExists = transactions.some((t) => t.id === transactionId);
|
|
124
|
+
if (filteredTransactionIds.has(transactionId) ||
|
|
125
|
+
!transactionExists) {
|
|
126
|
+
return {
|
|
127
|
+
transactionId,
|
|
128
|
+
transactionReviewLocalData: transactionData.transactionReviewLocalData,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
return null;
|
|
132
|
+
})
|
|
133
|
+
.filter((data) => data != null);
|
|
79
134
|
const fetchStatus = (0, reduceFetchState_1.reduceAllFetchState)([
|
|
80
135
|
accountList,
|
|
81
136
|
classList,
|
|
@@ -112,7 +167,7 @@ function getExpenseAutomationTransactionView(state) {
|
|
|
112
167
|
version: 0,
|
|
113
168
|
fetchState: fetchStatus.fetchState,
|
|
114
169
|
error: fetchStatus.error,
|
|
115
|
-
transactions:
|
|
170
|
+
transactions: filteredTransactionsWithCOT,
|
|
116
171
|
selectedCheckBoxTransactionIds,
|
|
117
172
|
transactionIdsWithUnsavedData,
|
|
118
173
|
uncategorizedAccounts: uncategorizedIncomeExpense,
|
|
@@ -121,7 +176,7 @@ function getExpenseAutomationTransactionView(state) {
|
|
|
121
176
|
classList: allClasses,
|
|
122
177
|
accountsHierarchyList,
|
|
123
178
|
classHierarchyList,
|
|
124
|
-
transactionLocalData,
|
|
179
|
+
transactionLocalData: filteredTransactionLocalData,
|
|
125
180
|
uiState,
|
|
126
181
|
refreshStatus,
|
|
127
182
|
saveStatus,
|
|
@@ -14,6 +14,7 @@ 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';
|
|
17
18
|
import { TransactionDetailKey } from '../../transactionDetail/transactionDetailState';
|
|
18
19
|
export declare const toTransactionsSortKey: (v: string) => "date" | "vendor" | "amount" | "category" | "class" | "memo" | "transaction_type";
|
|
19
20
|
export type TransactionsSortKey = ReturnType<typeof toTransactionsSortKey>;
|
|
@@ -89,6 +90,7 @@ export interface SupportedTransactionCategorization {
|
|
|
89
90
|
}
|
|
90
91
|
export declare const initialSupportedTransactionCategorization: SupportedTransactionCategorization;
|
|
91
92
|
export interface TransactionsTabViewState extends FetchedState {
|
|
93
|
+
filters: TransactionFilters;
|
|
92
94
|
markAsNotMiscategorizedStatus: FetchStateAndError;
|
|
93
95
|
refreshStatus: FetchStateAndError;
|
|
94
96
|
saveStatus: FetchStateAndError;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
+
import { Amount } from '../../commonStateTypes/amount';
|
|
2
|
+
import { ID } from '../../commonStateTypes/common';
|
|
1
3
|
import { TimePeriod } from '../../commonStateTypes/timePeriod';
|
|
2
4
|
import { UserRoleType } from '../../entity/userRole/userRoleType';
|
|
3
5
|
import { RootState } from '../../reducer';
|
|
4
6
|
import { ZeniDate } from '../../zeniDayJS';
|
|
5
7
|
import { TaskListFilterCategoryField, TaskListFilters } from '../taskManager/taskListView/taskList';
|
|
6
8
|
import { TaskWithUserDetails } from '../taskManager/taskListView/taskListSelector';
|
|
9
|
+
import { SupportedTransactionWithCOT } from '../../entity/transaction/transactionState';
|
|
10
|
+
import { TransactionType } from '../../entity/transaction/stateTypes/transactionType';
|
|
11
|
+
import { TransactionReviewLocalDataSelectorView } from '../expenseAutomationView/selectorTypes/transactionsViewSelectorTypes';
|
|
7
12
|
import { BillTransactionView } from './billPay/billList/billListSelector';
|
|
8
13
|
import { BillListViewFilterCategoryField, BillPayFilters } from './billPay/billList/billListState';
|
|
9
14
|
import { ReimbursementView } from './reimbursement/remiListView/remiListSelector';
|
|
@@ -50,8 +55,24 @@ export interface TransactionFilterCategory {
|
|
|
50
55
|
values: (string | ZeniDate)[];
|
|
51
56
|
valuesCombinationOperator: 'ANY';
|
|
52
57
|
}
|
|
58
|
+
export interface TransactionView {
|
|
59
|
+
amount: Amount;
|
|
60
|
+
createTime: ZeniDate;
|
|
61
|
+
date: ZeniDate;
|
|
62
|
+
description: string;
|
|
63
|
+
id: ID;
|
|
64
|
+
memo: string;
|
|
65
|
+
transaction: SupportedTransactionWithCOT;
|
|
66
|
+
type: TransactionType;
|
|
67
|
+
customerId?: ID;
|
|
68
|
+
customerName?: string;
|
|
69
|
+
transactionLocalData?: TransactionReviewLocalDataSelectorView;
|
|
70
|
+
typeName?: string;
|
|
71
|
+
vendorId?: ID;
|
|
72
|
+
vendorName?: string;
|
|
73
|
+
}
|
|
53
74
|
export type FilterCategoryValueType = string | number | ZeniDate;
|
|
54
|
-
export declare const applyAdvancedFiltersOnList: (entity: SpendManagementFilterEntityType, allItems: BillTransactionView[] | ReimbursementView[] | TaskWithUserDetails[], filters?: BillPayFilters | ReimbursementFilters | TaskListFilters, filteredItems?: (BillTransactionView | ReimbursementView | TaskWithUserDetails)[], index?: number) => (BillTransactionView | ReimbursementView | TaskWithUserDetails)[];
|
|
75
|
+
export declare const applyAdvancedFiltersOnList: (entity: SpendManagementFilterEntityType, allItems: BillTransactionView[] | ReimbursementView[] | TaskWithUserDetails[] | TransactionView[], filters?: BillPayFilters | ReimbursementFilters | TaskListFilters | TransactionFilters, filteredItems?: (BillTransactionView | ReimbursementView | TaskWithUserDetails | TransactionView)[], index?: number) => (BillTransactionView | ReimbursementView | TaskWithUserDetails | TransactionView)[];
|
|
55
76
|
export declare const isBillListDownloadable: (state: RootState, currentTimePeriod: TimePeriod) => boolean;
|
|
56
77
|
export declare const isRemiListDownloadable: (state: RootState, currentTimePeriod: TimePeriod) => boolean;
|
|
57
78
|
export declare const hideCreatedByFilter: (userRole: UserRoleType[]) => boolean;
|
|
@@ -119,7 +119,11 @@ const applyAdvancedFiltersOnList = (entity, allItems, filters, filteredItems = [
|
|
|
119
119
|
? getCategoryValueForBill(key, item)
|
|
120
120
|
: entity === 'reimbursement'
|
|
121
121
|
? getCategoryValueForReimbursement(key, item)
|
|
122
|
-
:
|
|
122
|
+
: entity === 'task_management'
|
|
123
|
+
? getCategoryValueForTaskList(key, item)
|
|
124
|
+
: entity === 'transaction_categorization'
|
|
125
|
+
? getCategoryValueForTransaction(key, item)
|
|
126
|
+
: undefined;
|
|
123
127
|
if (categoryValue == null) {
|
|
124
128
|
if (currentFilter.matchingOperator === 'not-equal') {
|
|
125
129
|
return true;
|
|
@@ -139,6 +143,7 @@ const applyAdvancedFiltersOnList = (entity, allItems, filters, filteredItems = [
|
|
|
139
143
|
'dueDate',
|
|
140
144
|
'creationDate',
|
|
141
145
|
'receiptDate',
|
|
146
|
+
'date',
|
|
142
147
|
]);
|
|
143
148
|
}
|
|
144
149
|
});
|
|
@@ -242,6 +247,114 @@ const getCategoryValueForReimbursement = (key, reimbursement) => {
|
|
|
242
247
|
return undefined;
|
|
243
248
|
}
|
|
244
249
|
};
|
|
250
|
+
const getCategoryValueForTransaction = (key, transaction) => {
|
|
251
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
|
252
|
+
switch (key) {
|
|
253
|
+
case 'amount':
|
|
254
|
+
return transaction.amount.amount;
|
|
255
|
+
case 'payee': {
|
|
256
|
+
// Priority: vendorName > customerName > from transactionLocalData
|
|
257
|
+
if (transaction.vendorName) {
|
|
258
|
+
return transaction.vendorName;
|
|
259
|
+
}
|
|
260
|
+
if (transaction.customerName) {
|
|
261
|
+
return transaction.customerName;
|
|
262
|
+
}
|
|
263
|
+
// Check transactionLocalData for vendor/customer
|
|
264
|
+
const localData = (_a = transaction.transactionLocalData) === null || _a === void 0 ? void 0 : _a.transactionReviewLocalData;
|
|
265
|
+
if ((_b = localData === null || localData === void 0 ? void 0 : localData.vendor) === null || _b === void 0 ? void 0 : _b.name) {
|
|
266
|
+
return localData.vendor.name;
|
|
267
|
+
}
|
|
268
|
+
if ((_c = localData === null || localData === void 0 ? void 0 : localData.customer) === null || _c === void 0 ? void 0 : _c.name) {
|
|
269
|
+
return localData.customer.name;
|
|
270
|
+
}
|
|
271
|
+
return undefined;
|
|
272
|
+
}
|
|
273
|
+
case 'payment_account_name': {
|
|
274
|
+
// Get from transaction.account or from lines
|
|
275
|
+
if ((_d = transaction.transaction.account) === null || _d === void 0 ? void 0 : _d.accountName) {
|
|
276
|
+
return transaction.transaction.account.accountName;
|
|
277
|
+
}
|
|
278
|
+
// Get from first line's account
|
|
279
|
+
const firstLine = (_e = transaction.transaction.lines) === null || _e === void 0 ? void 0 : _e[0];
|
|
280
|
+
if ((firstLine === null || firstLine === void 0 ? void 0 : firstLine.type) === 'transaction_with_account_and_class_line' ||
|
|
281
|
+
(firstLine === null || firstLine === void 0 ? void 0 : firstLine.type) === 'transaction_with_product_or_service_line' ||
|
|
282
|
+
(firstLine === null || firstLine === void 0 ? void 0 : firstLine.type) === 'journal_entry_transaction_line') {
|
|
283
|
+
const accountLine = firstLine;
|
|
284
|
+
return (_f = accountLine.account) === null || _f === void 0 ? void 0 : _f.accountName;
|
|
285
|
+
}
|
|
286
|
+
return undefined;
|
|
287
|
+
}
|
|
288
|
+
case 'payment_account_type': {
|
|
289
|
+
// Similar to payment_account_name but for type
|
|
290
|
+
if ((_g = transaction.transaction.account) === null || _g === void 0 ? void 0 : _g.accountType) {
|
|
291
|
+
return transaction.transaction.account.accountType;
|
|
292
|
+
}
|
|
293
|
+
const firstLineForType = (_h = transaction.transaction.lines) === null || _h === void 0 ? void 0 : _h[0];
|
|
294
|
+
if ((firstLineForType === null || firstLineForType === void 0 ? void 0 : firstLineForType.type) === 'transaction_with_account_and_class_line' ||
|
|
295
|
+
(firstLineForType === null || firstLineForType === void 0 ? void 0 : firstLineForType.type) === 'transaction_with_product_or_service_line' ||
|
|
296
|
+
(firstLineForType === null || firstLineForType === void 0 ? void 0 : firstLineForType.type) === 'journal_entry_transaction_line') {
|
|
297
|
+
const accountLineForType = firstLineForType;
|
|
298
|
+
return (_j = accountLineForType.account) === null || _j === void 0 ? void 0 : _j.accountType;
|
|
299
|
+
}
|
|
300
|
+
return undefined;
|
|
301
|
+
}
|
|
302
|
+
case 'category': {
|
|
303
|
+
// Get from transactionLocalData (preferred) or from transaction lines
|
|
304
|
+
const localDataForCategory = (_k = transaction.transactionLocalData) === null || _k === void 0 ? void 0 : _k.transactionReviewLocalData;
|
|
305
|
+
if (localDataForCategory) {
|
|
306
|
+
// Get category from first line item or most common
|
|
307
|
+
const firstLineItem = Object.values(localDataForCategory.lineItemById)[0];
|
|
308
|
+
if ((_l = firstLineItem === null || firstLineItem === void 0 ? void 0 : firstLineItem.account) === null || _l === void 0 ? void 0 : _l.accountId) {
|
|
309
|
+
return firstLineItem.account.accountId;
|
|
310
|
+
}
|
|
311
|
+
if ((_m = firstLineItem === null || firstLineItem === void 0 ? void 0 : firstLineItem.account) === null || _m === void 0 ? void 0 : _m.qboId) {
|
|
312
|
+
return firstLineItem.account.qboId;
|
|
313
|
+
}
|
|
314
|
+
if ((_o = firstLineItem === null || firstLineItem === void 0 ? void 0 : firstLineItem.account) === null || _o === void 0 ? void 0 : _o.accountName) {
|
|
315
|
+
return firstLineItem.account.accountName;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
// Fallback to transaction lines
|
|
319
|
+
const firstLineForCategory = (_p = transaction.transaction.lines) === null || _p === void 0 ? void 0 : _p[0];
|
|
320
|
+
if ((firstLineForCategory === null || firstLineForCategory === void 0 ? void 0 : firstLineForCategory.type) === 'transaction_with_account_and_class_line' ||
|
|
321
|
+
(firstLineForCategory === null || firstLineForCategory === void 0 ? void 0 : firstLineForCategory.type) === 'transaction_with_product_or_service_line' ||
|
|
322
|
+
(firstLineForCategory === null || firstLineForCategory === void 0 ? void 0 : firstLineForCategory.type) === 'journal_entry_transaction_line') {
|
|
323
|
+
const account = firstLineForCategory
|
|
324
|
+
.account;
|
|
325
|
+
return (_r = (_q = account === null || account === void 0 ? void 0 : account.accountId) !== null && _q !== void 0 ? _q : account === null || account === void 0 ? void 0 : account.qboId) !== null && _r !== void 0 ? _r : account === null || account === void 0 ? void 0 : account.accountName;
|
|
326
|
+
}
|
|
327
|
+
return undefined;
|
|
328
|
+
}
|
|
329
|
+
case 'class': {
|
|
330
|
+
// Similar to category but for class
|
|
331
|
+
const localDataForClass = (_s = transaction.transactionLocalData) === null || _s === void 0 ? void 0 : _s.transactionReviewLocalData;
|
|
332
|
+
if (localDataForClass) {
|
|
333
|
+
const firstLineItemForClass = Object.values(localDataForClass.lineItemById)[0];
|
|
334
|
+
if ((_t = firstLineItemForClass === null || firstLineItemForClass === void 0 ? void 0 : firstLineItemForClass.class) === null || _t === void 0 ? void 0 : _t.classId) {
|
|
335
|
+
return firstLineItemForClass.class.classId;
|
|
336
|
+
}
|
|
337
|
+
if ((_u = firstLineItemForClass === null || firstLineItemForClass === void 0 ? void 0 : firstLineItemForClass.class) === null || _u === void 0 ? void 0 : _u.qboId) {
|
|
338
|
+
return firstLineItemForClass.class.qboId;
|
|
339
|
+
}
|
|
340
|
+
if ((_v = firstLineItemForClass === null || firstLineItemForClass === void 0 ? void 0 : firstLineItemForClass.class) === null || _v === void 0 ? void 0 : _v.className) {
|
|
341
|
+
return firstLineItemForClass.class.className;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
const firstLineForClass = (_w = transaction.transaction.lines) === null || _w === void 0 ? void 0 : _w[0];
|
|
345
|
+
if ((firstLineForClass === null || firstLineForClass === void 0 ? void 0 : firstLineForClass.type) === 'transaction_with_account_and_class_line' ||
|
|
346
|
+
(firstLineForClass === null || firstLineForClass === void 0 ? void 0 : firstLineForClass.type) === 'transaction_with_product_or_service_line' ||
|
|
347
|
+
(firstLineForClass === null || firstLineForClass === void 0 ? void 0 : firstLineForClass.type) === 'journal_entry_transaction_line') {
|
|
348
|
+
const classData = firstLineForClass
|
|
349
|
+
.class;
|
|
350
|
+
return (_y = (_x = classData === null || classData === void 0 ? void 0 : classData.classId) !== null && _x !== void 0 ? _x : classData === null || classData === void 0 ? void 0 : classData.qboId) !== null && _y !== void 0 ? _y : classData === null || classData === void 0 ? void 0 : classData.className;
|
|
351
|
+
}
|
|
352
|
+
return undefined;
|
|
353
|
+
}
|
|
354
|
+
default:
|
|
355
|
+
return undefined;
|
|
356
|
+
}
|
|
357
|
+
};
|
|
245
358
|
const isBillListDownloadable = (state, currentTimePeriod) => {
|
|
246
359
|
const { billListState, billTransactionState, entityApprovalStatusState, userState, } = state;
|
|
247
360
|
const keys = billListState_1.ALL_BILL_TABS.filter((tab) => tab !== 'draft').map((tab) => (0, billListState_1.getBillListKey)(currentTimePeriod, tab));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "4.19.24-
|
|
3
|
+
"version": "4.19.24-betaAR13",
|
|
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
|
"types": "lib/index.d.ts",
|