@zeniai/client-epic-state 5.2.7-betaAK2 → 5.2.7-betaRD2
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/invoicing/invoicingCommonPayload.d.ts +0 -22
- package/lib/entity/invoicing/invoicingCommonPayload.js +5 -22
- 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/invoicing/invoicingCommonPayload.js +5 -22
- 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 +16 -9
- package/lib/esm/view/accountList/accountListReducer.js +1 -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/epics/transactionCategorization/backgroundRefetchReviewTabEpic.js +1 -0
- package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.js +1 -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/reducers/transactionsViewReducer.js +56 -11
- 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/selectors/transactionCategorizationSelector.js +2 -1
- package/lib/esm/view/expenseAutomationView/types/jeSchedulesViewState.js +5 -6
- package/lib/esm/view/expenseAutomationView/types/transactionGroup.js +21 -0
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewSelector.js +1 -2
- package/lib/esm/view/invoicing/invoicingConfigView/invoicingConfigViewSelector.js +0 -2
- package/lib/esm/view/invoicing/invoicingQboView/epics/fetchInvoicingAccountingPickersEpic.js +5 -10
- 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/invoicing/invoicingQboView/invoicingQboViewSelector.js +3 -27
- package/lib/esm/view/invoicing/settingsView/settingsViewSelector.js +3 -7
- 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 +97 -48
- package/lib/view/accountList/accountListReducer.js +1 -0
- package/lib/view/accountList/accountListState.d.ts +1 -1
- 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/epics/transactionCategorization/backgroundRefetchReviewTabEpic.js +1 -0
- package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.js +1 -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/payload/transactionCategorizationPayload.d.ts +11 -0
- 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 +6 -3
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +57 -12
- 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/selectorTypes/transactionsViewSelectorTypes.d.ts +2 -0
- package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.d.ts +21 -0
- package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +112 -0
- package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.d.ts +34 -0
- package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +302 -21
- package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +2 -1
- 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/expenseAutomationView/types/transactionGroup.d.ts +21 -0
- package/lib/view/expenseAutomationView/types/transactionGroup.js +25 -0
- package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +11 -0
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewSelector.d.ts +0 -5
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewSelector.js +0 -1
- package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewSelector.d.ts +0 -1
- package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewSelector.js +0 -2
- package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingAccountingPickersEpic.js +5 -10
- 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/invoicing/invoicingQboView/invoicingQboViewSelector.d.ts +1 -9
- package/lib/view/invoicing/invoicingQboView/invoicingQboViewSelector.js +4 -30
- package/lib/view/invoicing/settingsView/settingsViewSelector.d.ts +4 -11
- package/lib/view/invoicing/settingsView/settingsViewSelector.js +3 -7
- 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,106 @@
|
|
|
1
|
+
import { getAccountIdsForLabels, getAccountIdsForTypes, } from '../../../entity/account/accountSelector';
|
|
2
|
+
import { getScheduleTransactionById } from '../../../entity/transaction/transactionSelector';
|
|
3
|
+
import { getAccountIdsForLabel, getAccountList, getNestedAccountListHierarchy, } from '../../accountList/accountListSelector';
|
|
4
|
+
import { getClassList, getNestedClassListHierarchy, } from '../../classList/classListSelector';
|
|
5
|
+
import { getAccountsTypesForScheduleDetails } from '../../scheduleView/scheduleDetailView/scheduleDetailLocalDataHelper';
|
|
6
|
+
import { filterNestedAccountHierarchyById } from '../../scheduleView/scheduleDetailView/scheduleDetailSelector';
|
|
7
|
+
import { getAccountLabelForScheduleType, getAccountsTypesForScheduleEpics, } from '../../scheduleView/scheduleListView/scheduleListHelper';
|
|
8
|
+
/**
|
|
9
|
+
* The Base Transaction search is shared across schedule types (one search
|
|
10
|
+
* box, not one per prepaid_expenses/fixed_assets) — split out from
|
|
11
|
+
* getNewScheduleView so a consumer can read it without supplying an
|
|
12
|
+
* otherwise-irrelevant scheduleType.
|
|
13
|
+
*/
|
|
14
|
+
export const getNewScheduleSearchTransactionsView = (state) => {
|
|
15
|
+
const { searchTransactions } = state.expenseAutomationJESchedulesViewState.newSchedule;
|
|
16
|
+
const searchTransactionsResults = searchTransactions.searchResults
|
|
17
|
+
.map((key) => getScheduleTransactionById(state.transactionState, key))
|
|
18
|
+
.filter((transaction) => transaction != null);
|
|
19
|
+
return {
|
|
20
|
+
searchTransactionsResults,
|
|
21
|
+
searchTransactionsFetchState: {
|
|
22
|
+
fetchState: searchTransactions.fetchState,
|
|
23
|
+
error: searchTransactions.error,
|
|
24
|
+
},
|
|
25
|
+
searchTransactionsString: searchTransactions.searchString,
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
const ACCRUED_EXPENSE_ACCOUNT_LABELS = ['accrued_expenses'];
|
|
29
|
+
/**
|
|
30
|
+
* Account + class options and request status shared by both accrual creation forms — the one-time
|
|
31
|
+
* accrual and the recurring accrued schedule.
|
|
32
|
+
*
|
|
33
|
+
* getAccountsTypesForScheduleDetails('accrued_expenses') deliberately includes
|
|
34
|
+
* other_current_liabilities, because the accrued liability accounts live there —
|
|
35
|
+
* so the debit list has to subtract them back out, and the credit list keeps only
|
|
36
|
+
* them. Mirrors getScheduleAccruedDetailView, which is the form this one is
|
|
37
|
+
* modelled on.
|
|
38
|
+
*/
|
|
39
|
+
export const getNewAccrualAccountsView = (state) => {
|
|
40
|
+
const { accountState, accountListState, classState, classListState } = state;
|
|
41
|
+
const { newSchedule } = state.expenseAutomationJESchedulesViewState;
|
|
42
|
+
const accountType = getAccountsTypesForScheduleEpics();
|
|
43
|
+
const accrualAccountIds = getAccountIdsForTypes(accountState, getAccountsTypesForScheduleDetails('accrued_expenses'));
|
|
44
|
+
const accruedCategoryIds = getAccountIdsForLabels(accountState, ACCRUED_EXPENSE_ACCOUNT_LABELS);
|
|
45
|
+
const allAccountList = getAccountList(accountState, accountListState, accountType.accountListKey);
|
|
46
|
+
const nestedAccountHierarchy = getNestedAccountListHierarchy(accountListState, accountType.accountListKey);
|
|
47
|
+
const debitAccounts = allAccountList.accounts.filter((account) => accrualAccountIds.includes(account.accountId) &&
|
|
48
|
+
!accruedCategoryIds.includes(account.accountId));
|
|
49
|
+
const creditAccounts = allAccountList.accounts.filter((account) => accruedCategoryIds.includes(account.accountId));
|
|
50
|
+
const allClassList = getClassList(classState, classListState);
|
|
51
|
+
return {
|
|
52
|
+
accountListNestedAccountHierarchy: filterNestedAccountHierarchyById(nestedAccountHierarchy, debitAccounts.map((account) => account.accountId)),
|
|
53
|
+
accruedAccountListNestedAccountHierarchy: filterNestedAccountHierarchyById(nestedAccountHierarchy, creditAccounts.map((account) => account.accountId)),
|
|
54
|
+
allAccountList: debitAccounts,
|
|
55
|
+
allAccruedExpenseList: creditAccounts,
|
|
56
|
+
allClassList: allClassList.classes,
|
|
57
|
+
classListNestedAccountHierarchy: getNestedClassListHierarchy(classListState),
|
|
58
|
+
createStatus: newSchedule.createOneTimeAccrualStatus,
|
|
59
|
+
// The recurring accrued schedule saves through the accrued detail epics that the Vendor tab
|
|
60
|
+
// already uses, so its status is that slice's updateStatus rather than anything new here.
|
|
61
|
+
accruedScheduleSaveStatus: state.scheduleAccruedDetailState.updateStatus,
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
export const getNewScheduleView = (state, scheduleType) => {
|
|
65
|
+
const { accountState, accountListState, classState, classListState } = state;
|
|
66
|
+
const { newSchedule } = state.expenseAutomationJESchedulesViewState;
|
|
67
|
+
const searchTransactionsView = getNewScheduleSearchTransactionsView(state);
|
|
68
|
+
const accountType = getAccountsTypesForScheduleEpics();
|
|
69
|
+
const newScheduleAccountTypes = getAccountsTypesForScheduleDetails(scheduleType);
|
|
70
|
+
const newScheduleAccountIds = getAccountIdsForTypes(accountState, newScheduleAccountTypes);
|
|
71
|
+
const allAccountList = getAccountList(accountState, accountListState, accountType.accountListKey);
|
|
72
|
+
const filteredAccounts = allAccountList.accounts.filter((account) => newScheduleAccountIds.includes(account.accountId));
|
|
73
|
+
const accountListNestedAccountHierarchy = filterNestedAccountHierarchyById(getNestedAccountListHierarchy(accountListState, accountType.accountListKey), filteredAccounts.map((account) => account.accountId));
|
|
74
|
+
const allClassList = getClassList(classState, classListState);
|
|
75
|
+
const classListNestedAccountHierarchy = getNestedClassListHierarchy(classListState);
|
|
76
|
+
let allDepreciationAccountList;
|
|
77
|
+
let allDepreciationAccountListNestedAccountHierarchy;
|
|
78
|
+
if (scheduleType === 'fixed_assets') {
|
|
79
|
+
const depreciationCategoryIds = getAccountIdsForTypes(accountState, [
|
|
80
|
+
'fixed_assets',
|
|
81
|
+
'other_assets',
|
|
82
|
+
]);
|
|
83
|
+
const accountLabel = getAccountLabelForScheduleType('fixed_assets');
|
|
84
|
+
const fixedAssetLabelAccountIds = accountLabel != null
|
|
85
|
+
? getAccountIdsForLabel(accountListState, accountType.accountListKey, accountLabel)
|
|
86
|
+
: [];
|
|
87
|
+
allDepreciationAccountList = allAccountList.accounts.filter((account) => depreciationCategoryIds.includes(account.accountId) &&
|
|
88
|
+
!fixedAssetLabelAccountIds.includes(account.accountId));
|
|
89
|
+
allDepreciationAccountListNestedAccountHierarchy =
|
|
90
|
+
filterNestedAccountHierarchyById(getNestedAccountListHierarchy(accountListState, accountType.accountListKey), allDepreciationAccountList.map((account) => account.accountId));
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
scheduleType,
|
|
94
|
+
accountListNestedAccountHierarchy,
|
|
95
|
+
allAccountList: filteredAccounts,
|
|
96
|
+
allClassList: allClassList.classes,
|
|
97
|
+
allDepreciationAccountList,
|
|
98
|
+
allDepreciationAccountListNestedAccountHierarchy,
|
|
99
|
+
classListNestedAccountHierarchy,
|
|
100
|
+
newScheduleLocalData: newSchedule.newScheduleState[scheduleType],
|
|
101
|
+
saveStatus: newSchedule.saveStatus,
|
|
102
|
+
...searchTransactionsView,
|
|
103
|
+
fetchState: newSchedule.fetchState,
|
|
104
|
+
error: newSchedule.error,
|
|
105
|
+
};
|
|
106
|
+
};
|
|
@@ -3,7 +3,9 @@ import orderBy from 'lodash/orderBy';
|
|
|
3
3
|
import { reduceAnyFetchState } from '../../../commonStateTypes/reduceFetchState';
|
|
4
4
|
import { LAST_SCHEDULE_DAY_OF_MONTH, toMonthYearPeriodId, } from '../../../commonStateTypes/timePeriod';
|
|
5
5
|
import { getAccountIdsForTypes } from '../../../entity/account/accountSelector';
|
|
6
|
-
import {
|
|
6
|
+
import { generateJEOneTimeAccrualKey } from '../../../entity/jeSchedules/jeScheduleHelper';
|
|
7
|
+
import { getJEAccruedScheduleByJEScheduleKey, getJEOneTimeAccrualByKey, getJEScheduledTransactionByJEScheduleTransactionKey, } from '../../../entity/jeSchedules/jeSchedulesSelector';
|
|
8
|
+
import { ALL_SCHEDULES_TYPES, } from '../../../entity/jeSchedules/jeSchedulesTypes';
|
|
7
9
|
import { getCurrentTenant } from '../../../entity/tenant/tenantSelector';
|
|
8
10
|
import { getAccountIdsForLabel, getAccountList, getNestedAccountListHierarchy, getUncategorizedAccounts, } from '../../accountList/accountListSelector';
|
|
9
11
|
import { getClassList, getNestedClassListHierarchy, } from '../../classList/classListSelector';
|
|
@@ -11,8 +13,126 @@ import { getAccountsTypesForScheduleDetails } from '../../scheduleView/scheduleD
|
|
|
11
13
|
import { filterNestedAccountHierarchyById } from '../../scheduleView/scheduleDetailView/scheduleDetailSelector';
|
|
12
14
|
import { getAccountLabelForScheduleType, getAccountsTypesForScheduleList, } from '../../scheduleView/scheduleListView/scheduleListHelper';
|
|
13
15
|
import { getAllSteps } from './getAllStepsHelper';
|
|
16
|
+
import { ALL_JE_PAGE_TABS, getJESchedulePeriodTabKey, } from '../types/jeSchedulesViewState';
|
|
14
17
|
import { getJEAccountSettingsView } from './jeAccountSettingsViewSelector';
|
|
18
|
+
import { getNewScheduleView } from './jeNewScheduleViewSelector';
|
|
19
|
+
// Matches the AI-automation user addresses webc's schedule list row already
|
|
20
|
+
// checks (JEScheduleReadOnlyListRow/JEScheduleDraftListRow "Method" column,
|
|
21
|
+
// strings.ts aiBotEmail/botEmail) to determine whether a schedule was
|
|
22
|
+
// created by the AI accountant vs. a human.
|
|
23
|
+
const AI_BOT_EMAIL = 'ai@zeni.ai';
|
|
24
|
+
const BOT_EMAIL = 'bot@zeni.ai';
|
|
25
|
+
// A one-time accrual has no jeScheduleType of its own — it is not a JE schedule. It is still an
|
|
26
|
+
// accrued expense, so it counts and filters under that type on the page's type tabs.
|
|
27
|
+
const ONE_TIME_ACCRUAL_SCHEDULE_TYPE = 'accrued_expenses';
|
|
28
|
+
// Which of the two list buckets an accrual belongs in. `draft` still needs a human to post it;
|
|
29
|
+
// everything else is already on the books or in a transient claim.
|
|
30
|
+
const ONE_TIME_ACCRUAL_REVIEW_STATUSES = [
|
|
31
|
+
'draft',
|
|
32
|
+
];
|
|
33
|
+
/**
|
|
34
|
+
* `posting_blocked` is written by the posting Cron when a JE fails to post. It is an internal
|
|
35
|
+
* failure state with no human action attached, so it is dropped here rather than hidden at render
|
|
36
|
+
* time — filtering in the view would leave the group counts and KPI totals counting rows nobody
|
|
37
|
+
* can see. The expense-automation endpoint applies no status filter on the close-period path, so
|
|
38
|
+
* these rows do arrive.
|
|
39
|
+
*/
|
|
40
|
+
export function isRenderableOneTimeAccrual(accrual) {
|
|
41
|
+
return accrual.accrualStatus !== 'posting_blocked';
|
|
42
|
+
}
|
|
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
|
+
}
|
|
15
129
|
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) {
|
|
16
136
|
switch (sortKey) {
|
|
17
137
|
case 'vendor':
|
|
18
138
|
return (s) => s.vendor.name?.toLowerCase();
|
|
@@ -23,7 +143,9 @@ function getJEScheduleSortAccessor(sortKey) {
|
|
|
23
143
|
case 'depCategory':
|
|
24
144
|
return (s) => s.jeCredit.account?.accountName?.toLowerCase();
|
|
25
145
|
case 'scheduleCategory':
|
|
26
|
-
return (s) => s
|
|
146
|
+
return (s) => isAccruedScheduleRow(s)
|
|
147
|
+
? undefined
|
|
148
|
+
: s.baseTransaction.account?.accountName?.toLowerCase();
|
|
27
149
|
case 'startMonth':
|
|
28
150
|
return (s) => s.startDate?.valueOf();
|
|
29
151
|
case 'type':
|
|
@@ -51,11 +173,13 @@ function getJEScheduleSortAccessor(sortKey) {
|
|
|
51
173
|
return s.balanceAsOfToday?.amount ?? null;
|
|
52
174
|
};
|
|
53
175
|
case 'totalAmount':
|
|
54
|
-
return (s) => s
|
|
176
|
+
return (s) => getScheduleAmount(s);
|
|
55
177
|
case 'transactionDate':
|
|
56
|
-
return (s) => s.
|
|
178
|
+
return (s) => s.createTime?.valueOf();
|
|
57
179
|
case 'memo':
|
|
58
|
-
return (s) => s
|
|
180
|
+
return (s) => isAccruedScheduleRow(s)
|
|
181
|
+
? s.memo.toLowerCase()
|
|
182
|
+
: s.baseTransaction.memo?.toLowerCase();
|
|
59
183
|
default:
|
|
60
184
|
return (s) => s.startDate?.valueOf();
|
|
61
185
|
}
|
|
@@ -67,9 +191,15 @@ function sortJEScheduledTransactions(transactions, sortKey, sortOrder) {
|
|
|
67
191
|
export function getExpenseAutomationJESchedulesView(state) {
|
|
68
192
|
const jeScheduledTransaction = [];
|
|
69
193
|
const failedJeScheduledTransaction = [];
|
|
194
|
+
const accruedSchedules = [];
|
|
195
|
+
const oneTimeAccruals = [];
|
|
70
196
|
const { accountState, accountListState, classState, classListState, expenseAutomationJESchedulesViewState, expenseAutomationViewState, monthEndCloseChecksState, monthEndCloseChecksViewState, } = state;
|
|
71
|
-
const {
|
|
197
|
+
const { jeScheduleTransactionKeysByPeriodAndTab, jeScheduleAccruedKeysByPeriodAndTab, jeScheduleOneTimeAccrualKeysByPeriodAndTab, failedJeScheduleTransactionKeysByPeriodAndTab, jeScheduleLocalDataById, postStatusById, ignoreStatusById, revertStatusById, oneTimeAccrualActionStatusById, uiState, error, fetchState, refreshStatus, newSchedule, } = expenseAutomationJESchedulesViewState;
|
|
72
198
|
const accountSettingsView = getJEAccountSettingsView(state);
|
|
199
|
+
const newScheduleView = newSchedule.selectedDetailScheduleType === 'fixed_assets' ||
|
|
200
|
+
newSchedule.selectedDetailScheduleType === 'prepaid_expenses'
|
|
201
|
+
? getNewScheduleView(state, newSchedule.selectedDetailScheduleType)
|
|
202
|
+
: undefined;
|
|
73
203
|
const currentTenant = getCurrentTenant(state);
|
|
74
204
|
const { selectedPeriodByTenantId } = expenseAutomationViewState;
|
|
75
205
|
const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
|
|
@@ -97,27 +227,48 @@ export function getExpenseAutomationJESchedulesView(state) {
|
|
|
97
227
|
const filteredDepAccountListNestedAccountHierarchy = filterNestedAccountHierarchyById(depAccountListNestedAccountHierarchy, filteredDepAccounts.map((account) => account.accountId));
|
|
98
228
|
const classListNestedAccountHierarchy = getNestedClassListHierarchy(classListState);
|
|
99
229
|
const monthYearPeriodId = selectedPeriod != null ? toMonthYearPeriodId(selectedPeriod) : null;
|
|
100
|
-
const
|
|
101
|
-
?
|
|
102
|
-
: null;
|
|
103
|
-
const failedJeScheduleTransactionKeysForSelectedPeriod = monthYearPeriodId != null
|
|
104
|
-
? failedJeScheduleTransactionKeysByPeriod[monthYearPeriodId]
|
|
230
|
+
const selectedPeriodTabKey = monthYearPeriodId != null
|
|
231
|
+
? getJESchedulePeriodTabKey(uiState.selectedPageTab, monthYearPeriodId)
|
|
105
232
|
: null;
|
|
106
|
-
const
|
|
107
|
-
|
|
233
|
+
const jeScheduleTransactionKeysForSelectedTab = selectedPeriodTabKey != null
|
|
234
|
+
? jeScheduleTransactionKeysByPeriodAndTab[selectedPeriodTabKey]
|
|
235
|
+
: undefined;
|
|
236
|
+
const failedJeScheduleTransactionKeysForSelectedTab = selectedPeriodTabKey != null
|
|
237
|
+
? failedJeScheduleTransactionKeysByPeriodAndTab[selectedPeriodTabKey]
|
|
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
|
+
});
|
|
108
257
|
jeScheduleTransactionKeys.forEach((jeScheduleKey) => {
|
|
109
258
|
const jeScheduleDetails = getJEScheduledTransactionByJEScheduleTransactionKey(jeScheduleKey, state);
|
|
110
259
|
jeScheduledTransaction.push(jeScheduleDetails);
|
|
111
260
|
});
|
|
261
|
+
jeScheduleAccruedKeys.forEach((jeAccruedScheduleKey) => {
|
|
262
|
+
const accruedScheduleDetails = getJEAccruedScheduleByJEScheduleKey(jeAccruedScheduleKey, state);
|
|
263
|
+
if (accruedScheduleDetails != null) {
|
|
264
|
+
accruedSchedules.push(accruedScheduleDetails);
|
|
265
|
+
}
|
|
266
|
+
});
|
|
112
267
|
failedJeScheduleTransactionKeys.forEach((jeScheduleKey) => {
|
|
113
268
|
const jeScheduleDetails = getJEScheduledTransactionByJEScheduleTransactionKey(jeScheduleKey, state);
|
|
114
269
|
failedJeScheduledTransaction.push(jeScheduleDetails);
|
|
115
270
|
});
|
|
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);
|
|
271
|
+
const { sortKey, sortOrder, selectedJETypeFilter } = uiState;
|
|
121
272
|
const unsortedResolveSchedules = [];
|
|
122
273
|
failedJeScheduledTransaction.forEach((schedule) => {
|
|
123
274
|
schedule.scheduledJournalEntry.forEach((journalEntry) => {
|
|
@@ -129,10 +280,87 @@ export function getExpenseAutomationJESchedulesView(state) {
|
|
|
129
280
|
});
|
|
130
281
|
const resolveSchedules = sortJEScheduledTransactions(unsortedResolveSchedules, sortKey, sortOrder);
|
|
131
282
|
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
|
+
];
|
|
132
300
|
const pendingReviewSchedules = sortJEScheduledTransactions([
|
|
133
|
-
...
|
|
301
|
+
...allScheduleRows.filter((schedule) => isPendingReviewRow(schedule) && matchesTypeFilter(schedule)),
|
|
134
302
|
...validResolveForPending,
|
|
135
303
|
], 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
|
+
});
|
|
136
364
|
const allSteps = monthYearPeriodId != null
|
|
137
365
|
? getAllSteps(monthEndCloseChecksState, monthYearPeriodId, currentTenant.tenantId)
|
|
138
366
|
: [];
|
|
@@ -145,6 +373,20 @@ export function getExpenseAutomationJESchedulesView(state) {
|
|
|
145
373
|
{ fetchState, error },
|
|
146
374
|
monthEndFetchState,
|
|
147
375
|
]);
|
|
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
|
+
};
|
|
148
390
|
return {
|
|
149
391
|
uncategorizedAccounts,
|
|
150
392
|
allDepreciationAccountList: filteredDepAccounts,
|
|
@@ -153,14 +395,21 @@ export function getExpenseAutomationJESchedulesView(state) {
|
|
|
153
395
|
allAccountList: filteredAccounts,
|
|
154
396
|
accountListNestedAccountHierarchy,
|
|
155
397
|
allClassList: allClasses,
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
398
|
+
createdSchedules,
|
|
399
|
+
createdTotal,
|
|
400
|
+
hasLoadedForSelectedTab,
|
|
401
|
+
jeScheduleTypeCounts,
|
|
402
|
+
scheduleCountsByTab,
|
|
403
|
+
kpiSummary,
|
|
159
404
|
pendingReviewSchedules,
|
|
405
|
+
pendingReviewTotal,
|
|
160
406
|
resolveSchedules: resolveSchedules,
|
|
161
407
|
accountSettingsView,
|
|
408
|
+
newScheduleView,
|
|
162
409
|
postStatusById: postStatusById,
|
|
163
410
|
ignoreStatusById: ignoreStatusById,
|
|
411
|
+
revertStatusById: revertStatusById,
|
|
412
|
+
oneTimeAccrualActionStatusById: oneTimeAccrualActionStatusById,
|
|
164
413
|
fetchState: reducedFetchStatus.fetchState,
|
|
165
414
|
jeScheduleLocalDataById: jeScheduleLocalDataById,
|
|
166
415
|
uiState: uiState,
|
|
@@ -169,3 +418,26 @@ export function getExpenseAutomationJESchedulesView(state) {
|
|
|
169
418
|
completionStatus,
|
|
170
419
|
};
|
|
171
420
|
}
|
|
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
|
+
}
|
|
@@ -86,7 +86,7 @@ export const toTransactionView = (transaction, transactionLocalData) => {
|
|
|
86
86
|
export { getLastTransferEntryReplacement } from '../../createTransferEntry/createTransferEntrySelector';
|
|
87
87
|
export function getExpenseAutomationTransactionView(state) {
|
|
88
88
|
const { accountState, classState, classListState, accountListState, createTransferEntryState, expenseAutomationTransactionsViewState, expenseAutomationViewState, projectState, projectListState, transactionState, monthEndCloseChecksState, } = state;
|
|
89
|
-
const { selectedTransactionCategorizationCompletedSubTab, selectedTransactionCategorizationTab, } = expenseAutomationTransactionsViewState;
|
|
89
|
+
const { selectedTransactionCategorizationCompletedSubTab, selectedTransactionCategorizationTab, selectedTransactionGroup, } = expenseAutomationTransactionsViewState;
|
|
90
90
|
const { uiState, refreshStatus, saveStatus, markAsNotMiscategorizedStatus, transactionIdsBySelectedPeriod, transactionReviewLocalDataById, selectedCheckBoxTransactionIds, transactionIdsWithUnsavedData, uploadReceiptStatusById, selectedTransactionId, selectedTransactionLineId, filters, } = expenseAutomationTransactionsViewState.transactionCategorizationView[selectedTransactionCategorizationTab];
|
|
91
91
|
const uncategorizedIncomeExpense = getUncategorizedAccounts(accountState, accountListState, 'accountList');
|
|
92
92
|
const accountList = getAccountList(accountState, accountListState, 'accountList');
|
|
@@ -240,5 +240,6 @@ export function getExpenseAutomationTransactionView(state) {
|
|
|
240
240
|
creditCardTransferAccountsList,
|
|
241
241
|
transferAccounts: transferAccountsList,
|
|
242
242
|
selectedTransactionCategorizationCompletedSubTab,
|
|
243
|
+
selectedTransactionGroup,
|
|
243
244
|
};
|
|
244
245
|
}
|
|
@@ -16,9 +16,8 @@ const JE_SCHEDULE_SORT_KEYS = [
|
|
|
16
16
|
'memo',
|
|
17
17
|
];
|
|
18
18
|
export const toJEScheduleSortKey = (v) => stringToUnion(v, JE_SCHEDULE_SORT_KEYS);
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
export const toJEScheduleMainTab = (v) => stringToUnion(v, JE_SCHEDULE_MAIN_TABS);
|
|
19
|
+
const JE_PAGE_TABS = ['schedules', 'existing_schedules'];
|
|
20
|
+
export const toJEPageTab = (v) => stringToUnion(v, JE_PAGE_TABS);
|
|
21
|
+
export const ALL_JE_PAGE_TABS = JE_PAGE_TABS;
|
|
22
|
+
export const getJESchedulePeriodTabKey = (selectedPageTab, monthYearPeriodId) => `${selectedPageTab}_${monthYearPeriodId}`;
|
|
23
|
+
export const MIN_NEW_SCHEDULE_SEARCH_LENGTH = 2;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { stringToUnion } from '../../../commonStateTypes/stringToUnion';
|
|
2
|
+
/**
|
|
3
|
+
* Statement-level grouping for the Transaction Categorization listing, forwarded
|
|
4
|
+
* verbatim to the listing API as `transaction_group`. When revenue automation is
|
|
5
|
+
* enabled for the tenant the backend scopes the whole view by the line
|
|
6
|
+
* account_type: `'expense'` -> expense accounts, `'income'` -> income accounts,
|
|
7
|
+
* `'all'` -> both. When off, every value falls back to the legacy expense scope
|
|
8
|
+
* on the backend, so the group is only sent when the gate is on.
|
|
9
|
+
*
|
|
10
|
+
* The wire value for expenses is the singular `'expense'` (matches the backend
|
|
11
|
+
* `TransactionGroup` enum) even though the picker labels it "Expenses".
|
|
12
|
+
* Balance-sheet groups (assets, liability) are reserved for later and are not
|
|
13
|
+
* part of this union yet.
|
|
14
|
+
*/
|
|
15
|
+
export const TRANSACTION_GROUPS = ['all', 'income', 'expense'];
|
|
16
|
+
export const toTransactionGroup = (v) => stringToUnion(v != null ? v.trim().toLowerCase() : '', TRANSACTION_GROUPS);
|
|
17
|
+
/**
|
|
18
|
+
* Default group for the listing — matches the picker's default selection ("All").
|
|
19
|
+
* Single source of truth for initial slice state and any fall-back call site.
|
|
20
|
+
*/
|
|
21
|
+
export const DEFAULT_TRANSACTION_GROUP = 'all';
|
|
@@ -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,
|
|
4
|
+
import { INVOICING_INCOME_ACCOUNT_TYPES, getInvoicingQboView, invoicingAccountHierarchyForTypes, 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,7 +53,6 @@ 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),
|
|
57
56
|
qboClassHierarchy: isQboConnected
|
|
58
57
|
? getInvoicingQboView(state).nestedClassHierarchy
|
|
59
58
|
: [],
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { isInvoicingQboConnected } from '../invoicingQboView/invoicingQboViewSelector';
|
|
2
1
|
import { deriveInvoicingOnboardingStatus, } from './invoicingConfigViewPayload';
|
|
3
2
|
export const getInvoicingConfigView = (state) => {
|
|
4
3
|
const { acceptTermsFetchState, enableFetchState, ...configState } = state.invoicingConfigViewState;
|
|
@@ -15,7 +14,6 @@ export const getInvoicingOnboardingGateView = (state) => {
|
|
|
15
14
|
acceptTermsState: acceptTermsFetchState,
|
|
16
15
|
enableState: enableFetchState,
|
|
17
16
|
fetchState,
|
|
18
|
-
isQboConnected: isInvoicingQboConnected(state),
|
|
19
17
|
status: deriveInvoicingOnboardingStatus(state.invoicingConfigViewState.isInvoicingTosAccepted, state.invoicingConfigViewState.isInvoicingEnabled),
|
|
20
18
|
};
|
|
21
19
|
};
|
package/lib/esm/view/invoicing/invoicingQboView/epics/fetchInvoicingAccountingPickersEpic.js
CHANGED
|
@@ -9,17 +9,12 @@ 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
|
-
|
|
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 &&
|
|
12
|
+
if (accountList.hasValidState() === false &&
|
|
18
13
|
accountList.fetchState !== 'In-Progress') {
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
actions.push(fetchAccountList(INVOICING_ACCOUNT_LIST_KEY, true));
|
|
14
|
+
// AP/AR accounts cannot back an invoicing mapping, so they are excluded
|
|
15
|
+
// here — which is why this uses invoicing's own bucket rather than the
|
|
16
|
+
// general `accountList` other screens fill without those exclusions.
|
|
17
|
+
actions.push(fetchAccountList(INVOICING_ACCOUNT_LIST_KEY, true, true, true));
|
|
23
18
|
}
|
|
24
19
|
const classList = state.classListState;
|
|
25
20
|
if (classList.hasValidState() === false &&
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { of } from 'rxjs';
|
|
2
|
+
import { catchError, filter, map, mergeMap } from 'rxjs/operators';
|
|
3
|
+
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
|
|
4
|
+
import { mapInvoicingQboAccountOptions, } from '../invoicingQboViewPayload';
|
|
5
|
+
import { fetchInvoicingQboAccounts, updateInvoicingQboAccounts, updateInvoicingQboAccountsFailure, } from '../invoicingQboViewReducer';
|
|
6
|
+
export const fetchInvoicingQboAccountsEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(fetchInvoicingQboAccounts.match), mergeMap((action) => {
|
|
7
|
+
const { accountTypes } = action.payload;
|
|
8
|
+
const apiUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/qbo/accounts?account_types=${encodeURIComponent(accountTypes)}`;
|
|
9
|
+
return zeniAPI.getJSON(apiUrl).pipe(map((response) => {
|
|
10
|
+
if (isSuccessResponse(response)) {
|
|
11
|
+
return updateInvoicingQboAccounts({
|
|
12
|
+
accountTypes,
|
|
13
|
+
accounts: mapInvoicingQboAccountOptions(response.data?.accounts ?? []),
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return updateInvoicingQboAccountsFailure({
|
|
17
|
+
accountTypes,
|
|
18
|
+
status: response.status,
|
|
19
|
+
});
|
|
20
|
+
}), catchError((error) => of(updateInvoicingQboAccountsFailure({
|
|
21
|
+
accountTypes,
|
|
22
|
+
status: createZeniAPIStatus('Unexpected Error', 'Fetch QBO accounts REST API call errored out ' +
|
|
23
|
+
JSON.stringify(error)),
|
|
24
|
+
}))));
|
|
25
|
+
}));
|