@zeniai/client-epic-state 5.2.40 → 5.2.41-beta2MM

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 (122) hide show
  1. package/lib/entity/actualMatching/actualMatchingPayload.d.ts +31 -0
  2. package/lib/entity/actualMatching/actualMatchingPayload.js +52 -0
  3. package/lib/entity/actualMatching/actualMatchingReducer.d.ts +11 -0
  4. package/lib/entity/actualMatching/actualMatchingReducer.js +42 -0
  5. package/lib/entity/actualMatching/actualMatchingSelector.d.ts +3 -0
  6. package/lib/entity/actualMatching/actualMatchingSelector.js +6 -0
  7. package/lib/entity/actualMatching/actualMatchingState.d.ts +23 -0
  8. package/lib/entity/actualMatching/actualMatchingState.js +2 -0
  9. package/lib/entity/actualMatching/actualMatchingTypes.d.ts +1 -0
  10. package/lib/entity/actualMatching/actualMatchingTypes.js +2 -0
  11. package/lib/entity/file/fileReducer.d.ts +8 -0
  12. package/lib/entity/file/fileReducer.js +10 -2
  13. package/lib/entity/invoicing/invoicingCommonPayload.d.ts +14 -1
  14. package/lib/entity/jeSchedules/jeSchedulesPayload.d.ts +31 -0
  15. package/lib/entity/jeSchedules/jeSchedulesPayload.js +53 -0
  16. package/lib/entity/jeSchedules/jeSchedulesState.d.ts +33 -0
  17. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  18. package/lib/entity/snackbar/snackbarTypes.js +3 -0
  19. package/lib/epic.d.ts +9 -1
  20. package/lib/epic.js +16 -0
  21. package/lib/esm/entity/actualMatching/actualMatchingPayload.js +48 -0
  22. package/lib/esm/entity/actualMatching/actualMatchingReducer.js +38 -0
  23. package/lib/esm/entity/actualMatching/actualMatchingSelector.js +3 -0
  24. package/lib/esm/entity/actualMatching/actualMatchingState.js +1 -0
  25. package/lib/esm/entity/actualMatching/actualMatchingTypes.js +1 -0
  26. package/lib/esm/entity/file/fileReducer.js +10 -2
  27. package/lib/esm/entity/jeSchedules/jeSchedulesPayload.js +53 -0
  28. package/lib/esm/entity/snackbar/snackbarTypes.js +3 -0
  29. package/lib/esm/epic.js +16 -0
  30. package/lib/esm/index.js +7 -3
  31. package/lib/esm/reducer.js +6 -0
  32. package/lib/esm/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +25 -12
  33. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/actualMatching/fetchActualMatchingEpic.js +46 -0
  34. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/actualMatching/fetchActualMatchingMatchEpic.js +36 -0
  35. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/actualMatching/fetchActualMatchingPageEpic.js +7 -0
  36. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/actualMatching/ignoreActualMatchingSuggestionEpic.js +49 -0
  37. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/actualMatching/matchAndReverseAccrualsEpic.js +108 -0
  38. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/actualMatching/refreshActualMatchingList.js +16 -0
  39. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/actualMatching/searchMatchAccrualsEpic.js +60 -0
  40. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/actualMatching/searchMatchTransactionsEpic.js +74 -0
  41. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/actualMatching/undoReversalAccrualsEpic.js +78 -0
  42. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.js +13 -3
  43. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/prefetchOtherJeSchedulesTabEpic.js +40 -15
  44. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +19 -8
  45. package/lib/esm/view/expenseAutomationView/expenseAutomationViewReducer.js +2 -1
  46. package/lib/esm/view/expenseAutomationView/expenseAutomationViewSelector.js +24 -6
  47. package/lib/esm/view/expenseAutomationView/expenseAutomationViewState.js +4 -2
  48. package/lib/esm/view/expenseAutomationView/payload/actualMatchingPayload.js +68 -0
  49. package/lib/esm/view/expenseAutomationView/reducers/actualMatchingViewReducer.js +497 -0
  50. package/lib/esm/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +2 -1
  51. package/lib/esm/view/expenseAutomationView/selectorTypes/actualMatchingViewSelectorTypes.js +1 -0
  52. package/lib/esm/view/expenseAutomationView/selectors/actualMatchingViewSelector.js +432 -0
  53. package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +4 -0
  54. package/lib/esm/view/expenseAutomationView/types/actualMatchingViewState.js +47 -0
  55. package/lib/esm/view/expenseAutomationView/types/jeSchedulesViewState.js +8 -1
  56. package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewSelector.js +1 -1
  57. package/lib/esm/view/invoicing/settingsView/epics/fetchInvoicingSettingsEpic.js +6 -0
  58. package/lib/esm/view/invoicing/settingsView/epics/saveInvoicingSettingsEpic.js +7 -0
  59. package/lib/esm/view/invoicing/settingsView/invoicingBrandingFormConfig.js +1 -1
  60. package/lib/esm/view/invoicing/settingsView/settingsViewSelector.js +5 -0
  61. package/lib/esm/view/invoicing/settingsView/submitInvoicingBrandingFormEpic.js +9 -0
  62. package/lib/index.d.ts +14 -5
  63. package/lib/index.js +87 -48
  64. package/lib/reducer.d.ts +2 -0
  65. package/lib/reducer.js +6 -0
  66. package/lib/rootStateTypes.d.ts +4 -0
  67. package/lib/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +25 -12
  68. package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/fetchActualMatchingEpic.d.ts +9 -0
  69. package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/fetchActualMatchingEpic.js +50 -0
  70. package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/fetchActualMatchingMatchEpic.d.ts +12 -0
  71. package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/fetchActualMatchingMatchEpic.js +40 -0
  72. package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/fetchActualMatchingPageEpic.d.ts +5 -0
  73. package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/fetchActualMatchingPageEpic.js +11 -0
  74. package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/ignoreActualMatchingSuggestionEpic.d.ts +10 -0
  75. package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/ignoreActualMatchingSuggestionEpic.js +53 -0
  76. package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/matchAndReverseAccrualsEpic.d.ts +9 -0
  77. package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/matchAndReverseAccrualsEpic.js +112 -0
  78. package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/refreshActualMatchingList.d.ts +3 -0
  79. package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/refreshActualMatchingList.js +19 -0
  80. package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/searchMatchAccrualsEpic.d.ts +9 -0
  81. package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/searchMatchAccrualsEpic.js +64 -0
  82. package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/searchMatchTransactionsEpic.d.ts +8 -0
  83. package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/searchMatchTransactionsEpic.js +78 -0
  84. package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/undoReversalAccrualsEpic.d.ts +9 -0
  85. package/lib/view/expenseAutomationView/epics/jeSchedule/actualMatching/undoReversalAccrualsEpic.js +82 -0
  86. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.d.ts +2 -1
  87. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.js +13 -3
  88. package/lib/view/expenseAutomationView/epics/jeSchedule/prefetchOtherJeSchedulesTabEpic.d.ts +5 -1
  89. package/lib/view/expenseAutomationView/epics/jeSchedule/prefetchOtherJeSchedulesTabEpic.js +39 -14
  90. package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +18 -7
  91. package/lib/view/expenseAutomationView/expenseAutomationViewReducer.d.ts +2 -1
  92. package/lib/view/expenseAutomationView/expenseAutomationViewReducer.js +2 -1
  93. package/lib/view/expenseAutomationView/expenseAutomationViewSelector.js +24 -6
  94. package/lib/view/expenseAutomationView/expenseAutomationViewState.d.ts +2 -1
  95. package/lib/view/expenseAutomationView/expenseAutomationViewState.js +6 -3
  96. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  97. package/lib/view/expenseAutomationView/payload/actualMatchingPayload.d.ts +91 -0
  98. package/lib/view/expenseAutomationView/payload/actualMatchingPayload.js +74 -0
  99. package/lib/view/expenseAutomationView/reducers/actualMatchingViewReducer.d.ts +88 -0
  100. package/lib/view/expenseAutomationView/reducers/actualMatchingViewReducer.js +501 -0
  101. package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +6 -5
  102. package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +2 -1
  103. package/lib/view/expenseAutomationView/selectorTypes/actualMatchingViewSelectorTypes.d.ts +88 -0
  104. package/lib/view/expenseAutomationView/selectorTypes/actualMatchingViewSelectorTypes.js +2 -0
  105. package/lib/view/expenseAutomationView/selectorTypes/expenseAutomationViewSelectorTypes.d.ts +11 -0
  106. package/lib/view/expenseAutomationView/selectors/actualMatchingViewSelector.d.ts +40 -0
  107. package/lib/view/expenseAutomationView/selectors/actualMatchingViewSelector.js +452 -0
  108. package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +4 -0
  109. package/lib/view/expenseAutomationView/types/actualMatchingViewState.d.ts +116 -0
  110. package/lib/view/expenseAutomationView/types/actualMatchingViewState.js +56 -0
  111. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +1 -1
  112. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.js +8 -1
  113. package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewSelector.js +1 -1
  114. package/lib/view/invoicing/settingsView/epics/fetchInvoicingSettingsEpic.js +6 -0
  115. package/lib/view/invoicing/settingsView/epics/saveInvoicingSettingsEpic.js +7 -0
  116. package/lib/view/invoicing/settingsView/epics/settingsViewActionType.d.ts +2 -1
  117. package/lib/view/invoicing/settingsView/invoicingBrandingFormConfig.js +1 -1
  118. package/lib/view/invoicing/settingsView/settingsViewSelector.d.ts +8 -0
  119. package/lib/view/invoicing/settingsView/settingsViewSelector.js +5 -0
  120. package/lib/view/invoicing/settingsView/submitInvoicingBrandingFormEpic.d.ts +2 -1
  121. package/lib/view/invoicing/settingsView/submitInvoicingBrandingFormEpic.js +9 -0
  122. package/package.json +1 -1
