@zeniai/client-epic-state 5.2.11-beta0ND → 5.2.11-betaRD2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. package/lib/entity/invoicing/invoicingCommonPayload.d.ts +29 -27
  2. package/lib/entity/invoicing/invoicingCommonPayload.js +75 -37
  3. package/lib/entity/invoicing/product/productPayload.d.ts +0 -10
  4. package/lib/entity/invoicing/product/productPayload.js +2 -14
  5. package/lib/entity/jeSchedules/jeScheduleHelper.d.ts +1 -0
  6. package/lib/entity/jeSchedules/jeScheduleHelper.js +7 -0
  7. package/lib/entity/jeSchedules/jeSchedulesPayload.d.ts +66 -1
  8. package/lib/entity/jeSchedules/jeSchedulesPayload.js +135 -0
  9. package/lib/entity/jeSchedules/jeSchedulesReducer.d.ts +4 -2
  10. package/lib/entity/jeSchedules/jeSchedulesReducer.js +30 -2
  11. package/lib/entity/jeSchedules/jeSchedulesSelector.d.ts +11 -2
  12. package/lib/entity/jeSchedules/jeSchedulesSelector.js +38 -3
  13. package/lib/entity/jeSchedules/jeSchedulesState.d.ts +79 -1
  14. package/lib/entity/jeSchedules/jeSchedulesTypes.d.ts +24 -1
  15. package/lib/entity/jeSchedules/jeSchedulesTypes.js +88 -1
  16. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  17. package/lib/entity/snackbar/snackbarTypes.js +3 -0
  18. package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.d.ts +2 -0
  19. package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.js +2 -0
  20. package/lib/entity/transaction/stateTypes/scheduleTransaction.d.ts +2 -0
  21. package/lib/epic.d.ts +10 -3
  22. package/lib/epic.js +21 -12
  23. package/lib/esm/entity/invoicing/invoicingCommonPayload.js +73 -33
  24. package/lib/esm/entity/invoicing/product/productPayload.js +2 -14
  25. package/lib/esm/entity/jeSchedules/jeScheduleHelper.js +6 -0
  26. package/lib/esm/entity/jeSchedules/jeSchedulesPayload.js +135 -1
  27. package/lib/esm/entity/jeSchedules/jeSchedulesReducer.js +30 -2
  28. package/lib/esm/entity/jeSchedules/jeSchedulesSelector.js +36 -2
  29. package/lib/esm/entity/jeSchedules/jeSchedulesTypes.js +78 -0
  30. package/lib/esm/entity/snackbar/snackbarTypes.js +3 -0
  31. package/lib/esm/entity/transaction/payloadTypes/scheduleTransactionPayload.js +2 -0
  32. package/lib/esm/epic.js +17 -8
  33. package/lib/esm/index.js +20 -15
  34. package/lib/esm/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +6 -3
  35. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.js +9 -1
  36. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +41 -5
  37. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic.js +45 -0
  38. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/ignoreRecommendedJeScheduleEpic.js +14 -2
  39. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.js +99 -0
  40. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +25 -0
  41. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js +110 -0
  42. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +79 -0
  43. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.js +139 -0
  44. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.js +106 -0
  45. package/lib/esm/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +22 -0
  46. package/lib/esm/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.js +140 -0
  47. package/lib/esm/view/expenseAutomationView/payload/jeSchedulesPayload.js +55 -0
  48. package/lib/esm/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +311 -29
  49. package/lib/esm/view/expenseAutomationView/selectors/jeAccountSettingsViewSelector.js +1 -0
  50. package/lib/esm/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +106 -0
  51. package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +294 -22
  52. package/lib/esm/view/expenseAutomationView/types/jeSchedulesViewState.js +5 -6
  53. package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.js +9 -25
  54. package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +1 -6
  55. package/lib/esm/view/invoicing/invoicingQboView/invoicingQboViewSelector.js +0 -40
  56. package/lib/esm/view/invoicing/settingsView/settingsViewEpics.js +92 -0
  57. package/lib/esm/view/invoicing/settingsView/settingsViewReducer.js +1 -25
  58. package/lib/esm/view/invoicing/settingsView/settingsViewSelector.js +0 -41
  59. package/lib/esm/view/recommendation/recommendationReducer.js +1 -16
  60. package/lib/esm/view/scheduleView/scheduleListView/epics/fetchAccruedScheduleListEpic.js +1 -1
  61. package/lib/esm/view/scheduleView/scheduleListView/epics/fetchDownloadSchedulesEpic.js +7 -2
  62. package/lib/esm/view/scheduleView/scheduleListView/scheduleListReducer.js +5 -3
  63. package/lib/index.d.ts +24 -22
  64. package/lib/index.js +96 -60
  65. package/lib/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +6 -3
  66. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.js +9 -1
  67. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.d.ts +3 -2
  68. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +39 -3
  69. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic.d.ts +20 -0
  70. package/lib/view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic.js +49 -0
  71. package/lib/view/expenseAutomationView/epics/jeSchedule/ignoreRecommendedJeScheduleEpic.js +14 -2
  72. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.d.ts +8 -0
  73. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.js +103 -0
  74. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.d.ts +8 -0
  75. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +29 -0
  76. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.d.ts +45 -0
  77. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js +114 -0
  78. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.d.ts +8 -0
  79. package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +83 -0
  80. package/lib/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.d.ts +12 -0
  81. package/lib/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.js +146 -0
  82. package/lib/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.d.ts +64 -0
  83. package/lib/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.js +110 -0
  84. package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.d.ts +6 -0
  85. package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +26 -0
  86. package/lib/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.d.ts +36 -0
  87. package/lib/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.js +145 -0
  88. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  89. package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.d.ts +72 -3
  90. package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.js +58 -1
  91. package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +91 -12
  92. package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +313 -29
  93. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +1 -1
  94. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +2 -2
  95. package/lib/view/expenseAutomationView/selectorTypes/jeAccountSettingsViewSelectorTypes.d.ts +1 -0
  96. package/lib/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.d.ts +42 -0
  97. package/lib/view/expenseAutomationView/selectorTypes/jeSchedulesSelectorTypes.d.ts +36 -7
  98. package/lib/view/expenseAutomationView/selectors/jeAccountSettingsViewSelector.js +1 -0
  99. package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.d.ts +21 -0
  100. package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +112 -0
  101. package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.d.ts +34 -0
  102. package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +302 -21
  103. package/lib/view/expenseAutomationView/types/completedSubTab.d.ts +1 -1
  104. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +83 -8
  105. package/lib/view/expenseAutomationView/types/jeSchedulesViewState.js +8 -8
  106. package/lib/view/expenseAutomationView/types/reconciliationViewState.d.ts +2 -2
  107. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.d.ts +1 -12
  108. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.js +9 -25
  109. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +1 -6
  110. package/lib/view/invoicing/invoicingQboView/invoicingQboViewSelector.d.ts +1 -10
  111. package/lib/view/invoicing/invoicingQboView/invoicingQboViewSelector.js +1 -43
  112. package/lib/view/invoicing/settingsView/settingsViewEpics.d.ts +12 -0
  113. package/lib/view/invoicing/settingsView/settingsViewEpics.js +99 -0
  114. package/lib/view/invoicing/settingsView/settingsViewReducer.d.ts +1 -4
  115. package/lib/view/invoicing/settingsView/settingsViewReducer.js +2 -26
  116. package/lib/view/invoicing/settingsView/settingsViewSelector.d.ts +0 -35
  117. package/lib/view/invoicing/settingsView/settingsViewSelector.js +1 -43
  118. package/lib/view/invoicing/settingsView/settingsViewState.d.ts +0 -8
  119. package/lib/view/recommendation/recommendationPayload.d.ts +0 -34
  120. package/lib/view/recommendation/recommendationReducer.d.ts +1 -2
  121. package/lib/view/recommendation/recommendationReducer.js +2 -17
  122. package/lib/view/scheduleView/scheduleListView/epics/fetchAccruedScheduleListEpic.js +1 -1
  123. package/lib/view/scheduleView/scheduleListView/epics/fetchDownloadSchedulesEpic.js +7 -2
  124. package/lib/view/scheduleView/scheduleListView/scheduleListReducer.d.ts +4 -2
  125. package/lib/view/scheduleView/scheduleListView/scheduleListReducer.js +5 -3
  126. package/package.json +1 -1
  127. package/lib/esm/view/invoicing/settingsView/epics/connectInvoicingStripeEpic.js +0 -27
  128. package/lib/esm/view/invoicing/settingsView/epics/disconnectInvoicingStripeEpic.js +0 -19
  129. package/lib/esm/view/invoicing/settingsView/epics/fetchInvoicingSettingsEpic.js +0 -19
  130. package/lib/esm/view/invoicing/settingsView/epics/saveInvoicingSettingsEpic.js +0 -39
  131. package/lib/esm/view/invoicing/settingsView/epics/submitInvoicingQboSettingsEpic.js +0 -25
  132. package/lib/esm/view/invoicing/settingsView/invoicingQboSettingsFormConfig.js +0 -48
  133. package/lib/esm/view/recommendation/submitRecommendationFeedbackEpic.js +0 -52
  134. package/lib/view/invoicing/settingsView/epics/connectInvoicingStripeEpic.d.ts +0 -6
  135. package/lib/view/invoicing/settingsView/epics/connectInvoicingStripeEpic.js +0 -31
  136. package/lib/view/invoicing/settingsView/epics/disconnectInvoicingStripeEpic.d.ts +0 -6
  137. package/lib/view/invoicing/settingsView/epics/disconnectInvoicingStripeEpic.js +0 -23
  138. package/lib/view/invoicing/settingsView/epics/fetchInvoicingSettingsEpic.d.ts +0 -6
  139. package/lib/view/invoicing/settingsView/epics/fetchInvoicingSettingsEpic.js +0 -23
  140. package/lib/view/invoicing/settingsView/epics/saveInvoicingSettingsEpic.d.ts +0 -6
  141. package/lib/view/invoicing/settingsView/epics/saveInvoicingSettingsEpic.js +0 -43
  142. package/lib/view/invoicing/settingsView/epics/settingsViewActionType.d.ts +0 -5
  143. package/lib/view/invoicing/settingsView/epics/submitInvoicingQboSettingsEpic.d.ts +0 -11
  144. package/lib/view/invoicing/settingsView/epics/submitInvoicingQboSettingsEpic.js +0 -29
  145. package/lib/view/invoicing/settingsView/invoicingQboSettingsFormConfig.d.ts +0 -34
  146. package/lib/view/invoicing/settingsView/invoicingQboSettingsFormConfig.js +0 -53
  147. package/lib/view/recommendation/submitRecommendationFeedbackEpic.d.ts +0 -7
  148. package/lib/view/recommendation/submitRecommendationFeedbackEpic.js +0 -56
  149. /package/lib/esm/view/{invoicing/settingsView/epics/settingsViewActionType.js → expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js} +0 -0
  150. /package/lib/view/{invoicing/settingsView/epics/settingsViewActionType.js → expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js} +0 -0
