@zeniai/client-epic-state 5.1.82 → 5.1.83-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/entity/jeSchedules/jeScheduleHelper.d.ts +2 -0
- package/lib/entity/jeSchedules/jeScheduleHelper.js +7 -0
- package/lib/entity/jeSchedules/jeSchedulesPayload.d.ts +34 -1
- package/lib/entity/jeSchedules/jeSchedulesPayload.js +68 -0
- package/lib/entity/jeSchedules/jeSchedulesReducer.d.ts +4 -2
- package/lib/entity/jeSchedules/jeSchedulesReducer.js +26 -2
- package/lib/entity/jeSchedules/jeSchedulesSelector.d.ts +10 -2
- package/lib/entity/jeSchedules/jeSchedulesSelector.js +28 -3
- package/lib/entity/jeSchedules/jeSchedulesState.d.ts +41 -1
- package/lib/entity/jeSchedules/jeSchedulesTypes.d.ts +12 -1
- package/lib/entity/jeSchedules/jeSchedulesTypes.js +40 -1
- package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
- package/lib/entity/snackbar/snackbarTypes.js +29 -0
- package/lib/entity/tenant/clearAllEpic.d.ts +2 -2
- package/lib/entity/tenant/clearAllEpic.js +1 -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 +5 -1
- package/lib/epic.js +5 -1
- package/lib/esm/entity/jeSchedules/jeScheduleHelper.js +6 -0
- package/lib/esm/entity/jeSchedules/jeSchedulesPayload.js +68 -1
- package/lib/esm/entity/jeSchedules/jeSchedulesReducer.js +26 -2
- package/lib/esm/entity/jeSchedules/jeSchedulesSelector.js +26 -2
- package/lib/esm/entity/jeSchedules/jeSchedulesTypes.js +34 -0
- package/lib/esm/entity/snackbar/snackbarTypes.js +29 -0
- package/lib/esm/entity/tenant/clearAllEpic.js +2 -1
- package/lib/esm/entity/transaction/payloadTypes/scheduleTransactionPayload.js +2 -0
- package/lib/esm/epic.js +5 -1
- package/lib/esm/index.js +11 -5
- package/lib/esm/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +6 -3
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +34 -3
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +21 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js +110 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +73 -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/reducers/jeSchedulesViewReducer.js +163 -28
- package/lib/esm/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +1 -0
- package/lib/esm/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +70 -0
- package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +260 -22
- package/lib/esm/view/expenseAutomationView/types/jeSchedulesViewState.js +5 -6
- package/lib/esm/view/invoicing/createCreditNote/createCreditNoteEpic.js +24 -4
- package/lib/esm/view/invoicing/createInvoice/createInvoiceEpic.js +24 -4
- package/lib/esm/view/invoicing/createInvoice/createInvoiceSelector.js +37 -10
- package/lib/esm/view/invoicing/discountAction/discountActionEpic.js +33 -9
- package/lib/esm/view/invoicing/dunningAction/dunningActionEpic.js +35 -9
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/catalogDetailEditPayload.js +5 -1
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +32 -5
- package/lib/esm/view/invoicing/editInvoicingCouponDetailView/saveInvoicingCouponEpic.js +23 -3
- package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/saveInvoicingCustomerEpic.js +24 -4
- package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/saveInvoicingSubscriptionEpic.js +24 -4
- package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/syncInvoicingSubscriptionCouponsEpic.js +20 -3
- package/lib/esm/view/invoicing/invoiceAction/invoiceActionEpic.js +60 -17
- package/lib/esm/view/invoicing/invoicingConfigView/invoicingConfigViewReducer.js +30 -0
- package/lib/esm/view/invoicing/invoicingConfigView/invoicingConfigViewSelector.js +4 -29
- package/lib/esm/view/invoicing/invoicingQboView/epics/retryInvoicingQboSyncTaskEpic.js +29 -10
- package/lib/esm/view/invoicing/invoicingQboView/epics/startInvoicingQboBackfillEpic.js +28 -5
- package/lib/esm/view/invoicing/issueCreditNote/issueCreditNoteEpic.js +24 -4
- package/lib/esm/view/invoicing/issueCreditNote/issueCreditNoteSelector.js +22 -14
- package/lib/esm/view/invoicing/recordPayment/recordPaymentEpic.js +46 -7
- package/lib/esm/view/invoicing/settingsView/settingsViewEpics.js +26 -8
- package/lib/esm/view/invoicing/settingsView/settingsViewReducer.js +1 -1
- package/lib/esm/view/invoicing/settingsView/settingsViewSelector.js +4 -1
- package/lib/esm/view/invoicing/subscriptionAction/subscriptionActionEpic.js +41 -9
- package/lib/index.d.ts +18 -13
- package/lib/index.js +72 -50
- package/lib/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +6 -3
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.d.ts +2 -2
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +32 -1
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.d.ts +8 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +25 -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 +77 -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 +8 -1
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +45 -10
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +164 -28
- 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 +25 -0
- package/lib/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +2 -0
- package/lib/view/expenseAutomationView/selectorTypes/jeSchedulesSelectorTypes.d.ts +34 -8
- package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.d.ts +10 -0
- package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +75 -0
- package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.d.ts +10 -1
- package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +266 -21
- package/lib/view/expenseAutomationView/types/completedSubTab.d.ts +1 -1
- package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +59 -8
- package/lib/view/expenseAutomationView/types/jeSchedulesViewState.js +8 -8
- package/lib/view/invoicing/createCreditNote/createCreditNoteEpic.d.ts +2 -1
- package/lib/view/invoicing/createCreditNote/createCreditNoteEpic.js +23 -3
- package/lib/view/invoicing/createInvoice/createInvoiceEpic.d.ts +2 -1
- package/lib/view/invoicing/createInvoice/createInvoiceEpic.js +23 -3
- package/lib/view/invoicing/createInvoice/createInvoiceSelector.d.ts +22 -8
- package/lib/view/invoicing/createInvoice/createInvoiceSelector.js +37 -10
- package/lib/view/invoicing/discountAction/discountActionEpic.d.ts +2 -1
- package/lib/view/invoicing/discountAction/discountActionEpic.js +32 -8
- package/lib/view/invoicing/dunningAction/dunningActionEpic.d.ts +2 -1
- package/lib/view/invoicing/dunningAction/dunningActionEpic.js +34 -8
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/catalogDetailEditPayload.d.ts +3 -1
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/catalogDetailEditPayload.js +5 -1
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.d.ts +2 -1
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +31 -4
- package/lib/view/invoicing/editInvoicingCouponDetailView/saveInvoicingCouponEpic.d.ts +2 -1
- package/lib/view/invoicing/editInvoicingCouponDetailView/saveInvoicingCouponEpic.js +22 -2
- package/lib/view/invoicing/editInvoicingCustomerDetailView/saveInvoicingCustomerEpic.d.ts +2 -1
- package/lib/view/invoicing/editInvoicingCustomerDetailView/saveInvoicingCustomerEpic.js +23 -3
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/saveInvoicingSubscriptionEpic.d.ts +2 -1
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/saveInvoicingSubscriptionEpic.js +23 -3
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/syncInvoicingSubscriptionCouponsEpic.d.ts +2 -1
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/syncInvoicingSubscriptionCouponsEpic.js +19 -2
- package/lib/view/invoicing/invoiceAction/invoiceActionEpic.d.ts +2 -1
- package/lib/view/invoicing/invoiceAction/invoiceActionEpic.js +59 -16
- package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewPayload.d.ts +13 -0
- package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewReducer.d.ts +1 -1
- package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewReducer.js +30 -0
- package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewSelector.d.ts +11 -31
- package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewSelector.js +4 -29
- package/lib/view/invoicing/invoicingConfigView/invoicingConfigViewState.d.ts +15 -0
- package/lib/view/invoicing/invoicingQboView/epics/invoicingQboViewActionType.d.ts +2 -1
- package/lib/view/invoicing/invoicingQboView/epics/retryInvoicingQboSyncTaskEpic.js +28 -9
- package/lib/view/invoicing/invoicingQboView/epics/startInvoicingQboBackfillEpic.js +27 -4
- package/lib/view/invoicing/issueCreditNote/issueCreditNoteEpic.d.ts +2 -1
- package/lib/view/invoicing/issueCreditNote/issueCreditNoteEpic.js +23 -3
- package/lib/view/invoicing/issueCreditNote/issueCreditNoteSelector.d.ts +24 -7
- package/lib/view/invoicing/issueCreditNote/issueCreditNoteSelector.js +23 -16
- package/lib/view/invoicing/recordPayment/recordPaymentEpic.d.ts +2 -1
- package/lib/view/invoicing/recordPayment/recordPaymentEpic.js +45 -6
- package/lib/view/invoicing/settingsView/settingsViewEpics.d.ts +2 -1
- package/lib/view/invoicing/settingsView/settingsViewEpics.js +25 -7
- package/lib/view/invoicing/settingsView/settingsViewReducer.d.ts +10 -1
- package/lib/view/invoicing/settingsView/settingsViewReducer.js +1 -1
- package/lib/view/invoicing/settingsView/settingsViewSelector.d.ts +4 -2
- package/lib/view/invoicing/settingsView/settingsViewSelector.js +4 -1
- package/lib/view/invoicing/subscriptionAction/subscriptionActionEpic.d.ts +2 -1
- package/lib/view/invoicing/subscriptionAction/subscriptionActionEpic.js +40 -8
- package/package.json +1 -1
|
@@ -4,12 +4,30 @@ import { CompletionStatusType, FetchStateAndError, ID } from '../../../commonSta
|
|
|
4
4
|
import { SelectorView } from '../../../commonStateTypes/viewAndReport/viewAndReport';
|
|
5
5
|
import { AccountBase } from '../../../entity/account/accountState';
|
|
6
6
|
import { ClassBase } from '../../../entity/class/classState';
|
|
7
|
-
import {
|
|
8
|
-
import { JEScheduleTransactionKey } from '../../../entity/jeSchedules/jeSchedulesTypes';
|
|
7
|
+
import { JEScheduleTransactionKey, ScheduleTypes } from '../../../entity/jeSchedules/jeSchedulesTypes';
|
|
9
8
|
import { UncategorizedAccounts } from '../../accountList/accountListSelector';
|
|
10
9
|
import { JEAccountSettingsView } from '../selectorTypes/jeAccountSettingsViewSelectorTypes';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
10
|
+
import { NewScheduleView } from '../selectorTypes/jeNewScheduleViewSelectorTypes';
|
|
11
|
+
import { JEScheduleRow, JEScheduledTransactionWithFailedEntries } from '../selectors/jeSchedulesViewSelector';
|
|
12
|
+
import { JEPageTab, JEScheduleLocalData, JESchedulesViewUIState } from '../types/jeSchedulesViewState';
|
|
13
|
+
export interface JEKpiSummary {
|
|
14
|
+
aiAccountant: {
|
|
15
|
+
amount: number;
|
|
16
|
+
count: number;
|
|
17
|
+
};
|
|
18
|
+
manual: {
|
|
19
|
+
amount: number;
|
|
20
|
+
count: number;
|
|
21
|
+
};
|
|
22
|
+
needsReview: {
|
|
23
|
+
amount: number;
|
|
24
|
+
count: number;
|
|
25
|
+
};
|
|
26
|
+
total: {
|
|
27
|
+
amount: number;
|
|
28
|
+
count: number;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
13
31
|
export interface ExpenseAutomationJESchedulesViewSelector extends SelectorView {
|
|
14
32
|
accountListNestedAccountHierarchy: NestedAccountHierarchyForReport[];
|
|
15
33
|
accountSettingsView: JEAccountSettingsView;
|
|
@@ -18,16 +36,24 @@ export interface ExpenseAutomationJESchedulesViewSelector extends SelectorView {
|
|
|
18
36
|
allDepreciationAccountList: AccountBase[];
|
|
19
37
|
allDepreciationAccountListNestedAccountHierarchy: NestedAccountHierarchyForReport[];
|
|
20
38
|
classListNestedAccountHierarchy: NestedClassHierarchyForReport[];
|
|
21
|
-
completedSchedules: JEScheduledTransaction[];
|
|
22
39
|
completionStatus: CompletionStatusType;
|
|
23
|
-
|
|
40
|
+
createdSchedules: JEScheduleRow[];
|
|
41
|
+
createdTotal: number;
|
|
42
|
+
hasLoadedForSelectedTab: boolean;
|
|
24
43
|
ignoreStatusById: Record<JEScheduleTransactionKey, FetchStateAndError>;
|
|
25
44
|
jeScheduleLocalDataById: Record<ID, JEScheduleLocalData>;
|
|
26
|
-
|
|
27
|
-
|
|
45
|
+
jeScheduleTypeCounts: {
|
|
46
|
+
active: Record<ScheduleTypes, number>;
|
|
47
|
+
ongoing: Record<ScheduleTypes, number>;
|
|
48
|
+
};
|
|
49
|
+
kpiSummary: JEKpiSummary;
|
|
50
|
+
newScheduleView: NewScheduleView | undefined;
|
|
51
|
+
pendingReviewSchedules: JEScheduleRow[];
|
|
52
|
+
pendingReviewTotal: number;
|
|
28
53
|
postStatusById: Record<ID, FetchStateAndError>;
|
|
29
54
|
refreshStatus: FetchStateAndError;
|
|
30
55
|
resolveSchedules: JEScheduledTransactionWithFailedEntries[];
|
|
56
|
+
scheduleCountsByTab: Partial<Record<JEPageTab, number>>;
|
|
31
57
|
uiState: JESchedulesViewUIState;
|
|
32
58
|
uncategorizedAccounts: UncategorizedAccounts;
|
|
33
59
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RootState } from '../../../reducer';
|
|
2
|
+
import { NewScheduleSearchTransactionsView, NewScheduleView } from '../selectorTypes/jeNewScheduleViewSelectorTypes';
|
|
3
|
+
/**
|
|
4
|
+
* The Base Transaction search is shared across schedule types (one search
|
|
5
|
+
* box, not one per prepaid_expenses/fixed_assets) — split out from
|
|
6
|
+
* getNewScheduleView so a consumer can read it without supplying an
|
|
7
|
+
* otherwise-irrelevant scheduleType.
|
|
8
|
+
*/
|
|
9
|
+
export declare const getNewScheduleSearchTransactionsView: (state: RootState) => NewScheduleSearchTransactionsView;
|
|
10
|
+
export declare const getNewScheduleView: (state: RootState, scheduleType: "fixed_assets" | "prepaid_expenses") => NewScheduleView;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getNewScheduleView = 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 getNewScheduleView = (state, scheduleType) => {
|
|
33
|
+
const { accountState, accountListState, classState, classListState } = state;
|
|
34
|
+
const { newSchedule } = state.expenseAutomationJESchedulesViewState;
|
|
35
|
+
const searchTransactionsView = (0, exports.getNewScheduleSearchTransactionsView)(state);
|
|
36
|
+
const accountType = (0, scheduleListHelper_1.getAccountsTypesForScheduleEpics)();
|
|
37
|
+
const newScheduleAccountTypes = (0, scheduleDetailLocalDataHelper_1.getAccountsTypesForScheduleDetails)(scheduleType);
|
|
38
|
+
const newScheduleAccountIds = (0, accountSelector_1.getAccountIdsForTypes)(accountState, newScheduleAccountTypes);
|
|
39
|
+
const allAccountList = (0, accountListSelector_1.getAccountList)(accountState, accountListState, accountType.accountListKey);
|
|
40
|
+
const filteredAccounts = allAccountList.accounts.filter((account) => newScheduleAccountIds.includes(account.accountId));
|
|
41
|
+
const accountListNestedAccountHierarchy = (0, scheduleDetailSelector_1.filterNestedAccountHierarchyById)((0, accountListSelector_1.getNestedAccountListHierarchy)(accountListState, accountType.accountListKey), filteredAccounts.map((account) => account.accountId));
|
|
42
|
+
const allClassList = (0, classListSelector_1.getClassList)(classState, classListState);
|
|
43
|
+
const classListNestedAccountHierarchy = (0, classListSelector_1.getNestedClassListHierarchy)(classListState);
|
|
44
|
+
let allDepreciationAccountList;
|
|
45
|
+
let allDepreciationAccountListNestedAccountHierarchy;
|
|
46
|
+
if (scheduleType === 'fixed_assets') {
|
|
47
|
+
const depreciationCategoryIds = (0, accountSelector_1.getAccountIdsForTypes)(accountState, [
|
|
48
|
+
'fixed_assets',
|
|
49
|
+
'other_assets',
|
|
50
|
+
]);
|
|
51
|
+
const accountLabel = (0, scheduleListHelper_1.getAccountLabelForScheduleType)('fixed_assets');
|
|
52
|
+
const fixedAssetLabelAccountIds = accountLabel != null
|
|
53
|
+
? (0, accountListSelector_1.getAccountIdsForLabel)(accountListState, accountType.accountListKey, accountLabel)
|
|
54
|
+
: [];
|
|
55
|
+
allDepreciationAccountList = allAccountList.accounts.filter((account) => depreciationCategoryIds.includes(account.accountId) &&
|
|
56
|
+
!fixedAssetLabelAccountIds.includes(account.accountId));
|
|
57
|
+
allDepreciationAccountListNestedAccountHierarchy =
|
|
58
|
+
(0, scheduleDetailSelector_1.filterNestedAccountHierarchyById)((0, accountListSelector_1.getNestedAccountListHierarchy)(accountListState, accountType.accountListKey), allDepreciationAccountList.map((account) => account.accountId));
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
scheduleType,
|
|
62
|
+
accountListNestedAccountHierarchy,
|
|
63
|
+
allAccountList: filteredAccounts,
|
|
64
|
+
allClassList: allClassList.classes,
|
|
65
|
+
allDepreciationAccountList,
|
|
66
|
+
allDepreciationAccountListNestedAccountHierarchy,
|
|
67
|
+
classListNestedAccountHierarchy,
|
|
68
|
+
newScheduleLocalData: newSchedule.newScheduleState[scheduleType],
|
|
69
|
+
saveStatus: newSchedule.saveStatus,
|
|
70
|
+
...searchTransactionsView,
|
|
71
|
+
fetchState: newSchedule.fetchState,
|
|
72
|
+
error: newSchedule.error,
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
exports.getNewScheduleView = getNewScheduleView;
|
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
import { JEScheduledTransaction, ScheduledJournalEntry } from '../../../entity/jeSchedules/jeSchedulesSelector';
|
|
1
|
+
import { JEAccruedSchedule, JEOneTimeAccrual, JEScheduledTransaction, ScheduledJournalEntry } from '../../../entity/jeSchedules/jeSchedulesSelector';
|
|
2
|
+
import { ScheduleTypes } from '../../../entity/jeSchedules/jeSchedulesTypes';
|
|
2
3
|
import { RootState } from '../../../reducer';
|
|
3
4
|
import { ExpenseAutomationJESchedulesViewSelector } from '../selectorTypes/jeSchedulesSelectorTypes';
|
|
5
|
+
export declare function getJEScheduleRowType(schedule: JEScheduleRow): ScheduleTypes | undefined;
|
|
6
|
+
export declare function isPendingReviewRow(schedule: JEScheduleRow): boolean;
|
|
7
|
+
export declare function isExistingTabRow(schedule: JEScheduleRow): boolean;
|
|
8
|
+
export declare const isAiAccountantSchedule: (schedule: JEScheduleRow) => boolean;
|
|
9
|
+
export declare function isAccruedScheduleRow(schedule: JEScheduleRow): schedule is JEAccruedSchedule;
|
|
10
|
+
export declare function isOneTimeAccrualRow(schedule: JEScheduleRow): schedule is JEOneTimeAccrual;
|
|
4
11
|
export declare function getExpenseAutomationJESchedulesView(state: RootState): ExpenseAutomationJESchedulesViewSelector;
|
|
5
12
|
export interface JEScheduledTransactionWithFailedEntries extends Omit<JEScheduledTransaction, 'scheduledJournalEntry'> {
|
|
6
13
|
scheduledJournalEntry: ScheduledJournalEntry;
|
|
7
14
|
}
|
|
15
|
+
export type JEScheduleRow = JEAccruedSchedule | JEOneTimeAccrual | JEScheduledTransaction | JEScheduledTransactionWithFailedEntries;
|
|
16
|
+
export type JEScheduleRowWithoutOneTimeAccrual = Exclude<JEScheduleRow, JEOneTimeAccrual>;
|
|
@@ -3,6 +3,12 @@ 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.getJEScheduleRowType = getJEScheduleRowType;
|
|
8
|
+
exports.isPendingReviewRow = isPendingReviewRow;
|
|
9
|
+
exports.isExistingTabRow = isExistingTabRow;
|
|
10
|
+
exports.isAccruedScheduleRow = isAccruedScheduleRow;
|
|
11
|
+
exports.isOneTimeAccrualRow = isOneTimeAccrualRow;
|
|
6
12
|
exports.getExpenseAutomationJESchedulesView = getExpenseAutomationJESchedulesView;
|
|
7
13
|
const omit_1 = __importDefault(require("lodash/omit"));
|
|
8
14
|
const orderBy_1 = __importDefault(require("lodash/orderBy"));
|
|
@@ -10,6 +16,7 @@ const reduceFetchState_1 = require("../../../commonStateTypes/reduceFetchState")
|
|
|
10
16
|
const timePeriod_1 = require("../../../commonStateTypes/timePeriod");
|
|
11
17
|
const accountSelector_1 = require("../../../entity/account/accountSelector");
|
|
12
18
|
const jeSchedulesSelector_1 = require("../../../entity/jeSchedules/jeSchedulesSelector");
|
|
19
|
+
const jeSchedulesTypes_1 = require("../../../entity/jeSchedules/jeSchedulesTypes");
|
|
13
20
|
const tenantSelector_1 = require("../../../entity/tenant/tenantSelector");
|
|
14
21
|
const accountListSelector_1 = require("../../accountList/accountListSelector");
|
|
15
22
|
const classListSelector_1 = require("../../classList/classListSelector");
|
|
@@ -17,8 +24,119 @@ const scheduleDetailLocalDataHelper_1 = require("../../scheduleView/scheduleDeta
|
|
|
17
24
|
const scheduleDetailSelector_1 = require("../../scheduleView/scheduleDetailView/scheduleDetailSelector");
|
|
18
25
|
const scheduleListHelper_1 = require("../../scheduleView/scheduleListView/scheduleListHelper");
|
|
19
26
|
const expenseAutomationViewSelectorTypes_1 = require("../selectorTypes/expenseAutomationViewSelectorTypes");
|
|
27
|
+
const jeSchedulesViewState_1 = require("../types/jeSchedulesViewState");
|
|
20
28
|
const jeAccountSettingsViewSelector_1 = require("./jeAccountSettingsViewSelector");
|
|
29
|
+
const jeNewScheduleViewSelector_1 = require("./jeNewScheduleViewSelector");
|
|
30
|
+
// Matches the AI-automation user addresses webc's schedule list row already
|
|
31
|
+
// checks (JEScheduleReadOnlyListRow/JEScheduleDraftListRow "Method" column,
|
|
32
|
+
// strings.ts aiBotEmail/botEmail) to determine whether a schedule was
|
|
33
|
+
// created by the AI accountant vs. a human.
|
|
34
|
+
const AI_BOT_EMAIL = 'ai@zeni.ai';
|
|
35
|
+
const BOT_EMAIL = 'bot@zeni.ai';
|
|
36
|
+
// A one-time accrual has no jeScheduleType of its own — it is not a JE schedule. It is still an
|
|
37
|
+
// accrued expense, so it counts and filters under that type on the page's type tabs.
|
|
38
|
+
const ONE_TIME_ACCRUAL_SCHEDULE_TYPE = 'accrued_expenses';
|
|
39
|
+
// Which of the two list buckets an accrual belongs in. `draft` still needs a human to post it and
|
|
40
|
+
// `posting_blocked` needs attention, so both are review work; everything else is already on the
|
|
41
|
+
// books or in a transient claim.
|
|
42
|
+
const ONE_TIME_ACCRUAL_REVIEW_STATUSES = [
|
|
43
|
+
'draft',
|
|
44
|
+
'posting_blocked',
|
|
45
|
+
];
|
|
46
|
+
function getJEScheduleRowType(schedule) {
|
|
47
|
+
return isOneTimeAccrualRow(schedule)
|
|
48
|
+
? ONE_TIME_ACCRUAL_SCHEDULE_TYPE
|
|
49
|
+
: schedule.jeScheduleType;
|
|
50
|
+
}
|
|
51
|
+
function isPendingReviewRow(schedule) {
|
|
52
|
+
return isOneTimeAccrualRow(schedule)
|
|
53
|
+
? ONE_TIME_ACCRUAL_REVIEW_STATUSES.includes(schedule.accrualStatus)
|
|
54
|
+
: schedule.status.code === 'draft';
|
|
55
|
+
}
|
|
56
|
+
// Belongs on the Existing Schedules tab. For an accrual the endpoint has already filtered to
|
|
57
|
+
// posted, so this only has to agree with that rather than re-derive it.
|
|
58
|
+
function isExistingTabRow(schedule) {
|
|
59
|
+
return isOneTimeAccrualRow(schedule)
|
|
60
|
+
? schedule.accrualStatus === 'posted'
|
|
61
|
+
: schedule.status.code === 'ongoing';
|
|
62
|
+
}
|
|
63
|
+
// Exported (rather than kept as a closure inside the selector) so it can be
|
|
64
|
+
// unit-tested directly — confidenceScore is a separate, more narrowly
|
|
65
|
+
// populated field that can be null on a schedule the bot user created,
|
|
66
|
+
// which previously caused these schedules to display as "AI Accountant" in
|
|
67
|
+
// the list but count under "Manual" in the KPI summary.
|
|
68
|
+
const isAiAccountantSchedule = (schedule) => {
|
|
69
|
+
// A one-time accrual records who made it as `origin`, which is authoritative — no email
|
|
70
|
+
// sniffing needed, and the JE bot is often absent from the user entity entirely.
|
|
71
|
+
if (isOneTimeAccrualRow(schedule)) {
|
|
72
|
+
return schedule.origin === 'agent';
|
|
73
|
+
}
|
|
74
|
+
return (schedule.createdByUser?.email === AI_BOT_EMAIL ||
|
|
75
|
+
schedule.createdByUser?.email === BOT_EMAIL);
|
|
76
|
+
};
|
|
77
|
+
exports.isAiAccountantSchedule = isAiAccountantSchedule;
|
|
78
|
+
// Accrued schedules are structurally distinct — no baseTransaction, carrying recurringAmount and
|
|
79
|
+
// memo in its place — so anything reading baseTransaction has to branch on this first.
|
|
80
|
+
//
|
|
81
|
+
// Discriminates on jeAccruedScheduleKey, which only JEAccruedSchedule carries. jeScheduleType
|
|
82
|
+
// cannot be used: it is a data field present on BOTH row shapes, so an accrued-typed row that
|
|
83
|
+
// arrived through the prepaid/fixed DTO (failed_je_postings, legacy fetches) would be
|
|
84
|
+
// misclassified and then crash on recurringAmount / jeAccruedScheduleKey.
|
|
85
|
+
function isAccruedScheduleRow(schedule) {
|
|
86
|
+
return 'jeAccruedScheduleKey' in schedule;
|
|
87
|
+
}
|
|
88
|
+
// Same structural approach as isAccruedScheduleRow, and for the same reason: jeOneTimeAccrualKey
|
|
89
|
+
// exists only on this shape. Note the two guards are NOT interchangeable — a one-time accrual is
|
|
90
|
+
// not an accrued *schedule*, and routing it into the accrued branch would read recurringAmount,
|
|
91
|
+
// render postedCount/lifecycleTotal as a lifecycle and startDate–endDate as a period, none of
|
|
92
|
+
// which it has.
|
|
93
|
+
function isOneTimeAccrualRow(schedule) {
|
|
94
|
+
return 'jeOneTimeAccrualKey' in schedule;
|
|
95
|
+
}
|
|
96
|
+
function getScheduleAmount(schedule) {
|
|
97
|
+
if (isOneTimeAccrualRow(schedule)) {
|
|
98
|
+
return schedule.estimatedAmount.amount;
|
|
99
|
+
}
|
|
100
|
+
if (isAccruedScheduleRow(schedule)) {
|
|
101
|
+
return schedule.recurringAmount.amount;
|
|
102
|
+
}
|
|
103
|
+
return schedule.baseTransaction.amount.amount;
|
|
104
|
+
}
|
|
105
|
+
// A one-time accrual shares almost no sortable field with a schedule, so it gets its own accessor
|
|
106
|
+
// rather than a guard on each of the dozen cases below. Keys with no meaning for a single-month
|
|
107
|
+
// accrual -- amortizationPeriod, remainingMonths, runningBalance, jePostingDate, scheduleCategory --
|
|
108
|
+
// deliberately fall through to undefined, which sorts them together at one end.
|
|
109
|
+
function getOneTimeAccrualSortValue(accrual, sortKey) {
|
|
110
|
+
switch (sortKey) {
|
|
111
|
+
case 'vendor':
|
|
112
|
+
return accrual.vendorName.toLowerCase();
|
|
113
|
+
case 'category':
|
|
114
|
+
return accrual.jeDebitAccountName?.toLowerCase();
|
|
115
|
+
case 'class':
|
|
116
|
+
return accrual.jeDebitAccountingClassName?.toLowerCase();
|
|
117
|
+
case 'depCategory':
|
|
118
|
+
return accrual.jeCreditAccountName?.toLowerCase();
|
|
119
|
+
case 'type':
|
|
120
|
+
return ONE_TIME_ACCRUAL_SCHEDULE_TYPE;
|
|
121
|
+
case 'totalAmount':
|
|
122
|
+
return accrual.estimatedAmount.amount;
|
|
123
|
+
case 'transactionDate':
|
|
124
|
+
return accrual.postingDate?.valueOf();
|
|
125
|
+
case 'memo':
|
|
126
|
+
return accrual.memo.toLowerCase();
|
|
127
|
+
case 'startMonth':
|
|
128
|
+
return accrual.serviceMonth;
|
|
129
|
+
default:
|
|
130
|
+
return undefined;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
21
133
|
function getJEScheduleSortAccessor(sortKey) {
|
|
134
|
+
const scheduleAccessor = getScheduleRowSortAccessor(sortKey);
|
|
135
|
+
return (schedule) => isOneTimeAccrualRow(schedule)
|
|
136
|
+
? getOneTimeAccrualSortValue(schedule, sortKey)
|
|
137
|
+
: scheduleAccessor(schedule);
|
|
138
|
+
}
|
|
139
|
+
function getScheduleRowSortAccessor(sortKey) {
|
|
22
140
|
switch (sortKey) {
|
|
23
141
|
case 'vendor':
|
|
24
142
|
return (s) => s.vendor.name?.toLowerCase();
|
|
@@ -29,7 +147,9 @@ function getJEScheduleSortAccessor(sortKey) {
|
|
|
29
147
|
case 'depCategory':
|
|
30
148
|
return (s) => s.jeCredit.account?.accountName?.toLowerCase();
|
|
31
149
|
case 'scheduleCategory':
|
|
32
|
-
return (s) => s
|
|
150
|
+
return (s) => isAccruedScheduleRow(s)
|
|
151
|
+
? undefined
|
|
152
|
+
: s.baseTransaction.account?.accountName?.toLowerCase();
|
|
33
153
|
case 'startMonth':
|
|
34
154
|
return (s) => s.startDate?.valueOf();
|
|
35
155
|
case 'type':
|
|
@@ -57,11 +177,13 @@ function getJEScheduleSortAccessor(sortKey) {
|
|
|
57
177
|
return s.balanceAsOfToday?.amount ?? null;
|
|
58
178
|
};
|
|
59
179
|
case 'totalAmount':
|
|
60
|
-
return (s) => s
|
|
180
|
+
return (s) => getScheduleAmount(s);
|
|
61
181
|
case 'transactionDate':
|
|
62
|
-
return (s) => s.
|
|
182
|
+
return (s) => s.createTime?.valueOf();
|
|
63
183
|
case 'memo':
|
|
64
|
-
return (s) => s
|
|
184
|
+
return (s) => isAccruedScheduleRow(s)
|
|
185
|
+
? s.memo.toLowerCase()
|
|
186
|
+
: s.baseTransaction.memo?.toLowerCase();
|
|
65
187
|
default:
|
|
66
188
|
return (s) => s.startDate?.valueOf();
|
|
67
189
|
}
|
|
@@ -73,9 +195,15 @@ function sortJEScheduledTransactions(transactions, sortKey, sortOrder) {
|
|
|
73
195
|
function getExpenseAutomationJESchedulesView(state) {
|
|
74
196
|
const jeScheduledTransaction = [];
|
|
75
197
|
const failedJeScheduledTransaction = [];
|
|
198
|
+
const accruedSchedules = [];
|
|
199
|
+
const oneTimeAccruals = [];
|
|
76
200
|
const { accountState, accountListState, classState, classListState, expenseAutomationJESchedulesViewState, expenseAutomationViewState, monthEndCloseChecksState, monthEndCloseChecksViewState, } = state;
|
|
77
|
-
const {
|
|
201
|
+
const { jeScheduleTransactionKeysByPeriodAndTab, jeScheduleAccruedKeysByPeriodAndTab, jeScheduleOneTimeAccrualKeysByPeriodAndTab, failedJeScheduleTransactionKeysByPeriodAndTab, jeScheduleLocalDataById, postStatusById, ignoreStatusById, uiState, error, fetchState, refreshStatus, newSchedule, } = expenseAutomationJESchedulesViewState;
|
|
78
202
|
const accountSettingsView = (0, jeAccountSettingsViewSelector_1.getJEAccountSettingsView)(state);
|
|
203
|
+
const newScheduleView = newSchedule.selectedDetailScheduleType === 'fixed_assets' ||
|
|
204
|
+
newSchedule.selectedDetailScheduleType === 'prepaid_expenses'
|
|
205
|
+
? (0, jeNewScheduleViewSelector_1.getNewScheduleView)(state, newSchedule.selectedDetailScheduleType)
|
|
206
|
+
: undefined;
|
|
79
207
|
const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state);
|
|
80
208
|
const { selectedPeriodByTenantId } = expenseAutomationViewState;
|
|
81
209
|
const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
|
|
@@ -103,27 +231,48 @@ function getExpenseAutomationJESchedulesView(state) {
|
|
|
103
231
|
const filteredDepAccountListNestedAccountHierarchy = (0, scheduleDetailSelector_1.filterNestedAccountHierarchyById)(depAccountListNestedAccountHierarchy, filteredDepAccounts.map((account) => account.accountId));
|
|
104
232
|
const classListNestedAccountHierarchy = (0, classListSelector_1.getNestedClassListHierarchy)(classListState);
|
|
105
233
|
const monthYearPeriodId = selectedPeriod != null ? (0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod) : null;
|
|
106
|
-
const
|
|
107
|
-
?
|
|
108
|
-
: null;
|
|
109
|
-
const failedJeScheduleTransactionKeysForSelectedPeriod = monthYearPeriodId != null
|
|
110
|
-
? failedJeScheduleTransactionKeysByPeriod[monthYearPeriodId]
|
|
234
|
+
const selectedPeriodTabKey = monthYearPeriodId != null
|
|
235
|
+
? (0, jeSchedulesViewState_1.getJESchedulePeriodTabKey)(uiState.selectedPageTab, monthYearPeriodId)
|
|
111
236
|
: null;
|
|
112
|
-
const
|
|
113
|
-
|
|
237
|
+
const jeScheduleTransactionKeysForSelectedTab = selectedPeriodTabKey != null
|
|
238
|
+
? jeScheduleTransactionKeysByPeriodAndTab[selectedPeriodTabKey]
|
|
239
|
+
: undefined;
|
|
240
|
+
const failedJeScheduleTransactionKeysForSelectedTab = selectedPeriodTabKey != null
|
|
241
|
+
? failedJeScheduleTransactionKeysByPeriodAndTab[selectedPeriodTabKey]
|
|
242
|
+
: undefined;
|
|
243
|
+
// Distinguishes "this tab has never been fetched for this period" from "fetched and genuinely
|
|
244
|
+
// empty". Without it the page cannot tell a first visit from a real empty state, and renders an
|
|
245
|
+
// empty table where it should render a skeleton.
|
|
246
|
+
const hasLoadedForSelectedTab = jeScheduleTransactionKeysForSelectedTab != null;
|
|
247
|
+
const jeScheduleTransactionKeys = jeScheduleTransactionKeysForSelectedTab ?? [];
|
|
248
|
+
const failedJeScheduleTransactionKeys = failedJeScheduleTransactionKeysForSelectedTab ?? [];
|
|
249
|
+
const jeScheduleAccruedKeys = (selectedPeriodTabKey != null
|
|
250
|
+
? jeScheduleAccruedKeysByPeriodAndTab[selectedPeriodTabKey]
|
|
251
|
+
: undefined) ?? [];
|
|
252
|
+
const jeScheduleOneTimeAccrualKeys = (selectedPeriodTabKey != null
|
|
253
|
+
? jeScheduleOneTimeAccrualKeysByPeriodAndTab[selectedPeriodTabKey]
|
|
254
|
+
: undefined) ?? [];
|
|
255
|
+
jeScheduleOneTimeAccrualKeys.forEach((jeOneTimeAccrualKey) => {
|
|
256
|
+
const accrual = (0, jeSchedulesSelector_1.getJEOneTimeAccrualByKey)(jeOneTimeAccrualKey, state.jeSchedulesState);
|
|
257
|
+
if (accrual != null) {
|
|
258
|
+
oneTimeAccruals.push(accrual);
|
|
259
|
+
}
|
|
260
|
+
});
|
|
114
261
|
jeScheduleTransactionKeys.forEach((jeScheduleKey) => {
|
|
115
262
|
const jeScheduleDetails = (0, jeSchedulesSelector_1.getJEScheduledTransactionByJEScheduleTransactionKey)(jeScheduleKey, state);
|
|
116
263
|
jeScheduledTransaction.push(jeScheduleDetails);
|
|
117
264
|
});
|
|
265
|
+
jeScheduleAccruedKeys.forEach((jeAccruedScheduleKey) => {
|
|
266
|
+
const accruedScheduleDetails = (0, jeSchedulesSelector_1.getJEAccruedScheduleByJEScheduleKey)(jeAccruedScheduleKey, state);
|
|
267
|
+
if (accruedScheduleDetails != null) {
|
|
268
|
+
accruedSchedules.push(accruedScheduleDetails);
|
|
269
|
+
}
|
|
270
|
+
});
|
|
118
271
|
failedJeScheduleTransactionKeys.forEach((jeScheduleKey) => {
|
|
119
272
|
const jeScheduleDetails = (0, jeSchedulesSelector_1.getJEScheduledTransactionByJEScheduleTransactionKey)(jeScheduleKey, state);
|
|
120
273
|
failedJeScheduledTransaction.push(jeScheduleDetails);
|
|
121
274
|
});
|
|
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);
|
|
275
|
+
const { sortKey, sortOrder, selectedJETypeFilter } = uiState;
|
|
127
276
|
const unsortedResolveSchedules = [];
|
|
128
277
|
failedJeScheduledTransaction.forEach((schedule) => {
|
|
129
278
|
schedule.scheduledJournalEntry.forEach((journalEntry) => {
|
|
@@ -135,10 +284,87 @@ function getExpenseAutomationJESchedulesView(state) {
|
|
|
135
284
|
});
|
|
136
285
|
const resolveSchedules = sortJEScheduledTransactions(unsortedResolveSchedules, sortKey, sortOrder);
|
|
137
286
|
const validResolveForPending = unsortedResolveSchedules.filter((r) => jeScheduleLocalDataById[r.scheduledJournalEntry.scheduledJournalEntryID] != null);
|
|
287
|
+
const matchesTypeFilter = (schedule) => selectedJETypeFilter == null ||
|
|
288
|
+
getJEScheduleRowType(schedule) === selectedJETypeFilter;
|
|
289
|
+
const isCreatedStatus = (schedule) => {
|
|
290
|
+
// An accrual is "created" once it is not review work: posted, reversing, reversed, or in a
|
|
291
|
+
// transient posting claim.
|
|
292
|
+
if (isOneTimeAccrualRow(schedule)) {
|
|
293
|
+
return !isPendingReviewRow(schedule);
|
|
294
|
+
}
|
|
295
|
+
return (schedule.status.code === 'ongoing' ||
|
|
296
|
+
schedule.status.code === 'completed' ||
|
|
297
|
+
schedule.status.code === 'marked_as_completed');
|
|
298
|
+
};
|
|
299
|
+
const allScheduleRows = [
|
|
300
|
+
...jeScheduledTransaction,
|
|
301
|
+
...accruedSchedules,
|
|
302
|
+
...oneTimeAccruals,
|
|
303
|
+
];
|
|
138
304
|
const pendingReviewSchedules = sortJEScheduledTransactions([
|
|
139
|
-
...
|
|
305
|
+
...allScheduleRows.filter((schedule) => isPendingReviewRow(schedule) && matchesTypeFilter(schedule)),
|
|
140
306
|
...validResolveForPending,
|
|
141
307
|
], sortKey, sortOrder);
|
|
308
|
+
const createdSchedules = sortJEScheduledTransactions(allScheduleRows.filter((schedule) => isCreatedStatus(schedule) && matchesTypeFilter(schedule)), sortKey, sortOrder);
|
|
309
|
+
// KPI summary — derived from unfiltered schedules so counts are always accurate
|
|
310
|
+
const allSchedules = allScheduleRows;
|
|
311
|
+
const sumAmount = (schedules) => schedules.reduce((total, schedule) => total + (getScheduleAmount(schedule) ?? 0), 0);
|
|
312
|
+
const pendingReviewTotal = sumAmount(pendingReviewSchedules);
|
|
313
|
+
const createdTotal = sumAmount(createdSchedules);
|
|
314
|
+
const aiAccountantSchedules = allSchedules.filter(exports.isAiAccountantSchedule);
|
|
315
|
+
const manualSchedules = allSchedules.filter((schedule) => !(0, exports.isAiAccountantSchedule)(schedule));
|
|
316
|
+
const pendingUnfiltered = allSchedules.filter((schedule) => isPendingReviewRow(schedule));
|
|
317
|
+
const kpiSummary = {
|
|
318
|
+
aiAccountant: {
|
|
319
|
+
count: aiAccountantSchedules.length,
|
|
320
|
+
amount: sumAmount(aiAccountantSchedules),
|
|
321
|
+
},
|
|
322
|
+
manual: {
|
|
323
|
+
count: manualSchedules.length,
|
|
324
|
+
amount: sumAmount(manualSchedules),
|
|
325
|
+
},
|
|
326
|
+
needsReview: {
|
|
327
|
+
count: pendingUnfiltered.length,
|
|
328
|
+
amount: sumAmount(pendingUnfiltered),
|
|
329
|
+
},
|
|
330
|
+
total: {
|
|
331
|
+
count: allSchedules.length,
|
|
332
|
+
amount: sumAmount(allSchedules),
|
|
333
|
+
},
|
|
334
|
+
};
|
|
335
|
+
// Each tab's badge counts from that tab's own bucket. A tab that has not been fetched yet
|
|
336
|
+
// reports undefined rather than 0, so the UI can hide the badge instead of asserting "none".
|
|
337
|
+
const scheduleCountsByTab = {};
|
|
338
|
+
jeSchedulesViewState_1.ALL_JE_PAGE_TABS.forEach((pageTab) => {
|
|
339
|
+
const periodTabKey = monthYearPeriodId != null
|
|
340
|
+
? (0, jeSchedulesViewState_1.getJESchedulePeriodTabKey)(pageTab, monthYearPeriodId)
|
|
341
|
+
: null;
|
|
342
|
+
const transactionKeys = periodTabKey != null
|
|
343
|
+
? jeScheduleTransactionKeysByPeriodAndTab[periodTabKey]
|
|
344
|
+
: undefined;
|
|
345
|
+
if (transactionKeys == null) {
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
const accruedKeys = (periodTabKey != null
|
|
349
|
+
? jeScheduleAccruedKeysByPeriodAndTab[periodTabKey]
|
|
350
|
+
: undefined) ?? [];
|
|
351
|
+
const oneTimeAccrualKeys = (periodTabKey != null
|
|
352
|
+
? jeScheduleOneTimeAccrualKeysByPeriodAndTab[periodTabKey]
|
|
353
|
+
: undefined) ?? [];
|
|
354
|
+
const rowsForTab = [
|
|
355
|
+
...transactionKeys.map((transactionKey) => (0, jeSchedulesSelector_1.getJEScheduledTransactionByJEScheduleTransactionKey)(transactionKey, state)),
|
|
356
|
+
...accruedKeys
|
|
357
|
+
.map((accruedKey) => (0, jeSchedulesSelector_1.getJEAccruedScheduleByJEScheduleKey)(accruedKey, state))
|
|
358
|
+
.filter((accruedRow) => accruedRow != null),
|
|
359
|
+
...oneTimeAccrualKeys
|
|
360
|
+
.map((accrualKey) => (0, jeSchedulesSelector_1.getJEOneTimeAccrualByKey)(accrualKey, state.jeSchedulesState))
|
|
361
|
+
.filter((accrualRow) => accrualRow != null),
|
|
362
|
+
];
|
|
363
|
+
scheduleCountsByTab[pageTab] =
|
|
364
|
+
pageTab === 'existing_schedules'
|
|
365
|
+
? rowsForTab.filter((row) => isExistingTabRow(row)).length
|
|
366
|
+
: rowsForTab.filter((row) => isPendingReviewRow(row) || isCreatedStatus(row)).length;
|
|
367
|
+
});
|
|
142
368
|
const allSteps = monthYearPeriodId != null
|
|
143
369
|
? (0, expenseAutomationViewSelectorTypes_1.getAllSteps)(monthEndCloseChecksState, monthYearPeriodId, currentTenant.tenantId)
|
|
144
370
|
: [];
|
|
@@ -151,6 +377,20 @@ function getExpenseAutomationJESchedulesView(state) {
|
|
|
151
377
|
{ fetchState, error },
|
|
152
378
|
monthEndFetchState,
|
|
153
379
|
]);
|
|
380
|
+
const countByType = (schedules) => {
|
|
381
|
+
const counts = jeSchedulesTypes_1.ALL_SCHEDULES_TYPES.reduce((acc, type) => ({ ...acc, [type]: 0 }), {});
|
|
382
|
+
schedules.forEach((schedule) => {
|
|
383
|
+
const scheduleType = getJEScheduleRowType(schedule);
|
|
384
|
+
if (scheduleType != null) {
|
|
385
|
+
counts[scheduleType] += 1;
|
|
386
|
+
}
|
|
387
|
+
});
|
|
388
|
+
return counts;
|
|
389
|
+
};
|
|
390
|
+
const jeScheduleTypeCounts = {
|
|
391
|
+
active: countByType(allSchedules.filter((schedule) => isPendingReviewRow(schedule) || isCreatedStatus(schedule))),
|
|
392
|
+
ongoing: countByType(allSchedules.filter((schedule) => isExistingTabRow(schedule))),
|
|
393
|
+
};
|
|
154
394
|
return {
|
|
155
395
|
uncategorizedAccounts,
|
|
156
396
|
allDepreciationAccountList: filteredDepAccounts,
|
|
@@ -159,12 +399,17 @@ function getExpenseAutomationJESchedulesView(state) {
|
|
|
159
399
|
allAccountList: filteredAccounts,
|
|
160
400
|
accountListNestedAccountHierarchy,
|
|
161
401
|
allClassList: allClasses,
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
402
|
+
createdSchedules,
|
|
403
|
+
createdTotal,
|
|
404
|
+
hasLoadedForSelectedTab,
|
|
405
|
+
jeScheduleTypeCounts,
|
|
406
|
+
scheduleCountsByTab,
|
|
407
|
+
kpiSummary,
|
|
165
408
|
pendingReviewSchedules,
|
|
409
|
+
pendingReviewTotal,
|
|
166
410
|
resolveSchedules: resolveSchedules,
|
|
167
411
|
accountSettingsView,
|
|
412
|
+
newScheduleView,
|
|
168
413
|
postStatusById: postStatusById,
|
|
169
414
|
ignoreStatusById: ignoreStatusById,
|
|
170
415
|
fetchState: reducedFetchStatus.fetchState,
|
|
@@ -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
|
|
@@ -1,22 +1,31 @@
|
|
|
1
1
|
import { NestedAccountHierarchyForReport } from '../../../commonStateTypes/accountView/nestedAccountID';
|
|
2
|
+
import { Amount } from '../../../commonStateTypes/amount';
|
|
2
3
|
import { FetchStateAndError, FetchedState, ID } from '../../../commonStateTypes/common';
|
|
3
4
|
import { Recommendation } from '../../../commonStateTypes/recommendationBase';
|
|
4
5
|
import { SortOrder } from '../../../commonStateTypes/selectorTypes/sortOrderTypes';
|
|
5
|
-
import { MonthYearPeriodId } from '../../../commonStateTypes/timePeriod';
|
|
6
|
+
import { MonthYearPeriodId, ScheduleDaysOfMonth } from '../../../commonStateTypes/timePeriod';
|
|
6
7
|
import { AccountBase } from '../../../entity/account/accountState';
|
|
7
|
-
import { JEScheduleTransactionKey, ScheduleTypes } from '../../../entity/jeSchedules/jeSchedulesTypes';
|
|
8
|
+
import { JEOneTimeAccrualKey, JEScheduleKey, JEScheduleTransactionKey, ScheduleJournalEntryStatusCodeType, ScheduleTransactionID, ScheduleTypes } from '../../../entity/jeSchedules/jeSchedulesTypes';
|
|
8
9
|
import { VendorBase } from '../../../entity/vendor/vendorState';
|
|
9
|
-
|
|
10
|
+
import { ZeniDate } from '../../../zeniDayJS';
|
|
11
|
+
import { JETransactionLink } from '../../scheduleView/scheduleDetailView/scheduleDetailState';
|
|
12
|
+
export declare const toJEScheduleSortKey: (v: string) => "vendor" | "type" | "category" | "class" | "memo" | "transactionDate" | "totalAmount" | "runningBalance" | "jePostingDate" | "depCategory" | "scheduleCategory" | "startMonth" | "amortizationPeriod" | "remainingMonths";
|
|
10
13
|
export type JEScheduleSortKey = ReturnType<typeof toJEScheduleSortKey>;
|
|
11
|
-
export declare const
|
|
12
|
-
export type
|
|
14
|
+
export declare const toJEPageTab: (v: string) => "schedules" | "existing_schedules";
|
|
15
|
+
export type JEPageTab = ReturnType<typeof toJEPageTab>;
|
|
16
|
+
export declare const ALL_JE_PAGE_TABS: readonly JEPageTab[];
|
|
17
|
+
export type JESchedulePeriodTabKey = `${JEPageTab}_${MonthYearPeriodId}`;
|
|
18
|
+
export declare const getJESchedulePeriodTabKey: (selectedPageTab: JEPageTab, monthYearPeriodId: MonthYearPeriodId) => JESchedulePeriodTabKey;
|
|
13
19
|
export interface JESchedulesViewUIState {
|
|
20
|
+
createdGroupCollapsed: boolean;
|
|
21
|
+
pendingGroupCollapsed: boolean;
|
|
14
22
|
scrollPosition: {
|
|
15
23
|
scrollTop: number;
|
|
16
24
|
scrollLeft?: number;
|
|
17
25
|
} | undefined;
|
|
18
26
|
searchString: string;
|
|
19
|
-
|
|
27
|
+
selectedJETypeFilter: ScheduleTypes | null;
|
|
28
|
+
selectedPageTab: JEPageTab;
|
|
20
29
|
sortKey: JEScheduleSortKey;
|
|
21
30
|
sortOrder: SortOrder;
|
|
22
31
|
totalCount: number;
|
|
@@ -33,14 +42,56 @@ export interface JEScheduleLocalData {
|
|
|
33
42
|
}
|
|
34
43
|
export interface JESchedulesViewState extends FetchedState {
|
|
35
44
|
accountSettings: AccountSettingsState;
|
|
36
|
-
|
|
45
|
+
failedJeScheduleTransactionKeysByPeriodAndTab: Record<JESchedulePeriodTabKey, JEScheduleTransactionKey[]>;
|
|
37
46
|
ignoreStatusById: Record<JEScheduleTransactionKey, FetchStateAndError>;
|
|
47
|
+
jeScheduleAccruedKeysByPeriodAndTab: Record<JESchedulePeriodTabKey, JEScheduleKey[]>;
|
|
38
48
|
jeScheduleLocalDataById: Record<ID, JEScheduleLocalData>;
|
|
39
|
-
|
|
49
|
+
jeScheduleOneTimeAccrualKeysByPeriodAndTab: Record<JESchedulePeriodTabKey, JEOneTimeAccrualKey[]>;
|
|
50
|
+
jeScheduleTransactionKeysByPeriodAndTab: Record<JESchedulePeriodTabKey, JEScheduleTransactionKey[]>;
|
|
51
|
+
newSchedule: NewJeScheduleState;
|
|
40
52
|
postStatusById: Record<ID, FetchStateAndError>;
|
|
41
53
|
refreshStatus: FetchStateAndError;
|
|
42
54
|
uiState: JESchedulesViewUIState;
|
|
43
55
|
}
|
|
56
|
+
export interface NewJeDetailLocalData {
|
|
57
|
+
amount: Amount;
|
|
58
|
+
jeLink: JETransactionLink;
|
|
59
|
+
memo: string;
|
|
60
|
+
postingDate: ZeniDate;
|
|
61
|
+
postingStatus: ScheduleJournalEntryStatusCodeType;
|
|
62
|
+
runningBalance: Amount;
|
|
63
|
+
}
|
|
64
|
+
export interface NewScheduleLocalData {
|
|
65
|
+
jeScheduleDetails: NewJeDetailLocalData[];
|
|
66
|
+
scheduleType: ScheduleTypes;
|
|
67
|
+
lastDayOfMonth?: boolean;
|
|
68
|
+
selectedAccount?: ID;
|
|
69
|
+
selectedBaseTransactionId?: ScheduleTransactionID;
|
|
70
|
+
selectedClass?: ID;
|
|
71
|
+
selectedDate?: ZeniDate;
|
|
72
|
+
selectedDayOfMonth?: ScheduleDaysOfMonth;
|
|
73
|
+
selectedJEScheduleKey?: JEScheduleTransactionKey;
|
|
74
|
+
selectedMonths?: number;
|
|
75
|
+
selectedVendor?: VendorBase;
|
|
76
|
+
}
|
|
77
|
+
export interface NewScheduleLocalDataFixedAssets extends NewScheduleLocalData {
|
|
78
|
+
assetId?: string;
|
|
79
|
+
selectedAccumulatedDepreciationCategory?: ID;
|
|
80
|
+
}
|
|
81
|
+
export interface SearchTransactionsState extends FetchStateAndError {
|
|
82
|
+
searchResults: JEScheduleTransactionKey[];
|
|
83
|
+
searchString?: string;
|
|
84
|
+
}
|
|
85
|
+
export declare const MIN_NEW_SCHEDULE_SEARCH_LENGTH = 2;
|
|
86
|
+
export interface NewJeScheduleState extends FetchStateAndError {
|
|
87
|
+
newScheduleState: {
|
|
88
|
+
fixed_assets: NewScheduleLocalDataFixedAssets;
|
|
89
|
+
prepaid_expenses: NewScheduleLocalData;
|
|
90
|
+
};
|
|
91
|
+
saveStatus: FetchStateAndError;
|
|
92
|
+
searchTransactions: SearchTransactionsState;
|
|
93
|
+
selectedDetailScheduleType?: ScheduleTypes;
|
|
94
|
+
}
|
|
44
95
|
export interface AccountSettingsLocalData {
|
|
45
96
|
previousAccruedExpensesAccount: AccountBase[];
|
|
46
97
|
previousFixedAssetsAccount: AccountBase[];
|