@zeniai/client-epic-state 5.2.10 → 5.2.11-betaAM1

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 (155) hide show
  1. package/lib/entity/jeSchedules/jeScheduleHelper.d.ts +1 -0
  2. package/lib/entity/jeSchedules/jeScheduleHelper.js +7 -0
  3. package/lib/entity/jeSchedules/jeSchedulesPayload.d.ts +86 -1
  4. package/lib/entity/jeSchedules/jeSchedulesPayload.js +172 -0
  5. package/lib/entity/jeSchedules/jeSchedulesReducer.d.ts +4 -2
  6. package/lib/entity/jeSchedules/jeSchedulesReducer.js +30 -2
  7. package/lib/entity/jeSchedules/jeSchedulesSelector.d.ts +11 -2
  8. package/lib/entity/jeSchedules/jeSchedulesSelector.js +38 -3
  9. package/lib/entity/jeSchedules/jeSchedulesState.d.ts +101 -1
  10. package/lib/entity/jeSchedules/jeSchedulesTypes.d.ts +24 -1
  11. package/lib/entity/jeSchedules/jeSchedulesTypes.js +88 -1
  12. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  13. package/lib/entity/snackbar/snackbarTypes.js +3 -0
  14. package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.d.ts +2 -0
  15. package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.js +2 -0
  16. package/lib/entity/transaction/stateTypes/scheduleTransaction.d.ts +2 -0
  17. package/lib/epic.d.ts +14 -1
  18. package/lib/epic.js +26 -0
  19. package/lib/esm/entity/jeSchedules/jeScheduleHelper.js +6 -0
  20. package/lib/esm/entity/jeSchedules/jeSchedulesPayload.js +172 -1
  21. package/lib/esm/entity/jeSchedules/jeSchedulesReducer.js +30 -2
  22. package/lib/esm/entity/jeSchedules/jeSchedulesSelector.js +36 -2
  23. package/lib/esm/entity/jeSchedules/jeSchedulesTypes.js +78 -0
  24. package/lib/esm/entity/snackbar/snackbarTypes.js +3 -0
  25. package/lib/esm/entity/transaction/payloadTypes/scheduleTransactionPayload.js +2 -0
  26. package/lib/esm/epic.js +26 -0
  27. package/lib/esm/index.js +19 -9
  28. package/lib/esm/reducer.js +3 -0
  29. package/lib/esm/view/companyMonthEndReportView/companyMonthEndReportViewReducer.js +6 -2
  30. package/lib/esm/view/companyMonthEndReportView/companyMonthEndReportViewState.js +4 -0
  31. package/lib/esm/view/companyMonthEndReportView/epics/saveCompanyMonthEndReportEpic.js +10 -6
  32. package/lib/esm/view/companyMonthEndReportView/epics/sendCompanyMonthEndReportEpic.js +9 -5
  33. package/lib/esm/view/companyMonthEndReportView/monthEndTemplateData.js +32 -0
  34. package/lib/esm/view/expenseAutomationView/epics/actualMatching/fetchActualMatchingEpic.js +46 -0
  35. package/lib/esm/view/expenseAutomationView/epics/actualMatching/fetchActualMatchingPageEpic.js +7 -0
  36. package/lib/esm/view/expenseAutomationView/epics/actualMatching/matchAndReverseAccrualsEpic.js +50 -0
  37. package/lib/esm/view/expenseAutomationView/epics/actualMatching/searchMatchAccrualsEpic.js +44 -0
  38. package/lib/esm/view/expenseAutomationView/epics/actualMatching/searchMatchTransactionsEpic.js +44 -0
  39. package/lib/esm/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +30 -10
  40. package/lib/esm/view/expenseAutomationView/epics/common/refreshExpenseAutomationCurrentTabEpic.js +9 -1
  41. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.js +9 -1
  42. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +41 -5
  43. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic.js +45 -0
  44. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/ignoreRecommendedJeScheduleEpic.js +14 -2
  45. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.js +104 -0
  46. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +25 -0
  47. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js +136 -0
  48. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +79 -0
  49. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.js +157 -0
  50. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.js +111 -0
  51. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +33 -0
  52. package/lib/esm/view/expenseAutomationView/expenseAutomationViewSelector.js +22 -7
  53. package/lib/esm/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.js +140 -0
  54. package/lib/esm/view/expenseAutomationView/payload/actualMatchingPayload.js +35 -0
  55. package/lib/esm/view/expenseAutomationView/payload/jeSchedulesPayload.js +55 -0
  56. package/lib/esm/view/expenseAutomationView/reducers/actualMatchingViewReducer.js +260 -0
  57. package/lib/esm/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +314 -29
  58. package/lib/esm/view/expenseAutomationView/selectorTypes/actualMatchingViewSelectorTypes.js +1 -0
  59. package/lib/esm/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +1 -0
  60. package/lib/esm/view/expenseAutomationView/selectors/actualMatchingViewSelector.js +162 -0
  61. package/lib/esm/view/expenseAutomationView/selectors/jeAccountSettingsViewSelector.js +1 -0
  62. package/lib/esm/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +106 -0
  63. package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +297 -22
  64. package/lib/esm/view/expenseAutomationView/types/actualMatchingViewState.js +22 -0
  65. package/lib/esm/view/expenseAutomationView/types/jeSchedulesViewState.js +8 -5
  66. package/lib/esm/view/scheduleView/scheduleListView/epics/fetchAccruedScheduleListEpic.js +1 -1
  67. package/lib/esm/view/scheduleView/scheduleListView/epics/fetchDownloadSchedulesEpic.js +7 -2
  68. package/lib/esm/view/scheduleView/scheduleListView/scheduleListReducer.js +5 -3
  69. package/lib/index.d.ts +25 -14
  70. package/lib/index.js +119 -51
  71. package/lib/reducer.d.ts +1 -0
  72. package/lib/reducer.js +3 -0
  73. package/lib/rootStateTypes.d.ts +2 -0
  74. package/lib/view/companyMonthEndReportView/companyMonthEndReportViewPayload.d.ts +8 -0
  75. package/lib/view/companyMonthEndReportView/companyMonthEndReportViewReducer.d.ts +6 -2
  76. package/lib/view/companyMonthEndReportView/companyMonthEndReportViewReducer.js +6 -2
  77. package/lib/view/companyMonthEndReportView/companyMonthEndReportViewState.d.ts +2 -0
  78. package/lib/view/companyMonthEndReportView/companyMonthEndReportViewState.js +4 -0
  79. package/lib/view/companyMonthEndReportView/epics/saveCompanyMonthEndReportEpic.js +10 -6
  80. package/lib/view/companyMonthEndReportView/epics/sendCompanyMonthEndReportEpic.js +9 -5
  81. package/lib/view/companyMonthEndReportView/monthEndTemplateData.d.ts +16 -0
  82. package/lib/view/companyMonthEndReportView/monthEndTemplateData.js +36 -0
  83. package/lib/view/expenseAutomationView/epics/actualMatching/fetchActualMatchingEpic.d.ts +9 -0
  84. package/lib/view/expenseAutomationView/epics/actualMatching/fetchActualMatchingEpic.js +50 -0
  85. package/lib/view/expenseAutomationView/epics/actualMatching/fetchActualMatchingPageEpic.d.ts +5 -0
  86. package/lib/view/expenseAutomationView/epics/actualMatching/fetchActualMatchingPageEpic.js +11 -0
  87. package/lib/view/expenseAutomationView/epics/actualMatching/matchAndReverseAccrualsEpic.d.ts +8 -0
  88. package/lib/view/expenseAutomationView/epics/actualMatching/matchAndReverseAccrualsEpic.js +54 -0
  89. package/lib/view/expenseAutomationView/epics/actualMatching/searchMatchAccrualsEpic.d.ts +8 -0
  90. package/lib/view/expenseAutomationView/epics/actualMatching/searchMatchAccrualsEpic.js +48 -0
  91. package/lib/view/expenseAutomationView/epics/actualMatching/searchMatchTransactionsEpic.d.ts +8 -0
  92. package/lib/view/expenseAutomationView/epics/actualMatching/searchMatchTransactionsEpic.js +48 -0
  93. package/lib/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.d.ts +2 -1
  94. package/lib/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +30 -10
  95. package/lib/view/expenseAutomationView/epics/common/refreshExpenseAutomationCurrentTabEpic.d.ts +2 -1
  96. package/lib/view/expenseAutomationView/epics/common/refreshExpenseAutomationCurrentTabEpic.js +9 -1
  97. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.js +9 -1
  98. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.d.ts +3 -2
  99. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +39 -3
  100. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic.d.ts +21 -0
  101. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic.js +49 -0
  102. package/lib/view/expenseAutomationView/epics/jeSchedule/ignoreRecommendedJeScheduleEpic.js +14 -2
  103. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.d.ts +9 -0
  104. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.js +108 -0
  105. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.d.ts +8 -0
  106. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +29 -0
  107. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.d.ts +9 -0
  108. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js +140 -0
  109. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.d.ts +8 -0
  110. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +83 -0
  111. package/lib/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.d.ts +13 -0
  112. package/lib/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.js +164 -0
  113. package/lib/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.d.ts +65 -0
  114. package/lib/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.js +115 -0
  115. package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.d.ts +7 -0
  116. package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +37 -0
  117. package/lib/view/expenseAutomationView/expenseAutomationViewSelector.js +22 -7
  118. package/lib/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.d.ts +36 -0
  119. package/lib/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.js +145 -0
  120. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  121. package/lib/view/expenseAutomationView/payload/actualMatchingPayload.d.ts +66 -0
  122. package/lib/view/expenseAutomationView/payload/actualMatchingPayload.js +40 -0
  123. package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.d.ts +72 -3
  124. package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.js +58 -1
  125. package/lib/view/expenseAutomationView/reducers/actualMatchingViewReducer.d.ts +53 -0
  126. package/lib/view/expenseAutomationView/reducers/actualMatchingViewReducer.js +264 -0
  127. package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +91 -12
  128. package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +316 -29
  129. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +1 -1
  130. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +2 -2
  131. package/lib/view/expenseAutomationView/selectorTypes/actualMatchingViewSelectorTypes.d.ts +58 -0
  132. package/lib/view/expenseAutomationView/selectorTypes/actualMatchingViewSelectorTypes.js +2 -0
  133. package/lib/view/expenseAutomationView/selectorTypes/expenseAutomationViewSelectorTypes.d.ts +2 -0
  134. package/lib/view/expenseAutomationView/selectorTypes/jeAccountSettingsViewSelectorTypes.d.ts +1 -0
  135. package/lib/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.d.ts +42 -0
  136. package/lib/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +2 -0
  137. package/lib/view/expenseAutomationView/selectorTypes/jeSchedulesSelectorTypes.d.ts +36 -7
  138. package/lib/view/expenseAutomationView/selectors/actualMatchingViewSelector.d.ts +9 -0
  139. package/lib/view/expenseAutomationView/selectors/actualMatchingViewSelector.js +172 -0
  140. package/lib/view/expenseAutomationView/selectors/jeAccountSettingsViewSelector.js +1 -0
  141. package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.d.ts +21 -0
  142. package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +112 -0
  143. package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.d.ts +34 -0
  144. package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +305 -21
  145. package/lib/view/expenseAutomationView/types/actualMatchingViewState.d.ts +76 -0
  146. package/lib/view/expenseAutomationView/types/actualMatchingViewState.js +27 -0
  147. package/lib/view/expenseAutomationView/types/completedSubTab.d.ts +1 -1
  148. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +83 -8
  149. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.js +11 -7
  150. package/lib/view/expenseAutomationView/types/reconciliationViewState.d.ts +1 -1
  151. package/lib/view/scheduleView/scheduleListView/epics/fetchAccruedScheduleListEpic.js +1 -1
  152. package/lib/view/scheduleView/scheduleListView/epics/fetchDownloadSchedulesEpic.js +7 -2
  153. package/lib/view/scheduleView/scheduleListView/scheduleListReducer.d.ts +4 -2
  154. package/lib/view/scheduleView/scheduleListView/scheduleListReducer.js +5 -3
  155. package/package.json +1 -1
@@ -0,0 +1,260 @@
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;