@@ -2,9 +2,16 @@ import { createSlice } from '@reduxjs/toolkit';
2
2
  import { geNestedAccountIDHierarchyForReport } from '../../../commonStateTypes/accountView/getNestedAccountIDHierarchyForReport';
3
3
  import { toMonthYearPeriodId, } from '../../../commonStateTypes/timePeriod';
4
4
  import { mapAccountBasePayloadToAccountBase, mapAccountMetadataPayloadToAccountMetadata, } from '../../../entity/account/accountPayload';
5
- import { getJEScheduleTransactionDetailKeyPayload, } from '../../../entity/jeSchedules/jeSchedulesPayload';
5
+ import { generateJEOneTimeAccrualKey } from '../../../entity/jeSchedules/jeScheduleHelper';
6
+ import { getJEScheduleKey, getJEScheduleTransactionDetailKeyPayload, } from '../../../entity/jeSchedules/jeSchedulesPayload';
6
7
  import { clearAll } from '../../../rootActions';
7
8
  import { mapAccountTypeRecommendationPayloadToAccountRecommendationByType, } from '../../accountMappingView/accountTypeRecommendation/accountTypeRecommendationPayload';
9
+ import { MIN_NEW_SCHEDULE_SEARCH_LENGTH, getJESchedulePeriodTabKey, } from '../types/jeSchedulesViewState';
10
+ function removeKeyFromEveryTabSlot(keysByPeriodAndTab, keyToRemove) {
11
+ for (const periodTabKey of Object.keys(keysByPeriodAndTab)) {
12
+ keysByPeriodAndTab[periodTabKey] = keysByPeriodAndTab[periodTabKey].filter((jeScheduleKey) => jeScheduleKey !== keyToRemove);
13
+ }
14
+ }
8
15
  export const accountSettingsInitialState = {
9
16
  localData: {
10
17
  selectedPrepaidExpensesAccountIds: [],
@@ -18,6 +25,7 @@ export const accountSettingsInitialState = {
18
25
  error: undefined,
19
26
  fetchState: 'Not-Started',
20
27
  },
28
+ hasLoadedAccountSettings: false,
21
29
  recommendationFetchState: {
22
30
  error: undefined,
23
31
  fetchState: 'Not-Started',
@@ -36,16 +44,37 @@ export const accountSettingsInitialState = {
36
44
  accruedExpensesNestedAccountListHierarchy: [],
37
45
  accruedExpensesRecommendations: [],
38
46
  };
47
+ export const getBaseNewScheduleLocalData = (scheduleType) => ({
48
+ scheduleType,
49
+ jeScheduleDetails: [],
50
+ });
51
+ export const newScheduleInitialState = {
52
+ fixed_assets: getBaseNewScheduleLocalData('fixed_assets'),
53
+ prepaid_expenses: getBaseNewScheduleLocalData('prepaid_expenses'),
54
+ };
55
+ export const searchTransactionsInitialState = {
56
+ searchResults: [],
57
+ fetchState: 'Not-Started',
58
+ error: undefined,
59
+ };
39
60
  export const initialState = {
40
- jeScheduleTransactionKeysByPeriod: {},
41
- failedJeScheduleTransactionKeysByPeriod: {},
61
+ jeScheduleTransactionKeysByPeriodAndTab: {},
62
+ jeScheduleAccruedKeysByPeriodAndTab: {},
63
+ jeScheduleOneTimeAccrualKeysByPeriodAndTab: {},
64
+ failedJeScheduleTransactionKeysByPeriodAndTab: {},
42
65
  postStatusById: {},
43
66
  ignoreStatusById: {},
67
+ revertStatusById: {},
44
68
  jeScheduleLocalDataById: {},
69
+ oneTimeAccrualActionStatusById: {},
70
+ oneTimeAccrualFetchStatusById: {},
45
71
  uiState: {
46
- searchString: '',
72
+ createdGroupCollapsed: false,
73
+ pendingGroupCollapsed: false,
47
74
  scrollPosition: { scrollTop: 0, scrollLeft: undefined },
48
- selectedMainTab: 'pending_review',
75
+ searchString: '',
76
+ selectedJETypeFilter: null,
77
+ selectedPageTab: 'schedules',
49
78
  sortKey: 'transactionDate',
50
79
  sortOrder: 'descending',
51
80
  totalCount: 0,
@@ -56,6 +85,14 @@ export const initialState = {
56
85
  error: undefined,
57
86
  },
58
87
  accountSettings: accountSettingsInitialState,
88
+ newSchedule: {
89
+ createOneTimeAccrualStatus: { fetchState: 'Not-Started', error: undefined },
90
+ newScheduleState: newScheduleInitialState,
91
+ saveStatus: { fetchState: 'Not-Started', error: undefined },
92
+ searchTransactions: searchTransactionsInitialState,
93
+ fetchState: 'Not-Started',
94
+ error: undefined,
95
+ },
59
96
  fetchState: 'Not-Started',
60
97
  error: undefined,
61
98
  hasValidState() {
@@ -100,9 +137,12 @@ const expenseAutomationJESchedulesView = createSlice({
100
137
  },
101
138
  },
102
139
  fetchJeSchedulesSuccess(draft, action) {
103
- const { jeSchedules, selectedPeriod, failedJeSchedules, refreshViewInBackground, } = action.payload;
140
+ const { jeSchedules, selectedPeriod, selectedPageTab, failedJeSchedules, accruedJeSchedules, oneTimeAccruals, refreshViewInBackground, } = action.payload;
141
+ const periodTabKey = getJESchedulePeriodTabKey(selectedPageTab, toMonthYearPeriodId(selectedPeriod));
104
142
  const jeScheduleTransactionKeys = jeSchedules.map((schedules) => getJEScheduleTransactionDetailKeyPayload(schedules.base_transaction));
105
143
  const failedJeScheduleTransactionKeys = failedJeSchedules.map((schedules) => getJEScheduleTransactionDetailKeyPayload(schedules.base_transaction));
144
+ const jeScheduleAccruedKeys = accruedJeSchedules.map((schedule) => getJEScheduleKey(schedule));
145
+ const jeScheduleOneTimeAccrualKeys = oneTimeAccruals.map((accrual) => generateJEOneTimeAccrualKey(accrual._id));
106
146
  if (refreshViewInBackground === true &&
107
147
  draft.refreshStatus.fetchState === 'In-Progress') {
108
148
  draft.refreshStatus = { fetchState: 'Completed', error: undefined };
@@ -111,19 +151,28 @@ const expenseAutomationJESchedulesView = createSlice({
111
151
  draft.fetchState = 'Completed';
112
152
  draft.error = undefined;
113
153
  }
114
- draft.jeScheduleTransactionKeysByPeriod[toMonthYearPeriodId(selectedPeriod)] = jeScheduleTransactionKeys;
115
- draft.failedJeScheduleTransactionKeysByPeriod[toMonthYearPeriodId(selectedPeriod)] = failedJeScheduleTransactionKeys;
154
+ draft.jeScheduleTransactionKeysByPeriodAndTab[periodTabKey] =
155
+ jeScheduleTransactionKeys;
156
+ draft.jeScheduleAccruedKeysByPeriodAndTab[periodTabKey] =
157
+ jeScheduleAccruedKeys;
158
+ draft.jeScheduleOneTimeAccrualKeysByPeriodAndTab[periodTabKey] =
159
+ jeScheduleOneTimeAccrualKeys;
160
+ draft.failedJeScheduleTransactionKeysByPeriodAndTab[periodTabKey] =
161
+ failedJeScheduleTransactionKeys;
116
162
  },
117
163
  fetchJeSchedulesFailure(draft, action) {
118
- const { status, selectedPeriod } = action.payload;
164
+ const { status, selectedPeriod, selectedPageTab } = action.payload;
165
+ const periodTabKey = getJESchedulePeriodTabKey(selectedPageTab, toMonthYearPeriodId(selectedPeriod));
119
166
  if (draft.refreshStatus.fetchState === 'In-Progress') {
120
167
  draft.refreshStatus = { fetchState: 'Error', error: status };
121
168
  }
122
169
  else {
123
170
  draft.fetchState = 'Error';
124
171
  draft.error = status;
172
+ draft.jeScheduleTransactionKeysByPeriodAndTab[periodTabKey] = [];
173
+ draft.jeScheduleAccruedKeysByPeriodAndTab[periodTabKey] = [];
174
+ draft.jeScheduleOneTimeAccrualKeysByPeriodAndTab[periodTabKey] = [];
125
175
  }
126
- draft.jeScheduleTransactionKeysByPeriod[toMonthYearPeriodId(selectedPeriod)] = [];
127
176
  },
128
177
  retryJeSchedule(draft, action) {
129
178
  const { scheduledJournalEntryID } = action.payload;
@@ -159,11 +208,13 @@ const expenseAutomationJESchedulesView = createSlice({
159
208
  };
160
209
  },
161
210
  ignoreRecommendedJeSchedule: {
162
- prepare(jeScheduleTransactionKey, scheduleType) {
211
+ prepare(jeScheduleTransactionKey, scheduleType, reason, note) {
163
212
  return {
164
213
  payload: {
165
214
  jeScheduleTransactionKey,
166
215
  scheduleType,
216
+ reason,
217
+ note,
167
218
  },
168
219
  };
169
220
  },
@@ -179,6 +230,41 @@ const expenseAutomationJESchedulesView = createSlice({
179
230
  };
180
231
  },
181
232
  },
233
+ revertJeSchedule: {
234
+ // jeScheduleTransactionKey is a JEScheduleKey for an accrued schedule, which has no base
235
+ // transaction to derive a transaction key from. It is only ever used as an opaque row
236
+ // identifier here -- for the row's spinner and for dropping the row from the list -- so one
237
+ // action serves both shapes rather than two near-identical ones.
238
+ prepare(jeScheduleId, jeScheduleTransactionKey, scheduleType, reason, note) {
239
+ return {
240
+ payload: {
241
+ jeScheduleId,
242
+ jeScheduleTransactionKey,
243
+ scheduleType,
244
+ reason,
245
+ note,
246
+ },
247
+ };
248
+ },
249
+ reducer(draft, action) {
250
+ draft.revertStatusById[action.payload.jeScheduleTransactionKey] = {
251
+ fetchState: 'In-Progress',
252
+ error: undefined,
253
+ };
254
+ },
255
+ },
256
+ revertJeScheduleSuccess(draft, action) {
257
+ draft.revertStatusById[action.payload.jeScheduleTransactionKey] = {
258
+ fetchState: 'Completed',
259
+ error: undefined,
260
+ };
261
+ },
262
+ revertJeScheduleFailure(draft, action) {
263
+ draft.revertStatusById[action.payload.jeScheduleTransactionKey] = {
264
+ fetchState: 'Error',
265
+ error: action.payload.status,
266
+ };
267
+ },
182
268
  ignoreRecommendedJeScheduleSuccess: {
183
269
  reducer(draft, action) {
184
270
  const { jeScheduleTransactionKey } = action.payload;
@@ -211,17 +297,18 @@ const expenseAutomationJESchedulesView = createSlice({
211
297
  };
212
298
  },
213
299
  updateJeScheduleTransactionKeys: {
214
- prepare(jeScheduleKeys, selectedPeriod) {
300
+ prepare(jeScheduleKeys, selectedPeriod, selectedPageTab) {
215
301
  return {
216
302
  payload: {
217
303
  jeScheduleKeys: jeScheduleKeys,
218
304
  selectedPeriod: selectedPeriod,
305
+ selectedPageTab: selectedPageTab,
219
306
  },
220
307
  };
221
308
  },
222
309
  reducer(draft, action) {
223
- const { selectedPeriod, jeScheduleKeys } = action.payload;
224
- draft.jeScheduleTransactionKeysByPeriod[toMonthYearPeriodId(selectedPeriod)] = jeScheduleKeys;
310
+ const { selectedPeriod, selectedPageTab, jeScheduleKeys } = action.payload;
311
+ draft.jeScheduleTransactionKeysByPeriodAndTab[getJESchedulePeriodTabKey(selectedPageTab, toMonthYearPeriodId(selectedPeriod))] = jeScheduleKeys;
225
312
  },
226
313
  },
227
314
  removeJeScheduleTransactionKey: {
@@ -234,12 +321,20 @@ const expenseAutomationJESchedulesView = createSlice({
234
321
  };
235
322
  },
236
323
  reducer(draft, action) {
237
- const { selectedPeriod, jeScheduleKey } = action.payload;
238
- const prevData = [
239
- ...(draft.jeScheduleTransactionKeysByPeriod[toMonthYearPeriodId(selectedPeriod)] ?? []),
240
- ];
241
- const filteredKeys = prevData.filter((jeKey) => jeKey !== jeScheduleKey);
242
- draft.jeScheduleTransactionKeysByPeriod[toMonthYearPeriodId(selectedPeriod)] = filteredKeys;
324
+ const { jeScheduleKey } = action.payload;
325
+ // Dropped from every tab's slot, not just the visible one: once a schedule is ignored or
326
+ // resolved it must not reappear when the user switches tabs and hits a cached list.
327
+ removeKeyFromEveryTabSlot(draft.jeScheduleTransactionKeysByPeriodAndTab, jeScheduleKey);
328
+ },
329
+ },
330
+ removeJeAccruedScheduleKey: {
331
+ prepare(jeAccruedScheduleKey) {
332
+ return { payload: { jeAccruedScheduleKey } };
333
+ },
334
+ reducer(draft, action) {
335
+ // Accrued keys live in their own per-tab map, so removeJeScheduleTransactionKey cannot drop
336
+ // them -- a reverted accrued schedule stayed on the list until the next fetch.
337
+ removeKeyFromEveryTabSlot(draft.jeScheduleAccruedKeysByPeriodAndTab, action.payload.jeAccruedScheduleKey);
243
338
  },
244
339
  },
245
340
  removeFailedJeScheduleTransactionKey: {
@@ -252,12 +347,8 @@ const expenseAutomationJESchedulesView = createSlice({
252
347
  };
253
348
  },
254
349
  reducer(draft, action) {
255
- const { selectedPeriod, failedJeScheduleKey } = action.payload;
256
- const prevData = [
257
- ...(draft.failedJeScheduleTransactionKeysByPeriod[toMonthYearPeriodId(selectedPeriod)] ?? []),
258
- ];
259
- const filteredKeys = prevData.filter((jeKey) => jeKey !== failedJeScheduleKey);
260
- draft.failedJeScheduleTransactionKeysByPeriod[toMonthYearPeriodId(selectedPeriod)] = filteredKeys;
350
+ const { failedJeScheduleKey } = action.payload;
351
+ removeKeyFromEveryTabSlot(draft.failedJeScheduleTransactionKeysByPeriodAndTab, failedJeScheduleKey);
261
352
  },
262
353
  },
263
354
  initializeJeScheduleLocalData: {
@@ -336,6 +427,9 @@ const expenseAutomationJESchedulesView = createSlice({
336
427
  error: status,
337
428
  fetchState: 'Error',
338
429
  };
430
+ // Set on failure too: a tenant whose account list errors must still reach the page rather
431
+ // than sit under a skeleton forever.
432
+ draft.accountSettings.hasLoadedAccountSettings = true;
339
433
  },
340
434
  updateAccountSettingsListForAccountTypes(draft, action) {
341
435
  doUpdateAccountSettingsListForAccountTypes(draft.accountSettings, action.payload.accountPayload);
@@ -369,6 +463,182 @@ const expenseAutomationJESchedulesView = createSlice({
369
463
  clearJeAccountSettingsLocalData(draft) {
370
464
  draft.accountSettings.localData = accountSettingsInitialState.localData;
371
465
  },
466
+ initializeNewSchedule: {
467
+ prepare({ scheduleType, shouldResetEnteredData = true, }) {
468
+ return { payload: { scheduleType, shouldResetEnteredData } };
469
+ },
470
+ reducer() {
471
+ // Purely an epic-trigger action — the epic fans out the account/class
472
+ // list fetches, and clears entered data only when asked to.
473
+ },
474
+ },
475
+ resetNewScheduleLocalData: {
476
+ prepare({ scheduleType, }) {
477
+ return { payload: { scheduleType } };
478
+ },
479
+ reducer(draft, action) {
480
+ const { scheduleType } = action.payload;
481
+ draft.newSchedule.newScheduleState[scheduleType] =
482
+ getBaseNewScheduleLocalData(scheduleType);
483
+ },
484
+ },
485
+ updateNewScheduleLocalData(draft, action) {
486
+ const { scheduleType, localData } = action.payload;
487
+ draft.newSchedule.newScheduleState[scheduleType] = {
488
+ ...draft.newSchedule.newScheduleState[scheduleType],
489
+ ...localData,
490
+ };
491
+ },
492
+ searchTransactionsForNewSchedule: {
493
+ prepare({ query, scheduleType, }) {
494
+ return { payload: { query, scheduleType } };
495
+ },
496
+ reducer(draft, action) {
497
+ const trimmed = action.payload.query.trim();
498
+ // Cleared or too-short query: no API (see epic) — reset immediately.
499
+ if (trimmed.length < MIN_NEW_SCHEDULE_SEARCH_LENGTH) {
500
+ draft.newSchedule.searchTransactions = searchTransactionsInitialState;
501
+ return;
502
+ }
503
+ draft.newSchedule.searchTransactions = {
504
+ ...draft.newSchedule.searchTransactions,
505
+ searchString: action.payload.query,
506
+ fetchState: 'In-Progress',
507
+ };
508
+ },
509
+ },
510
+ searchTransactionsForNewScheduleSuccess(draft, action) {
511
+ draft.newSchedule.searchTransactions = {
512
+ ...draft.newSchedule.searchTransactions,
513
+ searchResults: action.payload.searchResults,
514
+ fetchState: 'Completed',
515
+ error: undefined,
516
+ };
517
+ },
518
+ searchTransactionsForNewScheduleFailure(draft, action) {
519
+ draft.newSchedule.searchTransactions = {
520
+ ...draft.newSchedule.searchTransactions,
521
+ fetchState: 'Error',
522
+ error: action.payload.status,
523
+ };
524
+ },
525
+ clearSearchTransactionsForNewSchedule(draft) {
526
+ draft.newSchedule.searchTransactions = searchTransactionsInitialState;
527
+ },
528
+ saveNewSchedule: {
529
+ prepare({ scheduleType, }) {
530
+ return { payload: { scheduleType } };
531
+ },
532
+ reducer(draft) {
533
+ draft.newSchedule.saveStatus = {
534
+ fetchState: 'In-Progress',
535
+ error: undefined,
536
+ };
537
+ },
538
+ },
539
+ saveNewScheduleSuccess(draft) {
540
+ draft.newSchedule.saveStatus = {
541
+ fetchState: 'Completed',
542
+ error: undefined,
543
+ };
544
+ },
545
+ saveNewScheduleFailure(draft, action) {
546
+ draft.newSchedule.saveStatus = {
547
+ fetchState: 'Error',
548
+ error: action.payload.status,
549
+ };
550
+ },
551
+ createOneTimeAccrual: {
552
+ prepare(localData) {
553
+ return { payload: { localData } };
554
+ },
555
+ reducer(draft) {
556
+ draft.newSchedule.createOneTimeAccrualStatus = {
557
+ fetchState: 'In-Progress',
558
+ error: undefined,
559
+ };
560
+ },
561
+ },
562
+ createOneTimeAccrualSuccess(draft) {
563
+ draft.newSchedule.createOneTimeAccrualStatus = {
564
+ fetchState: 'Completed',
565
+ error: undefined,
566
+ };
567
+ },
568
+ createOneTimeAccrualFailure(draft, action) {
569
+ draft.newSchedule.createOneTimeAccrualStatus = {
570
+ fetchState: 'Error',
571
+ error: action.payload.status,
572
+ };
573
+ },
574
+ promoteOneTimeAccrual: {
575
+ prepare(accrualId, amount) {
576
+ return { payload: { accrualId, amount } };
577
+ },
578
+ reducer(draft, action) {
579
+ draft.oneTimeAccrualActionStatusById[action.payload.accrualId] = {
580
+ fetchState: 'In-Progress',
581
+ error: undefined,
582
+ };
583
+ },
584
+ },
585
+ revertOneTimeAccrual: {
586
+ prepare(accrualId, reason, note) {
587
+ return { payload: { accrualId, reason, note } };
588
+ },
589
+ reducer(draft, action) {
590
+ draft.oneTimeAccrualActionStatusById[action.payload.accrualId] = {
591
+ fetchState: 'In-Progress',
592
+ error: undefined,
593
+ };
594
+ },
595
+ },
596
+ ignoreOneTimeAccrual: {
597
+ prepare(accrualId, reason, note) {
598
+ return { payload: { accrualId, reason, note } };
599
+ },
600
+ reducer(draft, action) {
601
+ draft.oneTimeAccrualActionStatusById[action.payload.accrualId] = {
602
+ fetchState: 'In-Progress',
603
+ error: undefined,
604
+ };
605
+ },
606
+ },
607
+ fetchOneTimeAccrual: {
608
+ prepare(accrualId) {
609
+ return { payload: { accrualId } };
610
+ },
611
+ reducer(draft, action) {
612
+ draft.oneTimeAccrualFetchStatusById[action.payload.accrualId] = {
613
+ fetchState: 'In-Progress',
614
+ error: undefined,
615
+ };
616
+ },
617
+ },
618
+ fetchOneTimeAccrualSuccess(draft, action) {
619
+ draft.oneTimeAccrualFetchStatusById[action.payload.accrualId] = {
620
+ fetchState: 'Completed',
621
+ error: undefined,
622
+ };
623
+ },
624
+ fetchOneTimeAccrualFailure(draft, action) {
625
+ draft.oneTimeAccrualFetchStatusById[action.payload.accrualId] = {
626
+ fetchState: 'Error',
627
+ error: action.payload.status,
628
+ };
629
+ },
630
+ oneTimeAccrualActionSuccess(draft, action) {
631
+ draft.oneTimeAccrualActionStatusById[action.payload.accrualId] = {
632
+ fetchState: 'Completed',
633
+ error: undefined,
634
+ };
635
+ },
636
+ oneTimeAccrualActionFailure(draft, action) {
637
+ draft.oneTimeAccrualActionStatusById[action.payload.accrualId] = {
638
+ fetchState: 'Error',
639
+ error: action.payload.status,
640
+ };
641
+ },
372
642
  updateJESchedulesUIState(draft, action) {
373
643
  if (action.payload.sortKey != null) {
374
644
  draft.uiState.sortKey = action.payload.sortKey;
@@ -382,10 +652,21 @@ const expenseAutomationJESchedulesView = createSlice({
382
652
  if (action.payload.scrollPosition != null) {
383
653
  draft.uiState.scrollPosition = action.payload.scrollPosition;
384
654
  }
385
- if (action.payload.selectedMainTab != null) {
386
- draft.uiState.selectedMainTab = action.payload.selectedMainTab;
655
+ if (action.payload.selectedPageTab != null) {
656
+ draft.uiState.selectedPageTab = action.payload.selectedPageTab;
387
657
  }
388
658
  },
659
+ updateJEScheduleTypeFilter(draft, action) {
660
+ draft.uiState.selectedJETypeFilter = action.payload;
661
+ },
662
+ toggleJEPendingGroupCollapsed(draft) {
663
+ draft.uiState.pendingGroupCollapsed =
664
+ !draft.uiState.pendingGroupCollapsed;
665
+ },
666
+ toggleJECreatedGroupCollapsed(draft) {
667
+ draft.uiState.createdGroupCollapsed =
668
+ !draft.uiState.createdGroupCollapsed;
669
+ },
389
670
  clearExpenseAutomationJESchedulesView(draft) {
390
671
  Object.assign(draft, initialState);
391
672
  },
@@ -396,7 +677,7 @@ const expenseAutomationJESchedulesView = createSlice({
396
677
  });
397
678
  },
398
679
  });
399
- export const { clearExpenseAutomationJESchedulesView, clearJeAccountSettingsLocalData, clearJeScheduleLocalData, fetchAccountSettingsListForAccountTypes, fetchJeSchedules, fetchJeSchedulesFailure, fetchJeSchedulesPage, fetchJeSchedulesSuccess, fetchRecommendationForAccountSettings, ignoreRecommendedJeSchedule, ignoreRecommendedJeScheduleFailure, ignoreRecommendedJeScheduleSuccess, initializeAccountSettingsView, initializeJeScheduleLocalData, removeFailedJeScheduleTransactionKey, removeJeScheduleLocalDataById, removeJeScheduleTransactionKey, retryJeSchedule, retryJeScheduleFailure, retryJeScheduleSuccess, saveAccountSettings, saveAccountSettingsFailure, saveAccountSettingsLocalData, saveAccountSettingsSuccess, updateAccountSettingsListForAccountTypes, updateAccountSettingsListForAccountTypesFailure, updateJESchedulesUIState, updateJeScheduleLocalDataById, updateJeScheduleTransactionKeys, updateRecommendationForAccountSettings, updateRecommendationForAccountSettingsFailure, } = expenseAutomationJESchedulesView.actions;
680
+ export const { clearExpenseAutomationJESchedulesView, clearJeAccountSettingsLocalData, clearJeScheduleLocalData, clearSearchTransactionsForNewSchedule, createOneTimeAccrual, createOneTimeAccrualFailure, createOneTimeAccrualSuccess, ignoreOneTimeAccrual, oneTimeAccrualActionFailure, oneTimeAccrualActionSuccess, promoteOneTimeAccrual, revertJeSchedule, revertJeScheduleFailure, revertJeScheduleSuccess, revertOneTimeAccrual, fetchAccountSettingsListForAccountTypes, fetchJeSchedules, fetchJeSchedulesFailure, fetchJeSchedulesPage, fetchJeSchedulesSuccess, fetchOneTimeAccrual, fetchOneTimeAccrualFailure, fetchOneTimeAccrualSuccess, fetchRecommendationForAccountSettings, ignoreRecommendedJeSchedule, ignoreRecommendedJeScheduleFailure, ignoreRecommendedJeScheduleSuccess, initializeAccountSettingsView, initializeJeScheduleLocalData, initializeNewSchedule, removeFailedJeScheduleTransactionKey, removeJeScheduleLocalDataById, removeJeAccruedScheduleKey, removeJeScheduleTransactionKey, resetNewScheduleLocalData, retryJeSchedule, retryJeScheduleFailure, retryJeScheduleSuccess, saveAccountSettings, saveAccountSettingsFailure, saveAccountSettingsLocalData, saveAccountSettingsSuccess, saveNewSchedule, saveNewScheduleFailure, saveNewScheduleSuccess, searchTransactionsForNewSchedule, searchTransactionsForNewScheduleFailure, searchTransactionsForNewScheduleSuccess, toggleJECreatedGroupCollapsed, toggleJEPendingGroupCollapsed, updateAccountSettingsListForAccountTypes, updateAccountSettingsListForAccountTypesFailure, updateJESchedulesUIState, updateJEScheduleTypeFilter, updateJeScheduleLocalDataById, updateJeScheduleTransactionKeys, updateNewScheduleLocalData, updateRecommendationForAccountSettings, updateRecommendationForAccountSettingsFailure, } = expenseAutomationJESchedulesView.actions;
400
681
  export default expenseAutomationJESchedulesView.reducer;
401
682
  const doUpdateRecommendationForAccountSettings = (draft, payload) => {
402
683
  const { prepaidExpensesRecommendations, fixedAssetsRecommendations, accruedExpensesRecommendations, } = mapAccountTypeRecommendationPayloadToAccountRecommendationByType(payload);
@@ -464,4 +745,5 @@ const doUpdateAccountSettingsListForAccountTypes = (draft, accountPayloadList) =
464
745
  error: undefined,
465
746
  fetchState: 'Completed',
466
747
  };
748
+ draft.hasLoadedAccountSettings = true;
467
749
  };
@@ -22,6 +22,7 @@ export const getJEAccountSettingsView = createSelector((state) => state.expenseA
22
22
  fixedAssetsAccountHierarchy: jeAccountMappingState.fixedAssetsNestedAccountListHierarchy,
23
23
  accruedExpensesAccountHierarchy: jeAccountMappingState.accruedExpensesNestedAccountListHierarchy,
24
24
  fetchState: fetchState.fetchState,
25
+ hasLoaded: jeAccountMappingState.hasLoadedAccountSettings,
25
26
  saveState,
26
27
  };
27
28
  });
@@ -0,0 +1,106 @@
1
+ import { getAccountIdsForLabels, getAccountIdsForTypes, } from '../../../entity/account/accountSelector';
2
+ import { getScheduleTransactionById } from '../../../entity/transaction/transactionSelector';
3
+ import { getAccountIdsForLabel, getAccountList, getNestedAccountListHierarchy, } from '../../accountList/accountListSelector';
4
+ import { getClassList, getNestedClassListHierarchy, } from '../../classList/classListSelector';
5
+ import { getAccountsTypesForScheduleDetails } from '../../scheduleView/scheduleDetailView/scheduleDetailLocalDataHelper';
6
+ import { filterNestedAccountHierarchyById } from '../../scheduleView/scheduleDetailView/scheduleDetailSelector';
7
+ import { getAccountLabelForScheduleType, getAccountsTypesForScheduleEpics, } from '../../scheduleView/scheduleListView/scheduleListHelper';
8
+ /**
9
+ * The Base Transaction search is shared across schedule types (one search
10
+ * box, not one per prepaid_expenses/fixed_assets) — split out from
11
+ * getNewScheduleView so a consumer can read it without supplying an
12
+ * otherwise-irrelevant scheduleType.
13
+ */
14
+ export const getNewScheduleSearchTransactionsView = (state) => {
15
+ const { searchTransactions } = state.expenseAutomationJESchedulesViewState.newSchedule;
16
+ const searchTransactionsResults = searchTransactions.searchResults
17
+ .map((key) => getScheduleTransactionById(state.transactionState, key))
18
+ .filter((transaction) => transaction != null);
19
+ return {
20
+ searchTransactionsResults,
21
+ searchTransactionsFetchState: {
22
+ fetchState: searchTransactions.fetchState,
23
+ error: searchTransactions.error,
24
+ },
25
+ searchTransactionsString: searchTransactions.searchString,
26
+ };
27
+ };
28
+ const ACCRUED_EXPENSE_ACCOUNT_LABELS = ['accrued_expenses'];
29
+ /**
30
+ * Account + class options and request status shared by both accrual creation forms — the one-time
31
+ * accrual and the recurring accrued schedule.
32
+ *
33
+ * getAccountsTypesForScheduleDetails('accrued_expenses') deliberately includes
34
+ * other_current_liabilities, because the accrued liability accounts live there —
35
+ * so the debit list has to subtract them back out, and the credit list keeps only
36
+ * them. Mirrors getScheduleAccruedDetailView, which is the form this one is
37
+ * modelled on.
38
+ */
39
+ export const getNewAccrualAccountsView = (state) => {
40
+ const { accountState, accountListState, classState, classListState } = state;
41
+ const { newSchedule } = state.expenseAutomationJESchedulesViewState;
42
+ const accountType = getAccountsTypesForScheduleEpics();
43
+ const accrualAccountIds = getAccountIdsForTypes(accountState, getAccountsTypesForScheduleDetails('accrued_expenses'));
44
+ const accruedCategoryIds = getAccountIdsForLabels(accountState, ACCRUED_EXPENSE_ACCOUNT_LABELS);
45
+ const allAccountList = getAccountList(accountState, accountListState, accountType.accountListKey);
46
+ const nestedAccountHierarchy = getNestedAccountListHierarchy(accountListState, accountType.accountListKey);
47
+ const debitAccounts = allAccountList.accounts.filter((account) => accrualAccountIds.includes(account.accountId) &&
48
+ !accruedCategoryIds.includes(account.accountId));
49
+ const creditAccounts = allAccountList.accounts.filter((account) => accruedCategoryIds.includes(account.accountId));
50
+ const allClassList = getClassList(classState, classListState);
51
+ return {
52
+ accountListNestedAccountHierarchy: filterNestedAccountHierarchyById(nestedAccountHierarchy, debitAccounts.map((account) => account.accountId)),
53
+ accruedAccountListNestedAccountHierarchy: filterNestedAccountHierarchyById(nestedAccountHierarchy, creditAccounts.map((account) => account.accountId)),
54
+ allAccountList: debitAccounts,
55
+ allAccruedExpenseList: creditAccounts,
56
+ allClassList: allClassList.classes,
57
+ classListNestedAccountHierarchy: getNestedClassListHierarchy(classListState),
58
+ createStatus: newSchedule.createOneTimeAccrualStatus,
59
+ // The recurring accrued schedule saves through the accrued detail epics that the Vendor tab
60
+ // already uses, so its status is that slice's updateStatus rather than anything new here.
61
+ accruedScheduleSaveStatus: state.scheduleAccruedDetailState.updateStatus,
62
+ };
63
+ };
64
+ export const getNewScheduleView = (state, scheduleType) => {
65
+ const { accountState, accountListState, classState, classListState } = state;
66
+ const { newSchedule } = state.expenseAutomationJESchedulesViewState;
67
+ const searchTransactionsView = getNewScheduleSearchTransactionsView(state);
68
+ const accountType = getAccountsTypesForScheduleEpics();
69
+ const newScheduleAccountTypes = getAccountsTypesForScheduleDetails(scheduleType);
70
+ const newScheduleAccountIds = getAccountIdsForTypes(accountState, newScheduleAccountTypes);
71
+ const allAccountList = getAccountList(accountState, accountListState, accountType.accountListKey);
72
+ const filteredAccounts = allAccountList.accounts.filter((account) => newScheduleAccountIds.includes(account.accountId));
73
+ const accountListNestedAccountHierarchy = filterNestedAccountHierarchyById(getNestedAccountListHierarchy(accountListState, accountType.accountListKey), filteredAccounts.map((account) => account.accountId));
74
+ const allClassList = getClassList(classState, classListState);
75
+ const classListNestedAccountHierarchy = getNestedClassListHierarchy(classListState);
76
+ let allDepreciationAccountList;
77
+ let allDepreciationAccountListNestedAccountHierarchy;
78
+ if (scheduleType === 'fixed_assets') {
79
+ const depreciationCategoryIds = getAccountIdsForTypes(accountState, [
80
+ 'fixed_assets',
81
+ 'other_assets',
82
+ ]);
83
+ const accountLabel = getAccountLabelForScheduleType('fixed_assets');
84
+ const fixedAssetLabelAccountIds = accountLabel != null
85
+ ? getAccountIdsForLabel(accountListState, accountType.accountListKey, accountLabel)
86
+ : [];
87
+ allDepreciationAccountList = allAccountList.accounts.filter((account) => depreciationCategoryIds.includes(account.accountId) &&
88
+ !fixedAssetLabelAccountIds.includes(account.accountId));
89
+ allDepreciationAccountListNestedAccountHierarchy =
90
+ filterNestedAccountHierarchyById(getNestedAccountListHierarchy(accountListState, accountType.accountListKey), allDepreciationAccountList.map((account) => account.accountId));
91
+ }
92
+ return {
93
+ scheduleType,
94
+ accountListNestedAccountHierarchy,
95
+ allAccountList: filteredAccounts,
96
+ allClassList: allClassList.classes,
97
+ allDepreciationAccountList,
98
+ allDepreciationAccountListNestedAccountHierarchy,
99
+ classListNestedAccountHierarchy,
100
+ newScheduleLocalData: newSchedule.newScheduleState[scheduleType],
101
+ saveStatus: newSchedule.saveStatus,
102
+ ...searchTransactionsView,
103
+ fetchState: newSchedule.fetchState,
104
+ error: newSchedule.error,
105
+ };
106
+ };