@zeniai/client-epic-state 5.2.10 → 5.2.11-betaRD1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonStateTypes/selectorTypes/pickAndMergeForecastSection.d.ts +0 -0
- package/lib/commonStateTypes/selectorTypes/pickAndMergeForecastSection.js +1 -0
- package/lib/entity/invoicing/coupon/couponConstants.d.ts +11 -0
- package/lib/entity/invoicing/coupon/couponConstants.js +29 -0
- package/lib/entity/jeSchedules/jeScheduleHelper.d.ts +1 -0
- package/lib/entity/jeSchedules/jeScheduleHelper.js +7 -0
- package/lib/entity/jeSchedules/jeSchedulesPayload.d.ts +66 -1
- package/lib/entity/jeSchedules/jeSchedulesPayload.js +135 -0
- package/lib/entity/jeSchedules/jeSchedulesReducer.d.ts +4 -2
- package/lib/entity/jeSchedules/jeSchedulesReducer.js +30 -2
- package/lib/entity/jeSchedules/jeSchedulesSelector.d.ts +11 -2
- package/lib/entity/jeSchedules/jeSchedulesSelector.js +38 -3
- package/lib/entity/jeSchedules/jeSchedulesState.d.ts +79 -1
- package/lib/entity/jeSchedules/jeSchedulesTypes.d.ts +24 -1
- package/lib/entity/jeSchedules/jeSchedulesTypes.js +88 -1
- package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
- package/lib/entity/snackbar/snackbarTypes.js +3 -0
- package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.d.ts +2 -0
- package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.js +2 -0
- package/lib/entity/transaction/stateTypes/scheduleTransaction.d.ts +2 -0
- package/lib/epic.d.ts +9 -1
- package/lib/epic.js +16 -0
- package/lib/esm/commonStateTypes/selectorTypes/pickAndMergeForecastSection.js +1 -0
- package/lib/esm/entity/invoicing/coupon/couponConstants.js +26 -0
- package/lib/esm/entity/jeSchedules/jeScheduleHelper.js +6 -0
- package/lib/esm/entity/jeSchedules/jeSchedulesPayload.js +135 -1
- package/lib/esm/entity/jeSchedules/jeSchedulesReducer.js +30 -2
- package/lib/esm/entity/jeSchedules/jeSchedulesSelector.js +36 -2
- package/lib/esm/entity/jeSchedules/jeSchedulesTypes.js +78 -0
- package/lib/esm/entity/snackbar/snackbarTypes.js +3 -0
- package/lib/esm/entity/transaction/payloadTypes/scheduleTransactionPayload.js +2 -0
- package/lib/esm/epic.js +16 -0
- package/lib/esm/index.js +14 -8
- package/lib/esm/view/companyMonthEndReportView/companyMonthEndReportViewReducer.js +6 -2
- package/lib/esm/view/companyMonthEndReportView/companyMonthEndReportViewState.js +4 -0
- package/lib/esm/view/companyMonthEndReportView/epics/saveCompanyMonthEndReportEpic.js +10 -6
- package/lib/esm/view/companyMonthEndReportView/epics/sendCompanyMonthEndReportEpic.js +9 -5
- package/lib/esm/view/companyMonthEndReportView/monthEndTemplateData.js +32 -0
- package/lib/esm/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +6 -3
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +41 -5
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic.js +45 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/ignoreRecommendedJeScheduleEpic.js +14 -2
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.js +99 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +25 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js +110 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +79 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.js +139 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.js +106 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +22 -0
- package/lib/esm/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.js +140 -0
- package/lib/esm/view/expenseAutomationView/payload/jeSchedulesPayload.js +55 -0
- package/lib/esm/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +306 -29
- package/lib/esm/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +1 -0
- package/lib/esm/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +106 -0
- package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +294 -22
- package/lib/esm/view/expenseAutomationView/types/jeSchedulesViewState.js +5 -6
- package/lib/esm/view/invoicing/invoicingQboView/epics/fetchInvoicingQboAccountsEpic.js +25 -0
- package/lib/esm/view/invoicing/invoicingQboView/epics/fetchInvoicingQboClassesEpic.js +15 -0
- package/lib/esm/view/scheduleView/scheduleListView/epics/fetchAccruedScheduleListEpic.js +1 -1
- package/lib/esm/view/scheduleView/scheduleListView/epics/fetchDownloadSchedulesEpic.js +7 -2
- package/lib/esm/view/scheduleView/scheduleListView/scheduleListReducer.js +5 -3
- package/lib/esm/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoIntroClosedByOutsideClickEpic.js +18 -0
- package/lib/esm/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoRemindMeLaterClickedEpic.js +18 -0
- package/lib/esm/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryVideoViewedEpic.js +18 -0
- package/lib/esm/view/zeniAccountsPromoCard/zeniAccountsPromoCardEpic.js +16 -0
- package/lib/esm/view/zeniAccountsPromoCard/zeniAccountsPromoCardPayload.js +1 -0
- package/lib/esm/view/zeniAccountsPromoCard/zeniAccountsPromoCardReducer.js +60 -0
- package/lib/esm/view/zeniAccountsPromoCard/zeniAccountsPromoCardSelector.js +12 -0
- package/lib/esm/view/zeniAccountsPromoCard/zeniAccountsPromoCardState.js +1 -0
- package/lib/index.d.ts +19 -13
- package/lib/index.js +91 -47
- package/lib/view/companyMonthEndReportView/companyMonthEndReportViewPayload.d.ts +8 -0
- package/lib/view/companyMonthEndReportView/companyMonthEndReportViewReducer.d.ts +6 -2
- package/lib/view/companyMonthEndReportView/companyMonthEndReportViewReducer.js +6 -2
- package/lib/view/companyMonthEndReportView/companyMonthEndReportViewState.d.ts +2 -0
- package/lib/view/companyMonthEndReportView/companyMonthEndReportViewState.js +4 -0
- package/lib/view/companyMonthEndReportView/epics/saveCompanyMonthEndReportEpic.js +10 -6
- package/lib/view/companyMonthEndReportView/epics/sendCompanyMonthEndReportEpic.js +9 -5
- package/lib/view/companyMonthEndReportView/monthEndTemplateData.d.ts +16 -0
- package/lib/view/companyMonthEndReportView/monthEndTemplateData.js +36 -0
- package/lib/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +6 -3
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.d.ts +3 -2
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +39 -3
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic.d.ts +20 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic.js +49 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/ignoreRecommendedJeScheduleEpic.js +14 -2
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.d.ts +8 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.js +103 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.d.ts +8 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +29 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.d.ts +45 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js +114 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.d.ts +8 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +83 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.d.ts +12 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.js +146 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.d.ts +64 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.js +110 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.d.ts +6 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +26 -0
- package/lib/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.d.ts +36 -0
- package/lib/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.js +145 -0
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
- package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.d.ts +72 -3
- package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.js +58 -1
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +91 -12
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +308 -29
- package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +1 -1
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +2 -2
- package/lib/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.d.ts +42 -0
- package/lib/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +2 -0
- package/lib/view/expenseAutomationView/selectorTypes/jeSchedulesSelectorTypes.d.ts +36 -7
- package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.d.ts +21 -0
- package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +112 -0
- package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.d.ts +34 -0
- package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +302 -21
- package/lib/view/expenseAutomationView/types/completedSubTab.d.ts +1 -1
- package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +82 -8
- package/lib/view/expenseAutomationView/types/jeSchedulesViewState.js +8 -8
- package/lib/view/expenseAutomationView/types/reconciliationViewState.d.ts +1 -1
- package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingQboAccountsEpic.d.ts +6 -0
- package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingQboAccountsEpic.js +29 -0
- package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingQboClassesEpic.d.ts +6 -0
- package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingQboClassesEpic.js +19 -0
- package/lib/view/scheduleView/scheduleListView/epics/fetchAccruedScheduleListEpic.js +1 -1
- package/lib/view/scheduleView/scheduleListView/epics/fetchDownloadSchedulesEpic.js +7 -2
- package/lib/view/scheduleView/scheduleListView/scheduleListReducer.d.ts +4 -2
- package/lib/view/scheduleView/scheduleListView/scheduleListReducer.js +5 -3
- package/lib/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoIntroClosedByOutsideClickEpic.d.ts +8 -0
- package/lib/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoIntroClosedByOutsideClickEpic.js +22 -0
- package/lib/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoRemindMeLaterClickedEpic.d.ts +8 -0
- package/lib/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoRemindMeLaterClickedEpic.js +22 -0
- package/lib/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryVideoViewedEpic.d.ts +8 -0
- package/lib/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryVideoViewedEpic.js +22 -0
- package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardEpic.d.ts +13 -0
- package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardEpic.js +20 -0
- package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardPayload.d.ts +11 -0
- package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardPayload.js +2 -0
- package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardReducer.d.ts +7 -0
- package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardReducer.js +64 -0
- package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardSelector.d.ts +12 -0
- package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardSelector.js +15 -0
- package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardState.d.ts +9 -0
- package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardState.js +2 -0
- package/package.json +1 -1
|
@@ -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 {
|
|
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: [],
|
|
@@ -36,16 +43,37 @@ export const accountSettingsInitialState = {
|
|
|
36
43
|
accruedExpensesNestedAccountListHierarchy: [],
|
|
37
44
|
accruedExpensesRecommendations: [],
|
|
38
45
|
};
|
|
46
|
+
export const getBaseNewScheduleLocalData = (scheduleType) => ({
|
|
47
|
+
scheduleType,
|
|
48
|
+
jeScheduleDetails: [],
|
|
49
|
+
});
|
|
50
|
+
export const newScheduleInitialState = {
|
|
51
|
+
fixed_assets: getBaseNewScheduleLocalData('fixed_assets'),
|
|
52
|
+
prepaid_expenses: getBaseNewScheduleLocalData('prepaid_expenses'),
|
|
53
|
+
};
|
|
54
|
+
export const searchTransactionsInitialState = {
|
|
55
|
+
searchResults: [],
|
|
56
|
+
fetchState: 'Not-Started',
|
|
57
|
+
error: undefined,
|
|
58
|
+
};
|
|
39
59
|
export const initialState = {
|
|
40
|
-
|
|
41
|
-
|
|
60
|
+
jeScheduleTransactionKeysByPeriodAndTab: {},
|
|
61
|
+
jeScheduleAccruedKeysByPeriodAndTab: {},
|
|
62
|
+
jeScheduleOneTimeAccrualKeysByPeriodAndTab: {},
|
|
63
|
+
failedJeScheduleTransactionKeysByPeriodAndTab: {},
|
|
42
64
|
postStatusById: {},
|
|
43
65
|
ignoreStatusById: {},
|
|
66
|
+
revertStatusById: {},
|
|
44
67
|
jeScheduleLocalDataById: {},
|
|
68
|
+
oneTimeAccrualActionStatusById: {},
|
|
69
|
+
oneTimeAccrualFetchStatusById: {},
|
|
45
70
|
uiState: {
|
|
46
|
-
|
|
71
|
+
createdGroupCollapsed: false,
|
|
72
|
+
pendingGroupCollapsed: false,
|
|
47
73
|
scrollPosition: { scrollTop: 0, scrollLeft: undefined },
|
|
48
|
-
|
|
74
|
+
searchString: '',
|
|
75
|
+
selectedJETypeFilter: null,
|
|
76
|
+
selectedPageTab: 'schedules',
|
|
49
77
|
sortKey: 'transactionDate',
|
|
50
78
|
sortOrder: 'descending',
|
|
51
79
|
totalCount: 0,
|
|
@@ -56,6 +84,14 @@ export const initialState = {
|
|
|
56
84
|
error: undefined,
|
|
57
85
|
},
|
|
58
86
|
accountSettings: accountSettingsInitialState,
|
|
87
|
+
newSchedule: {
|
|
88
|
+
createOneTimeAccrualStatus: { fetchState: 'Not-Started', error: undefined },
|
|
89
|
+
newScheduleState: newScheduleInitialState,
|
|
90
|
+
saveStatus: { fetchState: 'Not-Started', error: undefined },
|
|
91
|
+
searchTransactions: searchTransactionsInitialState,
|
|
92
|
+
fetchState: 'Not-Started',
|
|
93
|
+
error: undefined,
|
|
94
|
+
},
|
|
59
95
|
fetchState: 'Not-Started',
|
|
60
96
|
error: undefined,
|
|
61
97
|
hasValidState() {
|
|
@@ -100,9 +136,12 @@ const expenseAutomationJESchedulesView = createSlice({
|
|
|
100
136
|
},
|
|
101
137
|
},
|
|
102
138
|
fetchJeSchedulesSuccess(draft, action) {
|
|
103
|
-
const { jeSchedules, selectedPeriod, failedJeSchedules, refreshViewInBackground, } = action.payload;
|
|
139
|
+
const { jeSchedules, selectedPeriod, selectedPageTab, failedJeSchedules, accruedJeSchedules, oneTimeAccruals, refreshViewInBackground, } = action.payload;
|
|
140
|
+
const periodTabKey = getJESchedulePeriodTabKey(selectedPageTab, toMonthYearPeriodId(selectedPeriod));
|
|
104
141
|
const jeScheduleTransactionKeys = jeSchedules.map((schedules) => getJEScheduleTransactionDetailKeyPayload(schedules.base_transaction));
|
|
105
142
|
const failedJeScheduleTransactionKeys = failedJeSchedules.map((schedules) => getJEScheduleTransactionDetailKeyPayload(schedules.base_transaction));
|
|
143
|
+
const jeScheduleAccruedKeys = accruedJeSchedules.map((schedule) => getJEScheduleKey(schedule));
|
|
144
|
+
const jeScheduleOneTimeAccrualKeys = oneTimeAccruals.map((accrual) => generateJEOneTimeAccrualKey(accrual._id));
|
|
106
145
|
if (refreshViewInBackground === true &&
|
|
107
146
|
draft.refreshStatus.fetchState === 'In-Progress') {
|
|
108
147
|
draft.refreshStatus = { fetchState: 'Completed', error: undefined };
|
|
@@ -111,19 +150,28 @@ const expenseAutomationJESchedulesView = createSlice({
|
|
|
111
150
|
draft.fetchState = 'Completed';
|
|
112
151
|
draft.error = undefined;
|
|
113
152
|
}
|
|
114
|
-
draft.
|
|
115
|
-
|
|
153
|
+
draft.jeScheduleTransactionKeysByPeriodAndTab[periodTabKey] =
|
|
154
|
+
jeScheduleTransactionKeys;
|
|
155
|
+
draft.jeScheduleAccruedKeysByPeriodAndTab[periodTabKey] =
|
|
156
|
+
jeScheduleAccruedKeys;
|
|
157
|
+
draft.jeScheduleOneTimeAccrualKeysByPeriodAndTab[periodTabKey] =
|
|
158
|
+
jeScheduleOneTimeAccrualKeys;
|
|
159
|
+
draft.failedJeScheduleTransactionKeysByPeriodAndTab[periodTabKey] =
|
|
160
|
+
failedJeScheduleTransactionKeys;
|
|
116
161
|
},
|
|
117
162
|
fetchJeSchedulesFailure(draft, action) {
|
|
118
|
-
const { status, selectedPeriod } = action.payload;
|
|
163
|
+
const { status, selectedPeriod, selectedPageTab } = action.payload;
|
|
164
|
+
const periodTabKey = getJESchedulePeriodTabKey(selectedPageTab, toMonthYearPeriodId(selectedPeriod));
|
|
119
165
|
if (draft.refreshStatus.fetchState === 'In-Progress') {
|
|
120
166
|
draft.refreshStatus = { fetchState: 'Error', error: status };
|
|
121
167
|
}
|
|
122
168
|
else {
|
|
123
169
|
draft.fetchState = 'Error';
|
|
124
170
|
draft.error = status;
|
|
171
|
+
draft.jeScheduleTransactionKeysByPeriodAndTab[periodTabKey] = [];
|
|
172
|
+
draft.jeScheduleAccruedKeysByPeriodAndTab[periodTabKey] = [];
|
|
173
|
+
draft.jeScheduleOneTimeAccrualKeysByPeriodAndTab[periodTabKey] = [];
|
|
125
174
|
}
|
|
126
|
-
draft.jeScheduleTransactionKeysByPeriod[toMonthYearPeriodId(selectedPeriod)] = [];
|
|
127
175
|
},
|
|
128
176
|
retryJeSchedule(draft, action) {
|
|
129
177
|
const { scheduledJournalEntryID } = action.payload;
|
|
@@ -159,11 +207,13 @@ const expenseAutomationJESchedulesView = createSlice({
|
|
|
159
207
|
};
|
|
160
208
|
},
|
|
161
209
|
ignoreRecommendedJeSchedule: {
|
|
162
|
-
prepare(jeScheduleTransactionKey, scheduleType) {
|
|
210
|
+
prepare(jeScheduleTransactionKey, scheduleType, reason, note) {
|
|
163
211
|
return {
|
|
164
212
|
payload: {
|
|
165
213
|
jeScheduleTransactionKey,
|
|
166
214
|
scheduleType,
|
|
215
|
+
reason,
|
|
216
|
+
note,
|
|
167
217
|
},
|
|
168
218
|
};
|
|
169
219
|
},
|
|
@@ -179,6 +229,41 @@ const expenseAutomationJESchedulesView = createSlice({
|
|
|
179
229
|
};
|
|
180
230
|
},
|
|
181
231
|
},
|
|
232
|
+
revertJeSchedule: {
|
|
233
|
+
// jeScheduleTransactionKey is a JEScheduleKey for an accrued schedule, which has no base
|
|
234
|
+
// transaction to derive a transaction key from. It is only ever used as an opaque row
|
|
235
|
+
// identifier here -- for the row's spinner and for dropping the row from the list -- so one
|
|
236
|
+
// action serves both shapes rather than two near-identical ones.
|
|
237
|
+
prepare(jeScheduleId, jeScheduleTransactionKey, scheduleType, reason, note) {
|
|
238
|
+
return {
|
|
239
|
+
payload: {
|
|
240
|
+
jeScheduleId,
|
|
241
|
+
jeScheduleTransactionKey,
|
|
242
|
+
scheduleType,
|
|
243
|
+
reason,
|
|
244
|
+
note,
|
|
245
|
+
},
|
|
246
|
+
};
|
|
247
|
+
},
|
|
248
|
+
reducer(draft, action) {
|
|
249
|
+
draft.revertStatusById[action.payload.jeScheduleTransactionKey] = {
|
|
250
|
+
fetchState: 'In-Progress',
|
|
251
|
+
error: undefined,
|
|
252
|
+
};
|
|
253
|
+
},
|
|
254
|
+
},
|
|
255
|
+
revertJeScheduleSuccess(draft, action) {
|
|
256
|
+
draft.revertStatusById[action.payload.jeScheduleTransactionKey] = {
|
|
257
|
+
fetchState: 'Completed',
|
|
258
|
+
error: undefined,
|
|
259
|
+
};
|
|
260
|
+
},
|
|
261
|
+
revertJeScheduleFailure(draft, action) {
|
|
262
|
+
draft.revertStatusById[action.payload.jeScheduleTransactionKey] = {
|
|
263
|
+
fetchState: 'Error',
|
|
264
|
+
error: action.payload.status,
|
|
265
|
+
};
|
|
266
|
+
},
|
|
182
267
|
ignoreRecommendedJeScheduleSuccess: {
|
|
183
268
|
reducer(draft, action) {
|
|
184
269
|
const { jeScheduleTransactionKey } = action.payload;
|
|
@@ -211,17 +296,18 @@ const expenseAutomationJESchedulesView = createSlice({
|
|
|
211
296
|
};
|
|
212
297
|
},
|
|
213
298
|
updateJeScheduleTransactionKeys: {
|
|
214
|
-
prepare(jeScheduleKeys, selectedPeriod) {
|
|
299
|
+
prepare(jeScheduleKeys, selectedPeriod, selectedPageTab) {
|
|
215
300
|
return {
|
|
216
301
|
payload: {
|
|
217
302
|
jeScheduleKeys: jeScheduleKeys,
|
|
218
303
|
selectedPeriod: selectedPeriod,
|
|
304
|
+
selectedPageTab: selectedPageTab,
|
|
219
305
|
},
|
|
220
306
|
};
|
|
221
307
|
},
|
|
222
308
|
reducer(draft, action) {
|
|
223
|
-
const { selectedPeriod, jeScheduleKeys } = action.payload;
|
|
224
|
-
draft.
|
|
309
|
+
const { selectedPeriod, selectedPageTab, jeScheduleKeys } = action.payload;
|
|
310
|
+
draft.jeScheduleTransactionKeysByPeriodAndTab[getJESchedulePeriodTabKey(selectedPageTab, toMonthYearPeriodId(selectedPeriod))] = jeScheduleKeys;
|
|
225
311
|
},
|
|
226
312
|
},
|
|
227
313
|
removeJeScheduleTransactionKey: {
|
|
@@ -234,12 +320,20 @@ const expenseAutomationJESchedulesView = createSlice({
|
|
|
234
320
|
};
|
|
235
321
|
},
|
|
236
322
|
reducer(draft, action) {
|
|
237
|
-
const {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
323
|
+
const { jeScheduleKey } = action.payload;
|
|
324
|
+
// Dropped from every tab's slot, not just the visible one: once a schedule is ignored or
|
|
325
|
+
// resolved it must not reappear when the user switches tabs and hits a cached list.
|
|
326
|
+
removeKeyFromEveryTabSlot(draft.jeScheduleTransactionKeysByPeriodAndTab, jeScheduleKey);
|
|
327
|
+
},
|
|
328
|
+
},
|
|
329
|
+
removeJeAccruedScheduleKey: {
|
|
330
|
+
prepare(jeAccruedScheduleKey) {
|
|
331
|
+
return { payload: { jeAccruedScheduleKey } };
|
|
332
|
+
},
|
|
333
|
+
reducer(draft, action) {
|
|
334
|
+
// Accrued keys live in their own per-tab map, so removeJeScheduleTransactionKey cannot drop
|
|
335
|
+
// them -- a reverted accrued schedule stayed on the list until the next fetch.
|
|
336
|
+
removeKeyFromEveryTabSlot(draft.jeScheduleAccruedKeysByPeriodAndTab, action.payload.jeAccruedScheduleKey);
|
|
243
337
|
},
|
|
244
338
|
},
|
|
245
339
|
removeFailedJeScheduleTransactionKey: {
|
|
@@ -252,12 +346,8 @@ const expenseAutomationJESchedulesView = createSlice({
|
|
|
252
346
|
};
|
|
253
347
|
},
|
|
254
348
|
reducer(draft, action) {
|
|
255
|
-
const {
|
|
256
|
-
|
|
257
|
-
...(draft.failedJeScheduleTransactionKeysByPeriod[toMonthYearPeriodId(selectedPeriod)] ?? []),
|
|
258
|
-
];
|
|
259
|
-
const filteredKeys = prevData.filter((jeKey) => jeKey !== failedJeScheduleKey);
|
|
260
|
-
draft.failedJeScheduleTransactionKeysByPeriod[toMonthYearPeriodId(selectedPeriod)] = filteredKeys;
|
|
349
|
+
const { failedJeScheduleKey } = action.payload;
|
|
350
|
+
removeKeyFromEveryTabSlot(draft.failedJeScheduleTransactionKeysByPeriodAndTab, failedJeScheduleKey);
|
|
261
351
|
},
|
|
262
352
|
},
|
|
263
353
|
initializeJeScheduleLocalData: {
|
|
@@ -369,6 +459,182 @@ const expenseAutomationJESchedulesView = createSlice({
|
|
|
369
459
|
clearJeAccountSettingsLocalData(draft) {
|
|
370
460
|
draft.accountSettings.localData = accountSettingsInitialState.localData;
|
|
371
461
|
},
|
|
462
|
+
initializeNewSchedule: {
|
|
463
|
+
prepare({ scheduleType, shouldResetEnteredData = true, }) {
|
|
464
|
+
return { payload: { scheduleType, shouldResetEnteredData } };
|
|
465
|
+
},
|
|
466
|
+
reducer() {
|
|
467
|
+
// Purely an epic-trigger action — the epic fans out the account/class
|
|
468
|
+
// list fetches, and clears entered data only when asked to.
|
|
469
|
+
},
|
|
470
|
+
},
|
|
471
|
+
resetNewScheduleLocalData: {
|
|
472
|
+
prepare({ scheduleType, }) {
|
|
473
|
+
return { payload: { scheduleType } };
|
|
474
|
+
},
|
|
475
|
+
reducer(draft, action) {
|
|
476
|
+
const { scheduleType } = action.payload;
|
|
477
|
+
draft.newSchedule.newScheduleState[scheduleType] =
|
|
478
|
+
getBaseNewScheduleLocalData(scheduleType);
|
|
479
|
+
},
|
|
480
|
+
},
|
|
481
|
+
updateNewScheduleLocalData(draft, action) {
|
|
482
|
+
const { scheduleType, localData } = action.payload;
|
|
483
|
+
draft.newSchedule.newScheduleState[scheduleType] = {
|
|
484
|
+
...draft.newSchedule.newScheduleState[scheduleType],
|
|
485
|
+
...localData,
|
|
486
|
+
};
|
|
487
|
+
},
|
|
488
|
+
searchTransactionsForNewSchedule: {
|
|
489
|
+
prepare({ query, scheduleType, }) {
|
|
490
|
+
return { payload: { query, scheduleType } };
|
|
491
|
+
},
|
|
492
|
+
reducer(draft, action) {
|
|
493
|
+
const trimmed = action.payload.query.trim();
|
|
494
|
+
// Cleared or too-short query: no API (see epic) — reset immediately.
|
|
495
|
+
if (trimmed.length < MIN_NEW_SCHEDULE_SEARCH_LENGTH) {
|
|
496
|
+
draft.newSchedule.searchTransactions = searchTransactionsInitialState;
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
draft.newSchedule.searchTransactions = {
|
|
500
|
+
...draft.newSchedule.searchTransactions,
|
|
501
|
+
searchString: action.payload.query,
|
|
502
|
+
fetchState: 'In-Progress',
|
|
503
|
+
};
|
|
504
|
+
},
|
|
505
|
+
},
|
|
506
|
+
searchTransactionsForNewScheduleSuccess(draft, action) {
|
|
507
|
+
draft.newSchedule.searchTransactions = {
|
|
508
|
+
...draft.newSchedule.searchTransactions,
|
|
509
|
+
searchResults: action.payload.searchResults,
|
|
510
|
+
fetchState: 'Completed',
|
|
511
|
+
error: undefined,
|
|
512
|
+
};
|
|
513
|
+
},
|
|
514
|
+
searchTransactionsForNewScheduleFailure(draft, action) {
|
|
515
|
+
draft.newSchedule.searchTransactions = {
|
|
516
|
+
...draft.newSchedule.searchTransactions,
|
|
517
|
+
fetchState: 'Error',
|
|
518
|
+
error: action.payload.status,
|
|
519
|
+
};
|
|
520
|
+
},
|
|
521
|
+
clearSearchTransactionsForNewSchedule(draft) {
|
|
522
|
+
draft.newSchedule.searchTransactions = searchTransactionsInitialState;
|
|
523
|
+
},
|
|
524
|
+
saveNewSchedule: {
|
|
525
|
+
prepare({ scheduleType, }) {
|
|
526
|
+
return { payload: { scheduleType } };
|
|
527
|
+
},
|
|
528
|
+
reducer(draft) {
|
|
529
|
+
draft.newSchedule.saveStatus = {
|
|
530
|
+
fetchState: 'In-Progress',
|
|
531
|
+
error: undefined,
|
|
532
|
+
};
|
|
533
|
+
},
|
|
534
|
+
},
|
|
535
|
+
saveNewScheduleSuccess(draft) {
|
|
536
|
+
draft.newSchedule.saveStatus = {
|
|
537
|
+
fetchState: 'Completed',
|
|
538
|
+
error: undefined,
|
|
539
|
+
};
|
|
540
|
+
},
|
|
541
|
+
saveNewScheduleFailure(draft, action) {
|
|
542
|
+
draft.newSchedule.saveStatus = {
|
|
543
|
+
fetchState: 'Error',
|
|
544
|
+
error: action.payload.status,
|
|
545
|
+
};
|
|
546
|
+
},
|
|
547
|
+
createOneTimeAccrual: {
|
|
548
|
+
prepare(localData) {
|
|
549
|
+
return { payload: { localData } };
|
|
550
|
+
},
|
|
551
|
+
reducer(draft) {
|
|
552
|
+
draft.newSchedule.createOneTimeAccrualStatus = {
|
|
553
|
+
fetchState: 'In-Progress',
|
|
554
|
+
error: undefined,
|
|
555
|
+
};
|
|
556
|
+
},
|
|
557
|
+
},
|
|
558
|
+
createOneTimeAccrualSuccess(draft) {
|
|
559
|
+
draft.newSchedule.createOneTimeAccrualStatus = {
|
|
560
|
+
fetchState: 'Completed',
|
|
561
|
+
error: undefined,
|
|
562
|
+
};
|
|
563
|
+
},
|
|
564
|
+
createOneTimeAccrualFailure(draft, action) {
|
|
565
|
+
draft.newSchedule.createOneTimeAccrualStatus = {
|
|
566
|
+
fetchState: 'Error',
|
|
567
|
+
error: action.payload.status,
|
|
568
|
+
};
|
|
569
|
+
},
|
|
570
|
+
promoteOneTimeAccrual: {
|
|
571
|
+
prepare(accrualId, amount) {
|
|
572
|
+
return { payload: { accrualId, amount } };
|
|
573
|
+
},
|
|
574
|
+
reducer(draft, action) {
|
|
575
|
+
draft.oneTimeAccrualActionStatusById[action.payload.accrualId] = {
|
|
576
|
+
fetchState: 'In-Progress',
|
|
577
|
+
error: undefined,
|
|
578
|
+
};
|
|
579
|
+
},
|
|
580
|
+
},
|
|
581
|
+
revertOneTimeAccrual: {
|
|
582
|
+
prepare(accrualId, reason, note) {
|
|
583
|
+
return { payload: { accrualId, reason, note } };
|
|
584
|
+
},
|
|
585
|
+
reducer(draft, action) {
|
|
586
|
+
draft.oneTimeAccrualActionStatusById[action.payload.accrualId] = {
|
|
587
|
+
fetchState: 'In-Progress',
|
|
588
|
+
error: undefined,
|
|
589
|
+
};
|
|
590
|
+
},
|
|
591
|
+
},
|
|
592
|
+
ignoreOneTimeAccrual: {
|
|
593
|
+
prepare(accrualId, reason, note) {
|
|
594
|
+
return { payload: { accrualId, reason, note } };
|
|
595
|
+
},
|
|
596
|
+
reducer(draft, action) {
|
|
597
|
+
draft.oneTimeAccrualActionStatusById[action.payload.accrualId] = {
|
|
598
|
+
fetchState: 'In-Progress',
|
|
599
|
+
error: undefined,
|
|
600
|
+
};
|
|
601
|
+
},
|
|
602
|
+
},
|
|
603
|
+
fetchOneTimeAccrual: {
|
|
604
|
+
prepare(accrualId) {
|
|
605
|
+
return { payload: { accrualId } };
|
|
606
|
+
},
|
|
607
|
+
reducer(draft, action) {
|
|
608
|
+
draft.oneTimeAccrualFetchStatusById[action.payload.accrualId] = {
|
|
609
|
+
fetchState: 'In-Progress',
|
|
610
|
+
error: undefined,
|
|
611
|
+
};
|
|
612
|
+
},
|
|
613
|
+
},
|
|
614
|
+
fetchOneTimeAccrualSuccess(draft, action) {
|
|
615
|
+
draft.oneTimeAccrualFetchStatusById[action.payload.accrualId] = {
|
|
616
|
+
fetchState: 'Completed',
|
|
617
|
+
error: undefined,
|
|
618
|
+
};
|
|
619
|
+
},
|
|
620
|
+
fetchOneTimeAccrualFailure(draft, action) {
|
|
621
|
+
draft.oneTimeAccrualFetchStatusById[action.payload.accrualId] = {
|
|
622
|
+
fetchState: 'Error',
|
|
623
|
+
error: action.payload.status,
|
|
624
|
+
};
|
|
625
|
+
},
|
|
626
|
+
oneTimeAccrualActionSuccess(draft, action) {
|
|
627
|
+
draft.oneTimeAccrualActionStatusById[action.payload.accrualId] = {
|
|
628
|
+
fetchState: 'Completed',
|
|
629
|
+
error: undefined,
|
|
630
|
+
};
|
|
631
|
+
},
|
|
632
|
+
oneTimeAccrualActionFailure(draft, action) {
|
|
633
|
+
draft.oneTimeAccrualActionStatusById[action.payload.accrualId] = {
|
|
634
|
+
fetchState: 'Error',
|
|
635
|
+
error: action.payload.status,
|
|
636
|
+
};
|
|
637
|
+
},
|
|
372
638
|
updateJESchedulesUIState(draft, action) {
|
|
373
639
|
if (action.payload.sortKey != null) {
|
|
374
640
|
draft.uiState.sortKey = action.payload.sortKey;
|
|
@@ -382,10 +648,21 @@ const expenseAutomationJESchedulesView = createSlice({
|
|
|
382
648
|
if (action.payload.scrollPosition != null) {
|
|
383
649
|
draft.uiState.scrollPosition = action.payload.scrollPosition;
|
|
384
650
|
}
|
|
385
|
-
if (action.payload.
|
|
386
|
-
draft.uiState.
|
|
651
|
+
if (action.payload.selectedPageTab != null) {
|
|
652
|
+
draft.uiState.selectedPageTab = action.payload.selectedPageTab;
|
|
387
653
|
}
|
|
388
654
|
},
|
|
655
|
+
updateJEScheduleTypeFilter(draft, action) {
|
|
656
|
+
draft.uiState.selectedJETypeFilter = action.payload;
|
|
657
|
+
},
|
|
658
|
+
toggleJEPendingGroupCollapsed(draft) {
|
|
659
|
+
draft.uiState.pendingGroupCollapsed =
|
|
660
|
+
!draft.uiState.pendingGroupCollapsed;
|
|
661
|
+
},
|
|
662
|
+
toggleJECreatedGroupCollapsed(draft) {
|
|
663
|
+
draft.uiState.createdGroupCollapsed =
|
|
664
|
+
!draft.uiState.createdGroupCollapsed;
|
|
665
|
+
},
|
|
389
666
|
clearExpenseAutomationJESchedulesView(draft) {
|
|
390
667
|
Object.assign(draft, initialState);
|
|
391
668
|
},
|
|
@@ -396,7 +673,7 @@ const expenseAutomationJESchedulesView = createSlice({
|
|
|
396
673
|
});
|
|
397
674
|
},
|
|
398
675
|
});
|
|
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;
|
|
676
|
+
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
677
|
export default expenseAutomationJESchedulesView.reducer;
|
|
401
678
|
const doUpdateRecommendationForAccountSettings = (draft, payload) => {
|
|
402
679
|
const { prepaidExpensesRecommendations, fixedAssetsRecommendations, accruedExpensesRecommendations, } = mapAccountTypeRecommendationPayloadToAccountRecommendationByType(payload);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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
|
+
};
|