@zeniai/client-epic-state 5.1.20 → 5.1.21-betaRD2
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/transaction/payloadTypes/customerTransactionPayload.js +1 -1
- package/lib/epic.d.ts +2 -1
- package/lib/epic.js +2 -1
- package/lib/esm/entity/transaction/payloadTypes/customerTransactionPayload.js +2 -2
- package/lib/esm/epic.js +2 -1
- package/lib/esm/index.js +2 -2
- package/lib/esm/view/expenseAutomationView/epics/fluxAnalysis/fetchFluxAnalysisViewEpic.js +1 -0
- package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.js +49 -11
- package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationViewEpic.js +30 -3
- package/lib/esm/view/expenseAutomationView/reducers/fluxAnalysisViewReducer.js +6 -1
- package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +37 -17
- package/lib/esm/view/expenseAutomationView/selectors/fluxAnalysisViewSelector.js +2 -1
- package/lib/esm/view/opExByVendor/opExByVendorReducer.js +28 -5
- package/lib/esm/view/opExByVendor/opExByVendorSelector.js +1 -0
- package/lib/esm/view/opExByVendor/refreshOpExByVendorReportEpic.js +21 -0
- package/lib/index.d.ts +2 -2
- package/lib/index.js +34 -33
- package/lib/view/expenseAutomationView/epics/fluxAnalysis/fetchFluxAnalysisViewEpic.js +1 -0
- package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.js +47 -9
- package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationViewEpic.js +30 -3
- package/lib/view/expenseAutomationView/payload/fluxAnalysisPayload.d.ts +8 -0
- package/lib/view/expenseAutomationView/payload/transactionCategorizationPayload.d.ts +7 -0
- package/lib/view/expenseAutomationView/reducers/fluxAnalysisViewReducer.d.ts +2 -1
- package/lib/view/expenseAutomationView/reducers/fluxAnalysisViewReducer.js +6 -1
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +37 -17
- package/lib/view/expenseAutomationView/selectors/fluxAnalysisViewSelector.js +2 -1
- package/lib/view/expenseAutomationView/types/fluxAnalysisViewState.d.ts +2 -0
- package/lib/view/opExByVendor/opExByVendorReducer.d.ts +6 -1
- package/lib/view/opExByVendor/opExByVendorReducer.js +29 -6
- package/lib/view/opExByVendor/opExByVendorSelector.d.ts +1 -0
- package/lib/view/opExByVendor/opExByVendorSelector.js +1 -0
- package/lib/view/opExByVendor/opExByVendorState.d.ts +1 -0
- package/lib/view/opExByVendor/refreshOpExByVendorReportEpic.d.ts +17 -0
- package/lib/view/opExByVendor/refreshOpExByVendorReportEpic.js +25 -0
- package/package.json +1 -1
|
@@ -7,6 +7,7 @@ import { fetchClassList } from '../../../classList/classListReducer';
|
|
|
7
7
|
import { fetchOwnerList } from '../../../ownerList/ownerListReducer';
|
|
8
8
|
import { fetchProjectList } from '../../../projectList/projectListReducer';
|
|
9
9
|
import { fetchTransactionCategorization, fetchTransactionCategorizationView, } from '../../reducers/transactionsViewReducer';
|
|
10
|
+
import { TRANSACTIONS_TABS } from '../../types/transactionsViewState';
|
|
10
11
|
export const fetchTransactionCategorizationViewEpic = (actions$, state$) => actions$.pipe(filter(fetchTransactionCategorizationView.match), mergeMap((action) => {
|
|
11
12
|
const { selectedTab, cacheOverride, keepExistingListItems, pageToken, period, refreshViewInBackground, searchString, resetListItems, isUncategorizedExpenseCategoryEnabled, } = action.payload;
|
|
12
13
|
const updateActions = [];
|
|
@@ -16,8 +17,8 @@ export const fetchTransactionCategorizationViewEpic = (actions$, state$) => acti
|
|
|
16
17
|
month: period.start.month,
|
|
17
18
|
year: period.start.year,
|
|
18
19
|
};
|
|
19
|
-
const
|
|
20
|
-
|
|
20
|
+
const periodId = toMonthYearPeriodId(monthYearPeriod);
|
|
21
|
+
const transactionIds = transactionIdsBySelectedPeriod[periodId] ?? [];
|
|
21
22
|
const accountList = state$.value.accountListState.byReportId['accountList'];
|
|
22
23
|
if (accountList.hasValidState() === false &&
|
|
23
24
|
accountList.fetchState === 'Not-Started') {
|
|
@@ -39,10 +40,36 @@ export const fetchTransactionCategorizationViewEpic = (actions$, state$) => acti
|
|
|
39
40
|
vendorOwnerList.fetchState === 'Not-Started') {
|
|
40
41
|
updateActions.push(fetchOwnerList());
|
|
41
42
|
}
|
|
42
|
-
if (
|
|
43
|
+
if (searchString === '' ||
|
|
44
|
+
cacheOverride === true ||
|
|
43
45
|
fetchState === 'Not-Started' ||
|
|
44
46
|
transactionIds.length === 0) {
|
|
45
47
|
updateActions.push(fetchTransactionCategorization(selectedTab, period, cacheOverride, keepExistingListItems, searchString, pageToken, refreshViewInBackground, resetListItems, isUncategorizedExpenseCategoryEnabled));
|
|
46
48
|
}
|
|
49
|
+
// On the initial load of a tab (searchString undefined = non-search fetch),
|
|
50
|
+
// preload every other tab that hasn't been fetched yet for this period.
|
|
51
|
+
// This makes switching to the other tab instant instead of triggering a
|
|
52
|
+
// fresh fetch on click. refreshViewInBackground=true keeps it silent.
|
|
53
|
+
if (searchString === undefined) {
|
|
54
|
+
TRANSACTIONS_TABS.filter((tab) => tab !== selectedTab).forEach((otherTab) => {
|
|
55
|
+
const otherTabFetchState = expenseAutomationTransactionsViewState.transactionCategorizationView[otherTab].fetchState;
|
|
56
|
+
if (otherTabFetchState === 'Not-Started') {
|
|
57
|
+
updateActions.push(fetchTransactionCategorization(otherTab, period, false, false, undefined, undefined, true, undefined, isUncategorizedExpenseCategoryEnabled));
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
// When search changes (searchString defined, including empty string to
|
|
62
|
+
// clear), also update every other tab so all tabs always reflect the same
|
|
63
|
+
// search query. Skip if the other tab already has this search string to
|
|
64
|
+
// avoid redundant work on noop updates. On clear, restore from snapshot
|
|
65
|
+
// if available; otherwise issue a background fetch.
|
|
66
|
+
if (searchString !== undefined) {
|
|
67
|
+
TRANSACTIONS_TABS.filter((tab) => tab !== selectedTab).forEach((otherTab) => {
|
|
68
|
+
const otherTabSearchString = expenseAutomationTransactionsViewState.transactionCategorizationView[otherTab].uiState.searchString;
|
|
69
|
+
if (searchString !== otherTabSearchString) {
|
|
70
|
+
updateActions.push(fetchTransactionCategorization(otherTab, period, true, keepExistingListItems, searchString, undefined, true, true, isUncategorizedExpenseCategoryEnabled));
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
47
74
|
return from(updateActions);
|
|
48
75
|
}));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createSlice } from '@reduxjs/toolkit';
|
|
2
2
|
import { toMonthYearPeriodId, } from '../../../commonStateTypes/timePeriod';
|
|
3
3
|
import { defaultVendorCurrency } from '../../../entity/vendor/vendorState';
|
|
4
|
+
import { date } from '../../../zeniDayJS';
|
|
4
5
|
import { toBalancesByMonthFromPayload, toVendorFluxAnalysisStatusFromPayload, } from '../helpers/helpers';
|
|
5
6
|
export const initialState = {
|
|
6
7
|
fluxAnalysisEntities: { operatingExpenses: [] },
|
|
@@ -31,6 +32,7 @@ export const initialState = {
|
|
|
31
32
|
fetchState: 'Not-Started',
|
|
32
33
|
error: undefined,
|
|
33
34
|
currency: defaultVendorCurrency,
|
|
35
|
+
lastRefreshSuccessTime: undefined,
|
|
34
36
|
totalBalancesAndVariance: undefined,
|
|
35
37
|
hasValidState() {
|
|
36
38
|
return this.fetchState == 'Completed';
|
|
@@ -99,7 +101,7 @@ const expenseAutomationFluxAnalysisView = createSlice({
|
|
|
99
101
|
},
|
|
100
102
|
},
|
|
101
103
|
fetchFluxAnalysisViewSuccess(draft, action) {
|
|
102
|
-
const { expensesPayload, selectedPeriod, keepExistingListItems, fetchReimbursement, currency, totalsPayload, } = action.payload;
|
|
104
|
+
const { expensesPayload, selectedPeriod, keepExistingListItems, fetchReimbursement, currency, status, totalsPayload, } = action.payload;
|
|
103
105
|
const periodId = toMonthYearPeriodId(selectedPeriod);
|
|
104
106
|
const group = draft.groupsBySelectedPeriod[periodId];
|
|
105
107
|
const groupToBeFetched = fetchReimbursement
|
|
@@ -109,6 +111,9 @@ const expenseAutomationFluxAnalysisView = createSlice({
|
|
|
109
111
|
// Handle fetch completion
|
|
110
112
|
handleFetchCompletion(draft, selectedPeriod, fetchReimbursement, groupToBeFetched);
|
|
111
113
|
draft.fetchState = 'Completed';
|
|
114
|
+
if (status?.last_refresh_success_time != null) {
|
|
115
|
+
draft.lastRefreshSuccessTime = date(status.last_refresh_success_time);
|
|
116
|
+
}
|
|
112
117
|
// Update flux analysis entities
|
|
113
118
|
const allFluxAnalysisEntities = updateFluxAnalysisEntities(draft.fluxAnalysisEntities, expensesPayload, currency);
|
|
114
119
|
// Update operating expense ids based on the "keepExistingListItems" flag
|
|
@@ -153,27 +153,39 @@ const expenseAutomationTransactionsView = createSlice({
|
|
|
153
153
|
draft.transactionCategorizationView[selectedTab].fetchState =
|
|
154
154
|
'In-Progress';
|
|
155
155
|
draft.transactionCategorizationView[selectedTab].error = undefined;
|
|
156
|
+
// A foreground fetch supersedes any in-flight background preload.
|
|
157
|
+
// Reset refreshStatus so a cancelled preload doesn't leave the
|
|
158
|
+
// spinner stuck at In-Progress.
|
|
159
|
+
draft.transactionCategorizationView[selectedTab].refreshStatus = {
|
|
160
|
+
fetchState: 'Not-Started',
|
|
161
|
+
error: undefined,
|
|
162
|
+
};
|
|
156
163
|
}
|
|
157
164
|
draft.transactionCategorizationView[selectedTab].uiState.pageToken =
|
|
158
165
|
pageToken ?? null;
|
|
159
|
-
|
|
160
|
-
|
|
166
|
+
// Only overwrite when explicitly set; undefined means a non-search fetch
|
|
167
|
+
// (tab switch, period change) should preserve the existing search string.
|
|
168
|
+
if (searchString !== undefined) {
|
|
169
|
+
draft.transactionCategorizationView[selectedTab].uiState.searchString =
|
|
170
|
+
searchString;
|
|
171
|
+
}
|
|
161
172
|
draft.transactionCategorizationView[selectedTab].error = undefined;
|
|
173
|
+
const monthYearPeriod = {
|
|
174
|
+
month: period.start.month,
|
|
175
|
+
year: period.start.year,
|
|
176
|
+
};
|
|
177
|
+
const periodId = toMonthYearPeriodId(monthYearPeriod);
|
|
178
|
+
const transactionIdsBySelectedPeriod = draft.transactionCategorizationView[selectedTab]
|
|
179
|
+
.transactionIdsBySelectedPeriod[periodId] ?? [];
|
|
162
180
|
// Reset list when we change the sort order and fetch list again
|
|
163
181
|
if (resetListItems === true) {
|
|
164
|
-
const monthYearPeriod = {
|
|
165
|
-
month: period.start.month,
|
|
166
|
-
year: period.start.year,
|
|
167
|
-
};
|
|
168
|
-
const transactionIdsBySelectedPeriod = draft.transactionCategorizationView[selectedTab]
|
|
169
|
-
.transactionIdsBySelectedPeriod[toMonthYearPeriodId(monthYearPeriod)];
|
|
170
182
|
transactionIdsBySelectedPeriod.forEach((transactionId) => {
|
|
171
183
|
delete draft.transactionCategorizationView[selectedTab]
|
|
172
184
|
.transactionReviewLocalDataById[transactionId];
|
|
173
185
|
});
|
|
174
186
|
draft.transactionCategorizationView[selectedTab].selectedCheckBoxTransactionIds =
|
|
175
187
|
draft.transactionCategorizationView[selectedTab].selectedCheckBoxTransactionIds.filter((selectedCheckBoxTransactionId) => transactionIdsBySelectedPeriod.includes(selectedCheckBoxTransactionId));
|
|
176
|
-
draft.transactionCategorizationView[selectedTab].transactionIdsBySelectedPeriod[
|
|
188
|
+
draft.transactionCategorizationView[selectedTab].transactionIdsBySelectedPeriod[periodId] = [];
|
|
177
189
|
draft.transactionCategorizationView[selectedTab].refreshStatus = {
|
|
178
190
|
fetchState: 'Not-Started',
|
|
179
191
|
error: undefined,
|
|
@@ -305,10 +317,12 @@ const expenseAutomationTransactionsView = createSlice({
|
|
|
305
317
|
}
|
|
306
318
|
},
|
|
307
319
|
updateTransactionFilters(draft, action) {
|
|
308
|
-
const {
|
|
309
|
-
//
|
|
310
|
-
//
|
|
311
|
-
|
|
320
|
+
const { filters } = action.payload;
|
|
321
|
+
// Filters are tab-agnostic (payee/category/class/amount), so apply to
|
|
322
|
+
// all tabs so switching tabs after filtering shows consistent results.
|
|
323
|
+
TRANSACTIONS_TABS.forEach((tab) => {
|
|
324
|
+
draft.transactionCategorizationView[tab].filters = filters;
|
|
325
|
+
});
|
|
312
326
|
},
|
|
313
327
|
saveTransactionCategorization: {
|
|
314
328
|
prepare(selectedTab, transactionIds, cotTrackingByTransactionId, isUncategorizedExpenseCategoryEnabled) {
|
|
@@ -660,18 +674,24 @@ const expenseAutomationTransactionsView = createSlice({
|
|
|
660
674
|
resetOtherTabsFetchState(draft, action) {
|
|
661
675
|
const { tabs, refreshViewInBackground } = action.payload;
|
|
662
676
|
tabs.forEach((tab) => {
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
677
|
+
const tabFetchState = draft.transactionCategorizationView[tab].fetchState;
|
|
678
|
+
if (refreshViewInBackground !== true) {
|
|
679
|
+
// Foreground fetch completed: mark other tabs as Completed.
|
|
666
680
|
draft.transactionCategorizationView[tab].fetchState = 'Completed';
|
|
667
681
|
draft.transactionCategorizationView[tab].error = undefined;
|
|
668
682
|
}
|
|
669
|
-
else {
|
|
683
|
+
else if (tabFetchState !== 'In-Progress') {
|
|
684
|
+
// Background fetch completed: reset the other tab's refreshStatus,
|
|
685
|
+
// but only when it is not mid-load. During a dual-search the active
|
|
686
|
+
// tab has its own foreground fetch in flight — clobbering its
|
|
687
|
+
// fetchState here would drop the skeleton and show an empty list.
|
|
670
688
|
draft.transactionCategorizationView[tab].refreshStatus = {
|
|
671
689
|
fetchState: 'Not-Started',
|
|
672
690
|
error: undefined,
|
|
673
691
|
};
|
|
674
692
|
}
|
|
693
|
+
// If tabFetchState === 'In-Progress' and refreshViewInBackground === true,
|
|
694
|
+
// leave the other tab's state untouched — it has its own active fetch.
|
|
675
695
|
});
|
|
676
696
|
},
|
|
677
697
|
fetchTransactionCategorizationFailure(draft, action) {
|
|
@@ -8,7 +8,7 @@ import { getVendorByVendorId } from '../../../entity/vendor/vendorSelector';
|
|
|
8
8
|
import { getAllSteps } from '../selectorTypes/expenseAutomationViewSelectorTypes';
|
|
9
9
|
export function getExpenseAutomationFluxAnalysisView(state) {
|
|
10
10
|
const { expenseAutomationFluxAnalysisViewState, monthEndCloseChecksState, monthEndCloseChecksViewState, } = state;
|
|
11
|
-
const { fetchState, error, refreshStatus, uiState, reviewOperatingExpenseIdsByPeriod, selectedSectionIdsByPeriod, groupsBySelectedPeriod, fluxAnalysisEntities, bulkReviewStatus, currency, totalBalancesAndVariance, } = expenseAutomationFluxAnalysisViewState;
|
|
11
|
+
const { fetchState, error, lastRefreshSuccessTime, refreshStatus, uiState, reviewOperatingExpenseIdsByPeriod, selectedSectionIdsByPeriod, groupsBySelectedPeriod, fluxAnalysisEntities, bulkReviewStatus, currency, totalBalancesAndVariance, } = expenseAutomationFluxAnalysisViewState;
|
|
12
12
|
const fetchStateAndError = {
|
|
13
13
|
fetchState,
|
|
14
14
|
error,
|
|
@@ -110,6 +110,7 @@ export function getExpenseAutomationFluxAnalysisView(state) {
|
|
|
110
110
|
refreshStatus,
|
|
111
111
|
currency,
|
|
112
112
|
completionStatus,
|
|
113
|
+
lastRefreshSuccessTime,
|
|
113
114
|
};
|
|
114
115
|
}
|
|
115
116
|
// Helper function to transform operating expense to vendor view
|
|
@@ -22,6 +22,10 @@ export const initialState = {
|
|
|
22
22
|
error: undefined,
|
|
23
23
|
},
|
|
24
24
|
},
|
|
25
|
+
refreshStatus: {
|
|
26
|
+
fetchState: 'Not-Started',
|
|
27
|
+
error: undefined,
|
|
28
|
+
},
|
|
25
29
|
summaryFetchState: {
|
|
26
30
|
fetchState: 'Not-Started',
|
|
27
31
|
error: undefined,
|
|
@@ -259,12 +263,32 @@ const opexByVendor = createSlice({
|
|
|
259
263
|
[timeframe]: [],
|
|
260
264
|
};
|
|
261
265
|
},
|
|
266
|
+
refreshOpExByVendorReport(draft) {
|
|
267
|
+
draft.refreshStatus = { fetchState: 'In-Progress', error: undefined };
|
|
268
|
+
},
|
|
269
|
+
refreshOpExByVendorReportSuccess(draft, action) {
|
|
270
|
+
draft.refreshStatus = { fetchState: 'Completed', error: undefined };
|
|
271
|
+
if (action.payload.lastRefreshSuccessTime != null) {
|
|
272
|
+
draft.lastRefreshSuccessTime = action.payload.lastRefreshSuccessTime;
|
|
273
|
+
}
|
|
274
|
+
},
|
|
275
|
+
refreshOpExByVendorReportFailure: {
|
|
276
|
+
prepare(error) {
|
|
277
|
+
return { payload: { error } };
|
|
278
|
+
},
|
|
279
|
+
reducer(draft, action) {
|
|
280
|
+
draft.refreshStatus = {
|
|
281
|
+
fetchState: 'Error',
|
|
282
|
+
error: action.payload.error,
|
|
283
|
+
};
|
|
284
|
+
},
|
|
285
|
+
},
|
|
262
286
|
clearOpExByVendor(draft) {
|
|
263
287
|
Object.assign(draft, initialState);
|
|
264
288
|
},
|
|
265
289
|
},
|
|
266
290
|
});
|
|
267
|
-
export const { fetchOpExByVendor, updateOpExByVendorReportGenerated, fetchOpExByVendorReportForTimeframe, updateOpExByVendorReportFailureForTimeframe, updateOpExByVendorReportSuccessForTimeframe, fetchOpExByVendorReportSummary, updateOpExByVendorReportSummaryFailure, updateOpExByVendorReportSummarySuccess, updateOpExByVendorTimeFrame, updateOpExByVendorUIState, clearOpExByVendor, updateOpExByVendorAdditionalBalancesSelection, updateOpExByVendorSort, updateOpExByVendorSortOrSearchInProgress, updateOpExByVendorPageFetchInProgress, updateOpExByVendorDownloadState, clearOpExByVendorSearch, updateOpExByVendorPageLimit, updateOpExByVendorSearchString, } = opexByVendor.actions;
|
|
291
|
+
export const { fetchOpExByVendor, updateOpExByVendorReportGenerated, fetchOpExByVendorReportForTimeframe, updateOpExByVendorReportFailureForTimeframe, updateOpExByVendorReportSuccessForTimeframe, fetchOpExByVendorReportSummary, updateOpExByVendorReportSummaryFailure, updateOpExByVendorReportSummarySuccess, updateOpExByVendorTimeFrame, updateOpExByVendorUIState, clearOpExByVendor, updateOpExByVendorAdditionalBalancesSelection, updateOpExByVendorSort, updateOpExByVendorSortOrSearchInProgress, updateOpExByVendorPageFetchInProgress, updateOpExByVendorDownloadState, clearOpExByVendorSearch, updateOpExByVendorPageLimit, updateOpExByVendorSearchString, refreshOpExByVendorReport, refreshOpExByVendorReportSuccess, refreshOpExByVendorReportFailure, } = opexByVendor.actions;
|
|
268
292
|
export default opexByVendor.reducer;
|
|
269
293
|
const doUpdateOpexByVendorReport = (draft, timeframe, reportPayload, queryProps) => {
|
|
270
294
|
if (reportPayload.status.is_report_generated == null) {
|
|
@@ -317,10 +341,9 @@ const doUpdateOpexByVendorReportSummary = (draft, reportPayload) => {
|
|
|
317
341
|
const report = mapReportPayloadToReport(reportPayload);
|
|
318
342
|
draft.firstMonthOfFY = report.firstMonthOfFY;
|
|
319
343
|
draft.bookCloseDate = report.bookCloseDate;
|
|
320
|
-
|
|
321
|
-
reportPayload.status.last_refresh_success_time
|
|
322
|
-
|
|
323
|
-
: undefined;
|
|
344
|
+
if (reportPayload.status.last_refresh_success_time != null) {
|
|
345
|
+
draft.lastRefreshSuccessTime = date(reportPayload.status.last_refresh_success_time);
|
|
346
|
+
}
|
|
324
347
|
draft.totalOpexByVendor = combineCOABalanceGrouped(mapCOABalanceGroupedPayloadV2ToCOABalanceGrouped(reportPayload.operating_expenses, reportPayload.currency, 'month'), mapCOABalanceGroupedPayloadV2ToCOABalanceGrouped(reportPayload.operating_expenses, reportPayload.currency, 'quarter'));
|
|
325
348
|
draft.summaryOpexByVendorKey = mapVendorSummaryBalances(reportPayload.operating_expenses, reportPayload.currency);
|
|
326
349
|
}
|
|
@@ -67,6 +67,7 @@ export const getOpExByVendorReport = createSelector((state) => state.opExByVendo
|
|
|
67
67
|
filter,
|
|
68
68
|
isReportGenerated: opExByVendorState.opExByVendorReportGenerated,
|
|
69
69
|
lastRefreshSuccessTime: opExByVendorState.lastRefreshSuccessTime,
|
|
70
|
+
refreshStatus: opExByVendorState.refreshStatus,
|
|
70
71
|
opexBalances,
|
|
71
72
|
summaryBalances,
|
|
72
73
|
allTimeframeTicks,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { of } from 'rxjs';
|
|
2
|
+
import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
|
|
3
|
+
import { createZeniAPIStatus } from '../../responsePayload';
|
|
4
|
+
import { date } from '../../zeniDayJS';
|
|
5
|
+
import { refreshOpExByVendorReport, refreshOpExByVendorReportFailure, refreshOpExByVendorReportSuccess, } from './opExByVendorReducer';
|
|
6
|
+
export const refreshOpExByVendorReportEpic = (actions$, _state, zeniAPI) => actions$.pipe(filter(refreshOpExByVendorReport.match), switchMap(() => {
|
|
7
|
+
return zeniAPI
|
|
8
|
+
.postAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/reports/operating-expenses-by-vendor/refresh`)
|
|
9
|
+
.pipe(mergeMap((response) => {
|
|
10
|
+
if (response.status.code >= 200 && response.status.code < 300) {
|
|
11
|
+
const lastRefreshSuccessTime = response.status.last_refresh_success_time != null
|
|
12
|
+
? date(response.status.last_refresh_success_time)
|
|
13
|
+
: undefined;
|
|
14
|
+
return of(refreshOpExByVendorReportSuccess({ lastRefreshSuccessTime }));
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
return of(refreshOpExByVendorReportFailure(response.status));
|
|
18
|
+
}
|
|
19
|
+
}), catchError((error) => of(refreshOpExByVendorReportFailure(createZeniAPIStatus('Unexpected error', 'Refresh OpEx by Vendor REST API call errored out: ' +
|
|
20
|
+
JSON.stringify(error))))));
|
|
21
|
+
}));
|
package/lib/index.d.ts
CHANGED
|
@@ -349,7 +349,7 @@ import { fetchOpEx, fetchOpExWithForecast, updateOpExCOABalancesRange, updateOpE
|
|
|
349
349
|
import { getOperatingExpensesForHighlightedRange, getOperatingExpensesForSelectedRange, getOperatingExpensesReport, getOperatingExpensesReportFetchState, getOperatingExpensesUIState } from './view/opEx/opExSelector';
|
|
350
350
|
import { OpExReport, OpExUIStateSelectorView } from './view/opEx/opExSelectorTypes';
|
|
351
351
|
import { OpExState, OpExUIState } from './view/opEx/opExState';
|
|
352
|
-
import { clearOpExByVendorSearch, fetchOpExByVendor, fetchOpExByVendorReportForTimeframe, updateOpExByVendorAdditionalBalancesSelection, updateOpExByVendorDownloadState, updateOpExByVendorPageFetchInProgress, updateOpExByVendorPageLimit, updateOpExByVendorSearchString, updateOpExByVendorSort, updateOpExByVendorSortOrSearchInProgress, updateOpExByVendorTimeFrame, updateOpExByVendorUIState } from './view/opExByVendor/opExByVendorReducer';
|
|
352
|
+
import { clearOpExByVendorSearch, fetchOpExByVendor, fetchOpExByVendorReportForTimeframe, refreshOpExByVendorReport, updateOpExByVendorAdditionalBalancesSelection, updateOpExByVendorDownloadState, updateOpExByVendorPageFetchInProgress, updateOpExByVendorPageLimit, updateOpExByVendorSearchString, updateOpExByVendorSort, updateOpExByVendorSortOrSearchInProgress, updateOpExByVendorTimeFrame, updateOpExByVendorUIState } from './view/opExByVendor/opExByVendorReducer';
|
|
353
353
|
import { OpExBalancesByVendor, OpExByVendorReport, OpExSummaryBalances, OpExVendorAndBalance, OpexVendorTimeframeKey, getOpExByVendorReport, getOpExByVendorUIState, getOpexVendorTimeframeKey, isOpexByVendorIDNotSpecifiedVendor } from './view/opExByVendor/opExByVendorSelector';
|
|
354
354
|
import { OpExByVendorState, OpexByVendorSortKey, OpexByVendorUIState, toOpexByVendorSortKeyType } from './view/opExByVendor/opExByVendorState';
|
|
355
355
|
import { fetchOpExClassesView, updateAccountViewMode as updateOpExAccountViewMode, updateClassesToFilterOut as updateOpExClassesToFilterOut, updateOpExClassesViewUIState } from './view/opExClassesView/opExClassesViewReducer';
|
|
@@ -702,7 +702,7 @@ export { CardBalanceState, getCardBalance, CardBalanceReport, fetchCardBalance,
|
|
|
702
702
|
export { CashBalanceState, getCashBalance, CashBalanceReport, fetchCashBalance };
|
|
703
703
|
export { fetchBillPayCard, fetchReimbursementCard };
|
|
704
704
|
export { fetchOpEx, updateOpExCOABalancesRange, updateOpExDownloadState, updateOpExUIState, getOperatingExpensesReportFetchState, getOperatingExpensesReport, getOperatingExpensesUIState, getOperatingExpensesForSelectedRange, getOperatingExpensesForHighlightedRange, OpExReport, OpExState, OpExUIState, OpExUIStateSelectorView, fetchOpExWithForecast, };
|
|
705
|
-
export { fetchOpExByVendor, fetchOpExByVendorReportForTimeframe, updateOpExByVendorTimeFrame, updateOpExByVendorUIState, OpExByVendorState, OpexByVendorSortKey, OpexByVendorUIState, OpExByVendorReport, getOpExByVendorReport, getOpExByVendorUIState, OpExBalancesByVendor, updateOpExByVendorAdditionalBalancesSelection, updateOpExByVendorSearchString, OpExSummaryBalances, updateOpExByVendorSort, updateOpExByVendorPageFetchInProgress, updateOpExByVendorSortOrSearchInProgress, updateOpExByVendorDownloadState, clearOpExByVendorSearch, updateOpExByVendorPageLimit, toOpexByVendorSortKeyType, OpExVendorAndBalance, OpexVendorTimeframeKey, getOpexVendorTimeframeKey, isOpexByVendorIDNotSpecifiedVendor, };
|
|
705
|
+
export { fetchOpExByVendor, fetchOpExByVendorReportForTimeframe, refreshOpExByVendorReport, updateOpExByVendorTimeFrame, updateOpExByVendorUIState, OpExByVendorState, OpexByVendorSortKey, OpexByVendorUIState, OpExByVendorReport, getOpExByVendorReport, getOpExByVendorUIState, OpExBalancesByVendor, updateOpExByVendorAdditionalBalancesSelection, updateOpExByVendorSearchString, OpExSummaryBalances, updateOpExByVendorSort, updateOpExByVendorPageFetchInProgress, updateOpExByVendorSortOrSearchInProgress, updateOpExByVendorDownloadState, clearOpExByVendorSearch, updateOpExByVendorPageLimit, toOpexByVendorSortKeyType, OpExVendorAndBalance, OpexVendorTimeframeKey, getOpexVendorTimeframeKey, isOpexByVendorIDNotSpecifiedVendor, };
|
|
706
706
|
export { fetchOpExClassesView, updateOpExAccountViewMode, updateOpExClassesToFilterOut, updateOpExClassesViewUIState, getOpExClassesView, getOpExClassesViewForHighlightedRange, getOpExClassesViewForSelectedRange, OpExClassesViewReport, isOpExClassesViewSectionID, isOpExClassesViewCalculatedSectionID, OpExClassesViewSectionID, OpExClassesViewCalculatedSectionID, };
|
|
707
707
|
export { fetchNetBurnOrIncomeClassesView, updateNetBurnOrIncomeAccountViewMode, updateNetBurnOrIncomeClassesToFilterOut, updateNetBurnOrIncomeClassesViewUIState, getNetBurnOrIncomeClassesView, getNetBurnOrIncomeClassesViewForHighlightedRange, getNetBurnOrIncomeClassesViewForSelectedRange, NetBurnOrIncomeClassesViewReport, isNetBurnOrIncomeClassesViewSectionID, isNetBurnOrIncomeClassesViewCalculatedSectionID, NetBurnOrIncomeClassesViewCalculatedSectionID, NetBurnOrIncomeClassesViewSectionID, };
|
|
708
708
|
export { fetchNetBurnOrIncome, updateNetBurnOrIncomeUIState, fetchNetBurnOrIncomeWithForecast, NetBurnOrIncomeState, NetBurnOrIncomeUIState, NetBurnOrIncomeReport, NetBurnOrIncomeCalculatedSectionID, NetBurnOrIncomeSectionID, updateNetBurnOrIncomeCOABalancesRange, updateNetBurnOrIncomeDownloadState, NetBurnOrIncomeUIStateSelectorView, getNetBurnOrIncomeReport, getNetBurnOrIncomeForSelectedRange, getNetBurnOrIncomeForHighlightedRange, getNetBurnOrIncomeUIState, getNetBurnOrIncomeReportFetchState, isNetBurnOrIncomeReportViewCalculatedSectionID, isNetBurnOrIncomeReportViewSectionID, };
|