@zeniai/client-epic-state 5.2.7-betaRD1 → 5.2.8
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/invoicing/invoicingCommonPayload.d.ts +22 -0
- package/lib/entity/invoicing/invoicingCommonPayload.js +51 -10
- package/lib/entity/jeSchedules/jeScheduleHelper.d.ts +0 -1
- package/lib/entity/jeSchedules/jeScheduleHelper.js +0 -7
- package/lib/entity/jeSchedules/jeSchedulesPayload.d.ts +1 -66
- package/lib/entity/jeSchedules/jeSchedulesPayload.js +0 -135
- package/lib/entity/jeSchedules/jeSchedulesReducer.d.ts +2 -4
- package/lib/entity/jeSchedules/jeSchedulesReducer.js +2 -30
- package/lib/entity/jeSchedules/jeSchedulesSelector.d.ts +2 -11
- package/lib/entity/jeSchedules/jeSchedulesSelector.js +3 -38
- package/lib/entity/jeSchedules/jeSchedulesState.d.ts +1 -79
- package/lib/entity/jeSchedules/jeSchedulesTypes.d.ts +1 -24
- package/lib/entity/jeSchedules/jeSchedulesTypes.js +1 -88
- package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
- package/lib/entity/snackbar/snackbarTypes.js +0 -3
- 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 -9
- package/lib/epic.js +0 -16
- package/lib/esm/entity/invoicing/invoicingCommonPayload.js +51 -10
- package/lib/esm/entity/jeSchedules/jeScheduleHelper.js +0 -6
- package/lib/esm/entity/jeSchedules/jeSchedulesPayload.js +1 -135
- package/lib/esm/entity/jeSchedules/jeSchedulesReducer.js +2 -30
- package/lib/esm/entity/jeSchedules/jeSchedulesSelector.js +2 -36
- package/lib/esm/entity/jeSchedules/jeSchedulesTypes.js +0 -78
- package/lib/esm/entity/snackbar/snackbarTypes.js +0 -3
- package/lib/esm/entity/transaction/payloadTypes/scheduleTransactionPayload.js +0 -2
- package/lib/esm/epic.js +0 -16
- package/lib/esm/index.js +8 -14
- package/lib/esm/view/accountList/accountListReducer.js +0 -1
- package/lib/esm/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +3 -6
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +5 -41
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/ignoreRecommendedJeScheduleEpic.js +2 -14
- package/lib/esm/view/expenseAutomationView/payload/jeSchedulesPayload.js +0 -55
- package/lib/esm/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +29 -306
- package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +22 -294
- package/lib/esm/view/expenseAutomationView/types/jeSchedulesViewState.js +6 -5
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewSelector.js +2 -1
- package/lib/esm/view/invoicing/invoicingConfigView/invoicingConfigViewSelector.js +2 -0
- package/lib/esm/view/invoicing/invoicingQboView/epics/fetchInvoicingAccountingPickersEpic.js +10 -5
- package/lib/esm/view/invoicing/invoicingQboView/invoicingQboViewSelector.js +27 -3
- package/lib/esm/view/invoicing/settingsView/settingsViewSelector.js +7 -3
- package/lib/esm/view/scheduleView/scheduleListView/epics/fetchAccruedScheduleListEpic.js +1 -1
- package/lib/esm/view/scheduleView/scheduleListView/epics/fetchDownloadSchedulesEpic.js +2 -7
- package/lib/esm/view/scheduleView/scheduleListView/scheduleListReducer.js +3 -5
- package/lib/index.d.ts +12 -17
- package/lib/index.js +47 -91
- package/lib/view/accountList/accountListReducer.js +0 -1
- package/lib/view/accountList/accountListState.d.ts +1 -1
- package/lib/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +3 -6
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.d.ts +2 -3
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +3 -39
- package/lib/view/expenseAutomationView/epics/jeSchedule/ignoreRecommendedJeScheduleEpic.js +2 -14
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
- package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.d.ts +3 -72
- package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.js +1 -58
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +12 -91
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +29 -308
- 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 +7 -36
- package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.d.ts +0 -34
- package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +21 -302
- package/lib/view/expenseAutomationView/types/completedSubTab.d.ts +1 -1
- package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +8 -82
- package/lib/view/expenseAutomationView/types/jeSchedulesViewState.js +8 -8
- package/lib/view/expenseAutomationView/types/reconciliationViewState.d.ts +1 -1
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewSelector.d.ts +5 -0
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewSelector.js +1 -0
- package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewSelector.d.ts +1 -0
- package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewSelector.js +2 -0
- package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingAccountingPickersEpic.js +10 -5
- package/lib/view/invoicing/invoicingQboView/invoicingQboViewSelector.d.ts +9 -1
- package/lib/view/invoicing/invoicingQboView/invoicingQboViewSelector.js +30 -4
- package/lib/view/invoicing/settingsView/settingsViewSelector.d.ts +11 -4
- package/lib/view/invoicing/settingsView/settingsViewSelector.js +7 -3
- package/lib/view/scheduleView/scheduleListView/epics/fetchAccruedScheduleListEpic.js +1 -1
- package/lib/view/scheduleView/scheduleListView/epics/fetchDownloadSchedulesEpic.js +2 -7
- package/lib/view/scheduleView/scheduleListView/scheduleListReducer.d.ts +2 -4
- package/lib/view/scheduleView/scheduleListView/scheduleListReducer.js +3 -5
- package/package.json +1 -1
- package/lib/commonStateTypes/selectorTypes/pickAndMergeForecastSection.d.ts +0 -0
- package/lib/commonStateTypes/selectorTypes/pickAndMergeForecastSection.js +0 -1
- package/lib/entity/invoicing/coupon/couponConstants.d.ts +0 -11
- package/lib/entity/invoicing/coupon/couponConstants.js +0 -29
- package/lib/esm/commonStateTypes/selectorTypes/pickAndMergeForecastSection.js +0 -1
- package/lib/esm/entity/invoicing/coupon/couponConstants.js +0 -26
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic.js +0 -45
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.js +0 -81
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +0 -25
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js +0 -110
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +0 -79
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.js +0 -139
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.js +0 -106
- 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 -106
- package/lib/esm/view/invoicing/invoicingQboView/epics/fetchInvoicingQboAccountsEpic.js +0 -25
- package/lib/esm/view/invoicing/invoicingQboView/epics/fetchInvoicingQboClassesEpic.js +0 -15
- package/lib/esm/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoIntroClosedByOutsideClickEpic.js +0 -18
- package/lib/esm/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoRemindMeLaterClickedEpic.js +0 -18
- package/lib/esm/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryVideoViewedEpic.js +0 -18
- package/lib/esm/view/zeniAccountsPromoCard/zeniAccountsPromoCardEpic.js +0 -16
- package/lib/esm/view/zeniAccountsPromoCard/zeniAccountsPromoCardPayload.js +0 -1
- package/lib/esm/view/zeniAccountsPromoCard/zeniAccountsPromoCardReducer.js +0 -60
- package/lib/esm/view/zeniAccountsPromoCard/zeniAccountsPromoCardSelector.js +0 -12
- package/lib/esm/view/zeniAccountsPromoCard/zeniAccountsPromoCardState.js +0 -1
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic.d.ts +0 -20
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic.js +0 -49
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.d.ts +0 -8
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.js +0 -85
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.d.ts +0 -8
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +0 -29
- 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 -83
- package/lib/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.d.ts +0 -12
- package/lib/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.js +0 -146
- package/lib/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.d.ts +0 -64
- package/lib/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.js +0 -110
- 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 -42
- package/lib/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +0 -2
- package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.d.ts +0 -21
- package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +0 -112
- package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingQboAccountsEpic.d.ts +0 -6
- package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingQboAccountsEpic.js +0 -29
- package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingQboClassesEpic.d.ts +0 -6
- package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingQboClassesEpic.js +0 -19
- package/lib/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoIntroClosedByOutsideClickEpic.d.ts +0 -8
- package/lib/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoIntroClosedByOutsideClickEpic.js +0 -22
- package/lib/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoRemindMeLaterClickedEpic.d.ts +0 -8
- package/lib/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoRemindMeLaterClickedEpic.js +0 -22
- package/lib/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryVideoViewedEpic.d.ts +0 -8
- package/lib/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryVideoViewedEpic.js +0 -22
- package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardEpic.d.ts +0 -13
- package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardEpic.js +0 -20
- package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardPayload.d.ts +0 -11
- package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardPayload.js +0 -2
- package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardReducer.d.ts +0 -7
- package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardReducer.js +0 -64
- package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardSelector.d.ts +0 -12
- package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardSelector.js +0 -15
- package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardState.d.ts +0 -9
- package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardState.js +0 -2
|
@@ -3,9 +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 { getJEAccruedScheduleByJEScheduleKey, getJEOneTimeAccrualByKey, getJEScheduledTransactionByJEScheduleTransactionKey, } from '../../../entity/jeSchedules/jeSchedulesSelector';
|
|
8
|
-
import { ALL_SCHEDULES_TYPES, } from '../../../entity/jeSchedules/jeSchedulesTypes';
|
|
6
|
+
import { getJEScheduledTransactionByJEScheduleTransactionKey, } from '../../../entity/jeSchedules/jeSchedulesSelector';
|
|
9
7
|
import { getCurrentTenant } from '../../../entity/tenant/tenantSelector';
|
|
10
8
|
import { getAccountIdsForLabel, getAccountList, getNestedAccountListHierarchy, getUncategorizedAccounts, } from '../../accountList/accountListSelector';
|
|
11
9
|
import { getClassList, getNestedClassListHierarchy, } from '../../classList/classListSelector';
|
|
@@ -13,126 +11,8 @@ import { getAccountsTypesForScheduleDetails } from '../../scheduleView/scheduleD
|
|
|
13
11
|
import { filterNestedAccountHierarchyById } from '../../scheduleView/scheduleDetailView/scheduleDetailSelector';
|
|
14
12
|
import { getAccountLabelForScheduleType, getAccountsTypesForScheduleList, } from '../../scheduleView/scheduleListView/scheduleListHelper';
|
|
15
13
|
import { getAllSteps } from './getAllStepsHelper';
|
|
16
|
-
import { ALL_JE_PAGE_TABS, getJESchedulePeriodTabKey, } from '../types/jeSchedulesViewState';
|
|
17
14
|
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
|
-
}
|
|
43
|
-
export function getJEScheduleRowType(schedule) {
|
|
44
|
-
return isOneTimeAccrualRow(schedule)
|
|
45
|
-
? ONE_TIME_ACCRUAL_SCHEDULE_TYPE
|
|
46
|
-
: schedule.jeScheduleType;
|
|
47
|
-
}
|
|
48
|
-
export function isPendingReviewRow(schedule) {
|
|
49
|
-
return isOneTimeAccrualRow(schedule)
|
|
50
|
-
? ONE_TIME_ACCRUAL_REVIEW_STATUSES.includes(schedule.accrualStatus)
|
|
51
|
-
: schedule.status.code === 'draft';
|
|
52
|
-
}
|
|
53
|
-
// Belongs on the Existing Schedules tab. For an accrual the endpoint has already filtered to
|
|
54
|
-
// posted, so this only has to agree with that rather than re-derive it.
|
|
55
|
-
export function isExistingTabRow(schedule) {
|
|
56
|
-
return isOneTimeAccrualRow(schedule)
|
|
57
|
-
? schedule.accrualStatus === 'posted'
|
|
58
|
-
: schedule.status.code === 'ongoing';
|
|
59
|
-
}
|
|
60
|
-
// Exported (rather than kept as a closure inside the selector) so it can be
|
|
61
|
-
// unit-tested directly — confidenceScore is a separate, more narrowly
|
|
62
|
-
// populated field that can be null on a schedule the bot user created,
|
|
63
|
-
// which previously caused these schedules to display as "AI Accountant" in
|
|
64
|
-
// the list but count under "Manual" in the KPI summary.
|
|
65
|
-
export const isAiAccountantSchedule = (schedule) => {
|
|
66
|
-
// A one-time accrual records who made it as `origin`, which is authoritative — no email
|
|
67
|
-
// sniffing needed, and the JE bot is often absent from the user entity entirely.
|
|
68
|
-
if (isOneTimeAccrualRow(schedule)) {
|
|
69
|
-
return schedule.origin === 'agent';
|
|
70
|
-
}
|
|
71
|
-
return (schedule.createdByUser?.email === AI_BOT_EMAIL ||
|
|
72
|
-
schedule.createdByUser?.email === BOT_EMAIL);
|
|
73
|
-
};
|
|
74
|
-
// Accrued schedules are structurally distinct — no baseTransaction, carrying recurringAmount and
|
|
75
|
-
// memo in its place — so anything reading baseTransaction has to branch on this first.
|
|
76
|
-
//
|
|
77
|
-
// Discriminates on jeAccruedScheduleKey, which only JEAccruedSchedule carries. jeScheduleType
|
|
78
|
-
// cannot be used: it is a data field present on BOTH row shapes, so an accrued-typed row that
|
|
79
|
-
// arrived through the prepaid/fixed DTO (failed_je_postings, legacy fetches) would be
|
|
80
|
-
// misclassified and then crash on recurringAmount / jeAccruedScheduleKey.
|
|
81
|
-
export function isAccruedScheduleRow(schedule) {
|
|
82
|
-
return 'jeAccruedScheduleKey' in schedule;
|
|
83
|
-
}
|
|
84
|
-
// Same structural approach as isAccruedScheduleRow, and for the same reason: jeOneTimeAccrualKey
|
|
85
|
-
// exists only on this shape. Note the two guards are NOT interchangeable — a one-time accrual is
|
|
86
|
-
// not an accrued *schedule*, and routing it into the accrued branch would read recurringAmount,
|
|
87
|
-
// render postedCount/lifecycleTotal as a lifecycle and startDate–endDate as a period, none of
|
|
88
|
-
// which it has.
|
|
89
|
-
export function isOneTimeAccrualRow(schedule) {
|
|
90
|
-
return 'jeOneTimeAccrualKey' in schedule;
|
|
91
|
-
}
|
|
92
|
-
function getScheduleAmount(schedule) {
|
|
93
|
-
if (isOneTimeAccrualRow(schedule)) {
|
|
94
|
-
return schedule.estimatedAmount.amount;
|
|
95
|
-
}
|
|
96
|
-
if (isAccruedScheduleRow(schedule)) {
|
|
97
|
-
return schedule.recurringAmount.amount;
|
|
98
|
-
}
|
|
99
|
-
return schedule.baseTransaction.amount.amount;
|
|
100
|
-
}
|
|
101
|
-
// A one-time accrual shares almost no sortable field with a schedule, so it gets its own accessor
|
|
102
|
-
// rather than a guard on each of the dozen cases below. Keys with no meaning for a single-month
|
|
103
|
-
// accrual -- amortizationPeriod, remainingMonths, runningBalance, jePostingDate, scheduleCategory --
|
|
104
|
-
// deliberately fall through to undefined, which sorts them together at one end.
|
|
105
|
-
function getOneTimeAccrualSortValue(accrual, sortKey) {
|
|
106
|
-
switch (sortKey) {
|
|
107
|
-
case 'vendor':
|
|
108
|
-
return accrual.vendorName.toLowerCase();
|
|
109
|
-
case 'category':
|
|
110
|
-
return accrual.jeDebitAccountName?.toLowerCase();
|
|
111
|
-
case 'class':
|
|
112
|
-
return accrual.jeDebitAccountingClassName?.toLowerCase();
|
|
113
|
-
case 'depCategory':
|
|
114
|
-
return accrual.jeCreditAccountName?.toLowerCase();
|
|
115
|
-
case 'type':
|
|
116
|
-
return ONE_TIME_ACCRUAL_SCHEDULE_TYPE;
|
|
117
|
-
case 'totalAmount':
|
|
118
|
-
return accrual.estimatedAmount.amount;
|
|
119
|
-
case 'transactionDate':
|
|
120
|
-
return accrual.postingDate?.valueOf();
|
|
121
|
-
case 'memo':
|
|
122
|
-
return accrual.memo.toLowerCase();
|
|
123
|
-
case 'startMonth':
|
|
124
|
-
return accrual.serviceMonth;
|
|
125
|
-
default:
|
|
126
|
-
return undefined;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
15
|
function getJEScheduleSortAccessor(sortKey) {
|
|
130
|
-
const scheduleAccessor = getScheduleRowSortAccessor(sortKey);
|
|
131
|
-
return (schedule) => isOneTimeAccrualRow(schedule)
|
|
132
|
-
? getOneTimeAccrualSortValue(schedule, sortKey)
|
|
133
|
-
: scheduleAccessor(schedule);
|
|
134
|
-
}
|
|
135
|
-
function getScheduleRowSortAccessor(sortKey) {
|
|
136
16
|
switch (sortKey) {
|
|
137
17
|
case 'vendor':
|
|
138
18
|
return (s) => s.vendor.name?.toLowerCase();
|
|
@@ -143,9 +23,7 @@ function getScheduleRowSortAccessor(sortKey) {
|
|
|
143
23
|
case 'depCategory':
|
|
144
24
|
return (s) => s.jeCredit.account?.accountName?.toLowerCase();
|
|
145
25
|
case 'scheduleCategory':
|
|
146
|
-
return (s) =>
|
|
147
|
-
? undefined
|
|
148
|
-
: s.baseTransaction.account?.accountName?.toLowerCase();
|
|
26
|
+
return (s) => s.baseTransaction.account?.accountName?.toLowerCase();
|
|
149
27
|
case 'startMonth':
|
|
150
28
|
return (s) => s.startDate?.valueOf();
|
|
151
29
|
case 'type':
|
|
@@ -173,13 +51,11 @@ function getScheduleRowSortAccessor(sortKey) {
|
|
|
173
51
|
return s.balanceAsOfToday?.amount ?? null;
|
|
174
52
|
};
|
|
175
53
|
case 'totalAmount':
|
|
176
|
-
return (s) =>
|
|
54
|
+
return (s) => s.baseTransaction.amount.amount;
|
|
177
55
|
case 'transactionDate':
|
|
178
|
-
return (s) => s.
|
|
56
|
+
return (s) => s.baseTransaction.date.valueOf();
|
|
179
57
|
case 'memo':
|
|
180
|
-
return (s) =>
|
|
181
|
-
? s.memo.toLowerCase()
|
|
182
|
-
: s.baseTransaction.memo?.toLowerCase();
|
|
58
|
+
return (s) => s.baseTransaction.memo?.toLowerCase();
|
|
183
59
|
default:
|
|
184
60
|
return (s) => s.startDate?.valueOf();
|
|
185
61
|
}
|
|
@@ -191,15 +67,9 @@ function sortJEScheduledTransactions(transactions, sortKey, sortOrder) {
|
|
|
191
67
|
export function getExpenseAutomationJESchedulesView(state) {
|
|
192
68
|
const jeScheduledTransaction = [];
|
|
193
69
|
const failedJeScheduledTransaction = [];
|
|
194
|
-
const accruedSchedules = [];
|
|
195
|
-
const oneTimeAccruals = [];
|
|
196
70
|
const { accountState, accountListState, classState, classListState, expenseAutomationJESchedulesViewState, expenseAutomationViewState, monthEndCloseChecksState, monthEndCloseChecksViewState, } = state;
|
|
197
|
-
const {
|
|
71
|
+
const { jeScheduleTransactionKeysByPeriod, failedJeScheduleTransactionKeysByPeriod, jeScheduleLocalDataById, postStatusById, ignoreStatusById, uiState, error, fetchState, refreshStatus, } = expenseAutomationJESchedulesViewState;
|
|
198
72
|
const accountSettingsView = getJEAccountSettingsView(state);
|
|
199
|
-
const newScheduleView = newSchedule.selectedDetailScheduleType === 'fixed_assets' ||
|
|
200
|
-
newSchedule.selectedDetailScheduleType === 'prepaid_expenses'
|
|
201
|
-
? getNewScheduleView(state, newSchedule.selectedDetailScheduleType)
|
|
202
|
-
: undefined;
|
|
203
73
|
const currentTenant = getCurrentTenant(state);
|
|
204
74
|
const { selectedPeriodByTenantId } = expenseAutomationViewState;
|
|
205
75
|
const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
|
|
@@ -227,48 +97,27 @@ export function getExpenseAutomationJESchedulesView(state) {
|
|
|
227
97
|
const filteredDepAccountListNestedAccountHierarchy = filterNestedAccountHierarchyById(depAccountListNestedAccountHierarchy, filteredDepAccounts.map((account) => account.accountId));
|
|
228
98
|
const classListNestedAccountHierarchy = getNestedClassListHierarchy(classListState);
|
|
229
99
|
const monthYearPeriodId = selectedPeriod != null ? toMonthYearPeriodId(selectedPeriod) : null;
|
|
230
|
-
const
|
|
231
|
-
?
|
|
100
|
+
const jeScheduleTransactionKeysForSelectedPeriod = monthYearPeriodId != null
|
|
101
|
+
? jeScheduleTransactionKeysByPeriod[monthYearPeriodId]
|
|
232
102
|
: null;
|
|
233
|
-
const
|
|
234
|
-
?
|
|
235
|
-
:
|
|
236
|
-
const
|
|
237
|
-
|
|
238
|
-
: undefined;
|
|
239
|
-
// Distinguishes "this tab has never been fetched for this period" from "fetched and genuinely
|
|
240
|
-
// empty". Without it the page cannot tell a first visit from a real empty state, and renders an
|
|
241
|
-
// empty table where it should render a skeleton.
|
|
242
|
-
const hasLoadedForSelectedTab = jeScheduleTransactionKeysForSelectedTab != null;
|
|
243
|
-
const jeScheduleTransactionKeys = jeScheduleTransactionKeysForSelectedTab ?? [];
|
|
244
|
-
const failedJeScheduleTransactionKeys = failedJeScheduleTransactionKeysForSelectedTab ?? [];
|
|
245
|
-
const jeScheduleAccruedKeys = (selectedPeriodTabKey != null
|
|
246
|
-
? jeScheduleAccruedKeysByPeriodAndTab[selectedPeriodTabKey]
|
|
247
|
-
: undefined) ?? [];
|
|
248
|
-
const jeScheduleOneTimeAccrualKeys = (selectedPeriodTabKey != null
|
|
249
|
-
? jeScheduleOneTimeAccrualKeysByPeriodAndTab[selectedPeriodTabKey]
|
|
250
|
-
: undefined) ?? [];
|
|
251
|
-
jeScheduleOneTimeAccrualKeys.forEach((jeOneTimeAccrualKey) => {
|
|
252
|
-
const accrual = getJEOneTimeAccrualByKey(jeOneTimeAccrualKey, state.jeSchedulesState);
|
|
253
|
-
if (accrual != null && isRenderableOneTimeAccrual(accrual)) {
|
|
254
|
-
oneTimeAccruals.push(accrual);
|
|
255
|
-
}
|
|
256
|
-
});
|
|
103
|
+
const failedJeScheduleTransactionKeysForSelectedPeriod = monthYearPeriodId != null
|
|
104
|
+
? failedJeScheduleTransactionKeysByPeriod[monthYearPeriodId]
|
|
105
|
+
: null;
|
|
106
|
+
const jeScheduleTransactionKeys = jeScheduleTransactionKeysForSelectedPeriod ?? [];
|
|
107
|
+
const failedJeScheduleTransactionKeys = failedJeScheduleTransactionKeysForSelectedPeriod ?? [];
|
|
257
108
|
jeScheduleTransactionKeys.forEach((jeScheduleKey) => {
|
|
258
109
|
const jeScheduleDetails = getJEScheduledTransactionByJEScheduleTransactionKey(jeScheduleKey, state);
|
|
259
110
|
jeScheduledTransaction.push(jeScheduleDetails);
|
|
260
111
|
});
|
|
261
|
-
jeScheduleAccruedKeys.forEach((jeAccruedScheduleKey) => {
|
|
262
|
-
const accruedScheduleDetails = getJEAccruedScheduleByJEScheduleKey(jeAccruedScheduleKey, state);
|
|
263
|
-
if (accruedScheduleDetails != null) {
|
|
264
|
-
accruedSchedules.push(accruedScheduleDetails);
|
|
265
|
-
}
|
|
266
|
-
});
|
|
267
112
|
failedJeScheduleTransactionKeys.forEach((jeScheduleKey) => {
|
|
268
113
|
const jeScheduleDetails = getJEScheduledTransactionByJEScheduleTransactionKey(jeScheduleKey, state);
|
|
269
114
|
failedJeScheduledTransaction.push(jeScheduleDetails);
|
|
270
115
|
});
|
|
271
|
-
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);
|
|
272
121
|
const unsortedResolveSchedules = [];
|
|
273
122
|
failedJeScheduledTransaction.forEach((schedule) => {
|
|
274
123
|
schedule.scheduledJournalEntry.forEach((journalEntry) => {
|
|
@@ -280,87 +129,10 @@ export function getExpenseAutomationJESchedulesView(state) {
|
|
|
280
129
|
});
|
|
281
130
|
const resolveSchedules = sortJEScheduledTransactions(unsortedResolveSchedules, sortKey, sortOrder);
|
|
282
131
|
const validResolveForPending = unsortedResolveSchedules.filter((r) => jeScheduleLocalDataById[r.scheduledJournalEntry.scheduledJournalEntryID] != null);
|
|
283
|
-
const matchesTypeFilter = (schedule) => selectedJETypeFilter == null ||
|
|
284
|
-
getJEScheduleRowType(schedule) === selectedJETypeFilter;
|
|
285
|
-
const isCreatedStatus = (schedule) => {
|
|
286
|
-
// An accrual is "created" once it is not review work: posted, reversing, reversed, or in a
|
|
287
|
-
// transient posting claim.
|
|
288
|
-
if (isOneTimeAccrualRow(schedule)) {
|
|
289
|
-
return !isPendingReviewRow(schedule);
|
|
290
|
-
}
|
|
291
|
-
return (schedule.status.code === 'ongoing' ||
|
|
292
|
-
schedule.status.code === 'completed' ||
|
|
293
|
-
schedule.status.code === 'marked_as_completed');
|
|
294
|
-
};
|
|
295
|
-
const allScheduleRows = [
|
|
296
|
-
...jeScheduledTransaction,
|
|
297
|
-
...accruedSchedules,
|
|
298
|
-
...oneTimeAccruals,
|
|
299
|
-
];
|
|
300
132
|
const pendingReviewSchedules = sortJEScheduledTransactions([
|
|
301
|
-
...
|
|
133
|
+
...jeScheduledTransaction.filter((schedule) => schedule.status.code === 'draft'),
|
|
302
134
|
...validResolveForPending,
|
|
303
135
|
], sortKey, sortOrder);
|
|
304
|
-
const createdSchedules = sortJEScheduledTransactions(allScheduleRows.filter((schedule) => isCreatedStatus(schedule) && matchesTypeFilter(schedule)), sortKey, sortOrder);
|
|
305
|
-
// KPI summary — derived from unfiltered schedules so counts are always accurate
|
|
306
|
-
const allSchedules = allScheduleRows;
|
|
307
|
-
const sumAmount = (schedules) => schedules.reduce((total, schedule) => total + (getScheduleAmount(schedule) ?? 0), 0);
|
|
308
|
-
const pendingReviewTotal = sumAmount(pendingReviewSchedules);
|
|
309
|
-
const createdTotal = sumAmount(createdSchedules);
|
|
310
|
-
const aiAccountantSchedules = allSchedules.filter(isAiAccountantSchedule);
|
|
311
|
-
const manualSchedules = allSchedules.filter((schedule) => !isAiAccountantSchedule(schedule));
|
|
312
|
-
const pendingUnfiltered = allSchedules.filter((schedule) => isPendingReviewRow(schedule));
|
|
313
|
-
const kpiSummary = {
|
|
314
|
-
aiAccountant: {
|
|
315
|
-
count: aiAccountantSchedules.length,
|
|
316
|
-
amount: sumAmount(aiAccountantSchedules),
|
|
317
|
-
},
|
|
318
|
-
manual: {
|
|
319
|
-
count: manualSchedules.length,
|
|
320
|
-
amount: sumAmount(manualSchedules),
|
|
321
|
-
},
|
|
322
|
-
needsReview: {
|
|
323
|
-
count: pendingUnfiltered.length,
|
|
324
|
-
amount: sumAmount(pendingUnfiltered),
|
|
325
|
-
},
|
|
326
|
-
total: {
|
|
327
|
-
count: allSchedules.length,
|
|
328
|
-
amount: sumAmount(allSchedules),
|
|
329
|
-
},
|
|
330
|
-
};
|
|
331
|
-
// Each tab's badge counts from that tab's own bucket. A tab that has not been fetched yet
|
|
332
|
-
// reports undefined rather than 0, so the UI can hide the badge instead of asserting "none".
|
|
333
|
-
const scheduleCountsByTab = {};
|
|
334
|
-
ALL_JE_PAGE_TABS.forEach((pageTab) => {
|
|
335
|
-
const periodTabKey = monthYearPeriodId != null
|
|
336
|
-
? getJESchedulePeriodTabKey(pageTab, monthYearPeriodId)
|
|
337
|
-
: null;
|
|
338
|
-
const transactionKeys = periodTabKey != null
|
|
339
|
-
? jeScheduleTransactionKeysByPeriodAndTab[periodTabKey]
|
|
340
|
-
: undefined;
|
|
341
|
-
if (transactionKeys == null) {
|
|
342
|
-
return;
|
|
343
|
-
}
|
|
344
|
-
const accruedKeys = (periodTabKey != null
|
|
345
|
-
? jeScheduleAccruedKeysByPeriodAndTab[periodTabKey]
|
|
346
|
-
: undefined) ?? [];
|
|
347
|
-
const oneTimeAccrualKeys = (periodTabKey != null
|
|
348
|
-
? jeScheduleOneTimeAccrualKeysByPeriodAndTab[periodTabKey]
|
|
349
|
-
: undefined) ?? [];
|
|
350
|
-
const rowsForTab = [
|
|
351
|
-
...transactionKeys.map((transactionKey) => getJEScheduledTransactionByJEScheduleTransactionKey(transactionKey, state)),
|
|
352
|
-
...accruedKeys
|
|
353
|
-
.map((accruedKey) => getJEAccruedScheduleByJEScheduleKey(accruedKey, state))
|
|
354
|
-
.filter((accruedRow) => accruedRow != null),
|
|
355
|
-
...oneTimeAccrualKeys
|
|
356
|
-
.map((accrualKey) => getJEOneTimeAccrualByKey(accrualKey, state.jeSchedulesState))
|
|
357
|
-
.filter((accrualRow) => accrualRow != null && isRenderableOneTimeAccrual(accrualRow)),
|
|
358
|
-
];
|
|
359
|
-
scheduleCountsByTab[pageTab] =
|
|
360
|
-
pageTab === 'existing_schedules'
|
|
361
|
-
? rowsForTab.filter((row) => isExistingTabRow(row)).length
|
|
362
|
-
: rowsForTab.filter((row) => isPendingReviewRow(row) || isCreatedStatus(row)).length;
|
|
363
|
-
});
|
|
364
136
|
const allSteps = monthYearPeriodId != null
|
|
365
137
|
? getAllSteps(monthEndCloseChecksState, monthYearPeriodId, currentTenant.tenantId)
|
|
366
138
|
: [];
|
|
@@ -373,20 +145,6 @@ export function getExpenseAutomationJESchedulesView(state) {
|
|
|
373
145
|
{ fetchState, error },
|
|
374
146
|
monthEndFetchState,
|
|
375
147
|
]);
|
|
376
|
-
const countByType = (schedules) => {
|
|
377
|
-
const counts = ALL_SCHEDULES_TYPES.reduce((acc, type) => ({ ...acc, [type]: 0 }), {});
|
|
378
|
-
schedules.forEach((schedule) => {
|
|
379
|
-
const scheduleType = getJEScheduleRowType(schedule);
|
|
380
|
-
if (scheduleType != null) {
|
|
381
|
-
counts[scheduleType] += 1;
|
|
382
|
-
}
|
|
383
|
-
});
|
|
384
|
-
return counts;
|
|
385
|
-
};
|
|
386
|
-
const jeScheduleTypeCounts = {
|
|
387
|
-
active: countByType(allSchedules.filter((schedule) => isPendingReviewRow(schedule) || isCreatedStatus(schedule))),
|
|
388
|
-
ongoing: countByType(allSchedules.filter((schedule) => isExistingTabRow(schedule))),
|
|
389
|
-
};
|
|
390
148
|
return {
|
|
391
149
|
uncategorizedAccounts,
|
|
392
150
|
allDepreciationAccountList: filteredDepAccounts,
|
|
@@ -395,21 +153,14 @@ export function getExpenseAutomationJESchedulesView(state) {
|
|
|
395
153
|
allAccountList: filteredAccounts,
|
|
396
154
|
accountListNestedAccountHierarchy,
|
|
397
155
|
allClassList: allClasses,
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
jeScheduleTypeCounts,
|
|
402
|
-
scheduleCountsByTab,
|
|
403
|
-
kpiSummary,
|
|
156
|
+
completedSchedules,
|
|
157
|
+
draftSchedules,
|
|
158
|
+
ongoingSchedules,
|
|
404
159
|
pendingReviewSchedules,
|
|
405
|
-
pendingReviewTotal,
|
|
406
160
|
resolveSchedules: resolveSchedules,
|
|
407
161
|
accountSettingsView,
|
|
408
|
-
newScheduleView,
|
|
409
162
|
postStatusById: postStatusById,
|
|
410
163
|
ignoreStatusById: ignoreStatusById,
|
|
411
|
-
revertStatusById: revertStatusById,
|
|
412
|
-
oneTimeAccrualActionStatusById: oneTimeAccrualActionStatusById,
|
|
413
164
|
fetchState: reducedFetchStatus.fetchState,
|
|
414
165
|
jeScheduleLocalDataById: jeScheduleLocalDataById,
|
|
415
166
|
uiState: uiState,
|
|
@@ -418,26 +169,3 @@ export function getExpenseAutomationJESchedulesView(state) {
|
|
|
418
169
|
completionStatus,
|
|
419
170
|
};
|
|
420
171
|
}
|
|
421
|
-
/**
|
|
422
|
-
* One accrual plus the status of its promote / ignore request, for the detail screen.
|
|
423
|
-
*
|
|
424
|
-
* `accrual` is undefined on a cold load — a refresh or a shared link, where the list has never run
|
|
425
|
-
* — so the screen dispatches `fetchOneTimeAccrual` and waits on `detailFetchState`. The two states
|
|
426
|
-
* are separate on purpose: `actionFetchState` drives the row spinner and the post-revert navigation,
|
|
427
|
-
* and a page load must not look like an action that just finished.
|
|
428
|
-
*/
|
|
429
|
-
export function getExpenseAutomationJEOneTimeAccrualDetailView(state, accrualId) {
|
|
430
|
-
return {
|
|
431
|
-
accrual: getJEOneTimeAccrualByKey(generateJEOneTimeAccrualKey(accrualId), state.jeSchedulesState),
|
|
432
|
-
actionFetchState: state.expenseAutomationJESchedulesViewState
|
|
433
|
-
.oneTimeAccrualActionStatusById[accrualId] ?? {
|
|
434
|
-
fetchState: 'Not-Started',
|
|
435
|
-
error: undefined,
|
|
436
|
-
},
|
|
437
|
-
detailFetchState: state.expenseAutomationJESchedulesViewState
|
|
438
|
-
.oneTimeAccrualFetchStatusById[accrualId] ?? {
|
|
439
|
-
fetchState: 'Not-Started',
|
|
440
|
-
error: undefined,
|
|
441
|
-
},
|
|
442
|
-
};
|
|
443
|
-
}
|
|
@@ -16,8 +16,9 @@ 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
|
-
|
|
19
|
+
const JE_SCHEDULE_MAIN_TABS = [
|
|
20
|
+
'pending_review',
|
|
21
|
+
'ongoing',
|
|
22
|
+
'completed',
|
|
23
|
+
];
|
|
24
|
+
export const toJEScheduleMainTab = (v) => stringToUnion(v, JE_SCHEDULE_MAIN_TABS);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createSelector } from '@reduxjs/toolkit';
|
|
2
2
|
import { getInvoicingPlanById, getInvoicingPlansByIds, } from '../../../entity/invoicing/plan/planSelector';
|
|
3
3
|
import { getInvoicingConfigView, invoicingFieldHelpForGroup, } from '../invoicingConfigView/invoicingConfigViewSelector';
|
|
4
|
-
import { INVOICING_INCOME_ACCOUNT_TYPES, getInvoicingQboView, invoicingAccountHierarchyForTypes, isInvoicingQboConnected, } from '../invoicingQboView/invoicingQboViewSelector';
|
|
4
|
+
import { INVOICING_INCOME_ACCOUNT_TYPES, getInvoicingQboView, invoicingAccountHierarchyForTypes, isInvoicingAccountingPickerDataLoading, isInvoicingQboConnected, } from '../invoicingQboView/invoicingQboViewSelector';
|
|
5
5
|
import { INVOICING_CATALOG_APPLICABILITY_VALUES, INVOICING_CATALOG_PRICING_MODEL_VALUES, INVOICING_CATALOG_PRORATION_VALUES, INVOICING_CATALOG_TIER_TYPE_VALUES, entityToInvoicingCatalogItemFormLocalData, } from './invoicingCatalogItemFormConfig';
|
|
6
6
|
export const getEditInvoicingCatalogItemDetailViewState = (state) => ({
|
|
7
7
|
fetchState: state.editInvoicingCatalogItemDetailViewState.fetchState,
|
|
@@ -53,6 +53,7 @@ export const getInvoicingCatalogItemFormView = (state, id) => {
|
|
|
53
53
|
const { billingPeriodUnitOptions, catalogItemTypeOptions, catalogTierTypeOptionsByPricingModel, catalogTrialEndActionOptions, catalogTrialUnitOptions, } = getInvoicingConfigView(state);
|
|
54
54
|
return {
|
|
55
55
|
fieldHelp: invoicingFieldHelpForGroup(state, 'catalog'),
|
|
56
|
+
isQboPickerDataLoading: isInvoicingAccountingPickerDataLoading(state),
|
|
56
57
|
qboClassHierarchy: isQboConnected
|
|
57
58
|
? getInvoicingQboView(state).nestedClassHierarchy
|
|
58
59
|
: [],
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isInvoicingQboConnected } from '../invoicingQboView/invoicingQboViewSelector';
|
|
1
2
|
import { deriveInvoicingOnboardingStatus, } from './invoicingConfigViewPayload';
|
|
2
3
|
export const getInvoicingConfigView = (state) => {
|
|
3
4
|
const { acceptTermsFetchState, enableFetchState, ...configState } = state.invoicingConfigViewState;
|
|
@@ -14,6 +15,7 @@ export const getInvoicingOnboardingGateView = (state) => {
|
|
|
14
15
|
acceptTermsState: acceptTermsFetchState,
|
|
15
16
|
enableState: enableFetchState,
|
|
16
17
|
fetchState,
|
|
18
|
+
isQboConnected: isInvoicingQboConnected(state),
|
|
17
19
|
status: deriveInvoicingOnboardingStatus(state.invoicingConfigViewState.isInvoicingTosAccepted, state.invoicingConfigViewState.isInvoicingEnabled),
|
|
18
20
|
};
|
|
19
21
|
};
|
package/lib/esm/view/invoicing/invoicingQboView/epics/fetchInvoicingAccountingPickersEpic.js
CHANGED
|
@@ -9,12 +9,17 @@ import { INVOICING_ACCOUNT_LIST_KEY } from '../invoicingQboViewSelector';
|
|
|
9
9
|
export const fetchInvoicingAccountingPickersEpic = (actions$, state$) => actions$.pipe(filter(fetchInvoicingAccountingPickers.match), withLatestFrom(state$), mergeMap(([, state]) => {
|
|
10
10
|
const actions = [];
|
|
11
11
|
const accountList = state.accountListState.byReportId[INVOICING_ACCOUNT_LIST_KEY];
|
|
12
|
-
|
|
12
|
+
// `hasValidState` only reports that a fetch finished, not that it
|
|
13
|
+
// returned anything usable. The shared bucket can be Completed and empty
|
|
14
|
+
// because a screen that needs fewer accounts filled it first, which would
|
|
15
|
+
// leave the invoicing pickers empty with no request in flight to fix it.
|
|
16
|
+
const isAccountListUsable = accountList.hasValidState() && accountList.accountIds.length > 0;
|
|
17
|
+
if (isAccountListUsable === false &&
|
|
13
18
|
accountList.fetchState !== 'In-Progress') {
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
actions.push(fetchAccountList(INVOICING_ACCOUNT_LIST_KEY, true
|
|
19
|
+
// Same arguments the vendor and categorization screens pass, so this
|
|
20
|
+
// shares their cached list rather than replacing it with a narrower one.
|
|
21
|
+
// Invoicing narrows to income accounts when it builds its options.
|
|
22
|
+
actions.push(fetchAccountList(INVOICING_ACCOUNT_LIST_KEY, true));
|
|
18
23
|
}
|
|
19
24
|
const classList = state.classListState;
|
|
20
25
|
if (classList.hasValidState() === false &&
|
|
@@ -1,10 +1,34 @@
|
|
|
1
1
|
import { getAccountList, getNestedAccountListHierarchy, } from '../../accountList/accountListSelector';
|
|
2
2
|
import { getClassList, getNestedClassListHierarchy, } from '../../classList/classListSelector';
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
|
|
3
|
+
// The shared bucket, fetched with the same arguments as the other consumers so
|
|
4
|
+
// whichever screen loads first satisfies the rest. Invoicing narrows to income
|
|
5
|
+
// accounts when it builds its options, so it does not need its own copy.
|
|
6
|
+
export const INVOICING_ACCOUNT_LIST_KEY = 'accountList';
|
|
6
7
|
/** Whether QBO is connected, without building the option lists to find out. */
|
|
7
8
|
export const isInvoicingQboConnected = (state) => state.invoicingQboViewState.connection?.connected === true;
|
|
9
|
+
/**
|
|
10
|
+
* Whether the accounting pickers are still waiting on their data. Only true when
|
|
11
|
+
* QBO is connected: a tenant without it has no pickers to populate, so the form
|
|
12
|
+
* must not sit behind a skeleton waiting for lists it will never show.
|
|
13
|
+
*/
|
|
14
|
+
export const isInvoicingAccountingPickerDataLoading = (state) => {
|
|
15
|
+
const isPending = (fetchState) => fetchState === 'Not-Started' || fetchState === 'In-Progress';
|
|
16
|
+
// The connection settles first and decides whether the lists are fetched at
|
|
17
|
+
// all, so it counts as loading too. Reporting "not loading" while it is in
|
|
18
|
+
// flight renders the form, then takes it away again the moment the tenant
|
|
19
|
+
// turns out to be connected.
|
|
20
|
+
if (isPending(getInvoicingQboConnectionFetchState(state).fetchState)) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
if (!isInvoicingQboConnected(state)) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
const accountList = state.accountListState.byReportId[INVOICING_ACCOUNT_LIST_KEY];
|
|
27
|
+
return (isPending(accountList.fetchState) ||
|
|
28
|
+
isPending(state.classListState.fetchState));
|
|
29
|
+
};
|
|
30
|
+
/** The QBO connection fetch on its own, without building the bundled view. */
|
|
31
|
+
export const getInvoicingQboConnectionFetchState = (state) => state.invoicingQboViewState.connectionFetchState;
|
|
8
32
|
/**
|
|
9
33
|
* Account types that can back invoicing revenue. Named here so screens ask for
|
|
10
34
|
* "income accounts" rather than repeating the accounting service's vocabulary.
|
|
@@ -63,9 +63,10 @@ export function deriveInvoicingEnablePrerequisites(settings, isQboConnected, qbo
|
|
|
63
63
|
* two integration prerequisites kept separate so the hub can name the step still
|
|
64
64
|
* outstanding instead of showing a dead button.
|
|
65
65
|
*
|
|
66
|
-
* `
|
|
67
|
-
*
|
|
68
|
-
*
|
|
66
|
+
* `isInvoicingEnabled` decides whether the footer renders; `canEnableInvoicing`
|
|
67
|
+
* whether its button is live, and it still requires the onboarding step so the
|
|
68
|
+
* terms cannot be skipped. A tenant partway through therefore sees the footer,
|
|
69
|
+
* disabled and naming what is left, rather than nothing at all.
|
|
69
70
|
*
|
|
70
71
|
* Deliberately not folded into `getInvoicingConfigView`: that selector gates
|
|
71
72
|
* every invoicing route and stays a pure read of the config slice. The settings
|
|
@@ -75,7 +76,10 @@ export const getInvoicingSettingsHubView = (state) => {
|
|
|
75
76
|
const { dunningScheduleActionOptions, enableState, error: configError, fetchState: configFetchState, qboAccountMappingKindOptions, qboCustomerMatchingOptions, qboSyncStatusOptions, status, } = getInvoicingConfigView(state);
|
|
76
77
|
const { canEnable, isQboConfigured, isStripeConnected } = deriveInvoicingEnablePrerequisites(state.invoicingSettingsViewState.settings, state.invoicingQboViewState.connection?.connected === true, qboAccountMappingKindOptions);
|
|
77
78
|
return {
|
|
79
|
+
// Keeps the onboarding step in the gate: a tenant that has not accepted the
|
|
80
|
+
// terms cannot enable invoicing, whatever the integrations say.
|
|
78
81
|
canEnableInvoicing: status === 'settings' && canEnable,
|
|
82
|
+
isInvoicingEnabled: state.invoicingConfigViewState.isInvoicingEnabled === true,
|
|
79
83
|
configError,
|
|
80
84
|
configFetchState,
|
|
81
85
|
dunningScheduleActionOptions,
|
|
@@ -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: 'all',
|
|
34
34
|
};
|
|
35
35
|
return zeniAPI
|
|
36
36
|
.getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules?query=${encodeURIComponent(JSON.stringify(queryParam))}`)
|
|
@@ -7,14 +7,9 @@ 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
|
|
10
|
+
const { scheduleType, downloadCategories } = 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.
|
|
18
13
|
let scheduleState;
|
|
19
14
|
if (scheduleType !== 'accrued_expenses') {
|
|
20
15
|
scheduleState = getState(scheduleListState, scheduleType);
|
|
@@ -39,7 +34,7 @@ export const fetchDownloadSchedulesEpic = (actions$, state$, zeniAPI) => actions
|
|
|
39
34
|
base_txn_account_ids: downloadCategories,
|
|
40
35
|
sort_by: 'transaction_date',
|
|
41
36
|
sort_order: 'desc',
|
|
42
|
-
filter:
|
|
37
|
+
filter: 'all',
|
|
43
38
|
};
|
|
44
39
|
return zeniAPI
|
|
45
40
|
.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.
|
|
88
87
|
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,14 +109,13 @@ const scheduleListView = createSlice({
|
|
|
109
109
|
updateState(draft, action.payload.scheduleType, state);
|
|
110
110
|
}
|
|
111
111
|
},
|
|
112
|
-
prepare(scheduleType, timeframeAndCategory, downloadCategories,
|
|
112
|
+
prepare(scheduleType, timeframeAndCategory, downloadCategories, cacheOverride = false) {
|
|
113
113
|
return {
|
|
114
114
|
payload: {
|
|
115
115
|
timeframeAndCategory,
|
|
116
116
|
scheduleType,
|
|
117
117
|
cacheOverride,
|
|
118
118
|
downloadCategories,
|
|
119
|
-
statusFilter,
|
|
120
119
|
},
|
|
121
120
|
};
|
|
122
121
|
},
|
|
@@ -152,13 +151,12 @@ const scheduleListView = createSlice({
|
|
|
152
151
|
updateState(draft, action.payload.scheduleType, state);
|
|
153
152
|
}
|
|
154
153
|
},
|
|
155
|
-
prepare(scheduleType, timeframeAndCategory, cacheOverride = false
|
|
154
|
+
prepare(scheduleType, timeframeAndCategory, cacheOverride = false) {
|
|
156
155
|
return {
|
|
157
156
|
payload: {
|
|
158
157
|
timeframeAndCategory,
|
|
159
158
|
scheduleType,
|
|
160
159
|
cacheOverride,
|
|
161
|
-
statusFilter,
|
|
162
160
|
},
|
|
163
161
|
};
|
|
164
162
|
},
|