@zeniai/client-epic-state 4.13.78 → 4.13.80
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/view/commonVendorView/vendorView/epics/saveVendorEpic.js +4 -0
- 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 +26 -16
- package/lib/view/expenseAutomationView/selectors/fluxAnalysisViewSelector.js +5 -2
- package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +1 -0
- package/lib/view/expenseAutomationView/types/transactionsViewState.js +1 -0
- package/package.json +1 -1
|
@@ -85,6 +85,10 @@ const saveVendorEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operator
|
|
|
85
85
|
amount: 0,
|
|
86
86
|
currencyCode: vendorCurrencyCode,
|
|
87
87
|
currencySymbol: vendorCurrencySymbol,
|
|
88
|
+
}, recipientAmount: {
|
|
89
|
+
amount: 0,
|
|
90
|
+
currencyCode: vendorCurrencyCode,
|
|
91
|
+
currencySymbol: vendorCurrencySymbol,
|
|
88
92
|
}, id: '1', lineDescription: '', platformLineDetailType: 'account_based_expense_line_detail', type: 'transaction_with_account_and_class_line', billable: 'not_billable', isCategoryMiscategorized: false, isClassMiscategorized: false }, editBillViewState_1.defaultRecommendationStateObj);
|
|
89
93
|
}
|
|
90
94
|
}
|
|
@@ -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
|
},
|
|
@@ -219,13 +235,7 @@ const expenseAutomationTransactionsView = (0, toolkit_1.createSlice)({
|
|
|
219
235
|
const { vendorId, selectedAccount, selectedClassBase, transactions, transactionId, lineId, selectedTab, } = action.payload;
|
|
220
236
|
const transactionLocalData = (0, get_1.default)(draft[selectedTab].transactionReviewLocalDataById, transactionId, undefined);
|
|
221
237
|
if (transactionLocalData != null) {
|
|
222
|
-
const newTransactionLocalData = Object.assign(Object.assign({}, transactionLocalData.transactionReviewLocalData), { lineItemById: Object.assign(Object.assign({}, transactionLocalData.transactionReviewLocalData.lineItemById), { [lineId]: Object.assign(Object.assign({}, transactionLocalData.transactionReviewLocalData.lineItemById[lineId]), { account: selectedAccount
|
|
223
|
-
? selectedAccount
|
|
224
|
-
: transactionLocalData.transactionReviewLocalData
|
|
225
|
-
.lineItemById[lineId].account, class: selectedClassBase != null
|
|
226
|
-
? selectedClassBase
|
|
227
|
-
: transactionLocalData.transactionReviewLocalData
|
|
228
|
-
.lineItemById[lineId].class }) }) });
|
|
238
|
+
const newTransactionLocalData = Object.assign(Object.assign({}, transactionLocalData.transactionReviewLocalData), { lineItemById: Object.assign(Object.assign({}, transactionLocalData.transactionReviewLocalData.lineItemById), { [lineId]: Object.assign(Object.assign({}, transactionLocalData.transactionReviewLocalData.lineItemById[lineId]), { account: selectedAccount, class: selectedClassBase }) }) });
|
|
229
239
|
draft[selectedTab].transactionReviewLocalDataById[transactionId] = {
|
|
230
240
|
transactionReviewLocalData: newTransactionLocalData,
|
|
231
241
|
transactionId,
|
|
@@ -57,6 +57,8 @@ function getExpenseAutomationFluxAnalysisView(state) {
|
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
|
+
const isReviewCompleted = fetchStateAndError.fetchState === 'Completed' &&
|
|
61
|
+
operatingExpensesView.filter((operatingExpense) => operatingExpense.status === 'Pending Review').length === 0;
|
|
60
62
|
return {
|
|
61
63
|
fetchStatus: fetchStateAndError,
|
|
62
64
|
operatingExpensesView,
|
|
@@ -64,8 +66,9 @@ function getExpenseAutomationFluxAnalysisView(state) {
|
|
|
64
66
|
reviewOperatingExpensesIds,
|
|
65
67
|
uiState,
|
|
66
68
|
refreshStatus,
|
|
67
|
-
completionStatus:
|
|
68
|
-
|
|
69
|
+
completionStatus: (fetchStateAndError.fetchState === 'Completed' &&
|
|
70
|
+
operatingExpensesView.length === 0) ||
|
|
71
|
+
isReviewCompleted
|
|
69
72
|
? 'complete'
|
|
70
73
|
: 'incomplete',
|
|
71
74
|
};
|
|
@@ -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.80",
|
|
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",
|