@zeniai/client-epic-state 5.2.10 → 5.2.11-betaRD1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonStateTypes/selectorTypes/pickAndMergeForecastSection.d.ts +0 -0
- package/lib/commonStateTypes/selectorTypes/pickAndMergeForecastSection.js +1 -0
- package/lib/entity/invoicing/coupon/couponConstants.d.ts +11 -0
- package/lib/entity/invoicing/coupon/couponConstants.js +29 -0
- package/lib/entity/jeSchedules/jeScheduleHelper.d.ts +1 -0
- package/lib/entity/jeSchedules/jeScheduleHelper.js +7 -0
- package/lib/entity/jeSchedules/jeSchedulesPayload.d.ts +66 -1
- package/lib/entity/jeSchedules/jeSchedulesPayload.js +135 -0
- package/lib/entity/jeSchedules/jeSchedulesReducer.d.ts +4 -2
- package/lib/entity/jeSchedules/jeSchedulesReducer.js +30 -2
- package/lib/entity/jeSchedules/jeSchedulesSelector.d.ts +11 -2
- package/lib/entity/jeSchedules/jeSchedulesSelector.js +38 -3
- package/lib/entity/jeSchedules/jeSchedulesState.d.ts +79 -1
- package/lib/entity/jeSchedules/jeSchedulesTypes.d.ts +24 -1
- package/lib/entity/jeSchedules/jeSchedulesTypes.js +88 -1
- package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
- package/lib/entity/snackbar/snackbarTypes.js +3 -0
- package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.d.ts +2 -0
- package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.js +2 -0
- package/lib/entity/transaction/stateTypes/scheduleTransaction.d.ts +2 -0
- package/lib/epic.d.ts +9 -1
- package/lib/epic.js +16 -0
- package/lib/esm/commonStateTypes/selectorTypes/pickAndMergeForecastSection.js +1 -0
- package/lib/esm/entity/invoicing/coupon/couponConstants.js +26 -0
- package/lib/esm/entity/jeSchedules/jeScheduleHelper.js +6 -0
- package/lib/esm/entity/jeSchedules/jeSchedulesPayload.js +135 -1
- package/lib/esm/entity/jeSchedules/jeSchedulesReducer.js +30 -2
- package/lib/esm/entity/jeSchedules/jeSchedulesSelector.js +36 -2
- package/lib/esm/entity/jeSchedules/jeSchedulesTypes.js +78 -0
- package/lib/esm/entity/snackbar/snackbarTypes.js +3 -0
- package/lib/esm/entity/transaction/payloadTypes/scheduleTransactionPayload.js +2 -0
- package/lib/esm/epic.js +16 -0
- package/lib/esm/index.js +14 -8
- package/lib/esm/view/companyMonthEndReportView/companyMonthEndReportViewReducer.js +6 -2
- package/lib/esm/view/companyMonthEndReportView/companyMonthEndReportViewState.js +4 -0
- package/lib/esm/view/companyMonthEndReportView/epics/saveCompanyMonthEndReportEpic.js +10 -6
- package/lib/esm/view/companyMonthEndReportView/epics/sendCompanyMonthEndReportEpic.js +9 -5
- package/lib/esm/view/companyMonthEndReportView/monthEndTemplateData.js +32 -0
- package/lib/esm/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +6 -3
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +41 -5
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic.js +45 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/ignoreRecommendedJeScheduleEpic.js +14 -2
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.js +99 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +25 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js +110 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +79 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.js +139 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.js +106 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +22 -0
- package/lib/esm/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.js +140 -0
- package/lib/esm/view/expenseAutomationView/payload/jeSchedulesPayload.js +55 -0
- package/lib/esm/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +306 -29
- package/lib/esm/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +1 -0
- package/lib/esm/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +106 -0
- package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +294 -22
- package/lib/esm/view/expenseAutomationView/types/jeSchedulesViewState.js +5 -6
- package/lib/esm/view/invoicing/invoicingQboView/epics/fetchInvoicingQboAccountsEpic.js +25 -0
- package/lib/esm/view/invoicing/invoicingQboView/epics/fetchInvoicingQboClassesEpic.js +15 -0
- package/lib/esm/view/scheduleView/scheduleListView/epics/fetchAccruedScheduleListEpic.js +1 -1
- package/lib/esm/view/scheduleView/scheduleListView/epics/fetchDownloadSchedulesEpic.js +7 -2
- package/lib/esm/view/scheduleView/scheduleListView/scheduleListReducer.js +5 -3
- package/lib/esm/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoIntroClosedByOutsideClickEpic.js +18 -0
- package/lib/esm/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoRemindMeLaterClickedEpic.js +18 -0
- package/lib/esm/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryVideoViewedEpic.js +18 -0
- package/lib/esm/view/zeniAccountsPromoCard/zeniAccountsPromoCardEpic.js +16 -0
- package/lib/esm/view/zeniAccountsPromoCard/zeniAccountsPromoCardPayload.js +1 -0
- package/lib/esm/view/zeniAccountsPromoCard/zeniAccountsPromoCardReducer.js +60 -0
- package/lib/esm/view/zeniAccountsPromoCard/zeniAccountsPromoCardSelector.js +12 -0
- package/lib/esm/view/zeniAccountsPromoCard/zeniAccountsPromoCardState.js +1 -0
- package/lib/index.d.ts +19 -13
- package/lib/index.js +91 -47
- package/lib/view/companyMonthEndReportView/companyMonthEndReportViewPayload.d.ts +8 -0
- package/lib/view/companyMonthEndReportView/companyMonthEndReportViewReducer.d.ts +6 -2
- package/lib/view/companyMonthEndReportView/companyMonthEndReportViewReducer.js +6 -2
- package/lib/view/companyMonthEndReportView/companyMonthEndReportViewState.d.ts +2 -0
- package/lib/view/companyMonthEndReportView/companyMonthEndReportViewState.js +4 -0
- package/lib/view/companyMonthEndReportView/epics/saveCompanyMonthEndReportEpic.js +10 -6
- package/lib/view/companyMonthEndReportView/epics/sendCompanyMonthEndReportEpic.js +9 -5
- package/lib/view/companyMonthEndReportView/monthEndTemplateData.d.ts +16 -0
- package/lib/view/companyMonthEndReportView/monthEndTemplateData.js +36 -0
- package/lib/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +6 -3
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.d.ts +3 -2
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +39 -3
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic.d.ts +20 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic.js +49 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/ignoreRecommendedJeScheduleEpic.js +14 -2
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.d.ts +8 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.js +103 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.d.ts +8 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +29 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.d.ts +45 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js +114 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.d.ts +8 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +83 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.d.ts +12 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.js +146 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.d.ts +64 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.js +110 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.d.ts +6 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +26 -0
- package/lib/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.d.ts +36 -0
- package/lib/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.js +145 -0
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
- package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.d.ts +72 -3
- package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.js +58 -1
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +91 -12
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +308 -29
- package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +1 -1
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +2 -2
- package/lib/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.d.ts +42 -0
- package/lib/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +2 -0
- package/lib/view/expenseAutomationView/selectorTypes/jeSchedulesSelectorTypes.d.ts +36 -7
- package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.d.ts +21 -0
- package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +112 -0
- package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.d.ts +34 -0
- package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +302 -21
- package/lib/view/expenseAutomationView/types/completedSubTab.d.ts +1 -1
- package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +82 -8
- package/lib/view/expenseAutomationView/types/jeSchedulesViewState.js +8 -8
- package/lib/view/expenseAutomationView/types/reconciliationViewState.d.ts +1 -1
- package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingQboAccountsEpic.d.ts +6 -0
- package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingQboAccountsEpic.js +29 -0
- package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingQboClassesEpic.d.ts +6 -0
- package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingQboClassesEpic.js +19 -0
- package/lib/view/scheduleView/scheduleListView/epics/fetchAccruedScheduleListEpic.js +1 -1
- package/lib/view/scheduleView/scheduleListView/epics/fetchDownloadSchedulesEpic.js +7 -2
- package/lib/view/scheduleView/scheduleListView/scheduleListReducer.d.ts +4 -2
- package/lib/view/scheduleView/scheduleListView/scheduleListReducer.js +5 -3
- package/lib/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoIntroClosedByOutsideClickEpic.d.ts +8 -0
- package/lib/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoIntroClosedByOutsideClickEpic.js +22 -0
- package/lib/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoRemindMeLaterClickedEpic.d.ts +8 -0
- package/lib/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoRemindMeLaterClickedEpic.js +22 -0
- package/lib/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryVideoViewedEpic.d.ts +8 -0
- package/lib/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryVideoViewedEpic.js +22 -0
- package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardEpic.d.ts +13 -0
- package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardEpic.js +20 -0
- package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardPayload.d.ts +11 -0
- package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardPayload.js +2 -0
- package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardReducer.d.ts +7 -0
- package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardReducer.js +64 -0
- package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardSelector.d.ts +12 -0
- package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardSelector.js +15 -0
- package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardState.d.ts +9 -0
- package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardState.js +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getNewScheduleView = exports.getNewAccrualAccountsView = exports.getNewScheduleSearchTransactionsView = void 0;
|
|
4
|
+
const accountSelector_1 = require("../../../entity/account/accountSelector");
|
|
5
|
+
const transactionSelector_1 = require("../../../entity/transaction/transactionSelector");
|
|
6
|
+
const accountListSelector_1 = require("../../accountList/accountListSelector");
|
|
7
|
+
const classListSelector_1 = require("../../classList/classListSelector");
|
|
8
|
+
const scheduleDetailLocalDataHelper_1 = require("../../scheduleView/scheduleDetailView/scheduleDetailLocalDataHelper");
|
|
9
|
+
const scheduleDetailSelector_1 = require("../../scheduleView/scheduleDetailView/scheduleDetailSelector");
|
|
10
|
+
const scheduleListHelper_1 = require("../../scheduleView/scheduleListView/scheduleListHelper");
|
|
11
|
+
/**
|
|
12
|
+
* The Base Transaction search is shared across schedule types (one search
|
|
13
|
+
* box, not one per prepaid_expenses/fixed_assets) — split out from
|
|
14
|
+
* getNewScheduleView so a consumer can read it without supplying an
|
|
15
|
+
* otherwise-irrelevant scheduleType.
|
|
16
|
+
*/
|
|
17
|
+
const getNewScheduleSearchTransactionsView = (state) => {
|
|
18
|
+
const { searchTransactions } = state.expenseAutomationJESchedulesViewState.newSchedule;
|
|
19
|
+
const searchTransactionsResults = searchTransactions.searchResults
|
|
20
|
+
.map((key) => (0, transactionSelector_1.getScheduleTransactionById)(state.transactionState, key))
|
|
21
|
+
.filter((transaction) => transaction != null);
|
|
22
|
+
return {
|
|
23
|
+
searchTransactionsResults,
|
|
24
|
+
searchTransactionsFetchState: {
|
|
25
|
+
fetchState: searchTransactions.fetchState,
|
|
26
|
+
error: searchTransactions.error,
|
|
27
|
+
},
|
|
28
|
+
searchTransactionsString: searchTransactions.searchString,
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
exports.getNewScheduleSearchTransactionsView = getNewScheduleSearchTransactionsView;
|
|
32
|
+
const ACCRUED_EXPENSE_ACCOUNT_LABELS = ['accrued_expenses'];
|
|
33
|
+
/**
|
|
34
|
+
* Account + class options and request status shared by both accrual creation forms — the one-time
|
|
35
|
+
* accrual and the recurring accrued schedule.
|
|
36
|
+
*
|
|
37
|
+
* getAccountsTypesForScheduleDetails('accrued_expenses') deliberately includes
|
|
38
|
+
* other_current_liabilities, because the accrued liability accounts live there —
|
|
39
|
+
* so the debit list has to subtract them back out, and the credit list keeps only
|
|
40
|
+
* them. Mirrors getScheduleAccruedDetailView, which is the form this one is
|
|
41
|
+
* modelled on.
|
|
42
|
+
*/
|
|
43
|
+
const getNewAccrualAccountsView = (state) => {
|
|
44
|
+
const { accountState, accountListState, classState, classListState } = state;
|
|
45
|
+
const { newSchedule } = state.expenseAutomationJESchedulesViewState;
|
|
46
|
+
const accountType = (0, scheduleListHelper_1.getAccountsTypesForScheduleEpics)();
|
|
47
|
+
const accrualAccountIds = (0, accountSelector_1.getAccountIdsForTypes)(accountState, (0, scheduleDetailLocalDataHelper_1.getAccountsTypesForScheduleDetails)('accrued_expenses'));
|
|
48
|
+
const accruedCategoryIds = (0, accountSelector_1.getAccountIdsForLabels)(accountState, ACCRUED_EXPENSE_ACCOUNT_LABELS);
|
|
49
|
+
const allAccountList = (0, accountListSelector_1.getAccountList)(accountState, accountListState, accountType.accountListKey);
|
|
50
|
+
const nestedAccountHierarchy = (0, accountListSelector_1.getNestedAccountListHierarchy)(accountListState, accountType.accountListKey);
|
|
51
|
+
const debitAccounts = allAccountList.accounts.filter((account) => accrualAccountIds.includes(account.accountId) &&
|
|
52
|
+
!accruedCategoryIds.includes(account.accountId));
|
|
53
|
+
const creditAccounts = allAccountList.accounts.filter((account) => accruedCategoryIds.includes(account.accountId));
|
|
54
|
+
const allClassList = (0, classListSelector_1.getClassList)(classState, classListState);
|
|
55
|
+
return {
|
|
56
|
+
accountListNestedAccountHierarchy: (0, scheduleDetailSelector_1.filterNestedAccountHierarchyById)(nestedAccountHierarchy, debitAccounts.map((account) => account.accountId)),
|
|
57
|
+
accruedAccountListNestedAccountHierarchy: (0, scheduleDetailSelector_1.filterNestedAccountHierarchyById)(nestedAccountHierarchy, creditAccounts.map((account) => account.accountId)),
|
|
58
|
+
allAccountList: debitAccounts,
|
|
59
|
+
allAccruedExpenseList: creditAccounts,
|
|
60
|
+
allClassList: allClassList.classes,
|
|
61
|
+
classListNestedAccountHierarchy: (0, classListSelector_1.getNestedClassListHierarchy)(classListState),
|
|
62
|
+
createStatus: newSchedule.createOneTimeAccrualStatus,
|
|
63
|
+
// The recurring accrued schedule saves through the accrued detail epics that the Vendor tab
|
|
64
|
+
// already uses, so its status is that slice's updateStatus rather than anything new here.
|
|
65
|
+
accruedScheduleSaveStatus: state.scheduleAccruedDetailState.updateStatus,
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
exports.getNewAccrualAccountsView = getNewAccrualAccountsView;
|
|
69
|
+
const getNewScheduleView = (state, scheduleType) => {
|
|
70
|
+
const { accountState, accountListState, classState, classListState } = state;
|
|
71
|
+
const { newSchedule } = state.expenseAutomationJESchedulesViewState;
|
|
72
|
+
const searchTransactionsView = (0, exports.getNewScheduleSearchTransactionsView)(state);
|
|
73
|
+
const accountType = (0, scheduleListHelper_1.getAccountsTypesForScheduleEpics)();
|
|
74
|
+
const newScheduleAccountTypes = (0, scheduleDetailLocalDataHelper_1.getAccountsTypesForScheduleDetails)(scheduleType);
|
|
75
|
+
const newScheduleAccountIds = (0, accountSelector_1.getAccountIdsForTypes)(accountState, newScheduleAccountTypes);
|
|
76
|
+
const allAccountList = (0, accountListSelector_1.getAccountList)(accountState, accountListState, accountType.accountListKey);
|
|
77
|
+
const filteredAccounts = allAccountList.accounts.filter((account) => newScheduleAccountIds.includes(account.accountId));
|
|
78
|
+
const accountListNestedAccountHierarchy = (0, scheduleDetailSelector_1.filterNestedAccountHierarchyById)((0, accountListSelector_1.getNestedAccountListHierarchy)(accountListState, accountType.accountListKey), filteredAccounts.map((account) => account.accountId));
|
|
79
|
+
const allClassList = (0, classListSelector_1.getClassList)(classState, classListState);
|
|
80
|
+
const classListNestedAccountHierarchy = (0, classListSelector_1.getNestedClassListHierarchy)(classListState);
|
|
81
|
+
let allDepreciationAccountList;
|
|
82
|
+
let allDepreciationAccountListNestedAccountHierarchy;
|
|
83
|
+
if (scheduleType === 'fixed_assets') {
|
|
84
|
+
const depreciationCategoryIds = (0, accountSelector_1.getAccountIdsForTypes)(accountState, [
|
|
85
|
+
'fixed_assets',
|
|
86
|
+
'other_assets',
|
|
87
|
+
]);
|
|
88
|
+
const accountLabel = (0, scheduleListHelper_1.getAccountLabelForScheduleType)('fixed_assets');
|
|
89
|
+
const fixedAssetLabelAccountIds = accountLabel != null
|
|
90
|
+
? (0, accountListSelector_1.getAccountIdsForLabel)(accountListState, accountType.accountListKey, accountLabel)
|
|
91
|
+
: [];
|
|
92
|
+
allDepreciationAccountList = allAccountList.accounts.filter((account) => depreciationCategoryIds.includes(account.accountId) &&
|
|
93
|
+
!fixedAssetLabelAccountIds.includes(account.accountId));
|
|
94
|
+
allDepreciationAccountListNestedAccountHierarchy =
|
|
95
|
+
(0, scheduleDetailSelector_1.filterNestedAccountHierarchyById)((0, accountListSelector_1.getNestedAccountListHierarchy)(accountListState, accountType.accountListKey), allDepreciationAccountList.map((account) => account.accountId));
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
scheduleType,
|
|
99
|
+
accountListNestedAccountHierarchy,
|
|
100
|
+
allAccountList: filteredAccounts,
|
|
101
|
+
allClassList: allClassList.classes,
|
|
102
|
+
allDepreciationAccountList,
|
|
103
|
+
allDepreciationAccountListNestedAccountHierarchy,
|
|
104
|
+
classListNestedAccountHierarchy,
|
|
105
|
+
newScheduleLocalData: newSchedule.newScheduleState[scheduleType],
|
|
106
|
+
saveStatus: newSchedule.saveStatus,
|
|
107
|
+
...searchTransactionsView,
|
|
108
|
+
fetchState: newSchedule.fetchState,
|
|
109
|
+
error: newSchedule.error,
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
exports.getNewScheduleView = getNewScheduleView;
|
|
@@ -1,3 +1,37 @@
|
|
|
1
|
+
import { FetchStateAndError, ID } from '../../../commonStateTypes/common';
|
|
2
|
+
import { JEAccruedSchedule, JEOneTimeAccrual, JEScheduledTransaction } from '../../../entity/jeSchedules/jeSchedulesSelector';
|
|
3
|
+
import { ScheduleTypes } from '../../../entity/jeSchedules/jeSchedulesTypes';
|
|
1
4
|
import { RootState } from '../../../rootStateTypes';
|
|
2
5
|
import { ExpenseAutomationJESchedulesViewSelector } from '../selectorTypes/jeSchedulesSelectorTypes';
|
|
6
|
+
import { JEScheduledTransactionWithFailedEntries } from './jeScheduledTransactionWithFailedEntries';
|
|
7
|
+
/**
|
|
8
|
+
* `posting_blocked` is written by the posting Cron when a JE fails to post. It is an internal
|
|
9
|
+
* failure state with no human action attached, so it is dropped here rather than hidden at render
|
|
10
|
+
* time — filtering in the view would leave the group counts and KPI totals counting rows nobody
|
|
11
|
+
* can see. The expense-automation endpoint applies no status filter on the close-period path, so
|
|
12
|
+
* these rows do arrive.
|
|
13
|
+
*/
|
|
14
|
+
export declare function isRenderableOneTimeAccrual(accrual: JEOneTimeAccrual): boolean;
|
|
15
|
+
export declare function getJEScheduleRowType(schedule: JEScheduleRow): ScheduleTypes | undefined;
|
|
16
|
+
export declare function isPendingReviewRow(schedule: JEScheduleRow): boolean;
|
|
17
|
+
export declare function isExistingTabRow(schedule: JEScheduleRow): boolean;
|
|
18
|
+
export declare const isAiAccountantSchedule: (schedule: JEScheduleRow) => boolean;
|
|
19
|
+
export declare function isAccruedScheduleRow(schedule: JEScheduleRow): schedule is JEAccruedSchedule;
|
|
20
|
+
export declare function isOneTimeAccrualRow(schedule: JEScheduleRow): schedule is JEOneTimeAccrual;
|
|
3
21
|
export declare function getExpenseAutomationJESchedulesView(state: RootState): ExpenseAutomationJESchedulesViewSelector;
|
|
22
|
+
export type JEScheduleRow = JEAccruedSchedule | JEOneTimeAccrual | JEScheduledTransaction | JEScheduledTransactionWithFailedEntries;
|
|
23
|
+
export type JEScheduleRowWithoutOneTimeAccrual = Exclude<JEScheduleRow, JEOneTimeAccrual>;
|
|
24
|
+
export interface ExpenseAutomationJEOneTimeAccrualDetailView {
|
|
25
|
+
actionFetchState: FetchStateAndError;
|
|
26
|
+
detailFetchState: FetchStateAndError;
|
|
27
|
+
accrual?: JEOneTimeAccrual;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* One accrual plus the status of its promote / ignore request, for the detail screen.
|
|
31
|
+
*
|
|
32
|
+
* `accrual` is undefined on a cold load — a refresh or a shared link, where the list has never run
|
|
33
|
+
* — so the screen dispatches `fetchOneTimeAccrual` and waits on `detailFetchState`. The two states
|
|
34
|
+
* are separate on purpose: `actionFetchState` drives the row spinner and the post-revert navigation,
|
|
35
|
+
* and a page load must not look like an action that just finished.
|
|
36
|
+
*/
|
|
37
|
+
export declare function getExpenseAutomationJEOneTimeAccrualDetailView(state: RootState, accrualId: ID): ExpenseAutomationJEOneTimeAccrualDetailView;
|
|
@@ -3,13 +3,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.isAiAccountantSchedule = void 0;
|
|
7
|
+
exports.isRenderableOneTimeAccrual = isRenderableOneTimeAccrual;
|
|
8
|
+
exports.getJEScheduleRowType = getJEScheduleRowType;
|
|
9
|
+
exports.isPendingReviewRow = isPendingReviewRow;
|
|
10
|
+
exports.isExistingTabRow = isExistingTabRow;
|
|
11
|
+
exports.isAccruedScheduleRow = isAccruedScheduleRow;
|
|
12
|
+
exports.isOneTimeAccrualRow = isOneTimeAccrualRow;
|
|
6
13
|
exports.getExpenseAutomationJESchedulesView = getExpenseAutomationJESchedulesView;
|
|
14
|
+
exports.getExpenseAutomationJEOneTimeAccrualDetailView = getExpenseAutomationJEOneTimeAccrualDetailView;
|
|
7
15
|
const omit_1 = __importDefault(require("lodash/omit"));
|
|
8
16
|
const orderBy_1 = __importDefault(require("lodash/orderBy"));
|
|
9
17
|
const reduceFetchState_1 = require("../../../commonStateTypes/reduceFetchState");
|
|
10
18
|
const timePeriod_1 = require("../../../commonStateTypes/timePeriod");
|
|
11
19
|
const accountSelector_1 = require("../../../entity/account/accountSelector");
|
|
20
|
+
const jeScheduleHelper_1 = require("../../../entity/jeSchedules/jeScheduleHelper");
|
|
12
21
|
const jeSchedulesSelector_1 = require("../../../entity/jeSchedules/jeSchedulesSelector");
|
|
22
|
+
const jeSchedulesTypes_1 = require("../../../entity/jeSchedules/jeSchedulesTypes");
|
|
13
23
|
const tenantSelector_1 = require("../../../entity/tenant/tenantSelector");
|
|
14
24
|
const accountListSelector_1 = require("../../accountList/accountListSelector");
|
|
15
25
|
const classListSelector_1 = require("../../classList/classListSelector");
|
|
@@ -17,8 +27,127 @@ const scheduleDetailLocalDataHelper_1 = require("../../scheduleView/scheduleDeta
|
|
|
17
27
|
const scheduleDetailSelector_1 = require("../../scheduleView/scheduleDetailView/scheduleDetailSelector");
|
|
18
28
|
const scheduleListHelper_1 = require("../../scheduleView/scheduleListView/scheduleListHelper");
|
|
19
29
|
const getAllStepsHelper_1 = require("./getAllStepsHelper");
|
|
30
|
+
const jeSchedulesViewState_1 = require("../types/jeSchedulesViewState");
|
|
20
31
|
const jeAccountSettingsViewSelector_1 = require("./jeAccountSettingsViewSelector");
|
|
32
|
+
const jeNewScheduleViewSelector_1 = require("./jeNewScheduleViewSelector");
|
|
33
|
+
// Matches the AI-automation user addresses webc's schedule list row already
|
|
34
|
+
// checks (JEScheduleReadOnlyListRow/JEScheduleDraftListRow "Method" column,
|
|
35
|
+
// strings.ts aiBotEmail/botEmail) to determine whether a schedule was
|
|
36
|
+
// created by the AI accountant vs. a human.
|
|
37
|
+
const AI_BOT_EMAIL = 'ai@zeni.ai';
|
|
38
|
+
const BOT_EMAIL = 'bot@zeni.ai';
|
|
39
|
+
// A one-time accrual has no jeScheduleType of its own — it is not a JE schedule. It is still an
|
|
40
|
+
// accrued expense, so it counts and filters under that type on the page's type tabs.
|
|
41
|
+
const ONE_TIME_ACCRUAL_SCHEDULE_TYPE = 'accrued_expenses';
|
|
42
|
+
// Which of the two list buckets an accrual belongs in. `draft` still needs a human to post it;
|
|
43
|
+
// everything else is already on the books or in a transient claim.
|
|
44
|
+
const ONE_TIME_ACCRUAL_REVIEW_STATUSES = [
|
|
45
|
+
'draft',
|
|
46
|
+
];
|
|
47
|
+
/**
|
|
48
|
+
* `posting_blocked` is written by the posting Cron when a JE fails to post. It is an internal
|
|
49
|
+
* failure state with no human action attached, so it is dropped here rather than hidden at render
|
|
50
|
+
* time — filtering in the view would leave the group counts and KPI totals counting rows nobody
|
|
51
|
+
* can see. The expense-automation endpoint applies no status filter on the close-period path, so
|
|
52
|
+
* these rows do arrive.
|
|
53
|
+
*/
|
|
54
|
+
function isRenderableOneTimeAccrual(accrual) {
|
|
55
|
+
return accrual.accrualStatus !== 'posting_blocked';
|
|
56
|
+
}
|
|
57
|
+
function getJEScheduleRowType(schedule) {
|
|
58
|
+
return isOneTimeAccrualRow(schedule)
|
|
59
|
+
? ONE_TIME_ACCRUAL_SCHEDULE_TYPE
|
|
60
|
+
: schedule.jeScheduleType;
|
|
61
|
+
}
|
|
62
|
+
function isPendingReviewRow(schedule) {
|
|
63
|
+
return isOneTimeAccrualRow(schedule)
|
|
64
|
+
? ONE_TIME_ACCRUAL_REVIEW_STATUSES.includes(schedule.accrualStatus)
|
|
65
|
+
: schedule.status.code === 'draft';
|
|
66
|
+
}
|
|
67
|
+
// Belongs on the Existing Schedules tab. For an accrual the endpoint has already filtered to
|
|
68
|
+
// posted, so this only has to agree with that rather than re-derive it.
|
|
69
|
+
function isExistingTabRow(schedule) {
|
|
70
|
+
return isOneTimeAccrualRow(schedule)
|
|
71
|
+
? schedule.accrualStatus === 'posted'
|
|
72
|
+
: schedule.status.code === 'ongoing';
|
|
73
|
+
}
|
|
74
|
+
// Exported (rather than kept as a closure inside the selector) so it can be
|
|
75
|
+
// unit-tested directly — confidenceScore is a separate, more narrowly
|
|
76
|
+
// populated field that can be null on a schedule the bot user created,
|
|
77
|
+
// which previously caused these schedules to display as "AI Accountant" in
|
|
78
|
+
// the list but count under "Manual" in the KPI summary.
|
|
79
|
+
const isAiAccountantSchedule = (schedule) => {
|
|
80
|
+
// A one-time accrual records who made it as `origin`, which is authoritative — no email
|
|
81
|
+
// sniffing needed, and the JE bot is often absent from the user entity entirely.
|
|
82
|
+
if (isOneTimeAccrualRow(schedule)) {
|
|
83
|
+
return schedule.origin === 'agent';
|
|
84
|
+
}
|
|
85
|
+
return (schedule.createdByUser?.email === AI_BOT_EMAIL ||
|
|
86
|
+
schedule.createdByUser?.email === BOT_EMAIL);
|
|
87
|
+
};
|
|
88
|
+
exports.isAiAccountantSchedule = isAiAccountantSchedule;
|
|
89
|
+
// Accrued schedules are structurally distinct — no baseTransaction, carrying recurringAmount and
|
|
90
|
+
// memo in its place — so anything reading baseTransaction has to branch on this first.
|
|
91
|
+
//
|
|
92
|
+
// Discriminates on jeAccruedScheduleKey, which only JEAccruedSchedule carries. jeScheduleType
|
|
93
|
+
// cannot be used: it is a data field present on BOTH row shapes, so an accrued-typed row that
|
|
94
|
+
// arrived through the prepaid/fixed DTO (failed_je_postings, legacy fetches) would be
|
|
95
|
+
// misclassified and then crash on recurringAmount / jeAccruedScheduleKey.
|
|
96
|
+
function isAccruedScheduleRow(schedule) {
|
|
97
|
+
return 'jeAccruedScheduleKey' in schedule;
|
|
98
|
+
}
|
|
99
|
+
// Same structural approach as isAccruedScheduleRow, and for the same reason: jeOneTimeAccrualKey
|
|
100
|
+
// exists only on this shape. Note the two guards are NOT interchangeable — a one-time accrual is
|
|
101
|
+
// not an accrued *schedule*, and routing it into the accrued branch would read recurringAmount,
|
|
102
|
+
// render postedCount/lifecycleTotal as a lifecycle and startDate–endDate as a period, none of
|
|
103
|
+
// which it has.
|
|
104
|
+
function isOneTimeAccrualRow(schedule) {
|
|
105
|
+
return 'jeOneTimeAccrualKey' in schedule;
|
|
106
|
+
}
|
|
107
|
+
function getScheduleAmount(schedule) {
|
|
108
|
+
if (isOneTimeAccrualRow(schedule)) {
|
|
109
|
+
return schedule.estimatedAmount.amount;
|
|
110
|
+
}
|
|
111
|
+
if (isAccruedScheduleRow(schedule)) {
|
|
112
|
+
return schedule.recurringAmount.amount;
|
|
113
|
+
}
|
|
114
|
+
return schedule.baseTransaction.amount.amount;
|
|
115
|
+
}
|
|
116
|
+
// A one-time accrual shares almost no sortable field with a schedule, so it gets its own accessor
|
|
117
|
+
// rather than a guard on each of the dozen cases below. Keys with no meaning for a single-month
|
|
118
|
+
// accrual -- amortizationPeriod, remainingMonths, runningBalance, jePostingDate, scheduleCategory --
|
|
119
|
+
// deliberately fall through to undefined, which sorts them together at one end.
|
|
120
|
+
function getOneTimeAccrualSortValue(accrual, sortKey) {
|
|
121
|
+
switch (sortKey) {
|
|
122
|
+
case 'vendor':
|
|
123
|
+
return accrual.vendorName.toLowerCase();
|
|
124
|
+
case 'category':
|
|
125
|
+
return accrual.jeDebitAccountName?.toLowerCase();
|
|
126
|
+
case 'class':
|
|
127
|
+
return accrual.jeDebitAccountingClassName?.toLowerCase();
|
|
128
|
+
case 'depCategory':
|
|
129
|
+
return accrual.jeCreditAccountName?.toLowerCase();
|
|
130
|
+
case 'type':
|
|
131
|
+
return ONE_TIME_ACCRUAL_SCHEDULE_TYPE;
|
|
132
|
+
case 'totalAmount':
|
|
133
|
+
return accrual.estimatedAmount.amount;
|
|
134
|
+
case 'transactionDate':
|
|
135
|
+
return accrual.postingDate?.valueOf();
|
|
136
|
+
case 'memo':
|
|
137
|
+
return accrual.memo.toLowerCase();
|
|
138
|
+
case 'startMonth':
|
|
139
|
+
return accrual.serviceMonth;
|
|
140
|
+
default:
|
|
141
|
+
return undefined;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
21
144
|
function getJEScheduleSortAccessor(sortKey) {
|
|
145
|
+
const scheduleAccessor = getScheduleRowSortAccessor(sortKey);
|
|
146
|
+
return (schedule) => isOneTimeAccrualRow(schedule)
|
|
147
|
+
? getOneTimeAccrualSortValue(schedule, sortKey)
|
|
148
|
+
: scheduleAccessor(schedule);
|
|
149
|
+
}
|
|
150
|
+
function getScheduleRowSortAccessor(sortKey) {
|
|
22
151
|
switch (sortKey) {
|
|
23
152
|
case 'vendor':
|
|
24
153
|
return (s) => s.vendor.name?.toLowerCase();
|
|
@@ -29,7 +158,9 @@ function getJEScheduleSortAccessor(sortKey) {
|
|
|
29
158
|
case 'depCategory':
|
|
30
159
|
return (s) => s.jeCredit.account?.accountName?.toLowerCase();
|
|
31
160
|
case 'scheduleCategory':
|
|
32
|
-
return (s) => s
|
|
161
|
+
return (s) => isAccruedScheduleRow(s)
|
|
162
|
+
? undefined
|
|
163
|
+
: s.baseTransaction.account?.accountName?.toLowerCase();
|
|
33
164
|
case 'startMonth':
|
|
34
165
|
return (s) => s.startDate?.valueOf();
|
|
35
166
|
case 'type':
|
|
@@ -57,11 +188,13 @@ function getJEScheduleSortAccessor(sortKey) {
|
|
|
57
188
|
return s.balanceAsOfToday?.amount ?? null;
|
|
58
189
|
};
|
|
59
190
|
case 'totalAmount':
|
|
60
|
-
return (s) => s
|
|
191
|
+
return (s) => getScheduleAmount(s);
|
|
61
192
|
case 'transactionDate':
|
|
62
|
-
return (s) => s.
|
|
193
|
+
return (s) => s.createTime?.valueOf();
|
|
63
194
|
case 'memo':
|
|
64
|
-
return (s) => s
|
|
195
|
+
return (s) => isAccruedScheduleRow(s)
|
|
196
|
+
? s.memo.toLowerCase()
|
|
197
|
+
: s.baseTransaction.memo?.toLowerCase();
|
|
65
198
|
default:
|
|
66
199
|
return (s) => s.startDate?.valueOf();
|
|
67
200
|
}
|
|
@@ -73,9 +206,15 @@ function sortJEScheduledTransactions(transactions, sortKey, sortOrder) {
|
|
|
73
206
|
function getExpenseAutomationJESchedulesView(state) {
|
|
74
207
|
const jeScheduledTransaction = [];
|
|
75
208
|
const failedJeScheduledTransaction = [];
|
|
209
|
+
const accruedSchedules = [];
|
|
210
|
+
const oneTimeAccruals = [];
|
|
76
211
|
const { accountState, accountListState, classState, classListState, expenseAutomationJESchedulesViewState, expenseAutomationViewState, monthEndCloseChecksState, monthEndCloseChecksViewState, } = state;
|
|
77
|
-
const {
|
|
212
|
+
const { jeScheduleTransactionKeysByPeriodAndTab, jeScheduleAccruedKeysByPeriodAndTab, jeScheduleOneTimeAccrualKeysByPeriodAndTab, failedJeScheduleTransactionKeysByPeriodAndTab, jeScheduleLocalDataById, postStatusById, ignoreStatusById, revertStatusById, oneTimeAccrualActionStatusById, uiState, error, fetchState, refreshStatus, newSchedule, } = expenseAutomationJESchedulesViewState;
|
|
78
213
|
const accountSettingsView = (0, jeAccountSettingsViewSelector_1.getJEAccountSettingsView)(state);
|
|
214
|
+
const newScheduleView = newSchedule.selectedDetailScheduleType === 'fixed_assets' ||
|
|
215
|
+
newSchedule.selectedDetailScheduleType === 'prepaid_expenses'
|
|
216
|
+
? (0, jeNewScheduleViewSelector_1.getNewScheduleView)(state, newSchedule.selectedDetailScheduleType)
|
|
217
|
+
: undefined;
|
|
79
218
|
const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state);
|
|
80
219
|
const { selectedPeriodByTenantId } = expenseAutomationViewState;
|
|
81
220
|
const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
|
|
@@ -103,27 +242,48 @@ function getExpenseAutomationJESchedulesView(state) {
|
|
|
103
242
|
const filteredDepAccountListNestedAccountHierarchy = (0, scheduleDetailSelector_1.filterNestedAccountHierarchyById)(depAccountListNestedAccountHierarchy, filteredDepAccounts.map((account) => account.accountId));
|
|
104
243
|
const classListNestedAccountHierarchy = (0, classListSelector_1.getNestedClassListHierarchy)(classListState);
|
|
105
244
|
const monthYearPeriodId = selectedPeriod != null ? (0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod) : null;
|
|
106
|
-
const
|
|
107
|
-
?
|
|
108
|
-
: null;
|
|
109
|
-
const failedJeScheduleTransactionKeysForSelectedPeriod = monthYearPeriodId != null
|
|
110
|
-
? failedJeScheduleTransactionKeysByPeriod[monthYearPeriodId]
|
|
245
|
+
const selectedPeriodTabKey = monthYearPeriodId != null
|
|
246
|
+
? (0, jeSchedulesViewState_1.getJESchedulePeriodTabKey)(uiState.selectedPageTab, monthYearPeriodId)
|
|
111
247
|
: null;
|
|
112
|
-
const
|
|
113
|
-
|
|
248
|
+
const jeScheduleTransactionKeysForSelectedTab = selectedPeriodTabKey != null
|
|
249
|
+
? jeScheduleTransactionKeysByPeriodAndTab[selectedPeriodTabKey]
|
|
250
|
+
: undefined;
|
|
251
|
+
const failedJeScheduleTransactionKeysForSelectedTab = selectedPeriodTabKey != null
|
|
252
|
+
? failedJeScheduleTransactionKeysByPeriodAndTab[selectedPeriodTabKey]
|
|
253
|
+
: undefined;
|
|
254
|
+
// Distinguishes "this tab has never been fetched for this period" from "fetched and genuinely
|
|
255
|
+
// empty". Without it the page cannot tell a first visit from a real empty state, and renders an
|
|
256
|
+
// empty table where it should render a skeleton.
|
|
257
|
+
const hasLoadedForSelectedTab = jeScheduleTransactionKeysForSelectedTab != null;
|
|
258
|
+
const jeScheduleTransactionKeys = jeScheduleTransactionKeysForSelectedTab ?? [];
|
|
259
|
+
const failedJeScheduleTransactionKeys = failedJeScheduleTransactionKeysForSelectedTab ?? [];
|
|
260
|
+
const jeScheduleAccruedKeys = (selectedPeriodTabKey != null
|
|
261
|
+
? jeScheduleAccruedKeysByPeriodAndTab[selectedPeriodTabKey]
|
|
262
|
+
: undefined) ?? [];
|
|
263
|
+
const jeScheduleOneTimeAccrualKeys = (selectedPeriodTabKey != null
|
|
264
|
+
? jeScheduleOneTimeAccrualKeysByPeriodAndTab[selectedPeriodTabKey]
|
|
265
|
+
: undefined) ?? [];
|
|
266
|
+
jeScheduleOneTimeAccrualKeys.forEach((jeOneTimeAccrualKey) => {
|
|
267
|
+
const accrual = (0, jeSchedulesSelector_1.getJEOneTimeAccrualByKey)(jeOneTimeAccrualKey, state.jeSchedulesState);
|
|
268
|
+
if (accrual != null && isRenderableOneTimeAccrual(accrual)) {
|
|
269
|
+
oneTimeAccruals.push(accrual);
|
|
270
|
+
}
|
|
271
|
+
});
|
|
114
272
|
jeScheduleTransactionKeys.forEach((jeScheduleKey) => {
|
|
115
273
|
const jeScheduleDetails = (0, jeSchedulesSelector_1.getJEScheduledTransactionByJEScheduleTransactionKey)(jeScheduleKey, state);
|
|
116
274
|
jeScheduledTransaction.push(jeScheduleDetails);
|
|
117
275
|
});
|
|
276
|
+
jeScheduleAccruedKeys.forEach((jeAccruedScheduleKey) => {
|
|
277
|
+
const accruedScheduleDetails = (0, jeSchedulesSelector_1.getJEAccruedScheduleByJEScheduleKey)(jeAccruedScheduleKey, state);
|
|
278
|
+
if (accruedScheduleDetails != null) {
|
|
279
|
+
accruedSchedules.push(accruedScheduleDetails);
|
|
280
|
+
}
|
|
281
|
+
});
|
|
118
282
|
failedJeScheduleTransactionKeys.forEach((jeScheduleKey) => {
|
|
119
283
|
const jeScheduleDetails = (0, jeSchedulesSelector_1.getJEScheduledTransactionByJEScheduleTransactionKey)(jeScheduleKey, state);
|
|
120
284
|
failedJeScheduledTransaction.push(jeScheduleDetails);
|
|
121
285
|
});
|
|
122
|
-
const { sortKey, sortOrder } = uiState;
|
|
123
|
-
const draftSchedules = sortJEScheduledTransactions(jeScheduledTransaction.filter((schedule) => schedule.status.code === 'draft'), sortKey, sortOrder);
|
|
124
|
-
const ongoingSchedules = sortJEScheduledTransactions(jeScheduledTransaction.filter((schedule) => schedule.status.code === 'ongoing'), sortKey, sortOrder);
|
|
125
|
-
const completedSchedules = sortJEScheduledTransactions(jeScheduledTransaction.filter((schedule) => schedule.status.code === 'completed' ||
|
|
126
|
-
schedule.status.code === 'marked_as_completed'), sortKey, sortOrder);
|
|
286
|
+
const { sortKey, sortOrder, selectedJETypeFilter } = uiState;
|
|
127
287
|
const unsortedResolveSchedules = [];
|
|
128
288
|
failedJeScheduledTransaction.forEach((schedule) => {
|
|
129
289
|
schedule.scheduledJournalEntry.forEach((journalEntry) => {
|
|
@@ -135,10 +295,87 @@ function getExpenseAutomationJESchedulesView(state) {
|
|
|
135
295
|
});
|
|
136
296
|
const resolveSchedules = sortJEScheduledTransactions(unsortedResolveSchedules, sortKey, sortOrder);
|
|
137
297
|
const validResolveForPending = unsortedResolveSchedules.filter((r) => jeScheduleLocalDataById[r.scheduledJournalEntry.scheduledJournalEntryID] != null);
|
|
298
|
+
const matchesTypeFilter = (schedule) => selectedJETypeFilter == null ||
|
|
299
|
+
getJEScheduleRowType(schedule) === selectedJETypeFilter;
|
|
300
|
+
const isCreatedStatus = (schedule) => {
|
|
301
|
+
// An accrual is "created" once it is not review work: posted, reversing, reversed, or in a
|
|
302
|
+
// transient posting claim.
|
|
303
|
+
if (isOneTimeAccrualRow(schedule)) {
|
|
304
|
+
return !isPendingReviewRow(schedule);
|
|
305
|
+
}
|
|
306
|
+
return (schedule.status.code === 'ongoing' ||
|
|
307
|
+
schedule.status.code === 'completed' ||
|
|
308
|
+
schedule.status.code === 'marked_as_completed');
|
|
309
|
+
};
|
|
310
|
+
const allScheduleRows = [
|
|
311
|
+
...jeScheduledTransaction,
|
|
312
|
+
...accruedSchedules,
|
|
313
|
+
...oneTimeAccruals,
|
|
314
|
+
];
|
|
138
315
|
const pendingReviewSchedules = sortJEScheduledTransactions([
|
|
139
|
-
...
|
|
316
|
+
...allScheduleRows.filter((schedule) => isPendingReviewRow(schedule) && matchesTypeFilter(schedule)),
|
|
140
317
|
...validResolveForPending,
|
|
141
318
|
], sortKey, sortOrder);
|
|
319
|
+
const createdSchedules = sortJEScheduledTransactions(allScheduleRows.filter((schedule) => isCreatedStatus(schedule) && matchesTypeFilter(schedule)), sortKey, sortOrder);
|
|
320
|
+
// KPI summary — derived from unfiltered schedules so counts are always accurate
|
|
321
|
+
const allSchedules = allScheduleRows;
|
|
322
|
+
const sumAmount = (schedules) => schedules.reduce((total, schedule) => total + (getScheduleAmount(schedule) ?? 0), 0);
|
|
323
|
+
const pendingReviewTotal = sumAmount(pendingReviewSchedules);
|
|
324
|
+
const createdTotal = sumAmount(createdSchedules);
|
|
325
|
+
const aiAccountantSchedules = allSchedules.filter(exports.isAiAccountantSchedule);
|
|
326
|
+
const manualSchedules = allSchedules.filter((schedule) => !(0, exports.isAiAccountantSchedule)(schedule));
|
|
327
|
+
const pendingUnfiltered = allSchedules.filter((schedule) => isPendingReviewRow(schedule));
|
|
328
|
+
const kpiSummary = {
|
|
329
|
+
aiAccountant: {
|
|
330
|
+
count: aiAccountantSchedules.length,
|
|
331
|
+
amount: sumAmount(aiAccountantSchedules),
|
|
332
|
+
},
|
|
333
|
+
manual: {
|
|
334
|
+
count: manualSchedules.length,
|
|
335
|
+
amount: sumAmount(manualSchedules),
|
|
336
|
+
},
|
|
337
|
+
needsReview: {
|
|
338
|
+
count: pendingUnfiltered.length,
|
|
339
|
+
amount: sumAmount(pendingUnfiltered),
|
|
340
|
+
},
|
|
341
|
+
total: {
|
|
342
|
+
count: allSchedules.length,
|
|
343
|
+
amount: sumAmount(allSchedules),
|
|
344
|
+
},
|
|
345
|
+
};
|
|
346
|
+
// Each tab's badge counts from that tab's own bucket. A tab that has not been fetched yet
|
|
347
|
+
// reports undefined rather than 0, so the UI can hide the badge instead of asserting "none".
|
|
348
|
+
const scheduleCountsByTab = {};
|
|
349
|
+
jeSchedulesViewState_1.ALL_JE_PAGE_TABS.forEach((pageTab) => {
|
|
350
|
+
const periodTabKey = monthYearPeriodId != null
|
|
351
|
+
? (0, jeSchedulesViewState_1.getJESchedulePeriodTabKey)(pageTab, monthYearPeriodId)
|
|
352
|
+
: null;
|
|
353
|
+
const transactionKeys = periodTabKey != null
|
|
354
|
+
? jeScheduleTransactionKeysByPeriodAndTab[periodTabKey]
|
|
355
|
+
: undefined;
|
|
356
|
+
if (transactionKeys == null) {
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
const accruedKeys = (periodTabKey != null
|
|
360
|
+
? jeScheduleAccruedKeysByPeriodAndTab[periodTabKey]
|
|
361
|
+
: undefined) ?? [];
|
|
362
|
+
const oneTimeAccrualKeys = (periodTabKey != null
|
|
363
|
+
? jeScheduleOneTimeAccrualKeysByPeriodAndTab[periodTabKey]
|
|
364
|
+
: undefined) ?? [];
|
|
365
|
+
const rowsForTab = [
|
|
366
|
+
...transactionKeys.map((transactionKey) => (0, jeSchedulesSelector_1.getJEScheduledTransactionByJEScheduleTransactionKey)(transactionKey, state)),
|
|
367
|
+
...accruedKeys
|
|
368
|
+
.map((accruedKey) => (0, jeSchedulesSelector_1.getJEAccruedScheduleByJEScheduleKey)(accruedKey, state))
|
|
369
|
+
.filter((accruedRow) => accruedRow != null),
|
|
370
|
+
...oneTimeAccrualKeys
|
|
371
|
+
.map((accrualKey) => (0, jeSchedulesSelector_1.getJEOneTimeAccrualByKey)(accrualKey, state.jeSchedulesState))
|
|
372
|
+
.filter((accrualRow) => accrualRow != null && isRenderableOneTimeAccrual(accrualRow)),
|
|
373
|
+
];
|
|
374
|
+
scheduleCountsByTab[pageTab] =
|
|
375
|
+
pageTab === 'existing_schedules'
|
|
376
|
+
? rowsForTab.filter((row) => isExistingTabRow(row)).length
|
|
377
|
+
: rowsForTab.filter((row) => isPendingReviewRow(row) || isCreatedStatus(row)).length;
|
|
378
|
+
});
|
|
142
379
|
const allSteps = monthYearPeriodId != null
|
|
143
380
|
? (0, getAllStepsHelper_1.getAllSteps)(monthEndCloseChecksState, monthYearPeriodId, currentTenant.tenantId)
|
|
144
381
|
: [];
|
|
@@ -151,6 +388,20 @@ function getExpenseAutomationJESchedulesView(state) {
|
|
|
151
388
|
{ fetchState, error },
|
|
152
389
|
monthEndFetchState,
|
|
153
390
|
]);
|
|
391
|
+
const countByType = (schedules) => {
|
|
392
|
+
const counts = jeSchedulesTypes_1.ALL_SCHEDULES_TYPES.reduce((acc, type) => ({ ...acc, [type]: 0 }), {});
|
|
393
|
+
schedules.forEach((schedule) => {
|
|
394
|
+
const scheduleType = getJEScheduleRowType(schedule);
|
|
395
|
+
if (scheduleType != null) {
|
|
396
|
+
counts[scheduleType] += 1;
|
|
397
|
+
}
|
|
398
|
+
});
|
|
399
|
+
return counts;
|
|
400
|
+
};
|
|
401
|
+
const jeScheduleTypeCounts = {
|
|
402
|
+
active: countByType(allSchedules.filter((schedule) => isPendingReviewRow(schedule) || isCreatedStatus(schedule))),
|
|
403
|
+
ongoing: countByType(allSchedules.filter((schedule) => isExistingTabRow(schedule))),
|
|
404
|
+
};
|
|
154
405
|
return {
|
|
155
406
|
uncategorizedAccounts,
|
|
156
407
|
allDepreciationAccountList: filteredDepAccounts,
|
|
@@ -159,14 +410,21 @@ function getExpenseAutomationJESchedulesView(state) {
|
|
|
159
410
|
allAccountList: filteredAccounts,
|
|
160
411
|
accountListNestedAccountHierarchy,
|
|
161
412
|
allClassList: allClasses,
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
413
|
+
createdSchedules,
|
|
414
|
+
createdTotal,
|
|
415
|
+
hasLoadedForSelectedTab,
|
|
416
|
+
jeScheduleTypeCounts,
|
|
417
|
+
scheduleCountsByTab,
|
|
418
|
+
kpiSummary,
|
|
165
419
|
pendingReviewSchedules,
|
|
420
|
+
pendingReviewTotal,
|
|
166
421
|
resolveSchedules: resolveSchedules,
|
|
167
422
|
accountSettingsView,
|
|
423
|
+
newScheduleView,
|
|
168
424
|
postStatusById: postStatusById,
|
|
169
425
|
ignoreStatusById: ignoreStatusById,
|
|
426
|
+
revertStatusById: revertStatusById,
|
|
427
|
+
oneTimeAccrualActionStatusById: oneTimeAccrualActionStatusById,
|
|
170
428
|
fetchState: reducedFetchStatus.fetchState,
|
|
171
429
|
jeScheduleLocalDataById: jeScheduleLocalDataById,
|
|
172
430
|
uiState: uiState,
|
|
@@ -175,3 +433,26 @@ function getExpenseAutomationJESchedulesView(state) {
|
|
|
175
433
|
completionStatus,
|
|
176
434
|
};
|
|
177
435
|
}
|
|
436
|
+
/**
|
|
437
|
+
* One accrual plus the status of its promote / ignore request, for the detail screen.
|
|
438
|
+
*
|
|
439
|
+
* `accrual` is undefined on a cold load — a refresh or a shared link, where the list has never run
|
|
440
|
+
* — so the screen dispatches `fetchOneTimeAccrual` and waits on `detailFetchState`. The two states
|
|
441
|
+
* are separate on purpose: `actionFetchState` drives the row spinner and the post-revert navigation,
|
|
442
|
+
* and a page load must not look like an action that just finished.
|
|
443
|
+
*/
|
|
444
|
+
function getExpenseAutomationJEOneTimeAccrualDetailView(state, accrualId) {
|
|
445
|
+
return {
|
|
446
|
+
accrual: (0, jeSchedulesSelector_1.getJEOneTimeAccrualByKey)((0, jeScheduleHelper_1.generateJEOneTimeAccrualKey)(accrualId), state.jeSchedulesState),
|
|
447
|
+
actionFetchState: state.expenseAutomationJESchedulesViewState
|
|
448
|
+
.oneTimeAccrualActionStatusById[accrualId] ?? {
|
|
449
|
+
fetchState: 'Not-Started',
|
|
450
|
+
error: undefined,
|
|
451
|
+
},
|
|
452
|
+
detailFetchState: state.expenseAutomationJESchedulesViewState
|
|
453
|
+
.oneTimeAccrualFetchStatusById[accrualId] ?? {
|
|
454
|
+
fetchState: 'Not-Started',
|
|
455
|
+
error: undefined,
|
|
456
|
+
},
|
|
457
|
+
};
|
|
458
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const toCompletedSubTab: (v: string) => "
|
|
1
|
+
export declare const toCompletedSubTab: (v: string) => "manual" | "all" | "ai_accountant";
|
|
2
2
|
export type CompletedSubTab = ReturnType<typeof toCompletedSubTab>;
|
|
3
3
|
/**
|
|
4
4
|
* "No sub-tab filter" sentinel — single source of truth for the default
|