@zeniai/client-epic-state 5.2.14 → 5.2.15
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/accountRecon/accountReconReducer.d.ts +2 -1
- package/lib/entity/accountRecon/accountReconReducer.js +22 -10
- package/lib/entity/accountRecon/accountReconSelector.d.ts +1 -0
- package/lib/entity/accountRecon/accountReconSelector.js +1 -0
- package/lib/entity/approvalRule/approvalRuleConflict.d.ts +13 -0
- package/lib/entity/approvalRule/approvalRuleConflict.js +16 -1
- package/lib/entity/jeSchedules/jeScheduleHelper.d.ts +1 -0
- package/lib/entity/jeSchedules/jeScheduleHelper.js +7 -0
- package/lib/entity/jeSchedules/jeSchedulesPayload.d.ts +78 -1
- package/lib/entity/jeSchedules/jeSchedulesPayload.js +183 -4
- 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 +123 -1
- package/lib/entity/jeSchedules/jeSchedulesTypes.d.ts +24 -1
- package/lib/entity/jeSchedules/jeSchedulesTypes.js +96 -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 +10 -1
- package/lib/epic.js +18 -0
- package/lib/esm/entity/accountRecon/accountReconReducer.js +22 -10
- package/lib/esm/entity/accountRecon/accountReconSelector.js +1 -0
- package/lib/esm/entity/approvalRule/approvalRuleConflict.js +16 -1
- package/lib/esm/entity/jeSchedules/jeScheduleHelper.js +6 -0
- package/lib/esm/entity/jeSchedules/jeSchedulesPayload.js +183 -5
- 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 +86 -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 +18 -0
- package/lib/esm/index.js +16 -10
- package/lib/esm/view/expenseAutomationView/epics/accountRecon/confirmStatementMappingEpic.js +2 -2
- package/lib/esm/view/expenseAutomationView/epics/accountRecon/deleteCombinedStatementEpic.js +54 -0
- package/lib/esm/view/expenseAutomationView/epics/accountRecon/fetchReconciliationViewEpic.js +1 -1
- package/lib/esm/view/expenseAutomationView/epics/accountRecon/updateCombinedStatementInfoEpic.js +3 -6
- package/lib/esm/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +6 -3
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.js +9 -1
- 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 +104 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +25 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js +138 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +79 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.js +180 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.js +111 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +28 -0
- package/lib/esm/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.js +140 -0
- package/lib/esm/view/expenseAutomationView/helpers/reconciliationHelpers.js +12 -0
- package/lib/esm/view/expenseAutomationView/payload/jeSchedulesPayload.js +55 -0
- package/lib/esm/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +319 -29
- package/lib/esm/view/expenseAutomationView/reducers/reconciliationViewReducer.js +20 -2
- package/lib/esm/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +1 -0
- package/lib/esm/view/expenseAutomationView/selectors/jeAccountSettingsViewSelector.js +1 -0
- package/lib/esm/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +106 -0
- package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +327 -22
- package/lib/esm/view/expenseAutomationView/types/jeSchedulesViewState.js +5 -6
- 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/billPay/billPaySetupApproverView/billPaySetupApproverViewSelector.js +20 -1
- package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewSelector.js +20 -1
- package/lib/index.d.ts +18 -13
- package/lib/index.js +92 -47
- package/lib/view/expenseAutomationView/epics/accountRecon/confirmStatementMappingEpic.d.ts +10 -2
- package/lib/view/expenseAutomationView/epics/accountRecon/confirmStatementMappingEpic.js +1 -1
- package/lib/view/expenseAutomationView/epics/accountRecon/deleteCombinedStatementEpic.d.ts +9 -0
- package/lib/view/expenseAutomationView/epics/accountRecon/deleteCombinedStatementEpic.js +58 -0
- package/lib/view/expenseAutomationView/epics/accountRecon/fetchReconciliationViewEpic.js +1 -1
- package/lib/view/expenseAutomationView/epics/accountRecon/updateCombinedStatementInfoEpic.js +3 -6
- package/lib/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +6 -3
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulePageEpic.js +9 -1
- 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 +21 -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 +9 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.js +108 -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 +9 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js +142 -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 +13 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.js +187 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.d.ts +65 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.js +115 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.d.ts +6 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +32 -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/reconciliationHelpers.d.ts +6 -0
- package/lib/view/expenseAutomationView/helpers/reconciliationHelpers.js +13 -0
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
- package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.d.ts +86 -3
- package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.js +58 -1
- package/lib/view/expenseAutomationView/payload/reconciliationPayload.d.ts +4 -0
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +93 -12
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +321 -29
- package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +1 -1
- package/lib/view/expenseAutomationView/reducers/reconciliationViewReducer.d.ts +6 -1
- package/lib/view/expenseAutomationView/reducers/reconciliationViewReducer.js +22 -4
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +2 -2
- package/lib/view/expenseAutomationView/selectorTypes/jeAccountSettingsViewSelectorTypes.d.ts +1 -0
- 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 +41 -7
- package/lib/view/expenseAutomationView/selectors/jeAccountSettingsViewSelector.js +1 -0
- 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 +335 -21
- package/lib/view/expenseAutomationView/types/completedSubTab.d.ts +1 -1
- package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +83 -8
- package/lib/view/expenseAutomationView/types/jeSchedulesViewState.js +8 -8
- package/lib/view/expenseAutomationView/types/reconciliationViewState.d.ts +1 -1
- 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/billPay/billPaySetupApproverView/billPaySetupApproverViewSelector.js +20 -1
- package/lib/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewSelectorTypes.d.ts +3 -0
- package/lib/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewSelector.js +20 -1
- package/lib/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewSelectorTypes.d.ts +3 -0
- package/package.json +1 -1
|
@@ -3,7 +3,9 @@ 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 {
|
|
6
|
+
import { generateJEOneTimeAccrualKey } from '../../../entity/jeSchedules/jeScheduleHelper';
|
|
7
|
+
import { getJEAccruedScheduleByJEScheduleKey, getJEOneTimeAccrualByKey, getJEScheduledTransactionByJEScheduleTransactionKey, } from '../../../entity/jeSchedules/jeSchedulesSelector';
|
|
8
|
+
import { ALL_SCHEDULES_TYPES, } from '../../../entity/jeSchedules/jeSchedulesTypes';
|
|
7
9
|
import { getCurrentTenant } from '../../../entity/tenant/tenantSelector';
|
|
8
10
|
import { getAccountIdsForLabel, getAccountList, getNestedAccountListHierarchy, getUncategorizedAccounts, } from '../../accountList/accountListSelector';
|
|
9
11
|
import { getClassList, getNestedClassListHierarchy, } from '../../classList/classListSelector';
|
|
@@ -11,8 +13,143 @@ import { getAccountsTypesForScheduleDetails } from '../../scheduleView/scheduleD
|
|
|
11
13
|
import { filterNestedAccountHierarchyById } from '../../scheduleView/scheduleDetailView/scheduleDetailSelector';
|
|
12
14
|
import { getAccountLabelForScheduleType, getAccountsTypesForScheduleList, } from '../../scheduleView/scheduleListView/scheduleListHelper';
|
|
13
15
|
import { getAllSteps } from './getAllStepsHelper';
|
|
16
|
+
import { ALL_JE_PAGE_TABS, getJESchedulePeriodTabKey, } from '../types/jeSchedulesViewState';
|
|
14
17
|
import { getJEAccountSettingsView } from './jeAccountSettingsViewSelector';
|
|
18
|
+
import { getNewScheduleView } from './jeNewScheduleViewSelector';
|
|
19
|
+
// Matches the AI-automation user addresses webc's schedule list row already
|
|
20
|
+
// checks (JEScheduleReadOnlyListRow/JEScheduleDraftListRow "Method" column,
|
|
21
|
+
// strings.ts aiBotEmail/botEmail) to determine whether a schedule was
|
|
22
|
+
// created by the AI accountant vs. a human.
|
|
23
|
+
const AI_BOT_EMAIL = 'ai@zeni.ai';
|
|
24
|
+
const BOT_EMAIL = 'bot@zeni.ai';
|
|
25
|
+
// A one-time accrual has no jeScheduleType of its own — it is not a JE schedule. It is still an
|
|
26
|
+
// accrued expense, so it counts and filters under that type on the page's type tabs.
|
|
27
|
+
const ONE_TIME_ACCRUAL_SCHEDULE_TYPE = 'accrued_expenses';
|
|
28
|
+
// Which of the two list buckets an accrual belongs in. `draft` still needs a human to post it;
|
|
29
|
+
// everything else is already on the books or in a transient claim.
|
|
30
|
+
const ONE_TIME_ACCRUAL_REVIEW_STATUSES = [
|
|
31
|
+
'draft',
|
|
32
|
+
];
|
|
33
|
+
/**
|
|
34
|
+
* `posting_blocked` is written by the posting Cron when a JE fails to post. It is an internal
|
|
35
|
+
* failure state with no human action attached, so it is dropped here rather than hidden at render
|
|
36
|
+
* time — filtering in the view would leave the group counts and KPI totals counting rows nobody
|
|
37
|
+
* can see. The expense-automation endpoint applies no status filter on the close-period path, so
|
|
38
|
+
* these rows do arrive.
|
|
39
|
+
*/
|
|
40
|
+
export function isRenderableOneTimeAccrual(accrual) {
|
|
41
|
+
return (accrual.accrualStatus !== 'posting_blocked' &&
|
|
42
|
+
// Terminal states the user has already decided. The GET list excludes both server-side, so
|
|
43
|
+
// these only appear in the window between an ignore/revert response being written back and the
|
|
44
|
+
// background refresh landing -- during which an ignored row would otherwise sit in Pending
|
|
45
|
+
// Review offering a Post button. Dropped here rather than at render time so group counts and
|
|
46
|
+
// KPI totals do not count rows nobody can see.
|
|
47
|
+
accrual.accrualStatus !== 'reverted' &&
|
|
48
|
+
!accrual.isIgnored);
|
|
49
|
+
}
|
|
50
|
+
export function getJEScheduleRowType(schedule) {
|
|
51
|
+
return isOneTimeAccrualRow(schedule)
|
|
52
|
+
? ONE_TIME_ACCRUAL_SCHEDULE_TYPE
|
|
53
|
+
: schedule.jeScheduleType;
|
|
54
|
+
}
|
|
55
|
+
export function isPendingReviewRow(schedule) {
|
|
56
|
+
return isOneTimeAccrualRow(schedule)
|
|
57
|
+
? ONE_TIME_ACCRUAL_REVIEW_STATUSES.includes(schedule.accrualStatus)
|
|
58
|
+
: schedule.status.code === 'draft';
|
|
59
|
+
}
|
|
60
|
+
// Belongs on the Existing Schedules tab. For an accrual the endpoint has already filtered to
|
|
61
|
+
// posted, so this only has to agree with that rather than re-derive it.
|
|
62
|
+
export function isExistingTabRow(schedule) {
|
|
63
|
+
return isOneTimeAccrualRow(schedule)
|
|
64
|
+
? schedule.accrualStatus === 'posted'
|
|
65
|
+
: schedule.status.code === 'ongoing';
|
|
66
|
+
}
|
|
67
|
+
// Exported (rather than kept as a closure inside the selector) so it can be
|
|
68
|
+
// unit-tested directly — confidenceScore is a separate, more narrowly
|
|
69
|
+
// populated field that can be null on a schedule the bot user created,
|
|
70
|
+
// which previously caused these schedules to display as "AI Accountant" in
|
|
71
|
+
// the list but count under "Manual" in the KPI summary.
|
|
72
|
+
export const isAiAccountantSchedule = (schedule) => {
|
|
73
|
+
// A one-time accrual records who made it as `origin`, which is authoritative — no email
|
|
74
|
+
// sniffing needed, and the JE bot is often absent from the user entity entirely.
|
|
75
|
+
if (isOneTimeAccrualRow(schedule)) {
|
|
76
|
+
return schedule.origin === 'agent';
|
|
77
|
+
}
|
|
78
|
+
return (schedule.createdByUser?.email === AI_BOT_EMAIL ||
|
|
79
|
+
schedule.createdByUser?.email === BOT_EMAIL);
|
|
80
|
+
};
|
|
81
|
+
// Accrued schedules are structurally distinct — no baseTransaction, carrying recurringAmount and
|
|
82
|
+
// memo in its place — so anything reading baseTransaction has to branch on this first.
|
|
83
|
+
//
|
|
84
|
+
// Discriminates on jeAccruedScheduleKey, which only JEAccruedSchedule carries. jeScheduleType
|
|
85
|
+
// cannot be used: it is a data field present on BOTH row shapes, so an accrued-typed row that
|
|
86
|
+
// arrived through the prepaid/fixed DTO (failed_je_postings, legacy fetches) would be
|
|
87
|
+
// misclassified and then crash on recurringAmount / jeAccruedScheduleKey.
|
|
88
|
+
export function isAccruedScheduleRow(schedule) {
|
|
89
|
+
return 'jeAccruedScheduleKey' in schedule;
|
|
90
|
+
}
|
|
91
|
+
// Same structural approach as isAccruedScheduleRow, and for the same reason: jeOneTimeAccrualKey
|
|
92
|
+
// exists only on this shape. Note the two guards are NOT interchangeable — a one-time accrual is
|
|
93
|
+
// not an accrued *schedule*, and routing it into the accrued branch would read recurringAmount,
|
|
94
|
+
// render postedCount/lifecycleTotal as a lifecycle and startDate–endDate as a period, none of
|
|
95
|
+
// which it has.
|
|
96
|
+
export function isOneTimeAccrualRow(schedule) {
|
|
97
|
+
return 'jeOneTimeAccrualKey' in schedule;
|
|
98
|
+
}
|
|
99
|
+
/** The row's own Amount, so callers can read its currency and not just its value. */
|
|
100
|
+
function getScheduleAmountObject(schedule) {
|
|
101
|
+
if (isOneTimeAccrualRow(schedule)) {
|
|
102
|
+
return schedule.estimatedAmount;
|
|
103
|
+
}
|
|
104
|
+
if (isAccruedScheduleRow(schedule)) {
|
|
105
|
+
return schedule.recurringAmount;
|
|
106
|
+
}
|
|
107
|
+
return schedule.baseTransaction.amount;
|
|
108
|
+
}
|
|
109
|
+
function getScheduleAmount(schedule) {
|
|
110
|
+
if (isOneTimeAccrualRow(schedule)) {
|
|
111
|
+
return schedule.estimatedAmount.amount;
|
|
112
|
+
}
|
|
113
|
+
if (isAccruedScheduleRow(schedule)) {
|
|
114
|
+
return schedule.recurringAmount.amount;
|
|
115
|
+
}
|
|
116
|
+
return schedule.baseTransaction.amount.amount;
|
|
117
|
+
}
|
|
118
|
+
// A one-time accrual shares almost no sortable field with a schedule, so it gets its own accessor
|
|
119
|
+
// rather than a guard on each of the dozen cases below. Keys with no meaning for a single-month
|
|
120
|
+
// accrual -- amortizationPeriod, remainingMonths, runningBalance, jePostingDate, scheduleCategory --
|
|
121
|
+
// deliberately fall through to undefined, which sorts them together at one end.
|
|
122
|
+
function getOneTimeAccrualSortValue(accrual, sortKey) {
|
|
123
|
+
switch (sortKey) {
|
|
124
|
+
case 'vendor':
|
|
125
|
+
return accrual.vendorName.toLowerCase();
|
|
126
|
+
case 'category':
|
|
127
|
+
return accrual.jeDebitAccountName?.toLowerCase();
|
|
128
|
+
case 'class':
|
|
129
|
+
return accrual.jeDebitAccountingClassName?.toLowerCase();
|
|
130
|
+
case 'depCategory':
|
|
131
|
+
return accrual.jeCreditAccountName?.toLowerCase();
|
|
132
|
+
case 'type':
|
|
133
|
+
return ONE_TIME_ACCRUAL_SCHEDULE_TYPE;
|
|
134
|
+
case 'totalAmount':
|
|
135
|
+
return accrual.estimatedAmount.amount;
|
|
136
|
+
case 'transactionDate':
|
|
137
|
+
return accrual.postingDate?.valueOf();
|
|
138
|
+
case 'memo':
|
|
139
|
+
return accrual.memo.toLowerCase();
|
|
140
|
+
case 'startMonth':
|
|
141
|
+
return accrual.serviceMonth;
|
|
142
|
+
default:
|
|
143
|
+
return undefined;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
15
146
|
function getJEScheduleSortAccessor(sortKey) {
|
|
147
|
+
const scheduleAccessor = getScheduleRowSortAccessor(sortKey);
|
|
148
|
+
return (schedule) => isOneTimeAccrualRow(schedule)
|
|
149
|
+
? getOneTimeAccrualSortValue(schedule, sortKey)
|
|
150
|
+
: scheduleAccessor(schedule);
|
|
151
|
+
}
|
|
152
|
+
function getScheduleRowSortAccessor(sortKey) {
|
|
16
153
|
switch (sortKey) {
|
|
17
154
|
case 'vendor':
|
|
18
155
|
return (s) => s.vendor.name?.toLowerCase();
|
|
@@ -23,7 +160,9 @@ function getJEScheduleSortAccessor(sortKey) {
|
|
|
23
160
|
case 'depCategory':
|
|
24
161
|
return (s) => s.jeCredit.account?.accountName?.toLowerCase();
|
|
25
162
|
case 'scheduleCategory':
|
|
26
|
-
return (s) => s
|
|
163
|
+
return (s) => isAccruedScheduleRow(s)
|
|
164
|
+
? undefined
|
|
165
|
+
: s.baseTransaction.account?.accountName?.toLowerCase();
|
|
27
166
|
case 'startMonth':
|
|
28
167
|
return (s) => s.startDate?.valueOf();
|
|
29
168
|
case 'type':
|
|
@@ -51,11 +190,13 @@ function getJEScheduleSortAccessor(sortKey) {
|
|
|
51
190
|
return s.balanceAsOfToday?.amount ?? null;
|
|
52
191
|
};
|
|
53
192
|
case 'totalAmount':
|
|
54
|
-
return (s) => s
|
|
193
|
+
return (s) => getScheduleAmount(s);
|
|
55
194
|
case 'transactionDate':
|
|
56
|
-
return (s) => s.
|
|
195
|
+
return (s) => s.createTime?.valueOf();
|
|
57
196
|
case 'memo':
|
|
58
|
-
return (s) => s
|
|
197
|
+
return (s) => isAccruedScheduleRow(s)
|
|
198
|
+
? s.memo.toLowerCase()
|
|
199
|
+
: s.baseTransaction.memo?.toLowerCase();
|
|
59
200
|
default:
|
|
60
201
|
return (s) => s.startDate?.valueOf();
|
|
61
202
|
}
|
|
@@ -67,9 +208,15 @@ function sortJEScheduledTransactions(transactions, sortKey, sortOrder) {
|
|
|
67
208
|
export function getExpenseAutomationJESchedulesView(state) {
|
|
68
209
|
const jeScheduledTransaction = [];
|
|
69
210
|
const failedJeScheduledTransaction = [];
|
|
211
|
+
const accruedSchedules = [];
|
|
212
|
+
const oneTimeAccruals = [];
|
|
70
213
|
const { accountState, accountListState, classState, classListState, expenseAutomationJESchedulesViewState, expenseAutomationViewState, monthEndCloseChecksState, monthEndCloseChecksViewState, } = state;
|
|
71
|
-
const {
|
|
214
|
+
const { jeScheduleTransactionKeysByPeriodAndTab, jeScheduleAccruedKeysByPeriodAndTab, jeScheduleOneTimeAccrualKeysByPeriodAndTab, failedJeScheduleTransactionKeysByPeriodAndTab, jeScheduleLocalDataById, postStatusById, ignoreStatusById, revertStatusById, oneTimeAccrualActionStatusById, uiState, error, fetchState, refreshStatus, newSchedule, } = expenseAutomationJESchedulesViewState;
|
|
72
215
|
const accountSettingsView = getJEAccountSettingsView(state);
|
|
216
|
+
const newScheduleView = newSchedule.selectedDetailScheduleType === 'fixed_assets' ||
|
|
217
|
+
newSchedule.selectedDetailScheduleType === 'prepaid_expenses'
|
|
218
|
+
? getNewScheduleView(state, newSchedule.selectedDetailScheduleType)
|
|
219
|
+
: undefined;
|
|
73
220
|
const currentTenant = getCurrentTenant(state);
|
|
74
221
|
const { selectedPeriodByTenantId } = expenseAutomationViewState;
|
|
75
222
|
const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
|
|
@@ -97,27 +244,48 @@ export function getExpenseAutomationJESchedulesView(state) {
|
|
|
97
244
|
const filteredDepAccountListNestedAccountHierarchy = filterNestedAccountHierarchyById(depAccountListNestedAccountHierarchy, filteredDepAccounts.map((account) => account.accountId));
|
|
98
245
|
const classListNestedAccountHierarchy = getNestedClassListHierarchy(classListState);
|
|
99
246
|
const monthYearPeriodId = selectedPeriod != null ? toMonthYearPeriodId(selectedPeriod) : null;
|
|
100
|
-
const
|
|
101
|
-
?
|
|
102
|
-
: null;
|
|
103
|
-
const failedJeScheduleTransactionKeysForSelectedPeriod = monthYearPeriodId != null
|
|
104
|
-
? failedJeScheduleTransactionKeysByPeriod[monthYearPeriodId]
|
|
247
|
+
const selectedPeriodTabKey = monthYearPeriodId != null
|
|
248
|
+
? getJESchedulePeriodTabKey(uiState.selectedPageTab, monthYearPeriodId)
|
|
105
249
|
: null;
|
|
106
|
-
const
|
|
107
|
-
|
|
250
|
+
const jeScheduleTransactionKeysForSelectedTab = selectedPeriodTabKey != null
|
|
251
|
+
? jeScheduleTransactionKeysByPeriodAndTab[selectedPeriodTabKey]
|
|
252
|
+
: undefined;
|
|
253
|
+
const failedJeScheduleTransactionKeysForSelectedTab = selectedPeriodTabKey != null
|
|
254
|
+
? failedJeScheduleTransactionKeysByPeriodAndTab[selectedPeriodTabKey]
|
|
255
|
+
: undefined;
|
|
256
|
+
// Distinguishes "this tab has never been fetched for this period" from "fetched and genuinely
|
|
257
|
+
// empty". Without it the page cannot tell a first visit from a real empty state, and renders an
|
|
258
|
+
// empty table where it should render a skeleton.
|
|
259
|
+
const hasLoadedForSelectedTab = jeScheduleTransactionKeysForSelectedTab != null;
|
|
260
|
+
const jeScheduleTransactionKeys = jeScheduleTransactionKeysForSelectedTab ?? [];
|
|
261
|
+
const failedJeScheduleTransactionKeys = failedJeScheduleTransactionKeysForSelectedTab ?? [];
|
|
262
|
+
const jeScheduleAccruedKeys = (selectedPeriodTabKey != null
|
|
263
|
+
? jeScheduleAccruedKeysByPeriodAndTab[selectedPeriodTabKey]
|
|
264
|
+
: undefined) ?? [];
|
|
265
|
+
const jeScheduleOneTimeAccrualKeys = (selectedPeriodTabKey != null
|
|
266
|
+
? jeScheduleOneTimeAccrualKeysByPeriodAndTab[selectedPeriodTabKey]
|
|
267
|
+
: undefined) ?? [];
|
|
268
|
+
jeScheduleOneTimeAccrualKeys.forEach((jeOneTimeAccrualKey) => {
|
|
269
|
+
const accrual = getJEOneTimeAccrualByKey(jeOneTimeAccrualKey, state.jeSchedulesState);
|
|
270
|
+
if (accrual != null && isRenderableOneTimeAccrual(accrual)) {
|
|
271
|
+
oneTimeAccruals.push(accrual);
|
|
272
|
+
}
|
|
273
|
+
});
|
|
108
274
|
jeScheduleTransactionKeys.forEach((jeScheduleKey) => {
|
|
109
275
|
const jeScheduleDetails = getJEScheduledTransactionByJEScheduleTransactionKey(jeScheduleKey, state);
|
|
110
276
|
jeScheduledTransaction.push(jeScheduleDetails);
|
|
111
277
|
});
|
|
278
|
+
jeScheduleAccruedKeys.forEach((jeAccruedScheduleKey) => {
|
|
279
|
+
const accruedScheduleDetails = getJEAccruedScheduleByJEScheduleKey(jeAccruedScheduleKey, state);
|
|
280
|
+
if (accruedScheduleDetails != null) {
|
|
281
|
+
accruedSchedules.push(accruedScheduleDetails);
|
|
282
|
+
}
|
|
283
|
+
});
|
|
112
284
|
failedJeScheduleTransactionKeys.forEach((jeScheduleKey) => {
|
|
113
285
|
const jeScheduleDetails = getJEScheduledTransactionByJEScheduleTransactionKey(jeScheduleKey, state);
|
|
114
286
|
failedJeScheduledTransaction.push(jeScheduleDetails);
|
|
115
287
|
});
|
|
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);
|
|
288
|
+
const { sortKey, sortOrder, selectedJETypeFilter } = uiState;
|
|
121
289
|
const unsortedResolveSchedules = [];
|
|
122
290
|
failedJeScheduledTransaction.forEach((schedule) => {
|
|
123
291
|
schedule.scheduledJournalEntry.forEach((journalEntry) => {
|
|
@@ -129,10 +297,103 @@ export function getExpenseAutomationJESchedulesView(state) {
|
|
|
129
297
|
});
|
|
130
298
|
const resolveSchedules = sortJEScheduledTransactions(unsortedResolveSchedules, sortKey, sortOrder);
|
|
131
299
|
const validResolveForPending = unsortedResolveSchedules.filter((r) => jeScheduleLocalDataById[r.scheduledJournalEntry.scheduledJournalEntryID] != null);
|
|
300
|
+
const matchesTypeFilter = (schedule) => selectedJETypeFilter == null ||
|
|
301
|
+
getJEScheduleRowType(schedule) === selectedJETypeFilter;
|
|
302
|
+
const isCreatedStatus = (schedule) => {
|
|
303
|
+
// An accrual is "created" once it is not review work: posted, reversing, reversed, or in a
|
|
304
|
+
// transient posting claim.
|
|
305
|
+
if (isOneTimeAccrualRow(schedule)) {
|
|
306
|
+
return !isPendingReviewRow(schedule);
|
|
307
|
+
}
|
|
308
|
+
return (schedule.status.code === 'ongoing' ||
|
|
309
|
+
schedule.status.code === 'completed' ||
|
|
310
|
+
schedule.status.code === 'marked_as_completed');
|
|
311
|
+
};
|
|
312
|
+
const allScheduleRows = [
|
|
313
|
+
...jeScheduledTransaction,
|
|
314
|
+
...accruedSchedules,
|
|
315
|
+
...oneTimeAccruals,
|
|
316
|
+
];
|
|
132
317
|
const pendingReviewSchedules = sortJEScheduledTransactions([
|
|
133
|
-
...
|
|
318
|
+
...allScheduleRows.filter((schedule) => isPendingReviewRow(schedule) && matchesTypeFilter(schedule)),
|
|
134
319
|
...validResolveForPending,
|
|
135
320
|
], sortKey, sortOrder);
|
|
321
|
+
const createdSchedules = sortJEScheduledTransactions(allScheduleRows.filter((schedule) => isCreatedStatus(schedule) && matchesTypeFilter(schedule)), sortKey, sortOrder);
|
|
322
|
+
// KPI summary — derived from unfiltered schedules so counts are always accurate
|
|
323
|
+
const allSchedules = allScheduleRows;
|
|
324
|
+
const sumAmount = (schedules) => schedules.reduce((total, schedule) => total + (getScheduleAmount(schedule) ?? 0), 0);
|
|
325
|
+
const pendingReviewTotal = sumAmount(pendingReviewSchedules);
|
|
326
|
+
const createdTotal = sumAmount(createdSchedules);
|
|
327
|
+
/**
|
|
328
|
+
* The currency the tiles render in. Taken from the schedules themselves rather than assumed:
|
|
329
|
+
* every row on a tab shares a tenant currency, so the first one that states it is the answer.
|
|
330
|
+
*/
|
|
331
|
+
const sumToAmount = (schedules) => {
|
|
332
|
+
const first = schedules[0];
|
|
333
|
+
const currency = first != null ? getScheduleAmountObject(first) : allScheduleAmountFallback;
|
|
334
|
+
return {
|
|
335
|
+
...currency,
|
|
336
|
+
amount: sumAmount(schedules),
|
|
337
|
+
};
|
|
338
|
+
};
|
|
339
|
+
// An empty bucket still has to render a currency; borrow it from any row on the page.
|
|
340
|
+
const allScheduleAmountFallback = allScheduleRows.length > 0
|
|
341
|
+
? getScheduleAmountObject(allScheduleRows[0])
|
|
342
|
+
: { amount: 0, currencyCode: '', currencySymbol: '' };
|
|
343
|
+
const aiAccountantSchedules = allSchedules.filter(isAiAccountantSchedule);
|
|
344
|
+
const manualSchedules = allSchedules.filter((schedule) => !isAiAccountantSchedule(schedule));
|
|
345
|
+
const pendingUnfiltered = allSchedules.filter((schedule) => isPendingReviewRow(schedule));
|
|
346
|
+
const kpiSummary = {
|
|
347
|
+
aiAccountant: {
|
|
348
|
+
count: aiAccountantSchedules.length,
|
|
349
|
+
amount: sumToAmount(aiAccountantSchedules),
|
|
350
|
+
},
|
|
351
|
+
manual: {
|
|
352
|
+
count: manualSchedules.length,
|
|
353
|
+
amount: sumToAmount(manualSchedules),
|
|
354
|
+
},
|
|
355
|
+
needsReview: {
|
|
356
|
+
count: pendingUnfiltered.length,
|
|
357
|
+
amount: sumToAmount(pendingUnfiltered),
|
|
358
|
+
},
|
|
359
|
+
total: {
|
|
360
|
+
count: allSchedules.length,
|
|
361
|
+
amount: sumToAmount(allSchedules),
|
|
362
|
+
},
|
|
363
|
+
};
|
|
364
|
+
// Each tab's badge counts from that tab's own bucket. A tab that has not been fetched yet
|
|
365
|
+
// reports undefined rather than 0, so the UI can hide the badge instead of asserting "none".
|
|
366
|
+
const scheduleCountsByTab = {};
|
|
367
|
+
ALL_JE_PAGE_TABS.forEach((pageTab) => {
|
|
368
|
+
const periodTabKey = monthYearPeriodId != null
|
|
369
|
+
? getJESchedulePeriodTabKey(pageTab, monthYearPeriodId)
|
|
370
|
+
: null;
|
|
371
|
+
const transactionKeys = periodTabKey != null
|
|
372
|
+
? jeScheduleTransactionKeysByPeriodAndTab[periodTabKey]
|
|
373
|
+
: undefined;
|
|
374
|
+
if (transactionKeys == null) {
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
const accruedKeys = (periodTabKey != null
|
|
378
|
+
? jeScheduleAccruedKeysByPeriodAndTab[periodTabKey]
|
|
379
|
+
: undefined) ?? [];
|
|
380
|
+
const oneTimeAccrualKeys = (periodTabKey != null
|
|
381
|
+
? jeScheduleOneTimeAccrualKeysByPeriodAndTab[periodTabKey]
|
|
382
|
+
: undefined) ?? [];
|
|
383
|
+
const rowsForTab = [
|
|
384
|
+
...transactionKeys.map((transactionKey) => getJEScheduledTransactionByJEScheduleTransactionKey(transactionKey, state)),
|
|
385
|
+
...accruedKeys
|
|
386
|
+
.map((accruedKey) => getJEAccruedScheduleByJEScheduleKey(accruedKey, state))
|
|
387
|
+
.filter((accruedRow) => accruedRow != null),
|
|
388
|
+
...oneTimeAccrualKeys
|
|
389
|
+
.map((accrualKey) => getJEOneTimeAccrualByKey(accrualKey, state.jeSchedulesState))
|
|
390
|
+
.filter((accrualRow) => accrualRow != null && isRenderableOneTimeAccrual(accrualRow)),
|
|
391
|
+
];
|
|
392
|
+
scheduleCountsByTab[pageTab] =
|
|
393
|
+
pageTab === 'existing_schedules'
|
|
394
|
+
? rowsForTab.filter((row) => isExistingTabRow(row)).length
|
|
395
|
+
: rowsForTab.filter((row) => isPendingReviewRow(row) || isCreatedStatus(row)).length;
|
|
396
|
+
});
|
|
136
397
|
const allSteps = monthYearPeriodId != null
|
|
137
398
|
? getAllSteps(monthEndCloseChecksState, monthYearPeriodId, currentTenant.tenantId)
|
|
138
399
|
: [];
|
|
@@ -145,6 +406,20 @@ export function getExpenseAutomationJESchedulesView(state) {
|
|
|
145
406
|
{ fetchState, error },
|
|
146
407
|
monthEndFetchState,
|
|
147
408
|
]);
|
|
409
|
+
const countByType = (schedules) => {
|
|
410
|
+
const counts = ALL_SCHEDULES_TYPES.reduce((acc, type) => ({ ...acc, [type]: 0 }), {});
|
|
411
|
+
schedules.forEach((schedule) => {
|
|
412
|
+
const scheduleType = getJEScheduleRowType(schedule);
|
|
413
|
+
if (scheduleType != null) {
|
|
414
|
+
counts[scheduleType] += 1;
|
|
415
|
+
}
|
|
416
|
+
});
|
|
417
|
+
return counts;
|
|
418
|
+
};
|
|
419
|
+
const jeScheduleTypeCounts = {
|
|
420
|
+
active: countByType(allSchedules.filter((schedule) => isPendingReviewRow(schedule) || isCreatedStatus(schedule))),
|
|
421
|
+
ongoing: countByType(allSchedules.filter((schedule) => isExistingTabRow(schedule))),
|
|
422
|
+
};
|
|
148
423
|
return {
|
|
149
424
|
uncategorizedAccounts,
|
|
150
425
|
allDepreciationAccountList: filteredDepAccounts,
|
|
@@ -153,14 +428,21 @@ export function getExpenseAutomationJESchedulesView(state) {
|
|
|
153
428
|
allAccountList: filteredAccounts,
|
|
154
429
|
accountListNestedAccountHierarchy,
|
|
155
430
|
allClassList: allClasses,
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
431
|
+
createdSchedules,
|
|
432
|
+
createdTotal,
|
|
433
|
+
hasLoadedForSelectedTab,
|
|
434
|
+
jeScheduleTypeCounts,
|
|
435
|
+
scheduleCountsByTab,
|
|
436
|
+
kpiSummary,
|
|
159
437
|
pendingReviewSchedules,
|
|
438
|
+
pendingReviewTotal,
|
|
160
439
|
resolveSchedules: resolveSchedules,
|
|
161
440
|
accountSettingsView,
|
|
441
|
+
newScheduleView,
|
|
162
442
|
postStatusById: postStatusById,
|
|
163
443
|
ignoreStatusById: ignoreStatusById,
|
|
444
|
+
revertStatusById: revertStatusById,
|
|
445
|
+
oneTimeAccrualActionStatusById: oneTimeAccrualActionStatusById,
|
|
164
446
|
fetchState: reducedFetchStatus.fetchState,
|
|
165
447
|
jeScheduleLocalDataById: jeScheduleLocalDataById,
|
|
166
448
|
uiState: uiState,
|
|
@@ -169,3 +451,26 @@ export function getExpenseAutomationJESchedulesView(state) {
|
|
|
169
451
|
completionStatus,
|
|
170
452
|
};
|
|
171
453
|
}
|
|
454
|
+
/**
|
|
455
|
+
* One accrual plus the status of its promote / ignore request, for the detail screen.
|
|
456
|
+
*
|
|
457
|
+
* `accrual` is undefined on a cold load — a refresh or a shared link, where the list has never run
|
|
458
|
+
* — so the screen dispatches `fetchOneTimeAccrual` and waits on `detailFetchState`. The two states
|
|
459
|
+
* are separate on purpose: `actionFetchState` drives the row spinner and the post-revert navigation,
|
|
460
|
+
* and a page load must not look like an action that just finished.
|
|
461
|
+
*/
|
|
462
|
+
export function getExpenseAutomationJEOneTimeAccrualDetailView(state, accrualId) {
|
|
463
|
+
return {
|
|
464
|
+
accrual: getJEOneTimeAccrualByKey(generateJEOneTimeAccrualKey(accrualId), state.jeSchedulesState),
|
|
465
|
+
actionFetchState: state.expenseAutomationJESchedulesViewState
|
|
466
|
+
.oneTimeAccrualActionStatusById[accrualId] ?? {
|
|
467
|
+
fetchState: 'Not-Started',
|
|
468
|
+
error: undefined,
|
|
469
|
+
},
|
|
470
|
+
detailFetchState: state.expenseAutomationJESchedulesViewState
|
|
471
|
+
.oneTimeAccrualFetchStatusById[accrualId] ?? {
|
|
472
|
+
fetchState: 'Not-Started',
|
|
473
|
+
error: undefined,
|
|
474
|
+
},
|
|
475
|
+
};
|
|
476
|
+
}
|
|
@@ -16,9 +16,8 @@ const JE_SCHEDULE_SORT_KEYS = [
|
|
|
16
16
|
'memo',
|
|
17
17
|
];
|
|
18
18
|
export const toJEScheduleSortKey = (v) => stringToUnion(v, JE_SCHEDULE_SORT_KEYS);
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
export const toJEScheduleMainTab = (v) => stringToUnion(v, JE_SCHEDULE_MAIN_TABS);
|
|
19
|
+
const JE_PAGE_TABS = ['schedules', 'existing_schedules'];
|
|
20
|
+
export const toJEPageTab = (v) => stringToUnion(v, JE_PAGE_TABS);
|
|
21
|
+
export const ALL_JE_PAGE_TABS = JE_PAGE_TABS;
|
|
22
|
+
export const getJESchedulePeriodTabKey = (selectedPageTab, monthYearPeriodId) => `${selectedPageTab}_${monthYearPeriodId}`;
|
|
23
|
+
export const MIN_NEW_SCHEDULE_SEARCH_LENGTH = 2;
|
|
@@ -30,7 +30,7 @@ export const fetchAccruedScheduleListEpic = (actions$, state$, zeniAPI) => actio
|
|
|
30
30
|
je_schedule_type: scheduleType,
|
|
31
31
|
sort_by: 'transaction_date',
|
|
32
32
|
sort_order: 'desc',
|
|
33
|
-
filter:
|
|
33
|
+
filter: action.payload.statusFilter,
|
|
34
34
|
};
|
|
35
35
|
return zeniAPI
|
|
36
36
|
.getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules?query=${encodeURIComponent(JSON.stringify(queryParam))}`)
|
|
@@ -7,9 +7,14 @@ import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePay
|
|
|
7
7
|
import { fetchDownloadSchedules, getState, updateDownloadScheduleFailure, updateDownloadScheduleSuccess, } from '../scheduleListReducer';
|
|
8
8
|
import { getScheduleListKey } from '../scheduleListTypes';
|
|
9
9
|
export const fetchDownloadSchedulesEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(fetchDownloadSchedules.match), mergeMap((action) => {
|
|
10
|
-
const { scheduleType, downloadCategories } = action.payload;
|
|
10
|
+
const { scheduleType, downloadCategories, statusFilter } = action.payload;
|
|
11
11
|
const scheduleListState = state$.value.scheduleListState;
|
|
12
12
|
// if parameters are provided, use those. else go to localdata
|
|
13
|
+
// Accrued is deliberately not served here. Its rows come back in a different shape, this
|
|
14
|
+
// epic writes them through updateJESchedules (the prepaid / fixed mapper), and
|
|
15
|
+
// doUpdateScheduleList never flips downloadState for accrued -- so a request would store the
|
|
16
|
+
// wrong data and then never report completion. Accrued downloads go through
|
|
17
|
+
// fetchAccruedScheduleList, which owns that shape end to end.
|
|
13
18
|
let scheduleState;
|
|
14
19
|
if (scheduleType !== 'accrued_expenses') {
|
|
15
20
|
scheduleState = getState(scheduleListState, scheduleType);
|
|
@@ -34,7 +39,7 @@ export const fetchDownloadSchedulesEpic = (actions$, state$, zeniAPI) => actions
|
|
|
34
39
|
base_txn_account_ids: downloadCategories,
|
|
35
40
|
sort_by: 'transaction_date',
|
|
36
41
|
sort_order: 'desc',
|
|
37
|
-
filter:
|
|
42
|
+
filter: statusFilter,
|
|
38
43
|
};
|
|
39
44
|
return zeniAPI
|
|
40
45
|
.getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/download?query=${encodeURIComponent(JSON.stringify(queryParam))}`)
|
|
@@ -84,8 +84,8 @@ const scheduleListView = createSlice({
|
|
|
84
84
|
reducers: {
|
|
85
85
|
fetchDownloadSchedules: {
|
|
86
86
|
reducer(draft, action) {
|
|
87
|
+
// Accrued is not downloaded through this action -- see fetchDownloadSchedulesEpic for why.
|
|
87
88
|
if (action.payload.scheduleType !== 'accrued_expenses') {
|
|
88
|
-
//if condition added for type narrowing
|
|
89
89
|
const state = getState(draft, action.payload.scheduleType);
|
|
90
90
|
const selectedTimeframe = action.payload.timeframeAndCategory.selectedTimeframe;
|
|
91
91
|
const selectedCategoryId = action.payload.timeframeAndCategory.selectedCategoryId;
|
|
@@ -109,13 +109,14 @@ const scheduleListView = createSlice({
|
|
|
109
109
|
updateState(draft, action.payload.scheduleType, state);
|
|
110
110
|
}
|
|
111
111
|
},
|
|
112
|
-
prepare(scheduleType, timeframeAndCategory, downloadCategories, cacheOverride = false) {
|
|
112
|
+
prepare(scheduleType, timeframeAndCategory, downloadCategories, statusFilter = 'all', cacheOverride = false) {
|
|
113
113
|
return {
|
|
114
114
|
payload: {
|
|
115
115
|
timeframeAndCategory,
|
|
116
116
|
scheduleType,
|
|
117
117
|
cacheOverride,
|
|
118
118
|
downloadCategories,
|
|
119
|
+
statusFilter,
|
|
119
120
|
},
|
|
120
121
|
};
|
|
121
122
|
},
|
|
@@ -151,12 +152,13 @@ const scheduleListView = createSlice({
|
|
|
151
152
|
updateState(draft, action.payload.scheduleType, state);
|
|
152
153
|
}
|
|
153
154
|
},
|
|
154
|
-
prepare(scheduleType, timeframeAndCategory, cacheOverride = false) {
|
|
155
|
+
prepare(scheduleType, timeframeAndCategory, cacheOverride = false, statusFilter = 'all') {
|
|
155
156
|
return {
|
|
156
157
|
payload: {
|
|
157
158
|
timeframeAndCategory,
|
|
158
159
|
scheduleType,
|
|
159
160
|
cacheOverride,
|
|
161
|
+
statusFilter,
|
|
160
162
|
},
|
|
161
163
|
};
|
|
162
164
|
},
|
|
@@ -7,7 +7,7 @@ import { getIsAccountingClassesEnabled } from '../../../../entity/tenant/tenantS
|
|
|
7
7
|
import { getUserByUserId } from '../../../../entity/user/userSelector';
|
|
8
8
|
import { getUserRoleByUserId } from '../../../../entity/userRole/userRoleSelector';
|
|
9
9
|
export const getBillPaySetupApproverView = createSelector((state) => state.billPaySetupApproverViewState, (state) => state.approvalRuleState, (state) => state.userState, (billPaySetupApproverViewState, approvalRuleState, userState) => {
|
|
10
|
-
const { approvalRulesDeleteStatusById, approvalRuleIds, fetchState, error, listeningToPusherEvent, newApprovalRuleId, } = billPaySetupApproverViewState;
|
|
10
|
+
const { approvalRulesDeleteStatusById, approvalRuleIds, approverListState, fetchState, error, listeningToPusherEvent, newApprovalRuleId, } = billPaySetupApproverViewState;
|
|
11
11
|
const deleteStateList = Object.values(approvalRulesDeleteStatusById);
|
|
12
12
|
const approvalRules = getApprovalRulesByIds(approvalRuleState, approvalRuleIds);
|
|
13
13
|
const allApprovalRules = approvalRules.map((approvalRule) => {
|
|
@@ -35,10 +35,15 @@ export const getBillPaySetupApproverView = createSelector((state) => state.billP
|
|
|
35
35
|
name: 'Require Info',
|
|
36
36
|
code: 'require_info',
|
|
37
37
|
};
|
|
38
|
+
const activeApproverIds = new Set(approverListState.approverIds);
|
|
39
|
+
const referencedApproverIds = new Set(allApprovalRules.flatMap((approvalRule) => approvalRule.steps.flatMap((step) => step.actors.map((actor) => actor.userId))));
|
|
40
|
+
const inactiveApproverIds = Array.from(referencedApproverIds).filter((userId) => !activeApproverIds.has(userId));
|
|
38
41
|
return {
|
|
39
42
|
allApprovalRules,
|
|
40
43
|
deleteStatus: reduceAnyFetchState(deleteStateList),
|
|
41
44
|
approvalRulesStatus,
|
|
45
|
+
approverListFetchStatus: approverListState.fetchStatus,
|
|
46
|
+
inactiveApproverIds,
|
|
42
47
|
fetchState,
|
|
43
48
|
error,
|
|
44
49
|
listeningToPusherEvent,
|
|
@@ -57,6 +62,19 @@ export const getBillPaySetupApproverUpdateDataView = createSelector((state) => s
|
|
|
57
62
|
};
|
|
58
63
|
})
|
|
59
64
|
.filter((approver) => approver.user != null);
|
|
65
|
+
const activeApproverIds = new Set(approverIds);
|
|
66
|
+
const currentRuleSteps = billPaySetupApproverViewUpdateData?.data?.steps ?? [];
|
|
67
|
+
const inactiveActorUserIds = new Set(currentRuleSteps
|
|
68
|
+
.flatMap((step) => step.actors.map((actor) => actor.userId))
|
|
69
|
+
.filter((userId) => userId != null && !activeApproverIds.has(userId)));
|
|
70
|
+
const inactiveActorApprovers = Array.from(inactiveActorUserIds)
|
|
71
|
+
.map((userId) => {
|
|
72
|
+
return {
|
|
73
|
+
user: getUserByUserId(userState, userId),
|
|
74
|
+
role: getUserRoleByUserId(userRoleState, userId),
|
|
75
|
+
};
|
|
76
|
+
})
|
|
77
|
+
.filter((approver) => approver.user != null);
|
|
60
78
|
const allAttributes = attributes;
|
|
61
79
|
const filteredApprovers = cloneDeep(allApprovers);
|
|
62
80
|
const filteredAttributes = cloneDeep(attributes);
|
|
@@ -90,6 +108,7 @@ export const getBillPaySetupApproverUpdateDataView = createSelector((state) => s
|
|
|
90
108
|
allApprovalRules,
|
|
91
109
|
allApprovers,
|
|
92
110
|
filteredApprovers,
|
|
111
|
+
inactiveActorApprovers,
|
|
93
112
|
allAttributes,
|
|
94
113
|
filteredAttributes,
|
|
95
114
|
billPaySetupApproverViewUpdateData,
|
|
@@ -7,7 +7,7 @@ import { getUserByUserId } from '../../../../entity/user/userSelector';
|
|
|
7
7
|
import { getUserRoleByUserId } from '../../../../entity/userRole/userRoleSelector';
|
|
8
8
|
export const getRemiSetupApproverView = (state, filterAdmins = true) => {
|
|
9
9
|
const { remiSetupApproverViewState, approvalRuleState, userState } = state;
|
|
10
|
-
const { approvalRulesDeleteStatusById, approvalRuleIds, fetchState, error, listeningToPusherEvent, newApprovalRuleId, } = remiSetupApproverViewState;
|
|
10
|
+
const { approvalRulesDeleteStatusById, approvalRuleIds, approverListState, fetchState, error, listeningToPusherEvent, newApprovalRuleId, } = remiSetupApproverViewState;
|
|
11
11
|
const deleteStateList = Object.values(approvalRulesDeleteStatusById);
|
|
12
12
|
const approvalRules = getApprovalRulesByIds(approvalRuleState, approvalRuleIds);
|
|
13
13
|
const allApprovalRules = approvalRules.map((approvalRule) => {
|
|
@@ -36,10 +36,15 @@ export const getRemiSetupApproverView = (state, filterAdmins = true) => {
|
|
|
36
36
|
name: 'Require Info',
|
|
37
37
|
code: 'require_info',
|
|
38
38
|
};
|
|
39
|
+
const activeApproverIds = new Set(approverListState.approverIds);
|
|
40
|
+
const referencedApproverIds = new Set(allApprovalRules.flatMap((approvalRule) => approvalRule.steps.flatMap((step) => step.actors.map((actor) => actor.userId))));
|
|
41
|
+
const inactiveApproverIds = Array.from(referencedApproverIds).filter((userId) => !activeApproverIds.has(userId));
|
|
39
42
|
return {
|
|
40
43
|
allApprovalRules,
|
|
41
44
|
deleteStatus: reduceAnyFetchState(deleteStateList),
|
|
42
45
|
approvalRulesStatus,
|
|
46
|
+
approverListFetchStatus: approverListState.fetchStatus,
|
|
47
|
+
inactiveApproverIds,
|
|
43
48
|
fetchState,
|
|
44
49
|
error,
|
|
45
50
|
listeningToPusherEvent,
|
|
@@ -74,6 +79,19 @@ export const getRemiSetupApproverUpdateDataView = createSelector((state) => stat
|
|
|
74
79
|
};
|
|
75
80
|
})
|
|
76
81
|
.filter((approver) => approver.user != null);
|
|
82
|
+
const activeApproverIds = new Set(approverIds);
|
|
83
|
+
const currentRuleSteps = remiSetupApproverViewUpdateData?.data?.steps ?? [];
|
|
84
|
+
const inactiveActorUserIds = new Set(currentRuleSteps
|
|
85
|
+
.flatMap((step) => step.actors.map((actor) => actor.userId))
|
|
86
|
+
.filter((userId) => userId != null && !activeApproverIds.has(userId)));
|
|
87
|
+
const inactiveActorApprovers = Array.from(inactiveActorUserIds)
|
|
88
|
+
.map((userId) => {
|
|
89
|
+
return {
|
|
90
|
+
user: getUserByUserId(userState, userId),
|
|
91
|
+
role: getUserRoleByUserId(userRoleState, userId),
|
|
92
|
+
};
|
|
93
|
+
})
|
|
94
|
+
.filter((approver) => approver.user != null);
|
|
77
95
|
const allAttributes = attributes;
|
|
78
96
|
const filteredApprovers = cloneDeep(allApprovers);
|
|
79
97
|
const filteredAttributes = cloneDeep(attributes);
|
|
@@ -108,6 +126,7 @@ export const getRemiSetupApproverUpdateDataView = createSelector((state) => stat
|
|
|
108
126
|
allAttributes,
|
|
109
127
|
filteredApprovers,
|
|
110
128
|
filteredAttributes,
|
|
129
|
+
inactiveActorApprovers,
|
|
111
130
|
allAccountingClasses,
|
|
112
131
|
remiSetupApproverViewUpdateData,
|
|
113
132
|
approversDetailsFetchStatus: reduceAllFetchState([
|