@zeniai/client-epic-state 5.1.85-betaRD3 → 5.1.86
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/entity/aiCfo/aiCfoState.d.ts +2 -2
- package/lib/entity/customerSatisfaction/customerSatisfactionReducer.d.ts +1 -1
- package/lib/entity/customerSatisfaction/customerSatisfactionReducer.js +2 -6
- package/lib/entity/jeSchedules/jeScheduleHelper.d.ts +0 -2
- package/lib/entity/jeSchedules/jeScheduleHelper.js +0 -7
- package/lib/entity/jeSchedules/jeSchedulesPayload.d.ts +1 -34
- package/lib/entity/jeSchedules/jeSchedulesPayload.js +0 -68
- package/lib/entity/jeSchedules/jeSchedulesReducer.d.ts +2 -4
- package/lib/entity/jeSchedules/jeSchedulesReducer.js +2 -24
- package/lib/entity/jeSchedules/jeSchedulesSelector.d.ts +2 -10
- package/lib/entity/jeSchedules/jeSchedulesSelector.js +3 -28
- package/lib/entity/jeSchedules/jeSchedulesState.d.ts +1 -41
- package/lib/entity/jeSchedules/jeSchedulesTypes.d.ts +1 -12
- package/lib/entity/jeSchedules/jeSchedulesTypes.js +1 -40
- package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
- package/lib/entity/snackbar/snackbarTypes.js +0 -29
- package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.d.ts +0 -2
- package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.js +0 -2
- package/lib/entity/transaction/stateTypes/scheduleTransaction.d.ts +0 -2
- package/lib/epic.d.ts +1 -5
- package/lib/epic.js +1 -5
- package/lib/esm/entity/customerSatisfaction/customerSatisfactionReducer.js +1 -4
- package/lib/esm/entity/jeSchedules/jeScheduleHelper.js +0 -6
- package/lib/esm/entity/jeSchedules/jeSchedulesPayload.js +1 -68
- package/lib/esm/entity/jeSchedules/jeSchedulesReducer.js +2 -24
- package/lib/esm/entity/jeSchedules/jeSchedulesSelector.js +2 -26
- package/lib/esm/entity/jeSchedules/jeSchedulesTypes.js +0 -34
- package/lib/esm/entity/snackbar/snackbarTypes.js +0 -29
- package/lib/esm/entity/transaction/payloadTypes/scheduleTransactionPayload.js +0 -2
- package/lib/esm/epic.js +1 -5
- package/lib/esm/index.js +5 -11
- package/lib/esm/view/companyHealthMetricView/companyHealthMetricConfigReducer.js +1 -4
- package/lib/esm/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +3 -6
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +3 -34
- package/lib/esm/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +28 -163
- package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +22 -260
- package/lib/esm/view/expenseAutomationView/types/jeSchedulesViewState.js +6 -5
- package/lib/esm/view/invoicing/createCreditNote/createCreditNoteEpic.js +4 -24
- package/lib/esm/view/invoicing/createInvoice/createInvoiceEpic.js +4 -24
- package/lib/esm/view/invoicing/createInvoice/createInvoiceSelector.js +10 -37
- package/lib/esm/view/invoicing/discountAction/discountActionEpic.js +9 -33
- package/lib/esm/view/invoicing/dunningAction/dunningActionEpic.js +9 -35
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/catalogDetailEditPayload.js +1 -5
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +5 -32
- package/lib/esm/view/invoicing/editInvoicingCouponDetailView/saveInvoicingCouponEpic.js +3 -23
- package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/saveInvoicingCustomerEpic.js +4 -24
- package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/saveInvoicingSubscriptionEpic.js +4 -24
- package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/syncInvoicingSubscriptionCouponsEpic.js +3 -20
- package/lib/esm/view/invoicing/invoiceAction/invoiceActionEpic.js +17 -60
- package/lib/esm/view/invoicing/invoicingConfigView/invoicingConfigViewReducer.js +0 -30
- package/lib/esm/view/invoicing/invoicingConfigView/invoicingConfigViewSelector.js +29 -4
- package/lib/esm/view/invoicing/invoicingQboView/epics/retryInvoicingQboSyncTaskEpic.js +10 -29
- package/lib/esm/view/invoicing/invoicingQboView/epics/startInvoicingQboBackfillEpic.js +5 -28
- package/lib/esm/view/invoicing/issueCreditNote/issueCreditNoteEpic.js +4 -24
- package/lib/esm/view/invoicing/issueCreditNote/issueCreditNoteSelector.js +14 -22
- package/lib/esm/view/invoicing/recordPayment/recordPaymentEpic.js +7 -46
- package/lib/esm/view/invoicing/settingsView/settingsViewEpics.js +8 -26
- package/lib/esm/view/invoicing/settingsView/settingsViewReducer.js +1 -1
- package/lib/esm/view/invoicing/settingsView/settingsViewSelector.js +1 -4
- package/lib/esm/view/invoicing/subscriptionAction/subscriptionActionEpic.js +9 -41
- package/lib/esm/view/vendorFiling1099/vendorFiling1099UploadDetails/vendorFiling1099UploadDetailsReducer.js +1 -4
- package/lib/esm/view/vendorTabView/vendorTabViewReducer.js +1 -4
- package/lib/index.d.ts +13 -18
- package/lib/index.js +50 -76
- package/lib/view/companyHealthMetricView/companyHealthMetricConfigReducer.d.ts +1 -1
- package/lib/view/companyHealthMetricView/companyHealthMetricConfigReducer.js +2 -5
- package/lib/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +3 -6
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.d.ts +2 -2
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +1 -32
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
- package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.d.ts +1 -8
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +10 -45
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +28 -164
- 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/jeSchedulesSelectorTypes.d.ts +8 -34
- package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.d.ts +1 -10
- package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +21 -266
- package/lib/view/expenseAutomationView/types/completedSubTab.d.ts +1 -1
- package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +8 -59
- package/lib/view/expenseAutomationView/types/jeSchedulesViewState.js +8 -8
- package/lib/view/invoicing/createCreditNote/createCreditNoteEpic.d.ts +1 -2
- package/lib/view/invoicing/createCreditNote/createCreditNoteEpic.js +3 -23
- package/lib/view/invoicing/createInvoice/createInvoiceEpic.d.ts +1 -2
- package/lib/view/invoicing/createInvoice/createInvoiceEpic.js +3 -23
- package/lib/view/invoicing/createInvoice/createInvoiceSelector.d.ts +8 -22
- package/lib/view/invoicing/createInvoice/createInvoiceSelector.js +10 -37
- package/lib/view/invoicing/discountAction/discountActionEpic.d.ts +1 -2
- package/lib/view/invoicing/discountAction/discountActionEpic.js +8 -32
- package/lib/view/invoicing/dunningAction/dunningActionEpic.d.ts +1 -2
- package/lib/view/invoicing/dunningAction/dunningActionEpic.js +8 -34
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/catalogDetailEditPayload.d.ts +1 -3
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/catalogDetailEditPayload.js +1 -5
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.d.ts +1 -2
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +4 -31
- package/lib/view/invoicing/editInvoicingCouponDetailView/saveInvoicingCouponEpic.d.ts +1 -2
- package/lib/view/invoicing/editInvoicingCouponDetailView/saveInvoicingCouponEpic.js +2 -22
- package/lib/view/invoicing/editInvoicingCustomerDetailView/saveInvoicingCustomerEpic.d.ts +1 -2
- package/lib/view/invoicing/editInvoicingCustomerDetailView/saveInvoicingCustomerEpic.js +3 -23
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/saveInvoicingSubscriptionEpic.d.ts +1 -2
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/saveInvoicingSubscriptionEpic.js +3 -23
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/syncInvoicingSubscriptionCouponsEpic.d.ts +1 -2
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/syncInvoicingSubscriptionCouponsEpic.js +2 -19
- package/lib/view/invoicing/invoiceAction/invoiceActionEpic.d.ts +1 -2
- package/lib/view/invoicing/invoiceAction/invoiceActionEpic.js +16 -59
- package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewPayload.d.ts +0 -13
- package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewReducer.d.ts +1 -1
- package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewReducer.js +0 -30
- package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewSelector.d.ts +31 -11
- package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewSelector.js +29 -4
- package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewState.d.ts +0 -15
- package/lib/view/invoicing/invoicingQboView/epics/invoicingQboViewActionType.d.ts +1 -2
- package/lib/view/invoicing/invoicingQboView/epics/retryInvoicingQboSyncTaskEpic.js +9 -28
- package/lib/view/invoicing/invoicingQboView/epics/startInvoicingQboBackfillEpic.js +4 -27
- package/lib/view/invoicing/issueCreditNote/issueCreditNoteEpic.d.ts +1 -2
- package/lib/view/invoicing/issueCreditNote/issueCreditNoteEpic.js +3 -23
- package/lib/view/invoicing/issueCreditNote/issueCreditNoteSelector.d.ts +7 -24
- package/lib/view/invoicing/issueCreditNote/issueCreditNoteSelector.js +16 -23
- package/lib/view/invoicing/recordPayment/recordPaymentEpic.d.ts +1 -2
- package/lib/view/invoicing/recordPayment/recordPaymentEpic.js +6 -45
- package/lib/view/invoicing/settingsView/settingsViewEpics.d.ts +1 -2
- package/lib/view/invoicing/settingsView/settingsViewEpics.js +7 -25
- package/lib/view/invoicing/settingsView/settingsViewReducer.d.ts +1 -10
- package/lib/view/invoicing/settingsView/settingsViewReducer.js +1 -1
- package/lib/view/invoicing/settingsView/settingsViewSelector.d.ts +2 -4
- package/lib/view/invoicing/settingsView/settingsViewSelector.js +1 -4
- package/lib/view/invoicing/subscriptionAction/subscriptionActionEpic.d.ts +1 -2
- package/lib/view/invoicing/subscriptionAction/subscriptionActionEpic.js +8 -40
- package/lib/view/vendorFiling1099/vendorFiling1099UploadDetails/vendorFiling1099UploadDetailsReducer.d.ts +1 -1
- package/lib/view/vendorFiling1099/vendorFiling1099UploadDetails/vendorFiling1099UploadDetailsReducer.js +2 -5
- package/lib/view/vendorTabView/vendorTabViewReducer.d.ts +1 -1
- package/lib/view/vendorTabView/vendorTabViewReducer.js +2 -5
- package/package.json +1 -1
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +0 -21
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js +0 -110
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +0 -73
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +0 -22
- package/lib/esm/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.js +0 -140
- package/lib/esm/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +0 -1
- package/lib/esm/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +0 -70
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.d.ts +0 -8
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +0 -25
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.d.ts +0 -45
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js +0 -114
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.d.ts +0 -8
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +0 -77
- package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.d.ts +0 -6
- package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +0 -26
- package/lib/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.d.ts +0 -36
- package/lib/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.js +0 -145
- package/lib/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.d.ts +0 -25
- package/lib/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +0 -2
- package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.d.ts +0 -10
- package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +0 -75
|
@@ -2,16 +2,9 @@ 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 {
|
|
6
|
-
import { getJEScheduleKey, getJEScheduleTransactionDetailKeyPayload, } from '../../../entity/jeSchedules/jeSchedulesPayload';
|
|
5
|
+
import { getJEScheduleTransactionDetailKeyPayload, } from '../../../entity/jeSchedules/jeSchedulesPayload';
|
|
7
6
|
import { clearAll } from '../../../rootActions';
|
|
8
7
|
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
|
-
}
|
|
15
8
|
export const accountSettingsInitialState = {
|
|
16
9
|
localData: {
|
|
17
10
|
selectedPrepaidExpensesAccountIds: [],
|
|
@@ -43,34 +36,16 @@ export const accountSettingsInitialState = {
|
|
|
43
36
|
accruedExpensesNestedAccountListHierarchy: [],
|
|
44
37
|
accruedExpensesRecommendations: [],
|
|
45
38
|
};
|
|
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
|
-
};
|
|
59
39
|
export const initialState = {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
jeScheduleOneTimeAccrualKeysByPeriodAndTab: {},
|
|
63
|
-
failedJeScheduleTransactionKeysByPeriodAndTab: {},
|
|
40
|
+
jeScheduleTransactionKeysByPeriod: {},
|
|
41
|
+
failedJeScheduleTransactionKeysByPeriod: {},
|
|
64
42
|
postStatusById: {},
|
|
65
43
|
ignoreStatusById: {},
|
|
66
44
|
jeScheduleLocalDataById: {},
|
|
67
45
|
uiState: {
|
|
68
|
-
createdGroupCollapsed: false,
|
|
69
|
-
pendingGroupCollapsed: false,
|
|
70
|
-
scrollPosition: { scrollTop: 0, scrollLeft: undefined },
|
|
71
46
|
searchString: '',
|
|
72
|
-
|
|
73
|
-
|
|
47
|
+
scrollPosition: { scrollTop: 0, scrollLeft: undefined },
|
|
48
|
+
selectedMainTab: 'pending_review',
|
|
74
49
|
sortKey: 'transactionDate',
|
|
75
50
|
sortOrder: 'descending',
|
|
76
51
|
totalCount: 0,
|
|
@@ -81,13 +56,6 @@ export const initialState = {
|
|
|
81
56
|
error: undefined,
|
|
82
57
|
},
|
|
83
58
|
accountSettings: accountSettingsInitialState,
|
|
84
|
-
newSchedule: {
|
|
85
|
-
newScheduleState: newScheduleInitialState,
|
|
86
|
-
saveStatus: { fetchState: 'Not-Started', error: undefined },
|
|
87
|
-
searchTransactions: searchTransactionsInitialState,
|
|
88
|
-
fetchState: 'Not-Started',
|
|
89
|
-
error: undefined,
|
|
90
|
-
},
|
|
91
59
|
fetchState: 'Not-Started',
|
|
92
60
|
error: undefined,
|
|
93
61
|
hasValidState() {
|
|
@@ -132,12 +100,9 @@ const expenseAutomationJESchedulesView = createSlice({
|
|
|
132
100
|
},
|
|
133
101
|
},
|
|
134
102
|
fetchJeSchedulesSuccess(draft, action) {
|
|
135
|
-
const { jeSchedules, selectedPeriod,
|
|
136
|
-
const periodTabKey = getJESchedulePeriodTabKey(selectedPageTab, toMonthYearPeriodId(selectedPeriod));
|
|
103
|
+
const { jeSchedules, selectedPeriod, failedJeSchedules, refreshViewInBackground, } = action.payload;
|
|
137
104
|
const jeScheduleTransactionKeys = jeSchedules.map((schedules) => getJEScheduleTransactionDetailKeyPayload(schedules.base_transaction));
|
|
138
105
|
const failedJeScheduleTransactionKeys = failedJeSchedules.map((schedules) => getJEScheduleTransactionDetailKeyPayload(schedules.base_transaction));
|
|
139
|
-
const jeScheduleAccruedKeys = accruedJeSchedules.map((schedule) => getJEScheduleKey(schedule));
|
|
140
|
-
const jeScheduleOneTimeAccrualKeys = oneTimeAccruals.map((accrual) => generateJEOneTimeAccrualKey(accrual._id));
|
|
141
106
|
if (refreshViewInBackground === true &&
|
|
142
107
|
draft.refreshStatus.fetchState === 'In-Progress') {
|
|
143
108
|
draft.refreshStatus = { fetchState: 'Completed', error: undefined };
|
|
@@ -146,28 +111,19 @@ const expenseAutomationJESchedulesView = createSlice({
|
|
|
146
111
|
draft.fetchState = 'Completed';
|
|
147
112
|
draft.error = undefined;
|
|
148
113
|
}
|
|
149
|
-
draft.
|
|
150
|
-
|
|
151
|
-
draft.jeScheduleAccruedKeysByPeriodAndTab[periodTabKey] =
|
|
152
|
-
jeScheduleAccruedKeys;
|
|
153
|
-
draft.jeScheduleOneTimeAccrualKeysByPeriodAndTab[periodTabKey] =
|
|
154
|
-
jeScheduleOneTimeAccrualKeys;
|
|
155
|
-
draft.failedJeScheduleTransactionKeysByPeriodAndTab[periodTabKey] =
|
|
156
|
-
failedJeScheduleTransactionKeys;
|
|
114
|
+
draft.jeScheduleTransactionKeysByPeriod[toMonthYearPeriodId(selectedPeriod)] = jeScheduleTransactionKeys;
|
|
115
|
+
draft.failedJeScheduleTransactionKeysByPeriod[toMonthYearPeriodId(selectedPeriod)] = failedJeScheduleTransactionKeys;
|
|
157
116
|
},
|
|
158
117
|
fetchJeSchedulesFailure(draft, action) {
|
|
159
|
-
const { status, selectedPeriod
|
|
160
|
-
const periodTabKey = getJESchedulePeriodTabKey(selectedPageTab, toMonthYearPeriodId(selectedPeriod));
|
|
118
|
+
const { status, selectedPeriod } = action.payload;
|
|
161
119
|
if (draft.refreshStatus.fetchState === 'In-Progress') {
|
|
162
120
|
draft.refreshStatus = { fetchState: 'Error', error: status };
|
|
163
121
|
}
|
|
164
122
|
else {
|
|
165
123
|
draft.fetchState = 'Error';
|
|
166
124
|
draft.error = status;
|
|
167
|
-
draft.jeScheduleTransactionKeysByPeriodAndTab[periodTabKey] = [];
|
|
168
|
-
draft.jeScheduleAccruedKeysByPeriodAndTab[periodTabKey] = [];
|
|
169
|
-
draft.jeScheduleOneTimeAccrualKeysByPeriodAndTab[periodTabKey] = [];
|
|
170
125
|
}
|
|
126
|
+
draft.jeScheduleTransactionKeysByPeriod[toMonthYearPeriodId(selectedPeriod)] = [];
|
|
171
127
|
},
|
|
172
128
|
retryJeSchedule(draft, action) {
|
|
173
129
|
const { scheduledJournalEntryID } = action.payload;
|
|
@@ -255,18 +211,17 @@ const expenseAutomationJESchedulesView = createSlice({
|
|
|
255
211
|
};
|
|
256
212
|
},
|
|
257
213
|
updateJeScheduleTransactionKeys: {
|
|
258
|
-
prepare(jeScheduleKeys, selectedPeriod
|
|
214
|
+
prepare(jeScheduleKeys, selectedPeriod) {
|
|
259
215
|
return {
|
|
260
216
|
payload: {
|
|
261
217
|
jeScheduleKeys: jeScheduleKeys,
|
|
262
218
|
selectedPeriod: selectedPeriod,
|
|
263
|
-
selectedPageTab: selectedPageTab,
|
|
264
219
|
},
|
|
265
220
|
};
|
|
266
221
|
},
|
|
267
222
|
reducer(draft, action) {
|
|
268
|
-
const { selectedPeriod,
|
|
269
|
-
draft.
|
|
223
|
+
const { selectedPeriod, jeScheduleKeys } = action.payload;
|
|
224
|
+
draft.jeScheduleTransactionKeysByPeriod[toMonthYearPeriodId(selectedPeriod)] = jeScheduleKeys;
|
|
270
225
|
},
|
|
271
226
|
},
|
|
272
227
|
removeJeScheduleTransactionKey: {
|
|
@@ -279,10 +234,12 @@ const expenseAutomationJESchedulesView = createSlice({
|
|
|
279
234
|
};
|
|
280
235
|
},
|
|
281
236
|
reducer(draft, action) {
|
|
282
|
-
const { jeScheduleKey } = action.payload;
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
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;
|
|
286
243
|
},
|
|
287
244
|
},
|
|
288
245
|
removeFailedJeScheduleTransactionKey: {
|
|
@@ -295,8 +252,12 @@ const expenseAutomationJESchedulesView = createSlice({
|
|
|
295
252
|
};
|
|
296
253
|
},
|
|
297
254
|
reducer(draft, action) {
|
|
298
|
-
const { failedJeScheduleKey } = action.payload;
|
|
299
|
-
|
|
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;
|
|
300
261
|
},
|
|
301
262
|
},
|
|
302
263
|
initializeJeScheduleLocalData: {
|
|
@@ -408,91 +369,6 @@ const expenseAutomationJESchedulesView = createSlice({
|
|
|
408
369
|
clearJeAccountSettingsLocalData(draft) {
|
|
409
370
|
draft.accountSettings.localData = accountSettingsInitialState.localData;
|
|
410
371
|
},
|
|
411
|
-
initializeNewSchedule: {
|
|
412
|
-
prepare({ scheduleType, }) {
|
|
413
|
-
return { payload: { scheduleType } };
|
|
414
|
-
},
|
|
415
|
-
reducer() {
|
|
416
|
-
// Purely an epic-trigger action — the epic fans out the account/class
|
|
417
|
-
// list fetches plus resetNewScheduleLocalData.
|
|
418
|
-
},
|
|
419
|
-
},
|
|
420
|
-
resetNewScheduleLocalData: {
|
|
421
|
-
prepare({ scheduleType, }) {
|
|
422
|
-
return { payload: { scheduleType } };
|
|
423
|
-
},
|
|
424
|
-
reducer(draft, action) {
|
|
425
|
-
const { scheduleType } = action.payload;
|
|
426
|
-
draft.newSchedule.newScheduleState[scheduleType] =
|
|
427
|
-
getBaseNewScheduleLocalData(scheduleType);
|
|
428
|
-
},
|
|
429
|
-
},
|
|
430
|
-
updateNewScheduleLocalData(draft, action) {
|
|
431
|
-
const { scheduleType, localData } = action.payload;
|
|
432
|
-
draft.newSchedule.newScheduleState[scheduleType] = {
|
|
433
|
-
...draft.newSchedule.newScheduleState[scheduleType],
|
|
434
|
-
...localData,
|
|
435
|
-
};
|
|
436
|
-
},
|
|
437
|
-
searchTransactionsForNewSchedule: {
|
|
438
|
-
prepare({ query, scheduleType, }) {
|
|
439
|
-
return { payload: { query, scheduleType } };
|
|
440
|
-
},
|
|
441
|
-
reducer(draft, action) {
|
|
442
|
-
const trimmed = action.payload.query.trim();
|
|
443
|
-
// Cleared or too-short query: no API (see epic) — reset immediately.
|
|
444
|
-
if (trimmed.length < MIN_NEW_SCHEDULE_SEARCH_LENGTH) {
|
|
445
|
-
draft.newSchedule.searchTransactions = searchTransactionsInitialState;
|
|
446
|
-
return;
|
|
447
|
-
}
|
|
448
|
-
draft.newSchedule.searchTransactions = {
|
|
449
|
-
...draft.newSchedule.searchTransactions,
|
|
450
|
-
searchString: action.payload.query,
|
|
451
|
-
fetchState: 'In-Progress',
|
|
452
|
-
};
|
|
453
|
-
},
|
|
454
|
-
},
|
|
455
|
-
searchTransactionsForNewScheduleSuccess(draft, action) {
|
|
456
|
-
draft.newSchedule.searchTransactions = {
|
|
457
|
-
...draft.newSchedule.searchTransactions,
|
|
458
|
-
searchResults: action.payload.searchResults,
|
|
459
|
-
fetchState: 'Completed',
|
|
460
|
-
error: undefined,
|
|
461
|
-
};
|
|
462
|
-
},
|
|
463
|
-
searchTransactionsForNewScheduleFailure(draft, action) {
|
|
464
|
-
draft.newSchedule.searchTransactions = {
|
|
465
|
-
...draft.newSchedule.searchTransactions,
|
|
466
|
-
fetchState: 'Error',
|
|
467
|
-
error: action.payload.status,
|
|
468
|
-
};
|
|
469
|
-
},
|
|
470
|
-
clearSearchTransactionsForNewSchedule(draft) {
|
|
471
|
-
draft.newSchedule.searchTransactions = searchTransactionsInitialState;
|
|
472
|
-
},
|
|
473
|
-
saveNewSchedule: {
|
|
474
|
-
prepare({ scheduleType, }) {
|
|
475
|
-
return { payload: { scheduleType } };
|
|
476
|
-
},
|
|
477
|
-
reducer(draft) {
|
|
478
|
-
draft.newSchedule.saveStatus = {
|
|
479
|
-
fetchState: 'In-Progress',
|
|
480
|
-
error: undefined,
|
|
481
|
-
};
|
|
482
|
-
},
|
|
483
|
-
},
|
|
484
|
-
saveNewScheduleSuccess(draft) {
|
|
485
|
-
draft.newSchedule.saveStatus = {
|
|
486
|
-
fetchState: 'Completed',
|
|
487
|
-
error: undefined,
|
|
488
|
-
};
|
|
489
|
-
},
|
|
490
|
-
saveNewScheduleFailure(draft, action) {
|
|
491
|
-
draft.newSchedule.saveStatus = {
|
|
492
|
-
fetchState: 'Error',
|
|
493
|
-
error: action.payload.status,
|
|
494
|
-
};
|
|
495
|
-
},
|
|
496
372
|
updateJESchedulesUIState(draft, action) {
|
|
497
373
|
if (action.payload.sortKey != null) {
|
|
498
374
|
draft.uiState.sortKey = action.payload.sortKey;
|
|
@@ -506,21 +382,10 @@ const expenseAutomationJESchedulesView = createSlice({
|
|
|
506
382
|
if (action.payload.scrollPosition != null) {
|
|
507
383
|
draft.uiState.scrollPosition = action.payload.scrollPosition;
|
|
508
384
|
}
|
|
509
|
-
if (action.payload.
|
|
510
|
-
draft.uiState.
|
|
385
|
+
if (action.payload.selectedMainTab != null) {
|
|
386
|
+
draft.uiState.selectedMainTab = action.payload.selectedMainTab;
|
|
511
387
|
}
|
|
512
388
|
},
|
|
513
|
-
updateJEScheduleTypeFilter(draft, action) {
|
|
514
|
-
draft.uiState.selectedJETypeFilter = action.payload;
|
|
515
|
-
},
|
|
516
|
-
toggleJEPendingGroupCollapsed(draft) {
|
|
517
|
-
draft.uiState.pendingGroupCollapsed =
|
|
518
|
-
!draft.uiState.pendingGroupCollapsed;
|
|
519
|
-
},
|
|
520
|
-
toggleJECreatedGroupCollapsed(draft) {
|
|
521
|
-
draft.uiState.createdGroupCollapsed =
|
|
522
|
-
!draft.uiState.createdGroupCollapsed;
|
|
523
|
-
},
|
|
524
389
|
clearExpenseAutomationJESchedulesView(draft) {
|
|
525
390
|
Object.assign(draft, initialState);
|
|
526
391
|
},
|
|
@@ -531,7 +396,7 @@ const expenseAutomationJESchedulesView = createSlice({
|
|
|
531
396
|
});
|
|
532
397
|
},
|
|
533
398
|
});
|
|
534
|
-
export const { clearExpenseAutomationJESchedulesView, clearJeAccountSettingsLocalData, clearJeScheduleLocalData,
|
|
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;
|
|
535
400
|
export default expenseAutomationJESchedulesView.reducer;
|
|
536
401
|
const doUpdateRecommendationForAccountSettings = (draft, payload) => {
|
|
537
402
|
const { prepaidExpensesRecommendations, fixedAssetsRecommendations, accruedExpensesRecommendations, } = mapAccountTypeRecommendationPayloadToAccountRecommendationByType(payload);
|
|
@@ -3,8 +3,7 @@ import orderBy from 'lodash/orderBy';
|
|
|
3
3
|
import { reduceAnyFetchState } from '../../../commonStateTypes/reduceFetchState';
|
|
4
4
|
import { LAST_SCHEDULE_DAY_OF_MONTH, toMonthYearPeriodId, } from '../../../commonStateTypes/timePeriod';
|
|
5
5
|
import { getAccountIdsForTypes } from '../../../entity/account/accountSelector';
|
|
6
|
-
import {
|
|
7
|
-
import { ALL_SCHEDULES_TYPES, } from '../../../entity/jeSchedules/jeSchedulesTypes';
|
|
6
|
+
import { getJEScheduledTransactionByJEScheduleTransactionKey, } from '../../../entity/jeSchedules/jeSchedulesSelector';
|
|
8
7
|
import { getCurrentTenant } from '../../../entity/tenant/tenantSelector';
|
|
9
8
|
import { getAccountIdsForLabel, getAccountList, getNestedAccountListHierarchy, getUncategorizedAccounts, } from '../../accountList/accountListSelector';
|
|
10
9
|
import { getClassList, getNestedClassListHierarchy, } from '../../classList/classListSelector';
|
|
@@ -12,118 +11,8 @@ import { getAccountsTypesForScheduleDetails } from '../../scheduleView/scheduleD
|
|
|
12
11
|
import { filterNestedAccountHierarchyById } from '../../scheduleView/scheduleDetailView/scheduleDetailSelector';
|
|
13
12
|
import { getAccountLabelForScheduleType, getAccountsTypesForScheduleList, } from '../../scheduleView/scheduleListView/scheduleListHelper';
|
|
14
13
|
import { getAllSteps } from '../selectorTypes/expenseAutomationViewSelectorTypes';
|
|
15
|
-
import { ALL_JE_PAGE_TABS, getJESchedulePeriodTabKey, } from '../types/jeSchedulesViewState';
|
|
16
14
|
import { getJEAccountSettingsView } from './jeAccountSettingsViewSelector';
|
|
17
|
-
import { getNewScheduleView } from './jeNewScheduleViewSelector';
|
|
18
|
-
// Matches the AI-automation user addresses webc's schedule list row already
|
|
19
|
-
// checks (JEScheduleReadOnlyListRow/JEScheduleDraftListRow "Method" column,
|
|
20
|
-
// strings.ts aiBotEmail/botEmail) to determine whether a schedule was
|
|
21
|
-
// created by the AI accountant vs. a human.
|
|
22
|
-
const AI_BOT_EMAIL = 'ai@zeni.ai';
|
|
23
|
-
const BOT_EMAIL = 'bot@zeni.ai';
|
|
24
|
-
// A one-time accrual has no jeScheduleType of its own — it is not a JE schedule. It is still an
|
|
25
|
-
// accrued expense, so it counts and filters under that type on the page's type tabs.
|
|
26
|
-
const ONE_TIME_ACCRUAL_SCHEDULE_TYPE = 'accrued_expenses';
|
|
27
|
-
// Which of the two list buckets an accrual belongs in. `draft` still needs a human to post it and
|
|
28
|
-
// `posting_blocked` needs attention, so both are review work; everything else is already on the
|
|
29
|
-
// books or in a transient claim.
|
|
30
|
-
const ONE_TIME_ACCRUAL_REVIEW_STATUSES = [
|
|
31
|
-
'draft',
|
|
32
|
-
'posting_blocked',
|
|
33
|
-
];
|
|
34
|
-
export function getJEScheduleRowType(schedule) {
|
|
35
|
-
return isOneTimeAccrualRow(schedule)
|
|
36
|
-
? ONE_TIME_ACCRUAL_SCHEDULE_TYPE
|
|
37
|
-
: schedule.jeScheduleType;
|
|
38
|
-
}
|
|
39
|
-
export function isPendingReviewRow(schedule) {
|
|
40
|
-
return isOneTimeAccrualRow(schedule)
|
|
41
|
-
? ONE_TIME_ACCRUAL_REVIEW_STATUSES.includes(schedule.accrualStatus)
|
|
42
|
-
: schedule.status.code === 'draft';
|
|
43
|
-
}
|
|
44
|
-
// Belongs on the Existing Schedules tab. For an accrual the endpoint has already filtered to
|
|
45
|
-
// posted, so this only has to agree with that rather than re-derive it.
|
|
46
|
-
export function isExistingTabRow(schedule) {
|
|
47
|
-
return isOneTimeAccrualRow(schedule)
|
|
48
|
-
? schedule.accrualStatus === 'posted'
|
|
49
|
-
: schedule.status.code === 'ongoing';
|
|
50
|
-
}
|
|
51
|
-
// Exported (rather than kept as a closure inside the selector) so it can be
|
|
52
|
-
// unit-tested directly — confidenceScore is a separate, more narrowly
|
|
53
|
-
// populated field that can be null on a schedule the bot user created,
|
|
54
|
-
// which previously caused these schedules to display as "AI Accountant" in
|
|
55
|
-
// the list but count under "Manual" in the KPI summary.
|
|
56
|
-
export const isAiAccountantSchedule = (schedule) => {
|
|
57
|
-
// A one-time accrual records who made it as `origin`, which is authoritative — no email
|
|
58
|
-
// sniffing needed, and the JE bot is often absent from the user entity entirely.
|
|
59
|
-
if (isOneTimeAccrualRow(schedule)) {
|
|
60
|
-
return schedule.origin === 'agent';
|
|
61
|
-
}
|
|
62
|
-
return (schedule.createdByUser?.email === AI_BOT_EMAIL ||
|
|
63
|
-
schedule.createdByUser?.email === BOT_EMAIL);
|
|
64
|
-
};
|
|
65
|
-
// Accrued schedules are structurally distinct — no baseTransaction, carrying recurringAmount and
|
|
66
|
-
// memo in its place — so anything reading baseTransaction has to branch on this first.
|
|
67
|
-
//
|
|
68
|
-
// Discriminates on jeAccruedScheduleKey, which only JEAccruedSchedule carries. jeScheduleType
|
|
69
|
-
// cannot be used: it is a data field present on BOTH row shapes, so an accrued-typed row that
|
|
70
|
-
// arrived through the prepaid/fixed DTO (failed_je_postings, legacy fetches) would be
|
|
71
|
-
// misclassified and then crash on recurringAmount / jeAccruedScheduleKey.
|
|
72
|
-
export function isAccruedScheduleRow(schedule) {
|
|
73
|
-
return 'jeAccruedScheduleKey' in schedule;
|
|
74
|
-
}
|
|
75
|
-
// Same structural approach as isAccruedScheduleRow, and for the same reason: jeOneTimeAccrualKey
|
|
76
|
-
// exists only on this shape. Note the two guards are NOT interchangeable — a one-time accrual is
|
|
77
|
-
// not an accrued *schedule*, and routing it into the accrued branch would read recurringAmount,
|
|
78
|
-
// render postedCount/lifecycleTotal as a lifecycle and startDate–endDate as a period, none of
|
|
79
|
-
// which it has.
|
|
80
|
-
export function isOneTimeAccrualRow(schedule) {
|
|
81
|
-
return 'jeOneTimeAccrualKey' in schedule;
|
|
82
|
-
}
|
|
83
|
-
function getScheduleAmount(schedule) {
|
|
84
|
-
if (isOneTimeAccrualRow(schedule)) {
|
|
85
|
-
return schedule.estimatedAmount.amount;
|
|
86
|
-
}
|
|
87
|
-
if (isAccruedScheduleRow(schedule)) {
|
|
88
|
-
return schedule.recurringAmount.amount;
|
|
89
|
-
}
|
|
90
|
-
return schedule.baseTransaction.amount.amount;
|
|
91
|
-
}
|
|
92
|
-
// A one-time accrual shares almost no sortable field with a schedule, so it gets its own accessor
|
|
93
|
-
// rather than a guard on each of the dozen cases below. Keys with no meaning for a single-month
|
|
94
|
-
// accrual -- amortizationPeriod, remainingMonths, runningBalance, jePostingDate, scheduleCategory --
|
|
95
|
-
// deliberately fall through to undefined, which sorts them together at one end.
|
|
96
|
-
function getOneTimeAccrualSortValue(accrual, sortKey) {
|
|
97
|
-
switch (sortKey) {
|
|
98
|
-
case 'vendor':
|
|
99
|
-
return accrual.vendorName.toLowerCase();
|
|
100
|
-
case 'category':
|
|
101
|
-
return accrual.jeDebitAccountName?.toLowerCase();
|
|
102
|
-
case 'class':
|
|
103
|
-
return accrual.jeDebitAccountingClassName?.toLowerCase();
|
|
104
|
-
case 'depCategory':
|
|
105
|
-
return accrual.jeCreditAccountName?.toLowerCase();
|
|
106
|
-
case 'type':
|
|
107
|
-
return ONE_TIME_ACCRUAL_SCHEDULE_TYPE;
|
|
108
|
-
case 'totalAmount':
|
|
109
|
-
return accrual.estimatedAmount.amount;
|
|
110
|
-
case 'transactionDate':
|
|
111
|
-
return accrual.postingDate?.valueOf();
|
|
112
|
-
case 'memo':
|
|
113
|
-
return accrual.memo.toLowerCase();
|
|
114
|
-
case 'startMonth':
|
|
115
|
-
return accrual.serviceMonth;
|
|
116
|
-
default:
|
|
117
|
-
return undefined;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
15
|
function getJEScheduleSortAccessor(sortKey) {
|
|
121
|
-
const scheduleAccessor = getScheduleRowSortAccessor(sortKey);
|
|
122
|
-
return (schedule) => isOneTimeAccrualRow(schedule)
|
|
123
|
-
? getOneTimeAccrualSortValue(schedule, sortKey)
|
|
124
|
-
: scheduleAccessor(schedule);
|
|
125
|
-
}
|
|
126
|
-
function getScheduleRowSortAccessor(sortKey) {
|
|
127
16
|
switch (sortKey) {
|
|
128
17
|
case 'vendor':
|
|
129
18
|
return (s) => s.vendor.name?.toLowerCase();
|
|
@@ -134,9 +23,7 @@ function getScheduleRowSortAccessor(sortKey) {
|
|
|
134
23
|
case 'depCategory':
|
|
135
24
|
return (s) => s.jeCredit.account?.accountName?.toLowerCase();
|
|
136
25
|
case 'scheduleCategory':
|
|
137
|
-
return (s) =>
|
|
138
|
-
? undefined
|
|
139
|
-
: s.baseTransaction.account?.accountName?.toLowerCase();
|
|
26
|
+
return (s) => s.baseTransaction.account?.accountName?.toLowerCase();
|
|
140
27
|
case 'startMonth':
|
|
141
28
|
return (s) => s.startDate?.valueOf();
|
|
142
29
|
case 'type':
|
|
@@ -164,13 +51,11 @@ function getScheduleRowSortAccessor(sortKey) {
|
|
|
164
51
|
return s.balanceAsOfToday?.amount ?? null;
|
|
165
52
|
};
|
|
166
53
|
case 'totalAmount':
|
|
167
|
-
return (s) =>
|
|
54
|
+
return (s) => s.baseTransaction.amount.amount;
|
|
168
55
|
case 'transactionDate':
|
|
169
|
-
return (s) => s.
|
|
56
|
+
return (s) => s.baseTransaction.date.valueOf();
|
|
170
57
|
case 'memo':
|
|
171
|
-
return (s) =>
|
|
172
|
-
? s.memo.toLowerCase()
|
|
173
|
-
: s.baseTransaction.memo?.toLowerCase();
|
|
58
|
+
return (s) => s.baseTransaction.memo?.toLowerCase();
|
|
174
59
|
default:
|
|
175
60
|
return (s) => s.startDate?.valueOf();
|
|
176
61
|
}
|
|
@@ -182,15 +67,9 @@ function sortJEScheduledTransactions(transactions, sortKey, sortOrder) {
|
|
|
182
67
|
export function getExpenseAutomationJESchedulesView(state) {
|
|
183
68
|
const jeScheduledTransaction = [];
|
|
184
69
|
const failedJeScheduledTransaction = [];
|
|
185
|
-
const accruedSchedules = [];
|
|
186
|
-
const oneTimeAccruals = [];
|
|
187
70
|
const { accountState, accountListState, classState, classListState, expenseAutomationJESchedulesViewState, expenseAutomationViewState, monthEndCloseChecksState, monthEndCloseChecksViewState, } = state;
|
|
188
|
-
const {
|
|
71
|
+
const { jeScheduleTransactionKeysByPeriod, failedJeScheduleTransactionKeysByPeriod, jeScheduleLocalDataById, postStatusById, ignoreStatusById, uiState, error, fetchState, refreshStatus, } = expenseAutomationJESchedulesViewState;
|
|
189
72
|
const accountSettingsView = getJEAccountSettingsView(state);
|
|
190
|
-
const newScheduleView = newSchedule.selectedDetailScheduleType === 'fixed_assets' ||
|
|
191
|
-
newSchedule.selectedDetailScheduleType === 'prepaid_expenses'
|
|
192
|
-
? getNewScheduleView(state, newSchedule.selectedDetailScheduleType)
|
|
193
|
-
: undefined;
|
|
194
73
|
const currentTenant = getCurrentTenant(state);
|
|
195
74
|
const { selectedPeriodByTenantId } = expenseAutomationViewState;
|
|
196
75
|
const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
|
|
@@ -218,48 +97,27 @@ export function getExpenseAutomationJESchedulesView(state) {
|
|
|
218
97
|
const filteredDepAccountListNestedAccountHierarchy = filterNestedAccountHierarchyById(depAccountListNestedAccountHierarchy, filteredDepAccounts.map((account) => account.accountId));
|
|
219
98
|
const classListNestedAccountHierarchy = getNestedClassListHierarchy(classListState);
|
|
220
99
|
const monthYearPeriodId = selectedPeriod != null ? toMonthYearPeriodId(selectedPeriod) : null;
|
|
221
|
-
const
|
|
222
|
-
?
|
|
100
|
+
const jeScheduleTransactionKeysForSelectedPeriod = monthYearPeriodId != null
|
|
101
|
+
? jeScheduleTransactionKeysByPeriod[monthYearPeriodId]
|
|
223
102
|
: null;
|
|
224
|
-
const
|
|
225
|
-
?
|
|
226
|
-
:
|
|
227
|
-
const
|
|
228
|
-
|
|
229
|
-
: undefined;
|
|
230
|
-
// Distinguishes "this tab has never been fetched for this period" from "fetched and genuinely
|
|
231
|
-
// empty". Without it the page cannot tell a first visit from a real empty state, and renders an
|
|
232
|
-
// empty table where it should render a skeleton.
|
|
233
|
-
const hasLoadedForSelectedTab = jeScheduleTransactionKeysForSelectedTab != null;
|
|
234
|
-
const jeScheduleTransactionKeys = jeScheduleTransactionKeysForSelectedTab ?? [];
|
|
235
|
-
const failedJeScheduleTransactionKeys = failedJeScheduleTransactionKeysForSelectedTab ?? [];
|
|
236
|
-
const jeScheduleAccruedKeys = (selectedPeriodTabKey != null
|
|
237
|
-
? jeScheduleAccruedKeysByPeriodAndTab[selectedPeriodTabKey]
|
|
238
|
-
: undefined) ?? [];
|
|
239
|
-
const jeScheduleOneTimeAccrualKeys = (selectedPeriodTabKey != null
|
|
240
|
-
? jeScheduleOneTimeAccrualKeysByPeriodAndTab[selectedPeriodTabKey]
|
|
241
|
-
: undefined) ?? [];
|
|
242
|
-
jeScheduleOneTimeAccrualKeys.forEach((jeOneTimeAccrualKey) => {
|
|
243
|
-
const accrual = getJEOneTimeAccrualByKey(jeOneTimeAccrualKey, state.jeSchedulesState);
|
|
244
|
-
if (accrual != null) {
|
|
245
|
-
oneTimeAccruals.push(accrual);
|
|
246
|
-
}
|
|
247
|
-
});
|
|
103
|
+
const failedJeScheduleTransactionKeysForSelectedPeriod = monthYearPeriodId != null
|
|
104
|
+
? failedJeScheduleTransactionKeysByPeriod[monthYearPeriodId]
|
|
105
|
+
: null;
|
|
106
|
+
const jeScheduleTransactionKeys = jeScheduleTransactionKeysForSelectedPeriod ?? [];
|
|
107
|
+
const failedJeScheduleTransactionKeys = failedJeScheduleTransactionKeysForSelectedPeriod ?? [];
|
|
248
108
|
jeScheduleTransactionKeys.forEach((jeScheduleKey) => {
|
|
249
109
|
const jeScheduleDetails = getJEScheduledTransactionByJEScheduleTransactionKey(jeScheduleKey, state);
|
|
250
110
|
jeScheduledTransaction.push(jeScheduleDetails);
|
|
251
111
|
});
|
|
252
|
-
jeScheduleAccruedKeys.forEach((jeAccruedScheduleKey) => {
|
|
253
|
-
const accruedScheduleDetails = getJEAccruedScheduleByJEScheduleKey(jeAccruedScheduleKey, state);
|
|
254
|
-
if (accruedScheduleDetails != null) {
|
|
255
|
-
accruedSchedules.push(accruedScheduleDetails);
|
|
256
|
-
}
|
|
257
|
-
});
|
|
258
112
|
failedJeScheduleTransactionKeys.forEach((jeScheduleKey) => {
|
|
259
113
|
const jeScheduleDetails = getJEScheduledTransactionByJEScheduleTransactionKey(jeScheduleKey, state);
|
|
260
114
|
failedJeScheduledTransaction.push(jeScheduleDetails);
|
|
261
115
|
});
|
|
262
|
-
const { sortKey, sortOrder
|
|
116
|
+
const { sortKey, sortOrder } = uiState;
|
|
117
|
+
const draftSchedules = sortJEScheduledTransactions(jeScheduledTransaction.filter((schedule) => schedule.status.code === 'draft'), sortKey, sortOrder);
|
|
118
|
+
const ongoingSchedules = sortJEScheduledTransactions(jeScheduledTransaction.filter((schedule) => schedule.status.code === 'ongoing'), sortKey, sortOrder);
|
|
119
|
+
const completedSchedules = sortJEScheduledTransactions(jeScheduledTransaction.filter((schedule) => schedule.status.code === 'completed' ||
|
|
120
|
+
schedule.status.code === 'marked_as_completed'), sortKey, sortOrder);
|
|
263
121
|
const unsortedResolveSchedules = [];
|
|
264
122
|
failedJeScheduledTransaction.forEach((schedule) => {
|
|
265
123
|
schedule.scheduledJournalEntry.forEach((journalEntry) => {
|
|
@@ -271,87 +129,10 @@ export function getExpenseAutomationJESchedulesView(state) {
|
|
|
271
129
|
});
|
|
272
130
|
const resolveSchedules = sortJEScheduledTransactions(unsortedResolveSchedules, sortKey, sortOrder);
|
|
273
131
|
const validResolveForPending = unsortedResolveSchedules.filter((r) => jeScheduleLocalDataById[r.scheduledJournalEntry.scheduledJournalEntryID] != null);
|
|
274
|
-
const matchesTypeFilter = (schedule) => selectedJETypeFilter == null ||
|
|
275
|
-
getJEScheduleRowType(schedule) === selectedJETypeFilter;
|
|
276
|
-
const isCreatedStatus = (schedule) => {
|
|
277
|
-
// An accrual is "created" once it is not review work: posted, reversing, reversed, or in a
|
|
278
|
-
// transient posting claim.
|
|
279
|
-
if (isOneTimeAccrualRow(schedule)) {
|
|
280
|
-
return !isPendingReviewRow(schedule);
|
|
281
|
-
}
|
|
282
|
-
return (schedule.status.code === 'ongoing' ||
|
|
283
|
-
schedule.status.code === 'completed' ||
|
|
284
|
-
schedule.status.code === 'marked_as_completed');
|
|
285
|
-
};
|
|
286
|
-
const allScheduleRows = [
|
|
287
|
-
...jeScheduledTransaction,
|
|
288
|
-
...accruedSchedules,
|
|
289
|
-
...oneTimeAccruals,
|
|
290
|
-
];
|
|
291
132
|
const pendingReviewSchedules = sortJEScheduledTransactions([
|
|
292
|
-
...
|
|
133
|
+
...jeScheduledTransaction.filter((schedule) => schedule.status.code === 'draft'),
|
|
293
134
|
...validResolveForPending,
|
|
294
135
|
], sortKey, sortOrder);
|
|
295
|
-
const createdSchedules = sortJEScheduledTransactions(allScheduleRows.filter((schedule) => isCreatedStatus(schedule) && matchesTypeFilter(schedule)), sortKey, sortOrder);
|
|
296
|
-
// KPI summary — derived from unfiltered schedules so counts are always accurate
|
|
297
|
-
const allSchedules = allScheduleRows;
|
|
298
|
-
const sumAmount = (schedules) => schedules.reduce((total, schedule) => total + (getScheduleAmount(schedule) ?? 0), 0);
|
|
299
|
-
const pendingReviewTotal = sumAmount(pendingReviewSchedules);
|
|
300
|
-
const createdTotal = sumAmount(createdSchedules);
|
|
301
|
-
const aiAccountantSchedules = allSchedules.filter(isAiAccountantSchedule);
|
|
302
|
-
const manualSchedules = allSchedules.filter((schedule) => !isAiAccountantSchedule(schedule));
|
|
303
|
-
const pendingUnfiltered = allSchedules.filter((schedule) => isPendingReviewRow(schedule));
|
|
304
|
-
const kpiSummary = {
|
|
305
|
-
aiAccountant: {
|
|
306
|
-
count: aiAccountantSchedules.length,
|
|
307
|
-
amount: sumAmount(aiAccountantSchedules),
|
|
308
|
-
},
|
|
309
|
-
manual: {
|
|
310
|
-
count: manualSchedules.length,
|
|
311
|
-
amount: sumAmount(manualSchedules),
|
|
312
|
-
},
|
|
313
|
-
needsReview: {
|
|
314
|
-
count: pendingUnfiltered.length,
|
|
315
|
-
amount: sumAmount(pendingUnfiltered),
|
|
316
|
-
},
|
|
317
|
-
total: {
|
|
318
|
-
count: allSchedules.length,
|
|
319
|
-
amount: sumAmount(allSchedules),
|
|
320
|
-
},
|
|
321
|
-
};
|
|
322
|
-
// Each tab's badge counts from that tab's own bucket. A tab that has not been fetched yet
|
|
323
|
-
// reports undefined rather than 0, so the UI can hide the badge instead of asserting "none".
|
|
324
|
-
const scheduleCountsByTab = {};
|
|
325
|
-
ALL_JE_PAGE_TABS.forEach((pageTab) => {
|
|
326
|
-
const periodTabKey = monthYearPeriodId != null
|
|
327
|
-
? getJESchedulePeriodTabKey(pageTab, monthYearPeriodId)
|
|
328
|
-
: null;
|
|
329
|
-
const transactionKeys = periodTabKey != null
|
|
330
|
-
? jeScheduleTransactionKeysByPeriodAndTab[periodTabKey]
|
|
331
|
-
: undefined;
|
|
332
|
-
if (transactionKeys == null) {
|
|
333
|
-
return;
|
|
334
|
-
}
|
|
335
|
-
const accruedKeys = (periodTabKey != null
|
|
336
|
-
? jeScheduleAccruedKeysByPeriodAndTab[periodTabKey]
|
|
337
|
-
: undefined) ?? [];
|
|
338
|
-
const oneTimeAccrualKeys = (periodTabKey != null
|
|
339
|
-
? jeScheduleOneTimeAccrualKeysByPeriodAndTab[periodTabKey]
|
|
340
|
-
: undefined) ?? [];
|
|
341
|
-
const rowsForTab = [
|
|
342
|
-
...transactionKeys.map((transactionKey) => getJEScheduledTransactionByJEScheduleTransactionKey(transactionKey, state)),
|
|
343
|
-
...accruedKeys
|
|
344
|
-
.map((accruedKey) => getJEAccruedScheduleByJEScheduleKey(accruedKey, state))
|
|
345
|
-
.filter((accruedRow) => accruedRow != null),
|
|
346
|
-
...oneTimeAccrualKeys
|
|
347
|
-
.map((accrualKey) => getJEOneTimeAccrualByKey(accrualKey, state.jeSchedulesState))
|
|
348
|
-
.filter((accrualRow) => accrualRow != null),
|
|
349
|
-
];
|
|
350
|
-
scheduleCountsByTab[pageTab] =
|
|
351
|
-
pageTab === 'existing_schedules'
|
|
352
|
-
? rowsForTab.filter((row) => isExistingTabRow(row)).length
|
|
353
|
-
: rowsForTab.filter((row) => isPendingReviewRow(row) || isCreatedStatus(row)).length;
|
|
354
|
-
});
|
|
355
136
|
const allSteps = monthYearPeriodId != null
|
|
356
137
|
? getAllSteps(monthEndCloseChecksState, monthYearPeriodId, currentTenant.tenantId)
|
|
357
138
|
: [];
|
|
@@ -364,20 +145,6 @@ export function getExpenseAutomationJESchedulesView(state) {
|
|
|
364
145
|
{ fetchState, error },
|
|
365
146
|
monthEndFetchState,
|
|
366
147
|
]);
|
|
367
|
-
const countByType = (schedules) => {
|
|
368
|
-
const counts = ALL_SCHEDULES_TYPES.reduce((acc, type) => ({ ...acc, [type]: 0 }), {});
|
|
369
|
-
schedules.forEach((schedule) => {
|
|
370
|
-
const scheduleType = getJEScheduleRowType(schedule);
|
|
371
|
-
if (scheduleType != null) {
|
|
372
|
-
counts[scheduleType] += 1;
|
|
373
|
-
}
|
|
374
|
-
});
|
|
375
|
-
return counts;
|
|
376
|
-
};
|
|
377
|
-
const jeScheduleTypeCounts = {
|
|
378
|
-
active: countByType(allSchedules.filter((schedule) => isPendingReviewRow(schedule) || isCreatedStatus(schedule))),
|
|
379
|
-
ongoing: countByType(allSchedules.filter((schedule) => isExistingTabRow(schedule))),
|
|
380
|
-
};
|
|
381
148
|
return {
|
|
382
149
|
uncategorizedAccounts,
|
|
383
150
|
allDepreciationAccountList: filteredDepAccounts,
|
|
@@ -386,17 +153,12 @@ export function getExpenseAutomationJESchedulesView(state) {
|
|
|
386
153
|
allAccountList: filteredAccounts,
|
|
387
154
|
accountListNestedAccountHierarchy,
|
|
388
155
|
allClassList: allClasses,
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
jeScheduleTypeCounts,
|
|
393
|
-
scheduleCountsByTab,
|
|
394
|
-
kpiSummary,
|
|
156
|
+
completedSchedules,
|
|
157
|
+
draftSchedules,
|
|
158
|
+
ongoingSchedules,
|
|
395
159
|
pendingReviewSchedules,
|
|
396
|
-
pendingReviewTotal,
|
|
397
160
|
resolveSchedules: resolveSchedules,
|
|
398
161
|
accountSettingsView,
|
|
399
|
-
newScheduleView,
|
|
400
162
|
postStatusById: postStatusById,
|
|
401
163
|
ignoreStatusById: ignoreStatusById,
|
|
402
164
|
fetchState: reducedFetchStatus.fetchState,
|