@zeniai/client-epic-state 5.2.22-betaAM1 → 5.2.22

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.
Files changed (63) hide show
  1. package/lib/entity/jeSchedules/jeSchedulesPayload.d.ts +0 -24
  2. package/lib/entity/jeSchedules/jeSchedulesPayload.js +0 -40
  3. package/lib/entity/jeSchedules/jeSchedulesState.d.ts +0 -26
  4. package/lib/epic.d.ts +1 -6
  5. package/lib/epic.js +0 -10
  6. package/lib/esm/entity/jeSchedules/jeSchedulesPayload.js +0 -40
  7. package/lib/esm/epic.js +0 -10
  8. package/lib/esm/index.js +2 -6
  9. package/lib/esm/reducer.js +0 -3
  10. package/lib/esm/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +11 -28
  11. package/lib/esm/view/expenseAutomationView/epics/common/refreshExpenseAutomationCurrentTabEpic.js +1 -9
  12. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +0 -5
  13. package/lib/esm/view/expenseAutomationView/expenseAutomationViewSelector.js +7 -22
  14. package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +0 -3
  15. package/lib/esm/view/expenseAutomationView/types/jeSchedulesViewState.js +1 -5
  16. package/lib/index.d.ts +4 -9
  17. package/lib/index.js +47 -73
  18. package/lib/reducer.d.ts +0 -1
  19. package/lib/reducer.js +0 -3
  20. package/lib/rootStateTypes.d.ts +0 -2
  21. package/lib/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.d.ts +1 -2
  22. package/lib/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +11 -28
  23. package/lib/view/expenseAutomationView/epics/common/refreshExpenseAutomationCurrentTabEpic.d.ts +1 -2
  24. package/lib/view/expenseAutomationView/epics/common/refreshExpenseAutomationCurrentTabEpic.js +1 -9
  25. package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.d.ts +1 -2
  26. package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +0 -5
  27. package/lib/view/expenseAutomationView/expenseAutomationViewSelector.js +7 -22
  28. package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +2 -2
  29. package/lib/view/expenseAutomationView/selectorTypes/expenseAutomationViewSelectorTypes.d.ts +0 -2
  30. package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +0 -3
  31. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +1 -1
  32. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.js +1 -5
  33. package/package.json +1 -1
  34. package/lib/esm/view/expenseAutomationView/epics/actualMatching/fetchActualMatchingEpic.js +0 -46
  35. package/lib/esm/view/expenseAutomationView/epics/actualMatching/fetchActualMatchingPageEpic.js +0 -7
  36. package/lib/esm/view/expenseAutomationView/epics/actualMatching/matchAndReverseAccrualsEpic.js +0 -50
  37. package/lib/esm/view/expenseAutomationView/epics/actualMatching/searchMatchAccrualsEpic.js +0 -44
  38. package/lib/esm/view/expenseAutomationView/epics/actualMatching/searchMatchTransactionsEpic.js +0 -44
  39. package/lib/esm/view/expenseAutomationView/payload/actualMatchingPayload.js +0 -60
  40. package/lib/esm/view/expenseAutomationView/reducers/actualMatchingViewReducer.js +0 -260
  41. package/lib/esm/view/expenseAutomationView/selectorTypes/actualMatchingViewSelectorTypes.js +0 -1
  42. package/lib/esm/view/expenseAutomationView/selectors/actualMatchingViewSelector.js +0 -200
  43. package/lib/esm/view/expenseAutomationView/types/actualMatchingViewState.js +0 -22
  44. package/lib/view/expenseAutomationView/epics/actualMatching/fetchActualMatchingEpic.d.ts +0 -9
  45. package/lib/view/expenseAutomationView/epics/actualMatching/fetchActualMatchingEpic.js +0 -50
  46. package/lib/view/expenseAutomationView/epics/actualMatching/fetchActualMatchingPageEpic.d.ts +0 -5
  47. package/lib/view/expenseAutomationView/epics/actualMatching/fetchActualMatchingPageEpic.js +0 -11
  48. package/lib/view/expenseAutomationView/epics/actualMatching/matchAndReverseAccrualsEpic.d.ts +0 -8
  49. package/lib/view/expenseAutomationView/epics/actualMatching/matchAndReverseAccrualsEpic.js +0 -54
  50. package/lib/view/expenseAutomationView/epics/actualMatching/searchMatchAccrualsEpic.d.ts +0 -8
  51. package/lib/view/expenseAutomationView/epics/actualMatching/searchMatchAccrualsEpic.js +0 -48
  52. package/lib/view/expenseAutomationView/epics/actualMatching/searchMatchTransactionsEpic.d.ts +0 -8
  53. package/lib/view/expenseAutomationView/epics/actualMatching/searchMatchTransactionsEpic.js +0 -48
  54. package/lib/view/expenseAutomationView/payload/actualMatchingPayload.d.ts +0 -72
  55. package/lib/view/expenseAutomationView/payload/actualMatchingPayload.js +0 -65
  56. package/lib/view/expenseAutomationView/reducers/actualMatchingViewReducer.d.ts +0 -53
  57. package/lib/view/expenseAutomationView/reducers/actualMatchingViewReducer.js +0 -264
  58. package/lib/view/expenseAutomationView/selectorTypes/actualMatchingViewSelectorTypes.d.ts +0 -59
  59. package/lib/view/expenseAutomationView/selectorTypes/actualMatchingViewSelectorTypes.js +0 -2
  60. package/lib/view/expenseAutomationView/selectors/actualMatchingViewSelector.d.ts +0 -11
  61. package/lib/view/expenseAutomationView/selectors/actualMatchingViewSelector.js +0 -212
  62. package/lib/view/expenseAutomationView/types/actualMatchingViewState.d.ts +0 -81
  63. package/lib/view/expenseAutomationView/types/actualMatchingViewState.js +0 -27
