@zeniai/client-epic-state 4.13.81 → 4.13.82
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/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationViewEpic.js +2 -2
- package/lib/view/expenseAutomationView/epics/transactionCategorization/initializeTransactionCategorizationLocalDataEpic.js +9 -4
- package/lib/view/expenseAutomationView/reducers/fluxAnalysisViewReducer.js +1 -0
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +4 -2
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +25 -9
- package/lib/view/expenseAutomationView/selectors/fluxAnalysisViewSelector.js +18 -5
- package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +1 -0
- package/lib/view/expenseAutomationView/types/transactionsViewState.js +1 -0
- package/package.json +1 -1
|
@@ -9,7 +9,7 @@ const classListReducer_1 = require("../../../classList/classListReducer");
|
|
|
9
9
|
const timePeriod_1 = require("../../../../commonStateTypes/timePeriod");
|
|
10
10
|
const fetchTransactionCategorizationViewEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(transactionsViewReducer_1.fetchTransactionCategorizationView.match), (0, operators_1.mergeMap)((action) => {
|
|
11
11
|
var _a;
|
|
12
|
-
const { selectedTab, cacheOverride, keepExistingListItems, pageToken, period, refreshViewInBackground, searchString, } = action.payload;
|
|
12
|
+
const { selectedTab, cacheOverride, keepExistingListItems, pageToken, period, refreshViewInBackground, searchString, resetListItems, } = action.payload;
|
|
13
13
|
const updateActions = [];
|
|
14
14
|
const { expenseAutomationTransactionsViewState } = state$.value;
|
|
15
15
|
const { fetchState, transactionIdsBySelectedPeriod } = expenseAutomationTransactionsViewState[selectedTab];
|
|
@@ -31,7 +31,7 @@ const fetchTransactionCategorizationViewEpic = (actions$, state$) => actions$.pi
|
|
|
31
31
|
if (cacheOverride === true ||
|
|
32
32
|
fetchState === 'Not-Started' ||
|
|
33
33
|
transactionIds.length === 0) {
|
|
34
|
-
updateActions.push((0, transactionsViewReducer_1.fetchTransactionCategorization)(selectedTab, period, cacheOverride, keepExistingListItems, searchString, pageToken, refreshViewInBackground));
|
|
34
|
+
updateActions.push((0, transactionsViewReducer_1.fetchTransactionCategorization)(selectedTab, period, cacheOverride, keepExistingListItems, searchString, pageToken, refreshViewInBackground, resetListItems));
|
|
35
35
|
}
|
|
36
36
|
return (0, rxjs_1.from)(updateActions);
|
|
37
37
|
}));
|
|
@@ -10,18 +10,23 @@ const transactionCategorizationLocalDataHelper_1 = require("../../helpers/transa
|
|
|
10
10
|
const initializeTransactionCategorizationViewLocalDataEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(transactionsViewReducer_1.initializeTransactionCategorizationViewLocalData.match), (0, operators_1.mergeMap)((action) => {
|
|
11
11
|
const { transactionIds, selectedPeriod, keepExistingListItems, selectedTab, pageToken, totalCount, refreshViewInBackground, } = action.payload;
|
|
12
12
|
const fetchActions = [];
|
|
13
|
-
const { transactionState } = state$.value;
|
|
14
|
-
const
|
|
13
|
+
const { transactionState, expenseAutomationTransactionsViewState, expenseAutomationViewState, } = state$.value;
|
|
14
|
+
const { selectedTransactionCategorizationTab } = expenseAutomationViewState;
|
|
15
|
+
const { transactionReviewLocalDataById } = expenseAutomationTransactionsViewState[selectedTransactionCategorizationTab];
|
|
16
|
+
const transactionLocalData = Object.assign({}, transactionReviewLocalDataById);
|
|
15
17
|
const transactions = (0, transactionSelector_1.getSupportedTransactionsByIds)(transactionState, transactionIds);
|
|
16
18
|
transactions.forEach((transaction) => {
|
|
19
|
+
var _a, _b, _c, _d;
|
|
20
|
+
const newTransactionsLocalData = (0, transactionCategorizationLocalDataHelper_1.toTransactionDetailLocalData)(transaction);
|
|
17
21
|
if (transactionLocalData[transaction.id] == null) {
|
|
18
|
-
transactionLocalData[transaction.id] = Object.assign(Object.assign({}, transactionsViewState_1.initialSupportedTransactionCategorization), { transactionId: transaction.id, transactionReviewLocalData: Object.assign({}, (0
|
|
22
|
+
transactionLocalData[transaction.id] = Object.assign(Object.assign({}, transactionsViewState_1.initialSupportedTransactionCategorization), { transactionId: transaction.id, transactionReviewLocalData: Object.assign(Object.assign({}, newTransactionsLocalData), { sortedLineItems: (_b = (_a = transaction.lines) === null || _a === void 0 ? void 0 : _a.map((line) => line.id)) !== null && _b !== void 0 ? _b : [] }) });
|
|
19
23
|
}
|
|
20
24
|
else {
|
|
21
25
|
transactionLocalData[transaction.id] = {
|
|
22
26
|
transactionId: transaction.id,
|
|
23
27
|
transactionReviewLocalData: Object.assign(Object.assign({}, transactionLocalData[transaction.id]
|
|
24
|
-
.transactionReviewLocalData), (
|
|
28
|
+
.transactionReviewLocalData), Object.assign(Object.assign({}, newTransactionsLocalData), { lineItemById: Object.assign(Object.assign({}, transactionLocalData[transaction.id]
|
|
29
|
+
.transactionReviewLocalData.lineItemById), newTransactionsLocalData.lineItemById), sortedLineItems: transactionLocalData[transaction.id].transactionReviewLocalData.sortedLineItems.concat((_d = (_c = transaction.lines) === null || _c === void 0 ? void 0 : _c.map((line) => line.id)) !== null && _d !== void 0 ? _d : []) })),
|
|
25
30
|
};
|
|
26
31
|
}
|
|
27
32
|
});
|
|
@@ -49,6 +49,7 @@ const expenseAutomationFluxAnalysisView = (0, toolkit_1.createSlice)({
|
|
|
49
49
|
draft.fetchState = 'In-Progress';
|
|
50
50
|
draft.error = undefined;
|
|
51
51
|
}
|
|
52
|
+
// Reset list when we change the sort order and fetch list again
|
|
52
53
|
if (resetListItems === true) {
|
|
53
54
|
draft.operatingExpenseIdsBySelectedPeriod[(0, timePeriod_1.toMonthYearPeriodId)(monthAndYear)] = [];
|
|
54
55
|
draft.reviewOperatingExpensesIds = [];
|
|
@@ -13,7 +13,7 @@ import { UpdateTransactionCategorization } from '../payload/transactionCategoriz
|
|
|
13
13
|
import { RecommendationByLineId, TransactionID } from '../../../entity/transaction/stateTypes/transaction';
|
|
14
14
|
export declare const initialTransactionTabViewState: TransactionsTabViewState;
|
|
15
15
|
export declare const initialState: TransactionsViewState;
|
|
16
|
-
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], {
|
|
16
|
+
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], {
|
|
17
17
|
selectedTab: "review" | "autoCategorized";
|
|
18
18
|
period: TimePeriod;
|
|
19
19
|
searchString: string | undefined;
|
|
@@ -21,6 +21,7 @@ export declare const fetchTransactionCategorization: import("@reduxjs/toolkit").
|
|
|
21
21
|
pageToken: PageToken | undefined;
|
|
22
22
|
cacheOverride: any;
|
|
23
23
|
refreshViewInBackground: any;
|
|
24
|
+
resetListItems: boolean | undefined;
|
|
24
25
|
}, string, never, never>, updateTransactionCategorizationUIState: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
25
26
|
selectedTab: TransactionsTab;
|
|
26
27
|
uiState: Partial<TransactionsViewUIState>;
|
|
@@ -89,7 +90,7 @@ export declare const fetchTransactionCategorization: import("@reduxjs/toolkit").
|
|
|
89
90
|
status: ZeniAPIStatus;
|
|
90
91
|
selectedTab: TransactionsTab;
|
|
91
92
|
refreshViewInBackground?: boolean | undefined;
|
|
92
|
-
}, string>, fetchTransactionCategorizationView: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[selectedTab: "review" | "autoCategorized", period: TimePeriod, cacheOverride?: any, keepExistingListItems?: any, searchString?: string | undefined, pageToken?: PageToken | undefined, refreshViewInBackground?: any], {
|
|
93
|
+
}, string>, fetchTransactionCategorizationView: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[selectedTab: "review" | "autoCategorized", period: TimePeriod, cacheOverride?: any, keepExistingListItems?: any, searchString?: string | undefined, pageToken?: PageToken | undefined, refreshViewInBackground?: any, resetListItems?: any], {
|
|
93
94
|
selectedTab: "review" | "autoCategorized";
|
|
94
95
|
period: TimePeriod;
|
|
95
96
|
searchString: string | undefined;
|
|
@@ -97,6 +98,7 @@ export declare const fetchTransactionCategorization: import("@reduxjs/toolkit").
|
|
|
97
98
|
pageToken: PageToken | undefined;
|
|
98
99
|
cacheOverride: any;
|
|
99
100
|
refreshViewInBackground: any;
|
|
101
|
+
resetListItems: any;
|
|
100
102
|
}, string, never, never>, updateSelectedCheckboxTransactionIds: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
101
103
|
selectedTab: TransactionsTab;
|
|
102
104
|
transactionIds: ID[];
|
|
@@ -53,7 +53,7 @@ const expenseAutomationTransactionsView = (0, toolkit_1.createSlice)({
|
|
|
53
53
|
reducers: {
|
|
54
54
|
fetchTransactionCategorizationView: {
|
|
55
55
|
prepare(selectedTab, period, cacheOverride = false, keepExistingListItems = false, searchString, // when this is defined the output should go to search result IDs
|
|
56
|
-
pageToken, refreshViewInBackground = false) {
|
|
56
|
+
pageToken, refreshViewInBackground = false, resetListItems = false) {
|
|
57
57
|
return {
|
|
58
58
|
payload: {
|
|
59
59
|
selectedTab,
|
|
@@ -63,6 +63,7 @@ const expenseAutomationTransactionsView = (0, toolkit_1.createSlice)({
|
|
|
63
63
|
pageToken,
|
|
64
64
|
cacheOverride,
|
|
65
65
|
refreshViewInBackground,
|
|
66
|
+
resetListItems,
|
|
66
67
|
},
|
|
67
68
|
};
|
|
68
69
|
},
|
|
@@ -72,9 +73,7 @@ const expenseAutomationTransactionsView = (0, toolkit_1.createSlice)({
|
|
|
72
73
|
},
|
|
73
74
|
fetchTransactionCategorization: {
|
|
74
75
|
reducer(draft, action) {
|
|
75
|
-
|
|
76
|
-
const { refreshViewInBackground } = action.payload;
|
|
77
|
-
const selectedTab = action.payload.selectedTab;
|
|
76
|
+
const { refreshViewInBackground, resetListItems, selectedTab, pageToken, searchString, period, } = action.payload;
|
|
78
77
|
if (refreshViewInBackground === true) {
|
|
79
78
|
draft[selectedTab].refreshStatus = {
|
|
80
79
|
fetchState: 'In-Progress',
|
|
@@ -86,20 +85,36 @@ const expenseAutomationTransactionsView = (0, toolkit_1.createSlice)({
|
|
|
86
85
|
draft[selectedTab].error = undefined;
|
|
87
86
|
}
|
|
88
87
|
// Note: Need to reset scroll position whenever a new fetch happens, except when fetching through scroll
|
|
89
|
-
if (
|
|
88
|
+
if (pageToken == null) {
|
|
90
89
|
// Page Token is null in each fetch except when fetching through scroll
|
|
91
90
|
draft[selectedTab].uiState.scrollPosition = {
|
|
92
91
|
scrollTop: 0,
|
|
93
92
|
scrollLeft: undefined,
|
|
94
93
|
};
|
|
95
94
|
}
|
|
96
|
-
draft[selectedTab].uiState.pageToken =
|
|
97
|
-
draft[selectedTab].uiState.searchString =
|
|
98
|
-
(_b = action.payload.searchString) !== null && _b !== void 0 ? _b : '';
|
|
95
|
+
draft[selectedTab].uiState.pageToken = pageToken !== null && pageToken !== void 0 ? pageToken : null;
|
|
96
|
+
draft[selectedTab].uiState.searchString = searchString !== null && searchString !== void 0 ? searchString : '';
|
|
99
97
|
draft[selectedTab].error = undefined;
|
|
98
|
+
// Reset list when we change the sort order and fetch list again
|
|
99
|
+
if (resetListItems === true) {
|
|
100
|
+
const monthYearPeriod = {
|
|
101
|
+
month: period.start.month,
|
|
102
|
+
year: period.start.year,
|
|
103
|
+
};
|
|
104
|
+
const transactionIdsBySelectedPeriod = draft[selectedTab].transactionIdsBySelectedPeriod[(0, timePeriod_1.toMonthYearPeriodId)(monthYearPeriod)];
|
|
105
|
+
transactionIdsBySelectedPeriod.forEach((transactionId) => {
|
|
106
|
+
delete draft[selectedTab].transactionReviewLocalDataById[transactionId];
|
|
107
|
+
});
|
|
108
|
+
draft[selectedTab].selectedCheckBoxTransactionIds = draft[selectedTab].selectedCheckBoxTransactionIds.filter((selectedCheckBoxTransactionId) => transactionIdsBySelectedPeriod.includes(selectedCheckBoxTransactionId));
|
|
109
|
+
draft[selectedTab].transactionIdsBySelectedPeriod[(0, timePeriod_1.toMonthYearPeriodId)(monthYearPeriod)] = [];
|
|
110
|
+
draft[selectedTab].refreshStatus = {
|
|
111
|
+
fetchState: 'Not-Started',
|
|
112
|
+
error: undefined,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
100
115
|
},
|
|
101
116
|
prepare(selectedTab, period, cacheOverride = false, keepExistingListItems = false, searchString, // when this is defined the output should go to search result IDs
|
|
102
|
-
pageToken, refreshViewInBackground = false) {
|
|
117
|
+
pageToken, refreshViewInBackground = false, resetListItems) {
|
|
103
118
|
return {
|
|
104
119
|
payload: {
|
|
105
120
|
selectedTab,
|
|
@@ -109,6 +124,7 @@ const expenseAutomationTransactionsView = (0, toolkit_1.createSlice)({
|
|
|
109
124
|
pageToken,
|
|
110
125
|
cacheOverride,
|
|
111
126
|
refreshViewInBackground,
|
|
127
|
+
resetListItems,
|
|
112
128
|
},
|
|
113
129
|
};
|
|
114
130
|
},
|
|
@@ -7,8 +7,10 @@ const userSelector_1 = require("../../../entity/user/userSelector");
|
|
|
7
7
|
const vendorSelector_1 = require("../../../entity/vendor/vendorSelector");
|
|
8
8
|
const tenantSelector_1 = require("../../../entity/tenant/tenantSelector");
|
|
9
9
|
const timePeriod_1 = require("../../../commonStateTypes/timePeriod");
|
|
10
|
+
const expenseAutomationViewSelectorTypes_1 = require("../selectorTypes/expenseAutomationViewSelectorTypes");
|
|
10
11
|
function getExpenseAutomationFluxAnalysisView(state) {
|
|
11
|
-
|
|
12
|
+
var _a;
|
|
13
|
+
const { expenseAutomationFluxAnalysisViewState, monthEndCloseChecksState } = state;
|
|
12
14
|
const { fetchState, error, refreshStatus, uiState, reviewOperatingExpensesIds, reviewStatusById, fluxAnalysisEntities, operatingExpenseIdsBySelectedPeriod, bulkReviewStatus, } = expenseAutomationFluxAnalysisViewState;
|
|
13
15
|
const fetchStateAndError = {
|
|
14
16
|
fetchState,
|
|
@@ -28,6 +30,10 @@ function getExpenseAutomationFluxAnalysisView(state) {
|
|
|
28
30
|
operatingExpenses.push(fluxEntity);
|
|
29
31
|
}
|
|
30
32
|
});
|
|
33
|
+
const allSteps = monthYearPeriodId != null
|
|
34
|
+
? (0, expenseAutomationViewSelectorTypes_1.getAllSteps)(monthEndCloseChecksState, monthYearPeriodId, currentTenant.tenantId)
|
|
35
|
+
: [];
|
|
36
|
+
const fluxCompletionStatus = (_a = allSteps.find((step) => step.step === 'flux_analysis')) === null || _a === void 0 ? void 0 : _a.completionStatus;
|
|
31
37
|
const operatingExpensesView = [];
|
|
32
38
|
operatingExpenses.forEach((operatingExpense) => {
|
|
33
39
|
const vendor = (0, vendorSelector_1.getVendorByVendorId)(state.vendorState, operatingExpense.vendorId);
|
|
@@ -57,6 +63,16 @@ function getExpenseAutomationFluxAnalysisView(state) {
|
|
|
57
63
|
});
|
|
58
64
|
}
|
|
59
65
|
});
|
|
66
|
+
const allOperatingExpensesReviewed = operatingExpensesView.filter((operatingExpense) => operatingExpense.status === 'Pending Review').length === 0;
|
|
67
|
+
const isFetchStateCompleted = fetchStateAndError.fetchState === 'Completed';
|
|
68
|
+
// If all operating expenses are fetched and reviewed, then the bulk review status should be 'complete'
|
|
69
|
+
// If there are no operating expenses (after fetch state is completed), then the bulk review status should be 'complete'
|
|
70
|
+
// If the flux analysis is complete and all operating expenses are reviewed (in our state), then the bulk review status should be 'complete'
|
|
71
|
+
const completionStatus = (isFetchStateCompleted && allOperatingExpensesReviewed) ||
|
|
72
|
+
(isFetchStateCompleted && operatingExpensesView.length === 0) ||
|
|
73
|
+
(fluxCompletionStatus === 'complete' && allOperatingExpensesReviewed)
|
|
74
|
+
? 'complete'
|
|
75
|
+
: 'incomplete';
|
|
60
76
|
return {
|
|
61
77
|
fetchStatus: fetchStateAndError,
|
|
62
78
|
operatingExpensesView,
|
|
@@ -64,10 +80,7 @@ function getExpenseAutomationFluxAnalysisView(state) {
|
|
|
64
80
|
reviewOperatingExpensesIds,
|
|
65
81
|
uiState,
|
|
66
82
|
refreshStatus,
|
|
67
|
-
completionStatus
|
|
68
|
-
fetchStateAndError.fetchState === 'Completed'
|
|
69
|
-
? 'complete'
|
|
70
|
-
: 'incomplete',
|
|
83
|
+
completionStatus,
|
|
71
84
|
};
|
|
72
85
|
}
|
|
73
86
|
exports.getExpenseAutomationFluxAnalysisView = getExpenseAutomationFluxAnalysisView;
|
|
@@ -58,6 +58,7 @@ export interface TransactionCategorizationLineItemData extends TransactionLineBa
|
|
|
58
58
|
}
|
|
59
59
|
export interface TransactionReviewLocalData {
|
|
60
60
|
lineItemById: Record<ID, TransactionCategorizationLineItemData>;
|
|
61
|
+
sortedLineItems: ID[];
|
|
61
62
|
vendor?: VendorBase;
|
|
62
63
|
memo?: string;
|
|
63
64
|
vendorDetails?: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "4.13.
|
|
3
|
+
"version": "4.13.82",
|
|
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",
|