@zeniai/client-epic-state 5.2.62-beta1MM → 5.2.62-beta2ND
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/actualMatching/actualMatchingReducer.d.ts +1 -3
- package/lib/entity/actualMatching/actualMatchingReducer.js +2 -11
- package/lib/entity/jeSchedules/jeSchedulesPayload.d.ts +0 -1
- package/lib/entity/jeSchedules/jeSchedulesPayload.js +0 -1
- package/lib/entity/jeSchedules/jeSchedulesState.d.ts +0 -1
- package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
- package/lib/entity/snackbar/snackbarTypes.js +1 -1
- package/lib/epic.d.ts +3 -3
- package/lib/epic.js +3 -3
- package/lib/esm/entity/actualMatching/actualMatchingReducer.js +1 -9
- package/lib/esm/entity/jeSchedules/jeSchedulesPayload.js +0 -1
- package/lib/esm/entity/snackbar/snackbarTypes.js +1 -1
- package/lib/esm/epic.js +3 -3
- package/lib/esm/index.js +7 -7
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/actualMatching/fetchActualMatchingMatchEpic.js +2 -4
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/actualMatching/matchAndReverseAccrualsEpic.js +13 -26
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/actualMatching/searchMatchTransactionsEpic.js +23 -2
- package/lib/esm/view/expenseAutomationView/reducers/actualMatchingViewReducer.js +38 -89
- package/lib/esm/view/expenseAutomationView/selectors/actualMatchingViewSelector.js +64 -61
- package/lib/esm/view/expenseAutomationView/types/actualMatchingViewState.js +0 -15
- package/lib/esm/view/spendManagement/commonSetup/epic/setup/resetKycKybEpic.js +37 -0
- package/lib/esm/view/spendManagement/commonSetup/setupViewReducer.js +18 -1
- package/lib/esm/view/spendManagement/commonSetup/setupViewSelector.js +2 -1
- package/lib/index.d.ts +8 -8
- package/lib/index.js +50 -57
- package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/fetchActualMatchingMatchEpic.d.ts +2 -2
- package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/fetchActualMatchingMatchEpic.js +1 -3
- package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/matchAndReverseAccrualsEpic.js +11 -24
- package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/searchMatchTransactionsEpic.js +22 -1
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
- package/lib/view/expenseAutomationView/payload/actualMatchingPayload.d.ts +1 -12
- package/lib/view/expenseAutomationView/reducers/actualMatchingViewReducer.d.ts +8 -19
- package/lib/view/expenseAutomationView/reducers/actualMatchingViewReducer.js +39 -90
- package/lib/view/expenseAutomationView/selectorTypes/actualMatchingViewSelectorTypes.d.ts +8 -20
- package/lib/view/expenseAutomationView/selectors/actualMatchingViewSelector.d.ts +4 -7
- package/lib/view/expenseAutomationView/selectors/actualMatchingViewSelector.js +64 -64
- package/lib/view/expenseAutomationView/types/actualMatchingViewState.d.ts +4 -20
- package/lib/view/expenseAutomationView/types/actualMatchingViewState.js +1 -18
- package/lib/view/spendManagement/commonSetup/epic/setup/resetKycKybEpic.d.ts +8 -0
- package/lib/view/spendManagement/commonSetup/epic/setup/resetKycKybEpic.js +41 -0
- package/lib/view/spendManagement/commonSetup/setupViewReducer.d.ts +1 -1
- package/lib/view/spendManagement/commonSetup/setupViewReducer.js +19 -2
- package/lib/view/spendManagement/commonSetup/setupViewSelector.d.ts +1 -0
- package/lib/view/spendManagement/commonSetup/setupViewSelector.js +2 -1
- package/lib/view/spendManagement/commonSetup/setupViewState.d.ts +1 -0
- package/package.json +1 -1
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/actualMatching/ignoreActualMatchingSuggestionEpic.js +0 -50
- package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/ignoreActualMatchingSuggestionEpic.d.ts +0 -10
- package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/ignoreActualMatchingSuggestionEpic.js +0 -54
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { from, of } from 'rxjs';
|
|
2
|
-
import { catchError, exhaustMap, filter,
|
|
2
|
+
import { catchError, exhaustMap, filter, mergeMap, takeUntil } from 'rxjs/operators';
|
|
3
3
|
import { getActualMatchingMatchById } from '../../../../../entity/actualMatching/actualMatchingSelector';
|
|
4
4
|
import { openSnackbar } from '../../../../../entity/snackbar/snackbarReducer';
|
|
5
|
-
import { createZeniAPIStatus, isSuccessResponse
|
|
5
|
+
import { createZeniAPIStatus, isSuccessResponse } from '../../../../../responsePayload';
|
|
6
6
|
import { clearAll } from '../../../../../rootActions';
|
|
7
7
|
import { toMatchAndReverseResult, } from '../../../payload/actualMatchingPayload';
|
|
8
8
|
import { clearMatchNewModal, fetchActualMatchingMatch, matchAndReverseAccruals, matchAndReverseAccrualsFailure, matchAndReverseAccrualsSuccess, } from '../../../reducers/actualMatchingViewReducer';
|
|
9
9
|
import { isMatchAndReverseCompleteStatus, } from '../../../types/actualMatchingViewState';
|
|
10
10
|
import { refreshActualMatchingList } from './refreshActualMatchingList';
|
|
11
11
|
function isMatchFailedStatus(status) {
|
|
12
|
-
return status === 'conflict' || status === 'claim_lost' || status === 'error';
|
|
12
|
+
return (status === 'conflict' || status === 'claim_lost' || status === 'error');
|
|
13
13
|
}
|
|
14
14
|
function matchAndReverseSnackbar(results, vendorName) {
|
|
15
15
|
const reversedCount = results.filter((result) => result.status === 'reversed').length;
|
|
@@ -56,15 +56,12 @@ function matchAndReverseHttpFailSnackbar(vendorName) {
|
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
58
|
function matchVendorName(state, matchId) {
|
|
59
|
-
return
|
|
60
|
-
?.vendorName ?? '');
|
|
59
|
+
return getActualMatchingMatchById(state.actualMatchingState, matchId)?.vendorName ?? '';
|
|
61
60
|
}
|
|
62
61
|
export const matchAndReverseAccrualsEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(matchAndReverseAccruals.match),
|
|
63
|
-
//
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
groupBy((action) => `${action.payload.transactionType.toLowerCase()}:${action.payload.transactionIntegrationId}`), mergeMap((perMatch$) => perMatch$.pipe(exhaustMap((action) => {
|
|
67
|
-
const { transactionId, transactionIntegrationId, transactionType, lineIds, accrualIds, transactionSyncToken, forMatchModal, } = action.payload;
|
|
62
|
+
// Posts reversing JEs; drop duplicate clicks while a request is in flight.
|
|
63
|
+
exhaustMap((action) => {
|
|
64
|
+
const { transactionId, transactionIntegrationId, transactionType, lineIds, accrualIds, transactionSyncToken, } = action.payload;
|
|
68
65
|
const body = {
|
|
69
66
|
transaction_id: transactionId,
|
|
70
67
|
transaction_integration_id: transactionIntegrationId,
|
|
@@ -83,39 +80,29 @@ groupBy((action) => `${action.payload.transactionType.toLowerCase()}:${action.pa
|
|
|
83
80
|
if (isSuccessResponse(response) && response.data != null) {
|
|
84
81
|
const results = response.data.results.map(toMatchAndReverseResult);
|
|
85
82
|
const successActions = [
|
|
86
|
-
matchAndReverseAccrualsSuccess({
|
|
87
|
-
matchId,
|
|
88
|
-
results,
|
|
89
|
-
...(forMatchModal === true ? { forMatchModal: true } : {}),
|
|
90
|
-
}),
|
|
83
|
+
matchAndReverseAccrualsSuccess({ matchId, results }),
|
|
91
84
|
];
|
|
92
85
|
const occupancyChanged = results.some((result) => isMatchAndReverseCompleteStatus(result.status));
|
|
93
86
|
const allComplete = results.length > 0 &&
|
|
94
87
|
results.every((result) => isMatchAndReverseCompleteStatus(result.status));
|
|
95
88
|
if (occupancyChanged) {
|
|
96
89
|
// List + detail: list can omit leftovers; detail GET always
|
|
97
|
-
// writes intended occupancy so
|
|
98
|
-
//
|
|
90
|
+
// writes intended occupancy so Continue match prefills the
|
|
91
|
+
// remaining leftover set instead of a stale cached row.
|
|
99
92
|
successActions.push(...refreshActualMatchingList(state$.value), fetchActualMatchingMatch(matchId, true));
|
|
100
93
|
}
|
|
101
94
|
const snackbar = matchAndReverseSnackbar(results, vendorName);
|
|
102
95
|
if (snackbar != null) {
|
|
103
96
|
successActions.push(snackbar);
|
|
104
97
|
}
|
|
105
|
-
if (allComplete
|
|
98
|
+
if (allComplete) {
|
|
106
99
|
successActions.push(clearMatchNewModal());
|
|
107
100
|
}
|
|
108
101
|
return from(successActions);
|
|
109
102
|
}
|
|
110
|
-
return of(matchAndReverseAccrualsFailure({
|
|
111
|
-
status: response.status,
|
|
112
|
-
matchId,
|
|
113
|
-
...(forMatchModal === true ? { forMatchModal: true } : {}),
|
|
114
|
-
}), matchAndReverseHttpFailSnackbar(vendorName));
|
|
103
|
+
return of(matchAndReverseAccrualsFailure({ status: response.status }), matchAndReverseHttpFailSnackbar(vendorName));
|
|
115
104
|
}), catchError((error) => of(matchAndReverseAccrualsFailure({
|
|
116
|
-
matchId,
|
|
117
|
-
...(forMatchModal === true ? { forMatchModal: true } : {}),
|
|
118
105
|
status: createZeniAPIStatus('Unexpected Error', 'Match and reverse accruals REST API call errored out' +
|
|
119
106
|
JSON.stringify(error)),
|
|
120
107
|
}), matchAndReverseHttpFailSnackbar(vendorName))), takeUntil(actions$.pipe(filter(clearAll.match))));
|
|
121
|
-
}))
|
|
108
|
+
}));
|
|
@@ -1,13 +1,34 @@
|
|
|
1
1
|
import { from, merge, of } from 'rxjs';
|
|
2
2
|
import { catchError, debounceTime, filter, mergeMap, switchMap, takeUntil, } from 'rxjs/operators';
|
|
3
|
+
import { getActualMatchingMatchById } from '../../../../../entity/actualMatching/actualMatchingSelector';
|
|
3
4
|
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../../responsePayload';
|
|
4
5
|
import { clearAll } from '../../../../../rootActions';
|
|
5
6
|
import { toActualMatchingTransactionSearchResult, } from '../../../payload/actualMatchingPayload';
|
|
6
7
|
import { openMatchNewModal, searchMatchAccruals, searchMatchTransactions, searchMatchTransactionsFailure, searchMatchTransactionsSuccess, } from '../../../reducers/actualMatchingViewReducer';
|
|
7
|
-
import { getTenantDisplayCurrency } from '../../../selectors/actualMatchingViewSelector';
|
|
8
|
+
import { getTenantDisplayCurrency, parseActualMatchingMatchId, } from '../../../selectors/actualMatchingViewSelector';
|
|
8
9
|
import { MATCH_SEARCH_DEBOUNCE_MS, MATCH_TRANSACTION_SEARCH_PAGE_SIZE, } from '../../../types/actualMatchingViewState';
|
|
9
10
|
export const searchMatchTransactionsEpic = (actions$, state$, zeniAPI) => {
|
|
10
|
-
const openModal$ = actions$.pipe(filter(openMatchNewModal.match), mergeMap(() =>
|
|
11
|
+
const openModal$ = actions$.pipe(filter(openMatchNewModal.match), mergeMap((action) => {
|
|
12
|
+
const matchId = action.payload.matchId;
|
|
13
|
+
if (matchId == null || matchId === '') {
|
|
14
|
+
return from([
|
|
15
|
+
searchMatchTransactions(''),
|
|
16
|
+
searchMatchAccruals(''),
|
|
17
|
+
]);
|
|
18
|
+
}
|
|
19
|
+
const match = getActualMatchingMatchById(state$.value.actualMatchingState, matchId);
|
|
20
|
+
const parsed = parseActualMatchingMatchId(matchId);
|
|
21
|
+
const transactionType = match?.transactionType != null && match.transactionType !== ''
|
|
22
|
+
? match.transactionType
|
|
23
|
+
: parsed?.transactionType;
|
|
24
|
+
const transactionIntegrationId = match?.transactionIntegrationId != null &&
|
|
25
|
+
match.transactionIntegrationId !== ''
|
|
26
|
+
? match.transactionIntegrationId
|
|
27
|
+
: parsed?.transactionIntegrationId;
|
|
28
|
+
return from([
|
|
29
|
+
searchMatchTransactions('', undefined, transactionType, transactionIntegrationId),
|
|
30
|
+
]);
|
|
31
|
+
}));
|
|
11
32
|
const searchActions$ = actions$.pipe(filter(searchMatchTransactions.match));
|
|
12
33
|
const pagination$ = searchActions$.pipe(filter((action) => action.payload.pageToken != null));
|
|
13
34
|
const newSearchDebounced$ = searchActions$.pipe(filter((action) => action.payload.pageToken == null), debounceTime(MATCH_SEARCH_DEBOUNCE_MS));
|
|
@@ -22,6 +22,9 @@ export const initialAccrualSearchState = {
|
|
|
22
22
|
};
|
|
23
23
|
export const initialMatchModalState = {
|
|
24
24
|
isOpen: false,
|
|
25
|
+
openedFromMatchId: undefined,
|
|
26
|
+
didPinPrefillTransactions: false,
|
|
27
|
+
pinnedTransactionResults: [],
|
|
25
28
|
transactionSearch: initialTransactionSearchState,
|
|
26
29
|
accrualSearch: initialAccrualSearchState,
|
|
27
30
|
confirmStatus: { fetchState: 'Not-Started', error: undefined },
|
|
@@ -41,28 +44,16 @@ export const initialState = {
|
|
|
41
44
|
sortOrder: 'descending',
|
|
42
45
|
searchString: '',
|
|
43
46
|
scrollPosition: { scrollTop: 0, scrollLeft: undefined },
|
|
44
|
-
statusFilter: 'all',
|
|
45
47
|
},
|
|
46
48
|
matchModal: initialMatchModalState,
|
|
47
49
|
undoReversalStatusByMatchId: {},
|
|
48
|
-
|
|
49
|
-
confirmStatusByMatchId: {},
|
|
50
|
-
closeMatchAfterUndoMatchIds: [],
|
|
51
|
-
closeMatchAfterIgnoreMatchIds: [],
|
|
50
|
+
closeMatchAfterUndo: false,
|
|
52
51
|
lastMatchResultsByMatchId: {},
|
|
53
52
|
lastUndoResultsByMatchId: {},
|
|
54
53
|
hasValidState() {
|
|
55
54
|
return this.fetchState == 'Completed';
|
|
56
55
|
},
|
|
57
56
|
};
|
|
58
|
-
function enqueueCloseMatchId(ids, matchId) {
|
|
59
|
-
if (!ids.includes(matchId)) {
|
|
60
|
-
ids.push(matchId);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
function dropCloseMatchId(ids, matchId) {
|
|
64
|
-
return ids.filter((id) => id !== matchId);
|
|
65
|
-
}
|
|
66
57
|
function pruneLastMatchResultsForUndone(draft, matchId, results) {
|
|
67
58
|
const undoneIds = new Set(results
|
|
68
59
|
.filter((result) => result.status === 'undone')
|
|
@@ -105,6 +96,9 @@ function resetMatchModalSearches(draft) {
|
|
|
105
96
|
error: undefined,
|
|
106
97
|
};
|
|
107
98
|
draft.matchModal.lastBatchResults = undefined;
|
|
99
|
+
draft.matchModal.openedFromMatchId = undefined;
|
|
100
|
+
draft.matchModal.didPinPrefillTransactions = false;
|
|
101
|
+
draft.matchModal.pinnedTransactionResults = [];
|
|
108
102
|
}
|
|
109
103
|
const expenseAutomationActualMatchingView = createSlice({
|
|
110
104
|
name: 'expenseAutomationActualMatchingView',
|
|
@@ -245,13 +239,21 @@ const expenseAutomationActualMatchingView = createSlice({
|
|
|
245
239
|
if (action.payload.scrollPosition != null) {
|
|
246
240
|
draft.uiState.scrollPosition = action.payload.scrollPosition;
|
|
247
241
|
}
|
|
248
|
-
if (action.payload.statusFilter != null) {
|
|
249
|
-
draft.uiState.statusFilter = action.payload.statusFilter;
|
|
250
|
-
}
|
|
251
242
|
},
|
|
252
|
-
openMatchNewModal
|
|
253
|
-
|
|
254
|
-
|
|
243
|
+
openMatchNewModal: {
|
|
244
|
+
prepare(matchId) {
|
|
245
|
+
return { payload: { matchId } };
|
|
246
|
+
},
|
|
247
|
+
reducer(draft, action) {
|
|
248
|
+
resetMatchModalSearches(draft);
|
|
249
|
+
draft.matchModal.isOpen = true;
|
|
250
|
+
const matchId = action.payload.matchId;
|
|
251
|
+
draft.matchModal.openedFromMatchId =
|
|
252
|
+
matchId != null && matchId !== '' ? matchId : undefined;
|
|
253
|
+
if (draft.matchModal.openedFromMatchId != null) {
|
|
254
|
+
draft.matchModal.accrualSearch.fetchState = 'Completed';
|
|
255
|
+
}
|
|
256
|
+
},
|
|
255
257
|
},
|
|
256
258
|
// Dismiss (Cancel / overlay). Store reset matches `clearMatchNewModal`;
|
|
257
259
|
// the actions stay distinct so confirm-success vs user-dismiss stay observable.
|
|
@@ -306,6 +308,11 @@ const expenseAutomationActualMatchingView = createSlice({
|
|
|
306
308
|
}
|
|
307
309
|
else {
|
|
308
310
|
draft.matchModal.transactionSearch.results = results;
|
|
311
|
+
if (draft.matchModal.openedFromMatchId != null &&
|
|
312
|
+
!draft.matchModal.didPinPrefillTransactions) {
|
|
313
|
+
draft.matchModal.didPinPrefillTransactions = true;
|
|
314
|
+
draft.matchModal.pinnedTransactionResults = results;
|
|
315
|
+
}
|
|
309
316
|
}
|
|
310
317
|
draft.matchModal.transactionSearch.nextPageToken = nextPageToken;
|
|
311
318
|
draft.matchModal.transactionSearch.isLoadingMore = false;
|
|
@@ -358,27 +365,21 @@ const expenseAutomationActualMatchingView = createSlice({
|
|
|
358
365
|
draft.matchModal.accrualSearch.error = action.payload.error;
|
|
359
366
|
},
|
|
360
367
|
matchAndReverseAccruals: {
|
|
361
|
-
reducer(draft
|
|
362
|
-
|
|
368
|
+
reducer(draft) {
|
|
369
|
+
draft.matchModal.confirmStatus = {
|
|
363
370
|
fetchState: 'In-Progress',
|
|
364
371
|
error: undefined,
|
|
365
372
|
};
|
|
366
|
-
if (action.payload.forMatchModal === true) {
|
|
367
|
-
draft.matchModal.confirmStatus = inProgress;
|
|
368
|
-
}
|
|
369
|
-
const matchId = `${action.payload.transactionType.toLowerCase()}:${action.payload.transactionIntegrationId}`;
|
|
370
|
-
draft.confirmStatusByMatchId[matchId] = inProgress;
|
|
371
373
|
},
|
|
372
|
-
prepare(transactionId, transactionIntegrationId, transactionType, lineIds, transactionSyncToken, accrualIds
|
|
374
|
+
prepare(transactionId, transactionIntegrationId, transactionType, lineIds, transactionSyncToken, accrualIds) {
|
|
373
375
|
return {
|
|
374
376
|
payload: {
|
|
375
|
-
accrualIds,
|
|
376
|
-
lineIds,
|
|
377
377
|
transactionId,
|
|
378
378
|
transactionIntegrationId,
|
|
379
|
-
transactionSyncToken,
|
|
380
379
|
transactionType,
|
|
381
|
-
|
|
380
|
+
lineIds,
|
|
381
|
+
transactionSyncToken,
|
|
382
|
+
accrualIds,
|
|
382
383
|
},
|
|
383
384
|
};
|
|
384
385
|
},
|
|
@@ -387,33 +388,23 @@ const expenseAutomationActualMatchingView = createSlice({
|
|
|
387
388
|
const { results } = action.payload;
|
|
388
389
|
const allComplete = results.length > 0 &&
|
|
389
390
|
results.every((result) => isMatchAndReverseCompleteStatus(result.status));
|
|
390
|
-
|
|
391
|
+
draft.matchModal.confirmStatus = allComplete
|
|
391
392
|
? { fetchState: 'Completed', error: undefined }
|
|
392
393
|
: {
|
|
393
394
|
fetchState: 'Error',
|
|
394
395
|
error: createZeniAPIStatus('Partial match-and-reverse', 'Some accruals were not reversed'),
|
|
395
396
|
};
|
|
396
|
-
|
|
397
|
-
draft.matchModal.confirmStatus = confirmStatus;
|
|
398
|
-
draft.matchModal.lastBatchResults = results;
|
|
399
|
-
}
|
|
397
|
+
draft.matchModal.lastBatchResults = results;
|
|
400
398
|
if (action.payload.matchId != null) {
|
|
401
|
-
draft.confirmStatusByMatchId[action.payload.matchId] = confirmStatus;
|
|
402
399
|
draft.lastMatchResultsByMatchId[action.payload.matchId] = results;
|
|
403
400
|
pruneLastUndoResultsForMatched(draft, action.payload.matchId, action.payload.results);
|
|
404
401
|
}
|
|
405
402
|
},
|
|
406
403
|
matchAndReverseAccrualsFailure(draft, action) {
|
|
407
|
-
|
|
404
|
+
draft.matchModal.confirmStatus = {
|
|
408
405
|
fetchState: 'Error',
|
|
409
406
|
error: action.payload.status,
|
|
410
407
|
};
|
|
411
|
-
if (action.payload.forMatchModal === true) {
|
|
412
|
-
draft.matchModal.confirmStatus = failed;
|
|
413
|
-
}
|
|
414
|
-
if (action.payload.matchId != null) {
|
|
415
|
-
draft.confirmStatusByMatchId[action.payload.matchId] = failed;
|
|
416
|
-
}
|
|
417
408
|
},
|
|
418
409
|
undoReversalAccruals: {
|
|
419
410
|
reducer(draft, action) {
|
|
@@ -435,12 +426,7 @@ const expenseAutomationActualMatchingView = createSlice({
|
|
|
435
426
|
};
|
|
436
427
|
const allUndone = results.length > 0 &&
|
|
437
428
|
results.every((result) => result.status === 'undone');
|
|
438
|
-
|
|
439
|
-
enqueueCloseMatchId(draft.closeMatchAfterUndoMatchIds, matchId);
|
|
440
|
-
}
|
|
441
|
-
else {
|
|
442
|
-
draft.closeMatchAfterUndoMatchIds = dropCloseMatchId(draft.closeMatchAfterUndoMatchIds, matchId);
|
|
443
|
-
}
|
|
429
|
+
draft.closeMatchAfterUndo = allUndone;
|
|
444
430
|
pruneLastMatchResultsForUndone(draft, matchId, results);
|
|
445
431
|
if (allUndone) {
|
|
446
432
|
delete draft.lastUndoResultsByMatchId[matchId];
|
|
@@ -454,44 +440,7 @@ const expenseAutomationActualMatchingView = createSlice({
|
|
|
454
440
|
},
|
|
455
441
|
},
|
|
456
442
|
ackCloseMatchAfterUndo(draft) {
|
|
457
|
-
draft.
|
|
458
|
-
},
|
|
459
|
-
ignoreActualMatchingSuggestion: {
|
|
460
|
-
prepare(matchId, reason, note) {
|
|
461
|
-
return { payload: { matchId, reason, note } };
|
|
462
|
-
},
|
|
463
|
-
reducer(draft, action) {
|
|
464
|
-
draft.ignoreStatusByMatchId[action.payload.matchId] = {
|
|
465
|
-
fetchState: 'In-Progress',
|
|
466
|
-
error: undefined,
|
|
467
|
-
};
|
|
468
|
-
},
|
|
469
|
-
},
|
|
470
|
-
ignoreActualMatchingSuggestionSuccess(draft, action) {
|
|
471
|
-
const { matchId } = action.payload;
|
|
472
|
-
draft.ignoreStatusByMatchId[matchId] = {
|
|
473
|
-
fetchState: 'Completed',
|
|
474
|
-
error: undefined,
|
|
475
|
-
};
|
|
476
|
-
enqueueCloseMatchId(draft.closeMatchAfterIgnoreMatchIds, matchId);
|
|
477
|
-
delete draft.lastMatchResultsByMatchId[matchId];
|
|
478
|
-
delete draft.lastUndoResultsByMatchId[matchId];
|
|
479
|
-
delete draft.detailFetchStateByMatchId[matchId];
|
|
480
|
-
delete draft.detailRefreshStatusByMatchId[matchId];
|
|
481
|
-
delete draft.undoReversalStatusByMatchId[matchId];
|
|
482
|
-
delete draft.confirmStatusByMatchId[matchId];
|
|
483
|
-
Object.keys(draft.matchIdsByPeriod).forEach((periodId) => {
|
|
484
|
-
draft.matchIdsByPeriod[periodId] = draft.matchIdsByPeriod[periodId].filter((id) => id !== matchId);
|
|
485
|
-
});
|
|
486
|
-
},
|
|
487
|
-
ignoreActualMatchingSuggestionFailure(draft, action) {
|
|
488
|
-
draft.ignoreStatusByMatchId[action.payload.matchId] = {
|
|
489
|
-
fetchState: 'Error',
|
|
490
|
-
error: action.payload.status,
|
|
491
|
-
};
|
|
492
|
-
},
|
|
493
|
-
ackCloseMatchAfterIgnore(draft) {
|
|
494
|
-
draft.closeMatchAfterIgnoreMatchIds.shift();
|
|
443
|
+
draft.closeMatchAfterUndo = false;
|
|
495
444
|
},
|
|
496
445
|
undoReversalAccrualsFailure(draft, action) {
|
|
497
446
|
draft.undoReversalStatusByMatchId[action.payload.matchId] = {
|
|
@@ -509,5 +458,5 @@ const expenseAutomationActualMatchingView = createSlice({
|
|
|
509
458
|
});
|
|
510
459
|
},
|
|
511
460
|
});
|
|
512
|
-
export const {
|
|
461
|
+
export const { ackCloseMatchAfterUndo, clearActualMatchingView, clearMatchNewModal, closeMatchNewModal, fetchActualMatching, fetchActualMatchingFailure, fetchActualMatchingMatch, fetchActualMatchingMatchFailure, fetchActualMatchingMatchSuccess, fetchActualMatchingPage, fetchActualMatchingSuccess, matchAndReverseAccruals, matchAndReverseAccrualsFailure, matchAndReverseAccrualsSuccess, openMatchNewModal, searchMatchAccruals, searchMatchAccrualsFailure, searchMatchAccrualsSuccess, searchMatchTransactions, searchMatchTransactionsFailure, searchMatchTransactionsSuccess, undoReversalAccruals, undoReversalAccrualsFailure, undoReversalAccrualsSuccess, updateActualMatchingUIState, } = expenseAutomationActualMatchingView.actions;
|
|
513
462
|
export default expenseAutomationActualMatchingView.reducer;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import orderBy from 'lodash/orderBy';
|
|
2
|
-
import { createSelector } from '@reduxjs/toolkit';
|
|
3
2
|
import { toMonthYearPeriodId, } from '../../../commonStateTypes/timePeriod';
|
|
4
3
|
import { getActualMatchingMatchById } from '../../../entity/actualMatching/actualMatchingSelector';
|
|
5
4
|
import { generateJEOneTimeAccrualKey } from '../../../entity/jeSchedules/jeScheduleHelper';
|
|
6
5
|
import { getJEOneTimeAccrualByKey, } from '../../../entity/jeSchedules/jeSchedulesSelector';
|
|
7
6
|
import { getCurrentTenant } from '../../../entity/tenant/tenantSelector';
|
|
8
7
|
import { date } from '../../../zeniDayJS';
|
|
8
|
+
import { actualMatchingTransactionLineKey, } from '../types/actualMatchingViewState';
|
|
9
9
|
export function getSelectedMonthYearForCurrentTenant(state) {
|
|
10
10
|
const tenantId = getCurrentTenant(state)?.tenantId;
|
|
11
11
|
if (tenantId == null) {
|
|
@@ -34,6 +34,27 @@ function toMatchModalAccrual(member) {
|
|
|
34
34
|
jeOneTimeAccrualKey: generateJEOneTimeAccrualKey(member.accrualId),
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
+
function uniqueMatchModalAccruals(pinned, searched) {
|
|
38
|
+
const byId = new Map();
|
|
39
|
+
pinned.forEach((row) => byId.set(row.accrualId, row));
|
|
40
|
+
searched.forEach((row) => {
|
|
41
|
+
if (!byId.has(row.accrualId)) {
|
|
42
|
+
byId.set(row.accrualId, row);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
return Array.from(byId.values());
|
|
46
|
+
}
|
|
47
|
+
function uniqueTransactionSearchResults(pinned, searched) {
|
|
48
|
+
const byKey = new Map();
|
|
49
|
+
pinned.forEach((row) => byKey.set(actualMatchingTransactionLineKey(row.transactionType, row.transactionIntegrationId, row.lineId), row));
|
|
50
|
+
searched.forEach((row) => {
|
|
51
|
+
const key = actualMatchingTransactionLineKey(row.transactionType, row.transactionIntegrationId, row.lineId);
|
|
52
|
+
if (!byKey.has(key)) {
|
|
53
|
+
byKey.set(key, row);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
return Array.from(byKey.values());
|
|
57
|
+
}
|
|
37
58
|
export function parseActualMatchingMatchId(matchId) {
|
|
38
59
|
const separator = matchId.indexOf(':');
|
|
39
60
|
if (separator <= 0 || separator === matchId.length - 1) {
|
|
@@ -206,7 +227,6 @@ function emptyKpiSummary() {
|
|
|
206
227
|
actualsReceived: { count: 0, expectedCount: 0, vendorsPending: 0 },
|
|
207
228
|
autoReversed: { count: 0, percent: 0, clearedAmount: 0 },
|
|
208
229
|
pendingReview: { count: 0, amount: 0, estimatedMinutesToClear: 0 },
|
|
209
|
-
reversed: { count: 0 },
|
|
210
230
|
variance: { percent: 0, averagePercentPerMatch: 0, netAmount: 0 },
|
|
211
231
|
};
|
|
212
232
|
}
|
|
@@ -262,7 +282,6 @@ export function buildActualMatchingKpiSummary(rows, displayCurrencyCode) {
|
|
|
262
282
|
}
|
|
263
283
|
const autoReversed = kpiRows.filter((row) => row.kind === 'auto_reversed');
|
|
264
284
|
const pendingReview = kpiRows.filter((row) => row.kind === 'pending_review');
|
|
265
|
-
const reversed = kpiRows.filter((row) => isReversedMatchKind(row.kind));
|
|
266
285
|
const receivedCount = kpiRows.length;
|
|
267
286
|
const rowsWithActual = kpiRows.filter((row) => row.actualAmount?.amount != null);
|
|
268
287
|
const accruedTotal = rowsWithActual.reduce((sum, row) => sum + (row.accruedAmount?.amount ?? row.estimatedAmount.amount), 0);
|
|
@@ -288,9 +307,6 @@ export function buildActualMatchingKpiSummary(rows, displayCurrencyCode) {
|
|
|
288
307
|
amount: sumRowAmounts(pendingReview, displayCurrencyCode),
|
|
289
308
|
estimatedMinutesToClear: pendingReview.length * ESTIMATED_MINUTES_PER_PENDING_MATCH,
|
|
290
309
|
},
|
|
291
|
-
reversed: {
|
|
292
|
-
count: reversed.length,
|
|
293
|
-
},
|
|
294
310
|
variance: {
|
|
295
311
|
percent: accruedTotal === 0
|
|
296
312
|
? 0
|
|
@@ -303,56 +319,23 @@ export function buildActualMatchingKpiSummary(rows, displayCurrencyCode) {
|
|
|
303
319
|
},
|
|
304
320
|
};
|
|
305
321
|
}
|
|
306
|
-
function
|
|
322
|
+
export function getExpenseAutomationActualMatchingMatchView(state, matchId) {
|
|
323
|
+
const view = state.expenseAutomationActualMatchingViewState;
|
|
307
324
|
return {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
325
|
+
match: getActualMatchingMatchById(state.actualMatchingState, matchId),
|
|
326
|
+
detailFetchState: view.detailFetchStateByMatchId[matchId] ?? NOT_STARTED,
|
|
327
|
+
refreshStatus: view.detailRefreshStatusByMatchId[matchId] ?? NOT_STARTED,
|
|
328
|
+
undoReversalStatus: view.undoReversalStatusByMatchId[matchId] ?? NOT_STARTED,
|
|
329
|
+
lastMatchResults: view.lastMatchResultsByMatchId?.[matchId],
|
|
330
|
+
lastUndoResults: view.lastUndoResultsByMatchId?.[matchId],
|
|
313
331
|
};
|
|
314
332
|
}
|
|
315
|
-
const EMPTY_ACTUAL_MATCHING_ROWS = [];
|
|
316
|
-
const matchViewSelectorById = new Map();
|
|
317
|
-
export function getExpenseAutomationActualMatchingMatchView(state, matchId) {
|
|
318
|
-
let selector = matchViewSelectorById.get(matchId);
|
|
319
|
-
if (selector == null) {
|
|
320
|
-
selector = createSelector([
|
|
321
|
-
(root) => root.expenseAutomationActualMatchingViewState,
|
|
322
|
-
(root) => getActualMatchingMatchById(root.actualMatchingState, matchId),
|
|
323
|
-
], (view, match) => ({
|
|
324
|
-
detailFetchState: view.detailFetchStateByMatchId[matchId] ?? NOT_STARTED,
|
|
325
|
-
ignoreStatus: view.ignoreStatusByMatchId[matchId] ?? NOT_STARTED,
|
|
326
|
-
lastMatchResults: view.lastMatchResultsByMatchId?.[matchId],
|
|
327
|
-
lastUndoResults: view.lastUndoResultsByMatchId?.[matchId],
|
|
328
|
-
match: match == null ? undefined : toActualMatchingMatchView(match),
|
|
329
|
-
refreshStatus: view.detailRefreshStatusByMatchId[matchId] ?? NOT_STARTED,
|
|
330
|
-
undoReversalStatus: view.undoReversalStatusByMatchId[matchId] ?? NOT_STARTED,
|
|
331
|
-
}));
|
|
332
|
-
matchViewSelectorById.set(matchId, selector);
|
|
333
|
-
}
|
|
334
|
-
return selector(state);
|
|
335
|
-
}
|
|
336
333
|
export function getCloseMatchAfterUndo(state) {
|
|
337
|
-
return state.expenseAutomationActualMatchingViewState
|
|
338
|
-
.closeMatchAfterUndoMatchIds[0];
|
|
339
|
-
}
|
|
340
|
-
export function getCloseMatchAfterUndoMatchId(state) {
|
|
341
|
-
return getCloseMatchAfterUndo(state);
|
|
342
|
-
}
|
|
343
|
-
export function getCloseMatchAfterIgnoreMatchId(state) {
|
|
344
|
-
return state.expenseAutomationActualMatchingViewState
|
|
345
|
-
.closeMatchAfterIgnoreMatchIds[0];
|
|
346
|
-
}
|
|
347
|
-
export function getActualMatchingMatchModalConfirmStatus(state, matchId) {
|
|
348
|
-
if (matchId != null && matchId !== '') {
|
|
349
|
-
return (state.expenseAutomationActualMatchingViewState.confirmStatusByMatchId[matchId] ?? NOT_STARTED);
|
|
350
|
-
}
|
|
351
|
-
return state.expenseAutomationActualMatchingViewState.matchModal.confirmStatus;
|
|
334
|
+
return state.expenseAutomationActualMatchingViewState.closeMatchAfterUndo;
|
|
352
335
|
}
|
|
353
336
|
export function getExpenseAutomationActualMatchingView(state) {
|
|
354
337
|
const { expenseAutomationActualMatchingViewState } = state;
|
|
355
|
-
const { matchIdsByPeriod, fetchState, error, refreshStatus, uiState, matchModal,
|
|
338
|
+
const { matchIdsByPeriod, fetchState, error, refreshStatus, uiState, matchModal, } = expenseAutomationActualMatchingViewState;
|
|
356
339
|
const selectedPeriod = getSelectedMonthYearForCurrentTenant(state);
|
|
357
340
|
const monthYearPeriodId = selectedPeriod != null ? toMonthYearPeriodId(selectedPeriod) : undefined;
|
|
358
341
|
const matchIds = monthYearPeriodId != null ? matchIdsByPeriod[monthYearPeriodId] : undefined;
|
|
@@ -362,18 +345,38 @@ export function getExpenseAutomationActualMatchingView(state) {
|
|
|
362
345
|
.filter((match) => match.members.length > 0)
|
|
363
346
|
.map(toActualMatchingRow);
|
|
364
347
|
const rows = allRows.filter((row) => matchesSearch(row, uiState.searchString));
|
|
365
|
-
const
|
|
366
|
-
const
|
|
367
|
-
const reversed = includeReversed
|
|
368
|
-
? sortActualMatchingRows(rows.filter((row) => isReversedMatchKind(row.kind)), uiState)
|
|
369
|
-
: EMPTY_ACTUAL_MATCHING_ROWS;
|
|
370
|
-
const pendingReview = includePendingReview
|
|
371
|
-
? sortActualMatchingRows(rows.filter((row) => row.kind === 'pending_review'), uiState)
|
|
372
|
-
: EMPTY_ACTUAL_MATCHING_ROWS;
|
|
348
|
+
const reversed = sortActualMatchingRows(rows.filter((row) => isReversedMatchKind(row.kind)), uiState);
|
|
349
|
+
const pendingReview = sortActualMatchingRows(rows.filter((row) => row.kind === 'pending_review'), uiState);
|
|
373
350
|
const kpiSummary = buildActualMatchingKpiSummary(allRows, getTenantDisplayCurrency(state)?.currencyCode);
|
|
374
351
|
const searchedAccruals = matchModal.accrualSearch.results
|
|
375
352
|
.map((key) => getJEOneTimeAccrualByKey(key, state.jeSchedulesState))
|
|
376
353
|
.filter((accrual) => accrual != null);
|
|
354
|
+
const openedMatch = matchModal.openedFromMatchId != null
|
|
355
|
+
? getActualMatchingMatchById(state.actualMatchingState, matchModal.openedFromMatchId)
|
|
356
|
+
: undefined;
|
|
357
|
+
const pinnedAccruals = [
|
|
358
|
+
...(openedMatch?.members ?? []),
|
|
359
|
+
...(openedMatch?.leftovers ?? []),
|
|
360
|
+
].map(toMatchModalAccrual);
|
|
361
|
+
const firstMember = openedMatch?.members[0];
|
|
362
|
+
const cleared = firstMember?.cleared;
|
|
363
|
+
const suggestion = firstMember?.matchSuggestion;
|
|
364
|
+
const stamp = cleared ?? suggestion;
|
|
365
|
+
const consumedLineIds = cleared?.consumedLineIds;
|
|
366
|
+
const prefill = openedMatch == null
|
|
367
|
+
? undefined
|
|
368
|
+
: {
|
|
369
|
+
selectedAccrualIds: [
|
|
370
|
+
...openedMatch.members.map((member) => member.accrualId),
|
|
371
|
+
...(openedMatch.leftovers ?? []).map((leftover) => leftover.accrualId),
|
|
372
|
+
],
|
|
373
|
+
actualAmount: openedMatch.actualAmount.amount,
|
|
374
|
+
matchedTransactionId: stamp?.matchedTransactionId,
|
|
375
|
+
matchedLineId: cleared == null ? suggestion?.matchedLineId : undefined,
|
|
376
|
+
...(consumedLineIds != null && consumedLineIds.length > 0
|
|
377
|
+
? { consumedLineIds }
|
|
378
|
+
: {}),
|
|
379
|
+
};
|
|
377
380
|
// `fetchState` is a flat slice field that survives a period switch. Until this
|
|
378
381
|
// month's ids land, leftover Completed/Error is the previous month. Report
|
|
379
382
|
// Not-Started so chrome matches Review's "cache slot missing" skeleton, not
|
|
@@ -391,16 +394,16 @@ export function getExpenseAutomationActualMatchingView(state) {
|
|
|
391
394
|
kpiSummary,
|
|
392
395
|
uiState,
|
|
393
396
|
refreshStatus,
|
|
394
|
-
ignoreStatusByMatchId,
|
|
395
|
-
undoReversalStatusByMatchId,
|
|
396
397
|
hasLoadedForSelectedPeriod: matchIds != null,
|
|
397
398
|
matchModal: {
|
|
398
399
|
isOpen: matchModal.isOpen,
|
|
400
|
+
openedFromMatchId: matchModal.openedFromMatchId,
|
|
401
|
+
prefill,
|
|
399
402
|
confirmStatus: matchModal.confirmStatus,
|
|
400
403
|
lastBatchResults: matchModal.lastBatchResults,
|
|
401
404
|
transactionSearch: {
|
|
402
405
|
query: matchModal.transactionSearch.query,
|
|
403
|
-
results: matchModal.transactionSearch.results,
|
|
406
|
+
results: uniqueTransactionSearchResults(matchModal.pinnedTransactionResults, matchModal.transactionSearch.results),
|
|
404
407
|
fetchState: {
|
|
405
408
|
fetchState: matchModal.transactionSearch.fetchState,
|
|
406
409
|
error: matchModal.transactionSearch.error,
|
|
@@ -410,7 +413,7 @@ export function getExpenseAutomationActualMatchingView(state) {
|
|
|
410
413
|
},
|
|
411
414
|
accrualSearch: {
|
|
412
415
|
query: matchModal.accrualSearch.query,
|
|
413
|
-
results: searchedAccruals,
|
|
416
|
+
results: uniqueMatchModalAccruals(pinnedAccruals, searchedAccruals),
|
|
414
417
|
fetchState: {
|
|
415
418
|
fetchState: matchModal.accrualSearch.fetchState,
|
|
416
419
|
error: matchModal.accrualSearch.error,
|
|
@@ -13,12 +13,6 @@ const ACTUAL_MATCHING_SORT_KEYS = [
|
|
|
13
13
|
'variance',
|
|
14
14
|
];
|
|
15
15
|
export const toActualMatchingSortKey = (v) => stringToUnion(v, ACTUAL_MATCHING_SORT_KEYS);
|
|
16
|
-
const ACTUAL_MATCHING_STATUS_FILTERS = [
|
|
17
|
-
'all',
|
|
18
|
-
'pending_review',
|
|
19
|
-
'reversed',
|
|
20
|
-
];
|
|
21
|
-
export const toActualMatchingStatusFilter = (v) => stringToUnion(v, ACTUAL_MATCHING_STATUS_FILTERS);
|
|
22
16
|
export const MATCH_TRANSACTION_SEARCH_PAGE_SIZE = 50;
|
|
23
17
|
export const MATCH_ACCRUAL_SEARCH_LIMIT = 50;
|
|
24
18
|
export const MATCH_SEARCH_DEBOUNCE_MS = 300;
|
|
@@ -39,15 +33,6 @@ const UNDO_REVERSAL_RESULT_STATUSES = [
|
|
|
39
33
|
'error',
|
|
40
34
|
];
|
|
41
35
|
export const toUndoReversalResultStatus = (v) => stringToUnion(v, UNDO_REVERSAL_RESULT_STATUSES);
|
|
42
|
-
const ACTUAL_MATCHING_IGNORE_REASONS = [
|
|
43
|
-
'wrong_bill',
|
|
44
|
-
'wrong_period',
|
|
45
|
-
'amount_off',
|
|
46
|
-
'already_handled',
|
|
47
|
-
'other_ignore',
|
|
48
|
-
];
|
|
49
|
-
export const toActualMatchingIgnoreReasonType = (v) => stringToUnion(v, ACTUAL_MATCHING_IGNORE_REASONS);
|
|
50
|
-
export const ALL_ACTUAL_MATCHING_IGNORE_REASONS = ACTUAL_MATCHING_IGNORE_REASONS;
|
|
51
36
|
export function actualMatchingTransactionLineKey(transactionType, transactionIntegrationId, lineId) {
|
|
52
37
|
return `${transactionType}:${transactionIntegrationId}:${lineId}`;
|
|
53
38
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { from } from 'rxjs';
|
|
2
|
+
import { catchError, filter, mergeMap } from 'rxjs/operators';
|
|
3
|
+
import { openSnackbar } from '../../../../../entity/snackbar/snackbarReducer';
|
|
4
|
+
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../../responsePayload';
|
|
5
|
+
import { resetKycKyb, resetKycKybFailure, resetKycKybSuccess, } from '../../setupViewReducer';
|
|
6
|
+
export const resetKycKybEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(resetKycKyb.match), mergeMap(() => zeniAPI
|
|
7
|
+
.putAndGetJSON(`${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/kyc-kyb-reset`, { is_reset_company_officers: false })
|
|
8
|
+
.pipe(mergeMap((response) => {
|
|
9
|
+
if (isSuccessResponse(response)) {
|
|
10
|
+
return from([
|
|
11
|
+
resetKycKybSuccess(),
|
|
12
|
+
openSnackbar({
|
|
13
|
+
messageSection: 'kyc_kyb_reset',
|
|
14
|
+
messageText: 'success',
|
|
15
|
+
type: 'success',
|
|
16
|
+
}),
|
|
17
|
+
]);
|
|
18
|
+
}
|
|
19
|
+
return from([
|
|
20
|
+
resetKycKybFailure(response.status),
|
|
21
|
+
openSnackbar({
|
|
22
|
+
messageSection: 'kyc_kyb_reset',
|
|
23
|
+
messageText: 'failed',
|
|
24
|
+
type: 'error',
|
|
25
|
+
}),
|
|
26
|
+
]);
|
|
27
|
+
}), catchError((error) => from([
|
|
28
|
+
resetKycKybFailure(createZeniAPIStatus('Unexpected error', 'Reset KYC/KYB errored out: ' +
|
|
29
|
+
(error instanceof Error
|
|
30
|
+
? error.message
|
|
31
|
+
: JSON.stringify(error)))),
|
|
32
|
+
openSnackbar({
|
|
33
|
+
messageSection: 'kyc_kyb_reset',
|
|
34
|
+
messageText: 'failed',
|
|
35
|
+
type: 'error',
|
|
36
|
+
}),
|
|
37
|
+
])))));
|