@@ -0,0 +1,497 @@
1
+ import { createSlice } from '@reduxjs/toolkit';
2
+ import { toMonthYearPeriodId } from '../../../commonStateTypes/timePeriod';
3
+ import { generateJEOneTimeAccrualKey } from '../../../entity/jeSchedules/jeScheduleHelper';
4
+ import { createZeniAPIStatus } from '../../../responsePayload';
5
+ import { clearAll } from '../../../rootActions';
6
+ import { actualMatchingTransactionLineKey, isMatchAndReverseCompleteStatus } from '../types/actualMatchingViewState';
7
+ export const initialTransactionSearchState = {
8
+ query: '',
9
+ results: [],
10
+ fetchState: 'Not-Started',
11
+ error: undefined,
12
+ nextPageToken: null,
13
+ isLoadingMore: false,
14
+ };
15
+ export const initialAccrualSearchState = {
16
+ query: '',
17
+ results: [],
18
+ fetchState: 'Not-Started',
19
+ error: undefined,
20
+ nextPageToken: null,
21
+ isLoadingMore: false,
22
+ };
23
+ export const initialMatchModalState = {
24
+ isOpen: false,
25
+ openedFromMatchId: undefined,
26
+ didPinPrefillTransactions: false,
27
+ pinnedTransactionResults: [],
28
+ transactionSearch: initialTransactionSearchState,
29
+ accrualSearch: initialAccrualSearchState,
30
+ confirmStatus: { fetchState: 'Not-Started', error: undefined },
31
+ };
32
+ export const initialState = {
33
+ matchIdsByPeriod: {},
34
+ fetchState: 'Not-Started',
35
+ error: undefined,
36
+ refreshStatus: {
37
+ fetchState: 'Not-Started',
38
+ error: undefined,
39
+ },
40
+ detailFetchStateByMatchId: {},
41
+ detailRefreshStatusByMatchId: {},
42
+ uiState: {
43
+ sortKey: 'date',
44
+ sortOrder: 'descending',
45
+ searchString: '',
46
+ scrollPosition: { scrollTop: 0, scrollLeft: undefined },
47
+ },
48
+ matchModal: initialMatchModalState,
49
+ undoReversalStatusByMatchId: {},
50
+ ignoreStatusByMatchId: {},
51
+ closeMatchAfterUndo: false,
52
+ lastMatchResultsByMatchId: {},
53
+ lastUndoResultsByMatchId: {},
54
+ hasValidState() {
55
+ return this.fetchState == 'Completed';
56
+ },
57
+ };
58
+ function pruneLastMatchResultsForUndone(draft, matchId, results) {
59
+ const undoneIds = new Set(results
60
+ .filter((result) => result.status === 'undone')
61
+ .map((result) => result.accrualId));
62
+ if (undoneIds.size === 0) {
63
+ return;
64
+ }
65
+ const existing = draft.lastMatchResultsByMatchId[matchId];
66
+ if (existing == null) {
67
+ return;
68
+ }
69
+ const kept = existing.filter((result) => !undoneIds.has(result.accrualId));
70
+ if (kept.length === 0) {
71
+ delete draft.lastMatchResultsByMatchId[matchId];
72
+ return;
73
+ }
74
+ draft.lastMatchResultsByMatchId[matchId] = kept;
75
+ }
76
+ function pruneLastUndoResultsForMatched(draft, matchId, results) {
77
+ const matchedIds = new Set(results.map((result) => result.accrualId));
78
+ if (matchedIds.size === 0) {
79
+ return;
80
+ }
81
+ const existing = draft.lastUndoResultsByMatchId[matchId];
82
+ if (existing == null) {
83
+ return;
84
+ }
85
+ const kept = existing.filter((result) => !matchedIds.has(result.accrualId));
86
+ if (kept.length === 0) {
87
+ delete draft.lastUndoResultsByMatchId[matchId];
88
+ return;
89
+ }
90
+ draft.lastUndoResultsByMatchId[matchId] = kept;
91
+ }
92
+ function resetMatchModalSearches(draft) {
93
+ draft.matchModal.transactionSearch = initialTransactionSearchState;
94
+ draft.matchModal.accrualSearch = initialAccrualSearchState;
95
+ draft.matchModal.confirmStatus = {
96
+ fetchState: 'Not-Started',
97
+ error: undefined,
98
+ };
99
+ draft.matchModal.lastBatchResults = undefined;
100
+ draft.matchModal.openedFromMatchId = undefined;
101
+ draft.matchModal.didPinPrefillTransactions = false;
102
+ draft.matchModal.pinnedTransactionResults = [];
103
+ }
104
+ const expenseAutomationActualMatchingView = createSlice({
105
+ name: 'expenseAutomationActualMatchingView',
106
+ initialState,
107
+ reducers: {
108
+ fetchActualMatchingPage: {
109
+ prepare(period, refreshViewInBackground = false) {
110
+ return {
111
+ payload: {
112
+ period,
113
+ refreshViewInBackground,
114
+ },
115
+ };
116
+ },
117
+ reducer() {
118
+ // Epic-only fan-out.
119
+ },
120
+ },
121
+ fetchActualMatching: {
122
+ reducer(draft, action) {
123
+ const { refreshViewInBackground } = action.payload;
124
+ if (refreshViewInBackground) {
125
+ draft.refreshStatus = { fetchState: 'In-Progress', error: undefined };
126
+ if (draft.fetchState === 'Not-Started') {
127
+ draft.fetchState = 'In-Progress';
128
+ }
129
+ }
130
+ else {
131
+ draft.fetchState = 'In-Progress';
132
+ draft.error = undefined;
133
+ }
134
+ },
135
+ prepare(period, refreshViewInBackground = false) {
136
+ return {
137
+ payload: {
138
+ period,
139
+ refreshViewInBackground,
140
+ },
141
+ };
142
+ },
143
+ },
144
+ fetchActualMatchingSuccess(draft, action) {
145
+ const { matchIds, selectedPeriod, refreshViewInBackground } = action.payload;
146
+ const periodId = toMonthYearPeriodId(selectedPeriod);
147
+ draft.matchIdsByPeriod[periodId] = matchIds;
148
+ if (refreshViewInBackground) {
149
+ draft.refreshStatus = { fetchState: 'Completed', error: undefined };
150
+ if (draft.fetchState !== 'Completed') {
151
+ draft.fetchState = 'Completed';
152
+ draft.error = undefined;
153
+ }
154
+ }
155
+ else {
156
+ draft.fetchState = 'Completed';
157
+ draft.error = undefined;
158
+ }
159
+ },
160
+ fetchActualMatchingFailure(draft, action) {
161
+ const { status, refreshViewInBackground, selectedPeriod } = action.payload;
162
+ const periodId = toMonthYearPeriodId(selectedPeriod);
163
+ // Stamp an empty slot so the selector does not remap this month's Error
164
+ // to leftover Not-Started chrome. Do not clobber ids from a prior success.
165
+ if (draft.matchIdsByPeriod[periodId] == null) {
166
+ draft.matchIdsByPeriod[periodId] = [];
167
+ }
168
+ if (refreshViewInBackground) {
169
+ draft.refreshStatus = { fetchState: 'Error', error: status };
170
+ if (draft.fetchState !== 'Completed') {
171
+ draft.fetchState = 'Error';
172
+ draft.error = status;
173
+ }
174
+ }
175
+ else {
176
+ draft.fetchState = 'Error';
177
+ draft.error = status;
178
+ }
179
+ },
180
+ fetchActualMatchingMatch: {
181
+ prepare(matchId, refreshViewInBackground = false) {
182
+ return { payload: { matchId, refreshViewInBackground } };
183
+ },
184
+ reducer(draft, action) {
185
+ const { matchId, refreshViewInBackground } = action.payload;
186
+ if (refreshViewInBackground) {
187
+ draft.detailRefreshStatusByMatchId[matchId] = {
188
+ fetchState: 'In-Progress',
189
+ error: undefined,
190
+ };
191
+ }
192
+ else {
193
+ draft.detailFetchStateByMatchId[matchId] = {
194
+ fetchState: 'In-Progress',
195
+ error: undefined,
196
+ };
197
+ }
198
+ },
199
+ },
200
+ fetchActualMatchingMatchSuccess(draft, action) {
201
+ const { matchId, refreshViewInBackground } = action.payload;
202
+ if (refreshViewInBackground) {
203
+ draft.detailRefreshStatusByMatchId[matchId] = {
204
+ fetchState: 'Completed',
205
+ error: undefined,
206
+ };
207
+ }
208
+ else {
209
+ draft.detailFetchStateByMatchId[matchId] = {
210
+ fetchState: 'Completed',
211
+ error: undefined,
212
+ };
213
+ }
214
+ },
215
+ fetchActualMatchingMatchFailure(draft, action) {
216
+ const { matchId, refreshViewInBackground, status } = action.payload;
217
+ if (refreshViewInBackground) {
218
+ draft.detailRefreshStatusByMatchId[matchId] = {
219
+ fetchState: 'Error',
220
+ error: status,
221
+ };
222
+ }
223
+ else {
224
+ draft.detailFetchStateByMatchId[matchId] = {
225
+ fetchState: 'Error',
226
+ error: status,
227
+ };
228
+ }
229
+ },
230
+ updateActualMatchingUIState(draft, action) {
231
+ if (action.payload.sortKey != null) {
232
+ draft.uiState.sortKey = action.payload.sortKey;
233
+ }
234
+ if (action.payload.sortOrder != null) {
235
+ draft.uiState.sortOrder = action.payload.sortOrder;
236
+ }
237
+ if (action.payload.searchString != null) {
238
+ draft.uiState.searchString = action.payload.searchString;
239
+ }
240
+ if (action.payload.scrollPosition != null) {
241
+ draft.uiState.scrollPosition = action.payload.scrollPosition;
242
+ }
243
+ },
244
+ openMatchNewModal: {
245
+ prepare(matchId) {
246
+ return { payload: { matchId } };
247
+ },
248
+ reducer(draft, action) {
249
+ resetMatchModalSearches(draft);
250
+ draft.matchModal.isOpen = true;
251
+ const matchId = action.payload.matchId;
252
+ draft.matchModal.openedFromMatchId =
253
+ matchId != null && matchId !== '' ? matchId : undefined;
254
+ if (draft.matchModal.openedFromMatchId != null) {
255
+ draft.matchModal.accrualSearch.fetchState = 'Completed';
256
+ }
257
+ },
258
+ },
259
+ // Dismiss (Cancel / overlay). Store reset matches `clearMatchNewModal`;
260
+ // the actions stay distinct so confirm-success vs user-dismiss stay observable.
261
+ closeMatchNewModal(draft) {
262
+ draft.matchModal.isOpen = false;
263
+ resetMatchModalSearches(draft);
264
+ },
265
+ // Confirm-success / host reset. Same slice write as close; different action type.
266
+ clearMatchNewModal(draft) {
267
+ draft.matchModal.isOpen = false;
268
+ resetMatchModalSearches(draft);
269
+ },
270
+ searchMatchTransactions: {
271
+ reducer(draft, action) {
272
+ const { query, pageToken } = action.payload;
273
+ const isLoadMore = pageToken != null;
274
+ draft.matchModal.transactionSearch.query = query;
275
+ if (isLoadMore) {
276
+ draft.matchModal.transactionSearch.isLoadingMore = true;
277
+ }
278
+ else {
279
+ draft.matchModal.transactionSearch.isLoadingMore = false;
280
+ draft.matchModal.transactionSearch.results = [];
281
+ draft.matchModal.transactionSearch.nextPageToken = null;
282
+ draft.matchModal.transactionSearch.fetchState = 'In-Progress';
283
+ draft.matchModal.transactionSearch.error = undefined;
284
+ }
285
+ },
286
+ prepare(query, pageToken, transactionType, transactionIntegrationId) {
287
+ return {
288
+ payload: {
289
+ query,
290
+ pageToken: pageToken ?? undefined,
291
+ transactionType,
292
+ transactionIntegrationId,
293
+ },
294
+ };
295
+ },
296
+ },
297
+ searchMatchTransactionsSuccess(draft, action) {
298
+ const { append, nextPageToken, results } = action.payload;
299
+ if (append) {
300
+ const merged = [
301
+ ...draft.matchModal.transactionSearch.results,
302
+ ...results,
303
+ ];
304
+ const byKey = new Map(merged.map((result) => [
305
+ actualMatchingTransactionLineKey(result.transactionType, result.transactionIntegrationId, result.lineId),
306
+ result,
307
+ ]));
308
+ draft.matchModal.transactionSearch.results = Array.from(byKey.values());
309
+ }
310
+ else {
311
+ draft.matchModal.transactionSearch.results = results;
312
+ if (draft.matchModal.openedFromMatchId != null &&
313
+ !draft.matchModal.didPinPrefillTransactions) {
314
+ draft.matchModal.didPinPrefillTransactions = true;
315
+ draft.matchModal.pinnedTransactionResults = results;
316
+ }
317
+ }
318
+ draft.matchModal.transactionSearch.nextPageToken = nextPageToken;
319
+ draft.matchModal.transactionSearch.isLoadingMore = false;
320
+ draft.matchModal.transactionSearch.fetchState = 'Completed';
321
+ draft.matchModal.transactionSearch.error = undefined;
322
+ },
323
+ searchMatchTransactionsFailure(draft, action) {
324
+ draft.matchModal.transactionSearch.isLoadingMore = false;
325
+ draft.matchModal.transactionSearch.fetchState = 'Error';
326
+ draft.matchModal.transactionSearch.error = action.payload.error;
327
+ },
328
+ searchMatchAccruals: {
329
+ reducer(draft, action) {
330
+ const { query, pageToken } = action.payload;
331
+ const isLoadMore = pageToken != null;
332
+ draft.matchModal.accrualSearch.query = query;
333
+ if (isLoadMore) {
334
+ draft.matchModal.accrualSearch.isLoadingMore = true;
335
+ }
336
+ else {
337
+ draft.matchModal.accrualSearch.isLoadingMore = false;
338
+ draft.matchModal.accrualSearch.results = [];
339
+ draft.matchModal.accrualSearch.nextPageToken = null;
340
+ draft.matchModal.accrualSearch.fetchState = 'In-Progress';
341
+ draft.matchModal.accrualSearch.error = undefined;
342
+ }
343
+ },
344
+ prepare(query, pageToken) {
345
+ return { payload: { query, pageToken: pageToken ?? undefined } };
346
+ },
347
+ },
348
+ searchMatchAccrualsSuccess(draft, action) {
349
+ const { append, nextPageToken, results } = action.payload;
350
+ const keys = results.map((accrual) => generateJEOneTimeAccrualKey(accrual._id));
351
+ if (append) {
352
+ const merged = [...draft.matchModal.accrualSearch.results, ...keys];
353
+ draft.matchModal.accrualSearch.results = Array.from(new Set(merged));
354
+ }
355
+ else {
356
+ draft.matchModal.accrualSearch.results = keys;
357
+ }
358
+ draft.matchModal.accrualSearch.nextPageToken = nextPageToken;
359
+ draft.matchModal.accrualSearch.isLoadingMore = false;
360
+ draft.matchModal.accrualSearch.fetchState = 'Completed';
361
+ draft.matchModal.accrualSearch.error = undefined;
362
+ },
363
+ searchMatchAccrualsFailure(draft, action) {
364
+ draft.matchModal.accrualSearch.isLoadingMore = false;
365
+ draft.matchModal.accrualSearch.fetchState = 'Error';
366
+ draft.matchModal.accrualSearch.error = action.payload.error;
367
+ },
368
+ matchAndReverseAccruals: {
369
+ reducer(draft) {
370
+ draft.matchModal.confirmStatus = {
371
+ fetchState: 'In-Progress',
372
+ error: undefined,
373
+ };
374
+ },
375
+ prepare(transactionId, transactionIntegrationId, transactionType, lineIds, transactionSyncToken, accrualIds) {
376
+ return {
377
+ payload: {
378
+ transactionId,
379
+ transactionIntegrationId,
380
+ transactionType,
381
+ lineIds,
382
+ transactionSyncToken,
383
+ accrualIds,
384
+ },
385
+ };
386
+ },
387
+ },
388
+ matchAndReverseAccrualsSuccess(draft, action) {
389
+ const { results } = action.payload;
390
+ const allComplete = results.length > 0 &&
391
+ results.every((result) => isMatchAndReverseCompleteStatus(result.status));
392
+ draft.matchModal.confirmStatus = allComplete
393
+ ? { fetchState: 'Completed', error: undefined }
394
+ : {
395
+ fetchState: 'Error',
396
+ error: createZeniAPIStatus('Partial match-and-reverse', 'Some accruals were not reversed'),
397
+ };
398
+ draft.matchModal.lastBatchResults = results;
399
+ if (action.payload.matchId != null) {
400
+ draft.lastMatchResultsByMatchId[action.payload.matchId] = results;
401
+ pruneLastUndoResultsForMatched(draft, action.payload.matchId, action.payload.results);
402
+ }
403
+ },
404
+ matchAndReverseAccrualsFailure(draft, action) {
405
+ draft.matchModal.confirmStatus = {
406
+ fetchState: 'Error',
407
+ error: action.payload.status,
408
+ };
409
+ },
410
+ undoReversalAccruals: {
411
+ reducer(draft, action) {
412
+ draft.undoReversalStatusByMatchId[action.payload.matchId] = {
413
+ fetchState: 'In-Progress',
414
+ error: undefined,
415
+ };
416
+ },
417
+ prepare(matchId, accrualIds) {
418
+ return { payload: { matchId, accrualIds } };
419
+ },
420
+ },
421
+ undoReversalAccrualsSuccess: {
422
+ reducer(draft, action) {
423
+ const { matchId, results } = action.payload;
424
+ draft.undoReversalStatusByMatchId[matchId] = {
425
+ fetchState: 'Completed',
426
+ error: undefined,
427
+ };
428
+ const allUndone = results.length > 0 &&
429
+ results.every((result) => result.status === 'undone');
430
+ draft.closeMatchAfterUndo = allUndone;
431
+ pruneLastMatchResultsForUndone(draft, matchId, results);
432
+ if (allUndone) {
433
+ delete draft.lastUndoResultsByMatchId[matchId];
434
+ }
435
+ else {
436
+ draft.lastUndoResultsByMatchId[matchId] = results;
437
+ }
438
+ },
439
+ prepare(matchId, results) {
440
+ return { payload: { matchId, results } };
441
+ },
442
+ },
443
+ ackCloseMatchAfterUndo(draft) {
444
+ draft.closeMatchAfterUndo = false;
445
+ },
446
+ ignoreActualMatchingSuggestion: {
447
+ prepare(matchId, reason, note) {
448
+ return { payload: { matchId, reason, note } };
449
+ },
450
+ reducer(draft, action) {
451
+ draft.ignoreStatusByMatchId[action.payload.matchId] = {
452
+ fetchState: 'In-Progress',
453
+ error: undefined,
454
+ };
455
+ },
456
+ },
457
+ ignoreActualMatchingSuggestionSuccess(draft, action) {
458
+ const { matchId } = action.payload;
459
+ draft.ignoreStatusByMatchId[matchId] = {
460
+ fetchState: 'Completed',
461
+ error: undefined,
462
+ };
463
+ draft.closeMatchAfterIgnoreMatchId = matchId;
464
+ if (draft.matchModal.openedFromMatchId === matchId) {
465
+ draft.matchModal = initialMatchModalState;
466
+ }
467
+ Object.keys(draft.matchIdsByPeriod).forEach((periodId) => {
468
+ draft.matchIdsByPeriod[periodId] = draft.matchIdsByPeriod[periodId].filter((id) => id !== matchId);
469
+ });
470
+ },
471
+ ignoreActualMatchingSuggestionFailure(draft, action) {
472
+ draft.ignoreStatusByMatchId[action.payload.matchId] = {
473
+ fetchState: 'Error',
474
+ error: action.payload.status,
475
+ };
476
+ },
477
+ ackCloseMatchAfterIgnore(draft) {
478
+ draft.closeMatchAfterIgnoreMatchId = undefined;
479
+ },
480
+ undoReversalAccrualsFailure(draft, action) {
481
+ draft.undoReversalStatusByMatchId[action.payload.matchId] = {
482
+ fetchState: 'Error',
483
+ error: action.payload.status,
484
+ };
485
+ },
486
+ clearActualMatchingView(draft) {
487
+ Object.assign(draft, initialState);
488
+ },
489
+ },
490
+ extraReducers: (builder) => {
491
+ builder.addCase(clearAll, (draft) => {
492
+ Object.assign(draft, initialState);
493
+ });
494
+ },
495
+ });
496
+ export const { ackCloseMatchAfterIgnore, ackCloseMatchAfterUndo, clearActualMatchingView, clearMatchNewModal, closeMatchNewModal, fetchActualMatching, fetchActualMatchingFailure, fetchActualMatchingMatch, fetchActualMatchingMatchFailure, fetchActualMatchingMatchSuccess, fetchActualMatchingPage, fetchActualMatchingSuccess, ignoreActualMatchingSuggestion, ignoreActualMatchingSuggestionFailure, ignoreActualMatchingSuggestionSuccess, matchAndReverseAccruals, matchAndReverseAccrualsFailure, matchAndReverseAccrualsSuccess, openMatchNewModal, searchMatchAccruals, searchMatchAccrualsFailure, searchMatchAccrualsSuccess, searchMatchTransactions, searchMatchTransactionsFailure, searchMatchTransactionsSuccess, undoReversalAccruals, undoReversalAccrualsFailure, undoReversalAccrualsSuccess, updateActualMatchingUIState, } = expenseAutomationActualMatchingView.actions;
497
+ export default expenseAutomationActualMatchingView.reducer;
@@ -105,11 +105,12 @@ const expenseAutomationJESchedulesView = createSlice({
105
105
  initialState,
106
106
  reducers: {
107
107
  fetchJeSchedulesPage: {
108
- prepare(period, refreshViewInBackground = false) {
108
+ prepare(period, refreshViewInBackground = false, isAccrualEnabled = false) {
109
109
  return {
110
110
  payload: {
111
111
  period,
112
112
  refreshViewInBackground,
113
+ isAccrualEnabled,
113
114
  },
114
115
  };
115
116
  },