@@ -1,260 +0,0 @@
1
- import { createSlice } from '@reduxjs/toolkit';
2
- import { toMonthYearPeriodId, } from '../../../commonStateTypes/timePeriod';
3
- import { generateJEOneTimeAccrualKey } from '../../../entity/jeSchedules/jeScheduleHelper';
4
- import { clearAll } from '../../../rootActions';
5
- export const initialTransactionSearchState = {
6
- query: '',
7
- results: [],
8
- fetchState: 'Not-Started',
9
- error: undefined,
10
- nextPageToken: null,
11
- isLoadingMore: false,
12
- };
13
- export const initialAccrualSearchState = {
14
- query: '',
15
- results: [],
16
- fetchState: 'Not-Started',
17
- error: undefined,
18
- nextPageToken: null,
19
- isLoadingMore: false,
20
- };
21
- export const initialMatchModalState = {
22
- isOpen: false,
23
- transactionSearch: initialTransactionSearchState,
24
- accrualSearch: initialAccrualSearchState,
25
- confirmStatus: { fetchState: 'Not-Started', error: undefined },
26
- };
27
- export const initialState = {
28
- accrualKeysByPeriod: {},
29
- fetchState: 'Not-Started',
30
- error: undefined,
31
- refreshStatus: {
32
- fetchState: 'Not-Started',
33
- error: undefined,
34
- },
35
- uiState: {
36
- sortKey: 'date',
37
- sortOrder: 'descending',
38
- searchString: '',
39
- scrollPosition: { scrollTop: 0, scrollLeft: undefined },
40
- },
41
- matchModal: initialMatchModalState,
42
- hasValidState() {
43
- return this.fetchState == 'Completed';
44
- },
45
- };
46
- function resetMatchModalSearches(draft) {
47
- draft.matchModal.transactionSearch = initialTransactionSearchState;
48
- draft.matchModal.accrualSearch = initialAccrualSearchState;
49
- draft.matchModal.confirmStatus = {
50
- fetchState: 'Not-Started',
51
- error: undefined,
52
- };
53
- draft.matchModal.lastBatchResults = undefined;
54
- }
55
- const expenseAutomationActualMatchingView = createSlice({
56
- name: 'expenseAutomationActualMatchingView',
57
- initialState,
58
- reducers: {
59
- fetchActualMatchingPage: {
60
- prepare(period, refreshViewInBackground = false) {
61
- return {
62
- payload: {
63
- period,
64
- refreshViewInBackground,
65
- },
66
- };
67
- },
68
- reducer() {
69
- // Epic-only fan-out.
70
- },
71
- },
72
- fetchActualMatching: {
73
- reducer(draft, action) {
74
- const { refreshViewInBackground } = action.payload;
75
- if (refreshViewInBackground) {
76
- draft.refreshStatus = { fetchState: 'In-Progress', error: undefined };
77
- }
78
- else {
79
- draft.fetchState = 'In-Progress';
80
- draft.error = undefined;
81
- }
82
- },
83
- prepare(period, refreshViewInBackground = false) {
84
- return {
85
- payload: {
86
- period,
87
- refreshViewInBackground,
88
- },
89
- };
90
- },
91
- },
92
- fetchActualMatchingSuccess(draft, action) {
93
- const { accruals, selectedPeriod, refreshViewInBackground } = action.payload;
94
- const periodId = toMonthYearPeriodId(selectedPeriod);
95
- draft.accrualKeysByPeriod[periodId] = accruals.map((accrual) => generateJEOneTimeAccrualKey(accrual._id));
96
- if (refreshViewInBackground) {
97
- draft.refreshStatus = { fetchState: 'Completed', error: undefined };
98
- }
99
- else {
100
- draft.fetchState = 'Completed';
101
- draft.error = undefined;
102
- }
103
- },
104
- fetchActualMatchingFailure(draft, action) {
105
- const { status, refreshViewInBackground } = action.payload;
106
- if (refreshViewInBackground) {
107
- draft.refreshStatus = { fetchState: 'Error', error: status };
108
- }
109
- else {
110
- draft.fetchState = 'Error';
111
- draft.error = status;
112
- }
113
- },
114
- updateActualMatchingUIState(draft, action) {
115
- if (action.payload.sortKey != null) {
116
- draft.uiState.sortKey = action.payload.sortKey;
117
- }
118
- if (action.payload.sortOrder != null) {
119
- draft.uiState.sortOrder = action.payload.sortOrder;
120
- }
121
- if (action.payload.searchString != null) {
122
- draft.uiState.searchString = action.payload.searchString;
123
- }
124
- if (action.payload.scrollPosition != null) {
125
- draft.uiState.scrollPosition = action.payload.scrollPosition;
126
- }
127
- },
128
- openMatchNewModal(draft) {
129
- draft.matchModal.isOpen = true;
130
- },
131
- closeMatchNewModal(draft) {
132
- draft.matchModal.isOpen = false;
133
- resetMatchModalSearches(draft);
134
- },
135
- clearMatchNewModal(draft) {
136
- draft.matchModal.isOpen = false;
137
- resetMatchModalSearches(draft);
138
- },
139
- searchMatchTransactions: {
140
- reducer(draft, action) {
141
- const { query, pageToken } = action.payload;
142
- const isLoadMore = pageToken != null;
143
- draft.matchModal.transactionSearch.query = query;
144
- if (isLoadMore) {
145
- draft.matchModal.transactionSearch.isLoadingMore = true;
146
- }
147
- else {
148
- draft.matchModal.transactionSearch.isLoadingMore = false;
149
- draft.matchModal.transactionSearch.results = [];
150
- draft.matchModal.transactionSearch.nextPageToken = null;
151
- draft.matchModal.transactionSearch.fetchState = 'In-Progress';
152
- draft.matchModal.transactionSearch.error = undefined;
153
- }
154
- },
155
- prepare({ query, pageToken }) {
156
- return { payload: { query, pageToken: pageToken ?? undefined } };
157
- },
158
- },
159
- searchMatchTransactionsSuccess(draft, action) {
160
- const { append, nextPageToken, results } = action.payload;
161
- if (append) {
162
- const merged = [
163
- ...draft.matchModal.transactionSearch.results,
164
- ...results,
165
- ];
166
- const byKey = new Map(merged.map((result) => [
167
- `${result.transactionId}:${result.lineId}`,
168
- result,
169
- ]));
170
- draft.matchModal.transactionSearch.results = Array.from(byKey.values());
171
- }
172
- else {
173
- draft.matchModal.transactionSearch.results = results;
174
- }
175
- draft.matchModal.transactionSearch.nextPageToken = nextPageToken;
176
- draft.matchModal.transactionSearch.isLoadingMore = false;
177
- draft.matchModal.transactionSearch.fetchState = 'Completed';
178
- draft.matchModal.transactionSearch.error = undefined;
179
- },
180
- searchMatchTransactionsFailure(draft, action) {
181
- draft.matchModal.transactionSearch.isLoadingMore = false;
182
- draft.matchModal.transactionSearch.fetchState = 'Error';
183
- draft.matchModal.transactionSearch.error = action.payload.error;
184
- },
185
- searchMatchAccruals: {
186
- reducer(draft, action) {
187
- const { query, pageToken } = action.payload;
188
- const isLoadMore = pageToken != null;
189
- draft.matchModal.accrualSearch.query = query;
190
- if (isLoadMore) {
191
- draft.matchModal.accrualSearch.isLoadingMore = true;
192
- }
193
- else {
194
- draft.matchModal.accrualSearch.isLoadingMore = false;
195
- draft.matchModal.accrualSearch.results = [];
196
- draft.matchModal.accrualSearch.nextPageToken = null;
197
- draft.matchModal.accrualSearch.fetchState = 'In-Progress';
198
- draft.matchModal.accrualSearch.error = undefined;
199
- }
200
- },
201
- prepare({ query, pageToken }) {
202
- return { payload: { query, pageToken: pageToken ?? undefined } };
203
- },
204
- },
205
- searchMatchAccrualsSuccess(draft, action) {
206
- const { append, nextPageToken, results } = action.payload;
207
- const keys = results.map((accrual) => generateJEOneTimeAccrualKey(accrual._id));
208
- if (append) {
209
- const merged = [...draft.matchModal.accrualSearch.results, ...keys];
210
- draft.matchModal.accrualSearch.results = Array.from(new Set(merged));
211
- }
212
- else {
213
- draft.matchModal.accrualSearch.results = keys;
214
- }
215
- draft.matchModal.accrualSearch.nextPageToken = nextPageToken;
216
- draft.matchModal.accrualSearch.isLoadingMore = false;
217
- draft.matchModal.accrualSearch.fetchState = 'Completed';
218
- draft.matchModal.accrualSearch.error = undefined;
219
- },
220
- searchMatchAccrualsFailure(draft, action) {
221
- draft.matchModal.accrualSearch.isLoadingMore = false;
222
- draft.matchModal.accrualSearch.fetchState = 'Error';
223
- draft.matchModal.accrualSearch.error = action.payload.error;
224
- },
225
- matchAndReverseAccruals: {
226
- reducer(draft) {
227
- draft.matchModal.confirmStatus = {
228
- fetchState: 'In-Progress',
229
- error: undefined,
230
- };
231
- },
232
- prepare(params) {
233
- return { payload: params };
234
- },
235
- },
236
- matchAndReverseAccrualsSuccess(draft, action) {
237
- draft.matchModal.confirmStatus = {
238
- fetchState: 'Completed',
239
- error: undefined,
240
- };
241
- draft.matchModal.lastBatchResults = action.payload.results;
242
- },
243
- matchAndReverseAccrualsFailure(draft, action) {
244
- draft.matchModal.confirmStatus = {
245
- fetchState: 'Error',
246
- error: action.payload.status,
247
- };
248
- },
249
- clearActualMatchingView(draft) {
250
- Object.assign(draft, initialState);
251
- },
252
- },
253
- extraReducers: (builder) => {
254
- builder.addCase(clearAll, (draft) => {
255
- Object.assign(draft, initialState);
256
- });
257
- },
258
- });
259
- export const { clearActualMatchingView, clearMatchNewModal, closeMatchNewModal, fetchActualMatching, fetchActualMatchingFailure, fetchActualMatchingPage, fetchActualMatchingSuccess, matchAndReverseAccruals, matchAndReverseAccrualsFailure, matchAndReverseAccrualsSuccess, openMatchNewModal, searchMatchAccruals, searchMatchAccrualsFailure, searchMatchAccrualsSuccess, searchMatchTransactions, searchMatchTransactionsFailure, searchMatchTransactionsSuccess, updateActualMatchingUIState, } = expenseAutomationActualMatchingView.actions;
260
- export default expenseAutomationActualMatchingView.reducer;
@@ -1,200 +0,0 @@
1
- import orderBy from 'lodash/orderBy';
2
- import { toMonthYearPeriodId } from '../../../commonStateTypes/timePeriod';
3
- import { getJEOneTimeAccrualByKey, } from '../../../entity/jeSchedules/jeSchedulesSelector';
4
- import { getCurrentTenant } from '../../../entity/tenant/tenantSelector';
5
- export function isAutoReversedAccrual(accrual) {
6
- return (accrual.accrualStatus === 'reversed' &&
7
- accrual.reversalTrigger === 'bill_match');
8
- }
9
- export function isManuallyReversedAccrual(accrual) {
10
- return (accrual.accrualStatus === 'reversed' &&
11
- accrual.reversalTrigger === 'manual_reverse');
12
- }
13
- export function isPendingReviewAccrual(accrual) {
14
- if (accrual.accrualStatus !== 'posted' || accrual.matchSuggestion == null) {
15
- return false;
16
- }
17
- const resolution = accrual.matchSuggestion.resolution;
18
- return resolution == null || resolution.length === 0;
19
- }
20
- function isGroupedClearedMatch(accrual) {
21
- const groupSum = accrual.cleared?.groupSum?.amount;
22
- if (groupSum == null || groupSum <= 0) {
23
- return false;
24
- }
25
- const matchShape = accrual.cleared?.matchShape;
26
- const accrualIdsLength = accrual.cleared?.accrualIds?.length ?? 0;
27
- return matchShape === '1:N' || matchShape === 'N:1' || accrualIdsLength > 1;
28
- }
29
- export function getClearedAllocatedActualAmount(accrual) {
30
- const matchedAmount = accrual.cleared?.matchedAmount?.amount;
31
- if (matchedAmount == null) {
32
- return undefined;
33
- }
34
- if (!isGroupedClearedMatch(accrual)) {
35
- return matchedAmount;
36
- }
37
- const groupSum = accrual.cleared?.groupSum?.amount;
38
- if (groupSum == null || groupSum <= 0) {
39
- return matchedAmount;
40
- }
41
- return matchedAmount * (accrual.estimatedAmount.amount / groupSum);
42
- }
43
- export function getActualMatchingAmount(accrual) {
44
- if (isPendingReviewAccrual(accrual)) {
45
- return (accrual.matchSuggestion?.matchedAmount?.amount ??
46
- accrual.estimatedAmount.amount);
47
- }
48
- if (isAutoReversedAccrual(accrual) || isManuallyReversedAccrual(accrual)) {
49
- return (getClearedAllocatedActualAmount(accrual) ?? accrual.estimatedAmount.amount);
50
- }
51
- return accrual.estimatedAmount.amount;
52
- }
53
- export function getActualMatchingReversalDate(accrual) {
54
- if (!isAutoReversedAccrual(accrual) && !isManuallyReversedAccrual(accrual)) {
55
- return undefined;
56
- }
57
- return accrual.actualReversalPostDate ?? accrual.cleared?.reversedAt;
58
- }
59
- function toActualMatchingRow(accrual, kind) {
60
- return {
61
- ...accrual,
62
- kind,
63
- reversalDate: kind === 'pending_review'
64
- ? undefined
65
- : getActualMatchingReversalDate(accrual),
66
- };
67
- }
68
- function matchesSearch(accrual, searchString) {
69
- const trimmed = searchString.trim().toLowerCase();
70
- if (trimmed.length === 0) {
71
- return true;
72
- }
73
- return (accrual.vendorName.toLowerCase().includes(trimmed) ||
74
- accrual.memo.toLowerCase().includes(trimmed));
75
- }
76
- function getActualMatchingSortValue(row, sortKey) {
77
- switch (sortKey) {
78
- case 'vendor':
79
- return row.vendorName.toLowerCase();
80
- case 'date':
81
- return row.reversalDate?.valueOf();
82
- case 'amount':
83
- return getActualMatchingAmount(row);
84
- case 'category':
85
- return row.jeDebitAccountName?.toLowerCase();
86
- case 'class':
87
- return row.jeDebitAccountingClassName?.toLowerCase();
88
- case 'type':
89
- return (row.cleared?.matchedTransactionType ??
90
- row.matchSuggestion?.matchedTransactionType)?.toLowerCase();
91
- case 'lifecycle':
92
- return row.kind;
93
- default:
94
- return undefined;
95
- }
96
- }
97
- function sortActualMatchingRows(rows, uiState) {
98
- const lodashOrder = uiState.sortOrder === 'ascending' ? 'asc' : 'desc';
99
- return orderBy(rows, [(row) => getActualMatchingSortValue(row, uiState.sortKey)], [lodashOrder]);
100
- }
101
- function emptyKpiSummary() {
102
- return {
103
- autoReversed: { count: 0, amount: 0 },
104
- pendingReview: { count: 0, amount: 0 },
105
- totalThisClose: { count: 0, amount: 0 },
106
- ai: { count: 0 },
107
- manual: { count: 0 },
108
- };
109
- }
110
- export function getExpenseAutomationActualMatchingView(state) {
111
- const { expenseAutomationActualMatchingViewState, expenseAutomationViewState } = state;
112
- const { accrualKeysByPeriod, fetchState, error, refreshStatus, uiState, matchModal, } = expenseAutomationActualMatchingViewState;
113
- const currentTenant = getCurrentTenant(state);
114
- const selectedPeriod = expenseAutomationViewState.selectedPeriodByTenantId[currentTenant.tenantId];
115
- const monthYearPeriodId = selectedPeriod != null ? toMonthYearPeriodId(selectedPeriod) : undefined;
116
- const accrualKeys = monthYearPeriodId != null
117
- ? accrualKeysByPeriod[monthYearPeriodId]
118
- : undefined;
119
- const accruals = (accrualKeys ?? [])
120
- .map((key) => getJEOneTimeAccrualByKey(key, state.jeSchedulesState))
121
- .filter((accrual) => accrual != null);
122
- const filtered = accruals.filter((accrual) => matchesSearch(accrual, uiState.searchString));
123
- const autoReversed = sortActualMatchingRows(filtered
124
- .filter(isAutoReversedAccrual)
125
- .map((accrual) => toActualMatchingRow(accrual, 'auto_reversed')), uiState);
126
- const pendingReview = sortActualMatchingRows(filtered
127
- .filter(isPendingReviewAccrual)
128
- .map((accrual) => toActualMatchingRow(accrual, 'pending_review')), uiState);
129
- const manuallyReversed = sortActualMatchingRows(filtered
130
- .filter(isManuallyReversedAccrual)
131
- .map((accrual) => toActualMatchingRow(accrual, 'manually_reversed')), uiState);
132
- const listedAccruals = accruals.filter((accrual) => isAutoReversedAccrual(accrual) ||
133
- isPendingReviewAccrual(accrual) ||
134
- isManuallyReversedAccrual(accrual));
135
- const kpiSummary = listedAccruals.length === 0
136
- ? emptyKpiSummary()
137
- : {
138
- autoReversed: {
139
- count: listedAccruals.filter(isAutoReversedAccrual).length,
140
- amount: listedAccruals
141
- .filter(isAutoReversedAccrual)
142
- .reduce((sum, accrual) => sum + getActualMatchingAmount(accrual), 0),
143
- },
144
- pendingReview: {
145
- count: listedAccruals.filter(isPendingReviewAccrual).length,
146
- amount: listedAccruals
147
- .filter(isPendingReviewAccrual)
148
- .reduce((sum, accrual) => sum + getActualMatchingAmount(accrual), 0),
149
- },
150
- totalThisClose: {
151
- count: listedAccruals.length,
152
- amount: listedAccruals.reduce((sum, accrual) => sum + getActualMatchingAmount(accrual), 0),
153
- },
154
- ai: {
155
- count: listedAccruals.filter((accrual) => accrual.origin === 'agent').length,
156
- },
157
- manual: {
158
- count: listedAccruals.filter((accrual) => accrual.origin === 'human').length,
159
- },
160
- };
161
- const accrualSearchResults = matchModal.accrualSearch.results
162
- .map((key) => getJEOneTimeAccrualByKey(key, state.jeSchedulesState))
163
- .filter((accrual) => accrual != null);
164
- return {
165
- fetchState,
166
- error,
167
- autoReversed,
168
- pendingReview,
169
- manuallyReversed,
170
- kpiSummary,
171
- uiState,
172
- refreshStatus,
173
- hasLoadedForSelectedPeriod: accrualKeys != null,
174
- matchModal: {
175
- isOpen: matchModal.isOpen,
176
- confirmStatus: matchModal.confirmStatus,
177
- lastBatchResults: matchModal.lastBatchResults,
178
- transactionSearch: {
179
- query: matchModal.transactionSearch.query,
180
- results: matchModal.transactionSearch.results,
181
- fetchState: {
182
- fetchState: matchModal.transactionSearch.fetchState,
183
- error: matchModal.transactionSearch.error,
184
- },
185
- nextPageToken: matchModal.transactionSearch.nextPageToken,
186
- isLoadingMore: matchModal.transactionSearch.isLoadingMore,
187
- },
188
- accrualSearch: {
189
- query: matchModal.accrualSearch.query,
190
- results: accrualSearchResults,
191
- fetchState: {
192
- fetchState: matchModal.accrualSearch.fetchState,
193
- error: matchModal.accrualSearch.error,
194
- },
195
- nextPageToken: matchModal.accrualSearch.nextPageToken,
196
- isLoadingMore: matchModal.accrualSearch.isLoadingMore,
197
- },
198
- },
199
- };
200
- }
@@ -1,22 +0,0 @@
1
- import { stringToUnion } from '../../../commonStateTypes/stringToUnion';
2
- const ACTUAL_MATCHING_SORT_KEYS = [
3
- 'vendor',
4
- 'date',
5
- 'amount',
6
- 'category',
7
- 'class',
8
- 'type',
9
- 'lifecycle',
10
- ];
11
- export const toActualMatchingSortKey = (v) => stringToUnion(v, ACTUAL_MATCHING_SORT_KEYS);
12
- export const MATCH_TRANSACTION_SEARCH_PAGE_SIZE = 50;
13
- export const MATCH_ACCRUAL_SEARCH_LIMIT = 50;
14
- export const MATCH_SEARCH_DEBOUNCE_MS = 300;
15
- const MATCH_AND_REVERSE_RESULT_STATUSES = [
16
- 'reversed',
17
- 'noop',
18
- 'conflict',
19
- 'claim_lost',
20
- 'error',
21
- ];
22
- export const toMatchAndReverseResultStatus = (v) => stringToUnion(v, MATCH_AND_REVERSE_RESULT_STATUSES);
@@ -1,9 +0,0 @@
1
- import { ActionsObservable, StateObservable } from 'redux-observable';
2
- import { Observable } from 'rxjs';
3
- import { updateJEOneTimeAccruals } from '../../../../entity/jeSchedules/jeSchedulesReducer';
4
- import { clearAll } from '../../../../rootActions';
5
- import { RootState } from '../../../../rootStateTypes';
6
- import { ZeniAPI } from '../../../../zeniAPI';
7
- import { fetchActualMatching, fetchActualMatchingFailure, fetchActualMatchingSuccess } from '../../reducers/actualMatchingViewReducer';
8
- export type ActionType = ReturnType<typeof clearAll> | ReturnType<typeof fetchActualMatching> | ReturnType<typeof fetchActualMatchingFailure> | ReturnType<typeof fetchActualMatchingSuccess> | ReturnType<typeof updateJEOneTimeAccruals>;
9
- export declare const fetchActualMatchingEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -1,50 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fetchActualMatchingEpic = void 0;
4
- const rxjs_1 = require("rxjs");
5
- const operators_1 = require("rxjs/operators");
6
- const jeSchedulesReducer_1 = require("../../../../entity/jeSchedules/jeSchedulesReducer");
7
- const tenantSelector_1 = require("../../../../entity/tenant/tenantSelector");
8
- const responsePayload_1 = require("../../../../responsePayload");
9
- const rootActions_1 = require("../../../../rootActions");
10
- const actualMatchingPayload_1 = require("../../payload/actualMatchingPayload");
11
- const actualMatchingViewReducer_1 = require("../../reducers/actualMatchingViewReducer");
12
- const fetchActualMatchingEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(actualMatchingViewReducer_1.fetchActualMatching.match), (0, operators_1.mergeMap)((action) => {
13
- const state = state$.value;
14
- const { period, refreshViewInBackground } = action.payload;
15
- const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state);
16
- const selectedPeriod = state.expenseAutomationViewState
17
- .selectedPeriodByTenantId[currentTenant.tenantId] ?? {
18
- month: period.start.month,
19
- year: period.start.year,
20
- };
21
- const serviceMonth = (0, actualMatchingPayload_1.toServiceMonthFromPeriod)(period);
22
- return zeniAPI
23
- .getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accruals?service_month=${encodeURIComponent(serviceMonth)}&view=actual_matching`)
24
- .pipe((0, operators_1.mergeMap)((response) => {
25
- if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
26
- const accruals = response.data.accruals ?? [];
27
- const updateActions = [];
28
- if (accruals.length > 0) {
29
- updateActions.push((0, jeSchedulesReducer_1.updateJEOneTimeAccruals)(accruals));
30
- }
31
- updateActions.push((0, actualMatchingViewReducer_1.fetchActualMatchingSuccess)({
32
- accruals,
33
- selectedPeriod,
34
- refreshViewInBackground,
35
- }));
36
- return (0, rxjs_1.from)(updateActions);
37
- }
38
- return (0, rxjs_1.of)((0, actualMatchingViewReducer_1.fetchActualMatchingFailure)({
39
- status: response.status,
40
- selectedPeriod,
41
- refreshViewInBackground,
42
- }));
43
- }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, actualMatchingViewReducer_1.fetchActualMatchingFailure)({
44
- status: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'fetch actual matching REST API call errored out' +
45
- JSON.stringify(error)),
46
- selectedPeriod,
47
- refreshViewInBackground,
48
- }))), (0, operators_1.takeUntil)(actions$.pipe((0, operators_1.filter)(rootActions_1.clearAll.match))));
49
- }));
50
- exports.fetchActualMatchingEpic = fetchActualMatchingEpic;
@@ -1,5 +0,0 @@
1
- import { ActionsObservable } from 'redux-observable';
2
- import { Observable } from 'rxjs';
3
- import { fetchActualMatching, fetchActualMatchingPage } from '../../reducers/actualMatchingViewReducer';
4
- export type ActionType = ReturnType<typeof fetchActualMatching> | ReturnType<typeof fetchActualMatchingPage>;
5
- export declare const fetchActualMatchingPageEpic: (actions$: ActionsObservable<ActionType>) => Observable<ActionType>;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fetchActualMatchingPageEpic = void 0;
4
- const rxjs_1 = require("rxjs");
5
- const operators_1 = require("rxjs/operators");
6
- const actualMatchingViewReducer_1 = require("../../reducers/actualMatchingViewReducer");
7
- const fetchActualMatchingPageEpic = (actions$) => actions$.pipe((0, operators_1.filter)(actualMatchingViewReducer_1.fetchActualMatchingPage.match), (0, operators_1.mergeMap)((action) => {
8
- const { period, refreshViewInBackground } = action.payload;
9
- return (0, rxjs_1.of)((0, actualMatchingViewReducer_1.fetchActualMatching)(period, refreshViewInBackground));
10
- }));
11
- exports.fetchActualMatchingPageEpic = fetchActualMatchingPageEpic;
@@ -1,8 +0,0 @@
1
- import { ActionsObservable, StateObservable } from 'redux-observable';
2
- import { Observable } from 'rxjs';
3
- import { clearAll } from '../../../../rootActions';
4
- import { RootState } from '../../../../rootStateTypes';
5
- import { ZeniAPI } from '../../../../zeniAPI';
6
- import { clearMatchNewModal, fetchActualMatching, matchAndReverseAccruals, matchAndReverseAccrualsFailure, matchAndReverseAccrualsSuccess } from '../../reducers/actualMatchingViewReducer';
7
- export type ActionType = ReturnType<typeof clearAll> | ReturnType<typeof clearMatchNewModal> | ReturnType<typeof fetchActualMatching> | ReturnType<typeof matchAndReverseAccruals> | ReturnType<typeof matchAndReverseAccrualsFailure> | ReturnType<typeof matchAndReverseAccrualsSuccess>;
8
- export declare const matchAndReverseAccrualsEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -1,54 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.matchAndReverseAccrualsEpic = void 0;
4
- const rxjs_1 = require("rxjs");
5
- const operators_1 = require("rxjs/operators");
6
- const timePeriod_1 = require("../../../../commonStateTypes/timePeriod");
7
- const tenantSelector_1 = require("../../../../entity/tenant/tenantSelector");
8
- const responsePayload_1 = require("../../../../responsePayload");
9
- const rootActions_1 = require("../../../../rootActions");
10
- const actualMatchingPayload_1 = require("../../payload/actualMatchingPayload");
11
- const actualMatchingViewReducer_1 = require("../../reducers/actualMatchingViewReducer");
12
- function refreshActualMatchingList(state) {
13
- const selectedMonthYear = state.expenseAutomationViewState.selectedPeriodByTenantId[(0, tenantSelector_1.getCurrentTenant)(state).tenantId];
14
- if (selectedMonthYear == null) {
15
- return [];
16
- }
17
- const period = (0, timePeriod_1.convertToPeriod)(selectedMonthYear);
18
- const start = (0, timePeriod_1.toAbsoluteDay)(period.start);
19
- const end = (0, timePeriod_1.toAbsoluteDay)(period.end);
20
- if (start == null || end == null) {
21
- return [];
22
- }
23
- return [(0, actualMatchingViewReducer_1.fetchActualMatching)({ start, end }, true)];
24
- }
25
- const matchAndReverseAccrualsEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(actualMatchingViewReducer_1.matchAndReverseAccruals.match), (0, operators_1.mergeMap)((action) => {
26
- const { transactionId, transactionIntegrationId, transactionType, lineId, accrualIds, } = action.payload;
27
- const body = {
28
- transaction_id: transactionId,
29
- transaction_integration_id: transactionIntegrationId,
30
- transaction_type: transactionType,
31
- line_id: lineId,
32
- accrual_ids: accrualIds,
33
- };
34
- return zeniAPI
35
- .postAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accruals/match-and-reverse`, body)
36
- .pipe((0, operators_1.mergeMap)((response) => {
37
- if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
38
- const results = (response.data.results ?? []).map(actualMatchingPayload_1.toMatchAndReverseResult);
39
- const successActions = [
40
- (0, actualMatchingViewReducer_1.matchAndReverseAccrualsSuccess)({ results }),
41
- ];
42
- const anyReversed = results.some((result) => result.status === 'reversed');
43
- if (anyReversed) {
44
- successActions.push(...refreshActualMatchingList(state$.value), (0, actualMatchingViewReducer_1.clearMatchNewModal)());
45
- }
46
- return (0, rxjs_1.from)(successActions);
47
- }
48
- return (0, rxjs_1.of)((0, actualMatchingViewReducer_1.matchAndReverseAccrualsFailure)({ status: response.status }));
49
- }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, actualMatchingViewReducer_1.matchAndReverseAccrualsFailure)({
50
- status: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Match and reverse accruals REST API call errored out' +
51
- JSON.stringify(error)),
52
- }))), (0, operators_1.takeUntil)(actions$.pipe((0, operators_1.filter)(rootActions_1.clearAll.match))));
53
- }));
54
- exports.matchAndReverseAccrualsEpic = matchAndReverseAccrualsEpic;
@@ -1,8 +0,0 @@
1
- import { ActionsObservable, StateObservable } from 'redux-observable';
2
- import { Observable } from 'rxjs';
3
- import { updateJEOneTimeAccruals } from '../../../../entity/jeSchedules/jeSchedulesReducer';
4
- import { RootState } from '../../../../rootStateTypes';
5
- import { ZeniAPI } from '../../../../zeniAPI';
6
- import { searchMatchAccruals, searchMatchAccrualsFailure, searchMatchAccrualsSuccess } from '../../reducers/actualMatchingViewReducer';
7
- export type ActionType = ReturnType<typeof searchMatchAccruals> | ReturnType<typeof searchMatchAccrualsFailure> | ReturnType<typeof searchMatchAccrualsSuccess> | ReturnType<typeof updateJEOneTimeAccruals>;
8
- export declare const searchMatchAccrualsEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;