@zeniai/client-epic-state 5.1.62-betaRD1 → 5.1.63
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/jeSchedulesPayload.d.ts +0 -2
- package/lib/entity/jeSchedules/jeSchedulesPayload.js +0 -2
- package/lib/entity/jeSchedules/jeSchedulesSelector.d.ts +0 -4
- package/lib/entity/jeSchedules/jeSchedulesSelector.js +1 -11
- package/lib/entity/jeSchedules/jeSchedulesState.d.ts +0 -2
- package/lib/epic.d.ts +1 -5
- package/lib/epic.js +1 -5
- package/lib/esm/entity/jeSchedules/jeSchedulesPayload.js +0 -2
- package/lib/esm/entity/jeSchedules/jeSchedulesSelector.js +1 -11
- package/lib/esm/epic.js +1 -5
- package/lib/esm/index.js +4 -7
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +2 -15
- package/lib/esm/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +6 -126
- package/lib/esm/view/expenseAutomationView/reducers/reconciliationViewReducer.js +30 -2
- package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +11 -65
- package/lib/esm/view/expenseAutomationView/types/jeSchedulesViewState.js +6 -3
- package/lib/index.d.ts +6 -9
- package/lib/index.js +48 -66
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +1 -14
- package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.d.ts +0 -1
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +8 -36
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +7 -128
- package/lib/view/expenseAutomationView/reducers/reconciliationViewReducer.js +30 -2
- package/lib/view/expenseAutomationView/selectorTypes/jeSchedulesSelectorTypes.d.ts +4 -29
- package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +11 -65
- package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +6 -53
- package/lib/view/expenseAutomationView/types/jeSchedulesViewState.js +8 -5
- package/package.json +1 -1
- package/lib/entity/transaction/scheduleTransactionHelper.d.ts +0 -15
- package/lib/entity/transaction/scheduleTransactionHelper.js +0 -43
- package/lib/esm/entity/transaction/scheduleTransactionHelper.js +0 -39
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +0 -21
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js +0 -110
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +0 -44
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +0 -22
- package/lib/esm/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.js +0 -152
- package/lib/esm/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +0 -1
- package/lib/esm/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +0 -71
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.d.ts +0 -8
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +0 -25
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.d.ts +0 -45
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js +0 -114
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.d.ts +0 -8
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +0 -48
- package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.d.ts +0 -6
- package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +0 -26
- package/lib/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.d.ts +0 -43
- package/lib/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.js +0 -158
- package/lib/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.d.ts +0 -25
- package/lib/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +0 -2
- package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.d.ts +0 -10
- package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +0 -76
|
@@ -1,29 +1,22 @@
|
|
|
1
1
|
import { NestedAccountHierarchyForReport } from '../../../commonStateTypes/accountView/nestedAccountID';
|
|
2
|
-
import { Amount } from '../../../commonStateTypes/amount';
|
|
3
2
|
import { FetchStateAndError, FetchedState, ID } from '../../../commonStateTypes/common';
|
|
4
3
|
import { Recommendation } from '../../../commonStateTypes/recommendationBase';
|
|
5
4
|
import { SortOrder } from '../../../commonStateTypes/selectorTypes/sortOrderTypes';
|
|
6
|
-
import { MonthYearPeriodId
|
|
5
|
+
import { MonthYearPeriodId } from '../../../commonStateTypes/timePeriod';
|
|
7
6
|
import { AccountBase } from '../../../entity/account/accountState';
|
|
8
|
-
import { JEScheduleTransactionKey,
|
|
9
|
-
import { TransactionID } from '../../../entity/transaction/stateTypes/transaction';
|
|
7
|
+
import { JEScheduleTransactionKey, ScheduleTypes } from '../../../entity/jeSchedules/jeSchedulesTypes';
|
|
10
8
|
import { VendorBase } from '../../../entity/vendor/vendorState';
|
|
11
|
-
|
|
12
|
-
import { JETransactionLink } from '../../scheduleView/scheduleDetailView/scheduleDetailState';
|
|
13
|
-
export declare const toJEScheduleSortKey: (v: string) => "vendor" | "type" | "category" | "class" | "memo" | "transactionDate" | "totalAmount" | "runningBalance" | "jePostingDate" | "depCategory" | "scheduleCategory" | "startMonth" | "amortizationPeriod" | "remainingMonths";
|
|
9
|
+
export declare const toJEScheduleSortKey: (v: string) => "vendor" | "type" | "category" | "class" | "memo" | "transactionDate" | "totalAmount" | "runningBalance" | "depCategory" | "scheduleCategory" | "startMonth" | "amortizationPeriod" | "jePostingDate" | "remainingMonths";
|
|
14
10
|
export type JEScheduleSortKey = ReturnType<typeof toJEScheduleSortKey>;
|
|
15
|
-
export declare const
|
|
16
|
-
export type
|
|
11
|
+
export declare const toJEScheduleMainTab: (v: string) => "completed" | "pending_review" | "ongoing";
|
|
12
|
+
export type JEScheduleMainTab = ReturnType<typeof toJEScheduleMainTab>;
|
|
17
13
|
export interface JESchedulesViewUIState {
|
|
18
|
-
createdGroupCollapsed: boolean;
|
|
19
|
-
pendingGroupCollapsed: boolean;
|
|
20
14
|
scrollPosition: {
|
|
21
15
|
scrollTop: number;
|
|
22
16
|
scrollLeft?: number;
|
|
23
17
|
} | undefined;
|
|
24
18
|
searchString: string;
|
|
25
|
-
|
|
26
|
-
selectedPageTab: JEPageTab;
|
|
19
|
+
selectedMainTab: JEScheduleMainTab;
|
|
27
20
|
sortKey: JEScheduleSortKey;
|
|
28
21
|
sortOrder: SortOrder;
|
|
29
22
|
totalCount: number;
|
|
@@ -44,50 +37,10 @@ export interface JESchedulesViewState extends FetchedState {
|
|
|
44
37
|
ignoreStatusById: Record<JEScheduleTransactionKey, FetchStateAndError>;
|
|
45
38
|
jeScheduleLocalDataById: Record<ID, JEScheduleLocalData>;
|
|
46
39
|
jeScheduleTransactionKeysByPeriod: Record<MonthYearPeriodId, JEScheduleTransactionKey[]>;
|
|
47
|
-
newSchedule: NewJeScheduleState;
|
|
48
40
|
postStatusById: Record<ID, FetchStateAndError>;
|
|
49
41
|
refreshStatus: FetchStateAndError;
|
|
50
42
|
uiState: JESchedulesViewUIState;
|
|
51
43
|
}
|
|
52
|
-
export interface NewJeDetailLocalData {
|
|
53
|
-
amount: Amount;
|
|
54
|
-
jeLink: JETransactionLink;
|
|
55
|
-
memo: string;
|
|
56
|
-
postingDate: ZeniDate;
|
|
57
|
-
postingStatus: ScheduleJournalEntryStatusCodeType;
|
|
58
|
-
runningBalance: Amount;
|
|
59
|
-
}
|
|
60
|
-
export interface NewScheduleLocalData {
|
|
61
|
-
jeScheduleDetails: NewJeDetailLocalData[];
|
|
62
|
-
scheduleType: ScheduleTypes;
|
|
63
|
-
lastDayOfMonth?: boolean;
|
|
64
|
-
selectedAccount?: ID;
|
|
65
|
-
selectedBaseTransactionId?: TransactionID;
|
|
66
|
-
selectedClass?: ID;
|
|
67
|
-
selectedDate?: ZeniDate;
|
|
68
|
-
selectedDayOfMonth?: ScheduleDaysOfMonth;
|
|
69
|
-
selectedJEScheduleKey?: JEScheduleTransactionKey;
|
|
70
|
-
selectedMonths?: number;
|
|
71
|
-
selectedVendor?: VendorBase;
|
|
72
|
-
}
|
|
73
|
-
export interface NewScheduleLocalDataFixedAssets extends NewScheduleLocalData {
|
|
74
|
-
assetId?: string;
|
|
75
|
-
selectedAccumulatedDepreciationCategory?: ID;
|
|
76
|
-
}
|
|
77
|
-
export interface SearchTransactionsState extends FetchStateAndError {
|
|
78
|
-
searchResults: ID[];
|
|
79
|
-
searchString?: string;
|
|
80
|
-
}
|
|
81
|
-
export declare const MIN_NEW_SCHEDULE_SEARCH_LENGTH = 2;
|
|
82
|
-
export interface NewJeScheduleState extends FetchStateAndError {
|
|
83
|
-
newScheduleState: {
|
|
84
|
-
fixed_assets: NewScheduleLocalDataFixedAssets;
|
|
85
|
-
prepaid_expenses: NewScheduleLocalData;
|
|
86
|
-
};
|
|
87
|
-
saveStatus: FetchStateAndError;
|
|
88
|
-
searchTransactions: SearchTransactionsState;
|
|
89
|
-
selectedDetailScheduleType?: ScheduleTypes;
|
|
90
|
-
}
|
|
91
44
|
export interface AccountSettingsLocalData {
|
|
92
45
|
previousAccruedExpensesAccount: AccountBase[];
|
|
93
46
|
previousFixedAssetsAccount: AccountBase[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.toJEScheduleMainTab = exports.toJEScheduleSortKey = void 0;
|
|
4
4
|
const stringToUnion_1 = require("../../../commonStateTypes/stringToUnion");
|
|
5
5
|
const JE_SCHEDULE_SORT_KEYS = [
|
|
6
6
|
'vendor',
|
|
@@ -20,7 +20,10 @@ const JE_SCHEDULE_SORT_KEYS = [
|
|
|
20
20
|
];
|
|
21
21
|
const toJEScheduleSortKey = (v) => (0, stringToUnion_1.stringToUnion)(v, JE_SCHEDULE_SORT_KEYS);
|
|
22
22
|
exports.toJEScheduleSortKey = toJEScheduleSortKey;
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
const JE_SCHEDULE_MAIN_TABS = [
|
|
24
|
+
'pending_review',
|
|
25
|
+
'ongoing',
|
|
26
|
+
'completed',
|
|
27
|
+
];
|
|
28
|
+
const toJEScheduleMainTab = (v) => (0, stringToUnion_1.stringToUnion)(v, JE_SCHEDULE_MAIN_TABS);
|
|
29
|
+
exports.toJEScheduleMainTab = toJEScheduleMainTab;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.63",
|
|
4
4
|
"description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/esm/index.js",
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { ID } from '../../commonStateTypes/common';
|
|
2
|
-
import { ScheduleTransaction } from './stateTypes/scheduleTransaction';
|
|
3
|
-
import { Line, TransactionWithAccountAndClassLine } from './stateTypes/transactionLine';
|
|
4
|
-
import { SupportedTransaction } from './transactionState';
|
|
5
|
-
export declare function hasAccountAndClassDetail(line: Line): line is TransactionWithAccountAndClassLine;
|
|
6
|
-
/**
|
|
7
|
-
* Builds a ScheduleTransaction directly from a Base Transaction search result
|
|
8
|
-
* (SupportedTransaction) and the chosen line, for schedule types where the
|
|
9
|
-
* user selects a transaction the search endpoint already returned — as
|
|
10
|
-
* opposed to the legacy flow's ScheduleTransaction, which only ever arrives
|
|
11
|
-
* via a GET /1.0/schedules/:id round trip. transaction.qboId stands in for
|
|
12
|
-
* thirdPartyTransactionId since this search endpoint doesn't send a field by
|
|
13
|
-
* that name, but qbo_id is the same identifier.
|
|
14
|
-
*/
|
|
15
|
-
export declare function mapSupportedTransactionLineToScheduleTransaction(transaction: SupportedTransaction, lineId: ID): ScheduleTransaction | undefined;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hasAccountAndClassDetail = hasAccountAndClassDetail;
|
|
4
|
-
exports.mapSupportedTransactionLineToScheduleTransaction = mapSupportedTransactionLineToScheduleTransaction;
|
|
5
|
-
function hasAccountAndClassDetail(line) {
|
|
6
|
-
return 'account' in line;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Builds a ScheduleTransaction directly from a Base Transaction search result
|
|
10
|
-
* (SupportedTransaction) and the chosen line, for schedule types where the
|
|
11
|
-
* user selects a transaction the search endpoint already returned — as
|
|
12
|
-
* opposed to the legacy flow's ScheduleTransaction, which only ever arrives
|
|
13
|
-
* via a GET /1.0/schedules/:id round trip. transaction.qboId stands in for
|
|
14
|
-
* thirdPartyTransactionId since this search endpoint doesn't send a field by
|
|
15
|
-
* that name, but qbo_id is the same identifier.
|
|
16
|
-
*/
|
|
17
|
-
function mapSupportedTransactionLineToScheduleTransaction(transaction, lineId) {
|
|
18
|
-
if (transaction.qboId == null || transaction.qboId === '') {
|
|
19
|
-
return undefined;
|
|
20
|
-
}
|
|
21
|
-
const line = transaction.lines?.find((candidate) => candidate.id === lineId);
|
|
22
|
-
if (line == null || !hasAccountAndClassDetail(line)) {
|
|
23
|
-
return undefined;
|
|
24
|
-
}
|
|
25
|
-
return {
|
|
26
|
-
id: transaction.id,
|
|
27
|
-
type: transaction.type,
|
|
28
|
-
typeOfTransaction: 'schedule',
|
|
29
|
-
typeName: transaction.typeName,
|
|
30
|
-
date: transaction.date,
|
|
31
|
-
memo: transaction.memo,
|
|
32
|
-
description: transaction.description,
|
|
33
|
-
lineId: line.id,
|
|
34
|
-
thirdPartyTransactionId: transaction.qboId,
|
|
35
|
-
account: line.account,
|
|
36
|
-
classBase: line.class,
|
|
37
|
-
amount: line.amount,
|
|
38
|
-
currency: {
|
|
39
|
-
currencyCode: line.amount.currencyCode,
|
|
40
|
-
currencySymbol: line.amount.currencySymbol,
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
export function hasAccountAndClassDetail(line) {
|
|
2
|
-
return 'account' in line;
|
|
3
|
-
}
|
|
4
|
-
/**
|
|
5
|
-
* Builds a ScheduleTransaction directly from a Base Transaction search result
|
|
6
|
-
* (SupportedTransaction) and the chosen line, for schedule types where the
|
|
7
|
-
* user selects a transaction the search endpoint already returned — as
|
|
8
|
-
* opposed to the legacy flow's ScheduleTransaction, which only ever arrives
|
|
9
|
-
* via a GET /1.0/schedules/:id round trip. transaction.qboId stands in for
|
|
10
|
-
* thirdPartyTransactionId since this search endpoint doesn't send a field by
|
|
11
|
-
* that name, but qbo_id is the same identifier.
|
|
12
|
-
*/
|
|
13
|
-
export function mapSupportedTransactionLineToScheduleTransaction(transaction, lineId) {
|
|
14
|
-
if (transaction.qboId == null || transaction.qboId === '') {
|
|
15
|
-
return undefined;
|
|
16
|
-
}
|
|
17
|
-
const line = transaction.lines?.find((candidate) => candidate.id === lineId);
|
|
18
|
-
if (line == null || !hasAccountAndClassDetail(line)) {
|
|
19
|
-
return undefined;
|
|
20
|
-
}
|
|
21
|
-
return {
|
|
22
|
-
id: transaction.id,
|
|
23
|
-
type: transaction.type,
|
|
24
|
-
typeOfTransaction: 'schedule',
|
|
25
|
-
typeName: transaction.typeName,
|
|
26
|
-
date: transaction.date,
|
|
27
|
-
memo: transaction.memo,
|
|
28
|
-
description: transaction.description,
|
|
29
|
-
lineId: line.id,
|
|
30
|
-
thirdPartyTransactionId: transaction.qboId,
|
|
31
|
-
account: line.account,
|
|
32
|
-
classBase: line.class,
|
|
33
|
-
amount: line.amount,
|
|
34
|
-
currency: {
|
|
35
|
-
currencyCode: line.amount.currencyCode,
|
|
36
|
-
currencySymbol: line.amount.currencySymbol,
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
}
|
package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { from } from 'rxjs';
|
|
2
|
-
import { filter, mergeMap } from 'rxjs/operators';
|
|
3
|
-
import { fetchAccountList } from '../../../../accountList/accountListReducer';
|
|
4
|
-
import { fetchClassList } from '../../../../classList/classListReducer';
|
|
5
|
-
import { getAccountsTypesForScheduleEpics } from '../../../../scheduleView/scheduleListView/scheduleListHelper';
|
|
6
|
-
import { clearSearchTransactionsForNewSchedule, initializeNewSchedule, resetNewScheduleLocalData, } from '../../../reducers/jeSchedulesViewReducer';
|
|
7
|
-
export const initializeNewScheduleEpic = (actions$, state$) => actions$.pipe(filter(initializeNewSchedule.match), mergeMap((action) => {
|
|
8
|
-
const newScheduleActions = [];
|
|
9
|
-
const accountType = getAccountsTypesForScheduleEpics();
|
|
10
|
-
const { accountListState, classListState } = state$.value;
|
|
11
|
-
if (accountListState.byReportId[accountType.accountListKey]?.fetchState ===
|
|
12
|
-
'Not-Started') {
|
|
13
|
-
newScheduleActions.push(fetchAccountList(accountType.accountListKey, true, false, false, false, accountType.allowedAccountList));
|
|
14
|
-
}
|
|
15
|
-
if (classListState.fetchState === 'Not-Started') {
|
|
16
|
-
newScheduleActions.push(fetchClassList());
|
|
17
|
-
}
|
|
18
|
-
newScheduleActions.push(resetNewScheduleLocalData({ scheduleType: action.payload.scheduleType }));
|
|
19
|
-
newScheduleActions.push(clearSearchTransactionsForNewSchedule());
|
|
20
|
-
return from(newScheduleActions);
|
|
21
|
-
}));
|
package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { from } from 'rxjs';
|
|
2
|
-
import { catchError, filter, mergeMap } from 'rxjs/operators';
|
|
3
|
-
import { updateJESchedules, updateJESchedulesDetails, } from '../../../../../entity/jeSchedules/jeSchedulesReducer';
|
|
4
|
-
import { openSnackbar } from '../../../../../entity/snackbar/snackbarReducer';
|
|
5
|
-
import { getSupportedTransactionById } from '../../../../../entity/transaction/transactionSelector';
|
|
6
|
-
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../../responsePayload';
|
|
7
|
-
import { prepareNewSchedulePayload, } from '../../../helpers/newScheduleLocalDataHelper';
|
|
8
|
-
import { resetNewScheduleLocalData, saveNewSchedule, saveNewScheduleFailure, saveNewScheduleSuccess, } from '../../../reducers/jeSchedulesViewReducer';
|
|
9
|
-
const FAILURE_REASON_MESSAGES = {
|
|
10
|
-
multi_line_not_supported: 'This transaction has multiple lines and cannot be scheduled yet.',
|
|
11
|
-
missing_third_party_id: 'This transaction is missing a QuickBooks reference and cannot be scheduled.',
|
|
12
|
-
missing_vendor: 'Select a vendor before saving this schedule.',
|
|
13
|
-
};
|
|
14
|
-
export const saveNewScheduleEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(saveNewSchedule.match), mergeMap((action) => {
|
|
15
|
-
const { scheduleType } = action.payload;
|
|
16
|
-
const state = state$.value;
|
|
17
|
-
const localData = state.expenseAutomationJESchedulesViewState.newSchedule
|
|
18
|
-
.newScheduleState[scheduleType];
|
|
19
|
-
const transactionId = localData.selectedBaseTransactionId?.id;
|
|
20
|
-
const transaction = transactionId != null
|
|
21
|
-
? getSupportedTransactionById(state.transactionState, transactionId)
|
|
22
|
-
: undefined;
|
|
23
|
-
if (transaction == null) {
|
|
24
|
-
return from([
|
|
25
|
-
saveNewScheduleFailure({
|
|
26
|
-
status: createZeniAPIStatus('Unexpected Error', 'No base transaction selected for this schedule.'),
|
|
27
|
-
}),
|
|
28
|
-
openSnackbar({
|
|
29
|
-
messageSection: 'create_schedule',
|
|
30
|
-
messageText: 'failed',
|
|
31
|
-
type: 'error',
|
|
32
|
-
variables: [
|
|
33
|
-
{
|
|
34
|
-
variableName: '_api-error_',
|
|
35
|
-
variableValue: 'No base transaction selected.',
|
|
36
|
-
},
|
|
37
|
-
],
|
|
38
|
-
}),
|
|
39
|
-
]);
|
|
40
|
-
}
|
|
41
|
-
const result = prepareNewSchedulePayload(transaction, localData, scheduleType);
|
|
42
|
-
if (!result.ok) {
|
|
43
|
-
const message = FAILURE_REASON_MESSAGES[result.reason];
|
|
44
|
-
return from([
|
|
45
|
-
saveNewScheduleFailure({
|
|
46
|
-
status: createZeniAPIStatus('Unexpected Error', message),
|
|
47
|
-
}),
|
|
48
|
-
openSnackbar({
|
|
49
|
-
messageSection: 'create_schedule',
|
|
50
|
-
messageText: 'failed',
|
|
51
|
-
type: 'error',
|
|
52
|
-
variables: [{ variableName: '_api-error_', variableValue: message }],
|
|
53
|
-
}),
|
|
54
|
-
]);
|
|
55
|
-
}
|
|
56
|
-
const vendorName = localData.selectedVendor?.name ?? transaction.vendorName ?? '';
|
|
57
|
-
const queryParam = {
|
|
58
|
-
je_schedule_type: scheduleType,
|
|
59
|
-
};
|
|
60
|
-
const payload = { ...result.payload };
|
|
61
|
-
return zeniAPI
|
|
62
|
-
.postAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules?query=${encodeURIComponent(JSON.stringify(queryParam))}`, payload)
|
|
63
|
-
.pipe(mergeMap((response) => {
|
|
64
|
-
if (isSuccessResponse(response) && response.data != null) {
|
|
65
|
-
return from([
|
|
66
|
-
updateJESchedules(response.data.je_schedules),
|
|
67
|
-
updateJESchedulesDetails(response.data.je_schedules, response.data.scheduled_journal_entries),
|
|
68
|
-
resetNewScheduleLocalData({ scheduleType }),
|
|
69
|
-
saveNewScheduleSuccess(),
|
|
70
|
-
openSnackbar({
|
|
71
|
-
messageSection: 'create_schedule',
|
|
72
|
-
messageText: 'success',
|
|
73
|
-
type: 'success',
|
|
74
|
-
variables: [
|
|
75
|
-
{ variableName: '_vendor_name_', variableValue: vendorName },
|
|
76
|
-
],
|
|
77
|
-
}),
|
|
78
|
-
]);
|
|
79
|
-
}
|
|
80
|
-
return from([
|
|
81
|
-
saveNewScheduleFailure({ status: response.status }),
|
|
82
|
-
openSnackbar({
|
|
83
|
-
messageSection: 'create_schedule',
|
|
84
|
-
messageText: 'failed',
|
|
85
|
-
type: 'error',
|
|
86
|
-
variables: [
|
|
87
|
-
{
|
|
88
|
-
variableName: '_api-error_',
|
|
89
|
-
variableValue: response.status.message,
|
|
90
|
-
},
|
|
91
|
-
],
|
|
92
|
-
}),
|
|
93
|
-
]);
|
|
94
|
-
}), catchError((error) => from([
|
|
95
|
-
openSnackbar({
|
|
96
|
-
messageSection: 'create_schedule',
|
|
97
|
-
messageText: 'failed',
|
|
98
|
-
type: 'error',
|
|
99
|
-
variables: [
|
|
100
|
-
{
|
|
101
|
-
variableName: '_api-error_',
|
|
102
|
-
variableValue: JSON.stringify(error),
|
|
103
|
-
},
|
|
104
|
-
],
|
|
105
|
-
}),
|
|
106
|
-
saveNewScheduleFailure({
|
|
107
|
-
status: createZeniAPIStatus('Unexpected Error', `Save New Schedule REST API call errored out ${JSON.stringify(error)}`),
|
|
108
|
-
}),
|
|
109
|
-
])));
|
|
110
|
-
}));
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { EMPTY, from, merge, of } from 'rxjs';
|
|
2
|
-
import { catchError, debounceTime, filter, mergeMap, switchMap, } from 'rxjs/operators';
|
|
3
|
-
import { updateTransactions } from '../../../../../entity/transaction/transactionReducer';
|
|
4
|
-
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../../responsePayload';
|
|
5
|
-
import { searchTransactionsForNewSchedule, searchTransactionsForNewScheduleFailure, searchTransactionsForNewScheduleSuccess, } from '../../../reducers/jeSchedulesViewReducer';
|
|
6
|
-
import { MIN_NEW_SCHEDULE_SEARCH_LENGTH } from '../../../types/jeSchedulesViewState';
|
|
7
|
-
/** Dropdown-sized result set — no pagination for Base Transaction search. */
|
|
8
|
-
const NEW_SCHEDULE_SEARCH_PAGE_SIZE = 10;
|
|
9
|
-
export const searchTransactionsForNewScheduleEpic = (actions$, _state$, zeniAPI) => {
|
|
10
|
-
const searchActions$ = actions$.pipe(filter(searchTransactionsForNewSchedule.match));
|
|
11
|
-
/** No API for empty or 1-char queries; immediate merge so switchMap cancels any in-flight HTTP. */
|
|
12
|
-
const newSearchTooShortOrClear$ = searchActions$.pipe(filter((action) => action.payload.query.trim().length < MIN_NEW_SCHEDULE_SEARCH_LENGTH));
|
|
13
|
-
const newSearchDebounced$ = searchActions$.pipe(filter((action) => action.payload.query.trim().length >= MIN_NEW_SCHEDULE_SEARCH_LENGTH), debounceTime(300));
|
|
14
|
-
return merge(newSearchTooShortOrClear$, newSearchDebounced$).pipe(switchMap((action) => {
|
|
15
|
-
const query = action.payload.query.trim();
|
|
16
|
-
if (query.length < MIN_NEW_SCHEDULE_SEARCH_LENGTH) {
|
|
17
|
-
return EMPTY;
|
|
18
|
-
}
|
|
19
|
-
const queryParam = {
|
|
20
|
-
page_size: NEW_SCHEDULE_SEARCH_PAGE_SIZE,
|
|
21
|
-
search_text: query,
|
|
22
|
-
};
|
|
23
|
-
return zeniAPI
|
|
24
|
-
.getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/base_transaction_search?query=${encodeURIComponent(JSON.stringify(queryParam))}`)
|
|
25
|
-
.pipe(mergeMap((response) => {
|
|
26
|
-
if (isSuccessResponse(response) && response.data != null) {
|
|
27
|
-
const { transactions } = response.data;
|
|
28
|
-
const actionsOut = [
|
|
29
|
-
updateTransactions(transactions, (value) => value.transaction_id, 'merge'),
|
|
30
|
-
searchTransactionsForNewScheduleSuccess({
|
|
31
|
-
searchResults: transactions.map((transaction) => transaction.transaction_id),
|
|
32
|
-
}),
|
|
33
|
-
];
|
|
34
|
-
return from(actionsOut);
|
|
35
|
-
}
|
|
36
|
-
return of(searchTransactionsForNewScheduleFailure({
|
|
37
|
-
status: response.status,
|
|
38
|
-
}));
|
|
39
|
-
}), catchError((error) => of(searchTransactionsForNewScheduleFailure({
|
|
40
|
-
status: createZeniAPIStatus('Unexpected Error', 'Search transactions for new schedule errored: ' +
|
|
41
|
-
JSON.stringify(error)),
|
|
42
|
-
}))));
|
|
43
|
-
}));
|
|
44
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { EMPTY, of } from 'rxjs';
|
|
2
|
-
import { filter, mergeMap } from 'rxjs/operators';
|
|
3
|
-
import { convertToPeriod, toAbsoluteDay, } from '../../../../commonStateTypes/timePeriod';
|
|
4
|
-
import { getCurrentTenant } from '../../../../entity/tenant/tenantSelector';
|
|
5
|
-
import { fetchJeSchedulesPage, updateJESchedulesUIState, } from '../../reducers/jeSchedulesViewReducer';
|
|
6
|
-
export const switchJESchedulesTabEpic = (actions$, state$) => actions$.pipe(filter(updateJESchedulesUIState.match), filter((action) => action.payload.selectedPageTab != null), mergeMap(() => {
|
|
7
|
-
const state = state$.value;
|
|
8
|
-
const { fetchState, refreshStatus } = state.expenseAutomationJESchedulesViewState;
|
|
9
|
-
if (fetchState === 'In-Progress' ||
|
|
10
|
-
refreshStatus.fetchState === 'In-Progress') {
|
|
11
|
-
return EMPTY;
|
|
12
|
-
}
|
|
13
|
-
const currentTenant = getCurrentTenant(state);
|
|
14
|
-
const selectedPeriod = state.expenseAutomationViewState.selectedPeriodByTenantId[currentTenant.tenantId];
|
|
15
|
-
const period = convertToPeriod(selectedPeriod);
|
|
16
|
-
const timePeriodStart = toAbsoluteDay(period.start);
|
|
17
|
-
const timePeriodEnd = toAbsoluteDay(period.end);
|
|
18
|
-
if (timePeriodStart == null || timePeriodEnd == null) {
|
|
19
|
-
return EMPTY;
|
|
20
|
-
}
|
|
21
|
-
return of(fetchJeSchedulesPage({ start: timePeriodStart, end: timePeriodEnd }, true));
|
|
22
|
-
}));
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import { toAmount } from '../../../commonStateTypes/amount';
|
|
2
|
-
import { DEFAULT_DATE_FORMAT } from '../../../commonStateTypes/fiscalYearHelpers/formatZeniDateFY';
|
|
3
|
-
import { MONTH_YEAR_FORMAT } from '../../../commonStateTypes/fiscalYearHelpers/formatZeniDateFY';
|
|
4
|
-
import { LAST_SCHEDULE_DAY_OF_MONTH } from '../../../commonStateTypes/timePeriod';
|
|
5
|
-
import { mapSupportedTransactionLineToScheduleTransaction } from '../../../entity/transaction/scheduleTransactionHelper';
|
|
6
|
-
import { getPostingDateAndStatusForIndex } from '../../scheduleView/scheduleDetailView/scheduleDetailLocalDataHelper';
|
|
7
|
-
import { mapScheduleTransactionToBaseScheduleTransactionPayload, } from '../../scheduleView/scheduleDetailView/scheduleDetailPayload';
|
|
8
|
-
const getNewScheduleMemo = (vendorName, schedulePostingDate, currentPeriod, totalPeriod, assetId) => {
|
|
9
|
-
const addAsset = assetId != null && assetId !== '' ? ` - ${assetId}` : '';
|
|
10
|
-
return `${vendorName} - ${schedulePostingDate.format(MONTH_YEAR_FORMAT)} (${currentPeriod} of ${totalPeriod})${addAsset}`;
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* Computes the month-by-month JE schedule breakdown for a brand-new schedule
|
|
14
|
-
* (no linked transaction yet) — replicates createNewSchedulesHelper's math
|
|
15
|
-
* (scheduleDetailLocalDataHelper.ts) exactly: lump-sum total split evenly
|
|
16
|
-
* across months with the rounding remainder absorbed by the last month, and a
|
|
17
|
-
* running balance that decrements each month and is forced to exactly 0 on
|
|
18
|
-
* the last row.
|
|
19
|
-
*/
|
|
20
|
-
export const computeNewScheduleJeDetails = (localData, totalAmount, vendorName) => {
|
|
21
|
-
const period = localData.selectedMonths;
|
|
22
|
-
const startingMonth = localData.selectedDate;
|
|
23
|
-
if (startingMonth == null || period == null) {
|
|
24
|
-
return [];
|
|
25
|
-
}
|
|
26
|
-
const assetId = 'assetId' in localData ? localData.assetId : undefined;
|
|
27
|
-
const averageAmount = Math.abs(Math.round((totalAmount.amount / period) * 100) / 100);
|
|
28
|
-
const lastMonthAmount = Math.abs(Math.round((Math.abs(totalAmount.amount) - averageAmount * (period - 1)) * 100) / 100);
|
|
29
|
-
let runningBalance = Math.abs(totalAmount.amount);
|
|
30
|
-
const negativeNumbers = totalAmount.amount < 0 || runningBalance < 0;
|
|
31
|
-
const newJeDetails = [];
|
|
32
|
-
for (let index = 0; index < period; index++) {
|
|
33
|
-
if (runningBalance > averageAmount) {
|
|
34
|
-
runningBalance = Math.round((runningBalance - averageAmount) * 100) / 100;
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
runningBalance = 0;
|
|
38
|
-
}
|
|
39
|
-
const amount = index === period - 1 ? lastMonthAmount : averageAmount;
|
|
40
|
-
runningBalance = index === period - 1 ? 0 : runningBalance;
|
|
41
|
-
const schedulePostingDate = startingMonth.add(index, 'month');
|
|
42
|
-
const { postingDate, postingStatus } = getPostingDateAndStatusForIndex(schedulePostingDate.month(), schedulePostingDate.year(), localData.lastDayOfMonth === true
|
|
43
|
-
? undefined
|
|
44
|
-
: localData.selectedDayOfMonth);
|
|
45
|
-
newJeDetails.push({
|
|
46
|
-
postingDate,
|
|
47
|
-
amount: toAmount(negativeNumbers ? -amount : amount, totalAmount.currencyCode, totalAmount.currencySymbol),
|
|
48
|
-
runningBalance: toAmount(negativeNumbers ? -runningBalance : runningBalance, totalAmount.currencyCode, totalAmount.currencySymbol),
|
|
49
|
-
postingStatus,
|
|
50
|
-
memo: getNewScheduleMemo(vendorName, schedulePostingDate, index + 1, period, assetId),
|
|
51
|
-
jeLink: { type: 'unknown' },
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
return newJeDetails;
|
|
55
|
-
};
|
|
56
|
-
/**
|
|
57
|
-
* Whether a Base Transaction search result can be selected for a new
|
|
58
|
-
* schedule this round — restricted to single-line transactions since the
|
|
59
|
-
* search/list endpoint's `lines` may not reflect the transaction's full line
|
|
60
|
-
* set, and there is no line-picker UI yet.
|
|
61
|
-
*/
|
|
62
|
-
export const isSupportedTransactionSelectableForNewSchedule = (transaction) => transaction.totalLinesCount === 1 && transaction.lines?.length === 1;
|
|
63
|
-
const mapNewJeDetailsToScheduledJournalEntryPayload = (jeScheduleDetails) => jeScheduleDetails.map((journalEntry) => ({
|
|
64
|
-
status: {
|
|
65
|
-
code: journalEntry.postingStatus,
|
|
66
|
-
label: journalEntry.postingStatus,
|
|
67
|
-
},
|
|
68
|
-
transaction_memo: journalEntry.memo,
|
|
69
|
-
third_party_id: journalEntry.jeLink.thirdPartyTransactionId ?? null,
|
|
70
|
-
expected_post_date: journalEntry.postingDate.format(DEFAULT_DATE_FORMAT),
|
|
71
|
-
amount: journalEntry.amount.amount,
|
|
72
|
-
balance: journalEntry.runningBalance.amount,
|
|
73
|
-
// Brand-new schedule — there is no prior scheduled-journal-entry history
|
|
74
|
-
// to cross-reference (unlike the legacy edit flow's equivalent mapper).
|
|
75
|
-
scheduled_journal_entry_id: null,
|
|
76
|
-
actual_post_date: null,
|
|
77
|
-
is_platform_generated: null,
|
|
78
|
-
je_schedule_id: null,
|
|
79
|
-
update_time: null,
|
|
80
|
-
create_time: null,
|
|
81
|
-
}));
|
|
82
|
-
/**
|
|
83
|
-
* Builds a savable schedule payload directly from a Base Transaction search
|
|
84
|
-
* result and the New Schedule form's local data — bypassing the legacy
|
|
85
|
-
* getJEScheduledTransactionByJEScheduleTransactionKey selector entirely,
|
|
86
|
-
* since that selector throws unless the entity has already round-tripped
|
|
87
|
-
* through a real GET /1.0/schedules/:id. A brand-new schedule has no such
|
|
88
|
-
* history, so this reads only from data already in hand (the selected
|
|
89
|
-
* transaction/line plus what the user filled into the form).
|
|
90
|
-
*/
|
|
91
|
-
export const prepareNewSchedulePayload = (transaction, localData, scheduleType) => {
|
|
92
|
-
const [firstLine] = transaction.lines ?? [];
|
|
93
|
-
if (!isSupportedTransactionSelectableForNewSchedule(transaction) ||
|
|
94
|
-
firstLine == null) {
|
|
95
|
-
return { ok: false, reason: 'multi_line_not_supported' };
|
|
96
|
-
}
|
|
97
|
-
const scheduleTransaction = mapSupportedTransactionLineToScheduleTransaction(transaction, firstLine.id);
|
|
98
|
-
if (scheduleTransaction == null) {
|
|
99
|
-
return { ok: false, reason: 'missing_third_party_id' };
|
|
100
|
-
}
|
|
101
|
-
const vendorId = localData.selectedVendor?.id ?? transaction.vendorId ?? '';
|
|
102
|
-
const vendorName = localData.selectedVendor?.name ?? transaction.vendorName ?? '';
|
|
103
|
-
if (vendorId === '' || vendorName === '') {
|
|
104
|
-
return { ok: false, reason: 'missing_vendor' };
|
|
105
|
-
}
|
|
106
|
-
const vendor = {
|
|
107
|
-
vendor_id: vendorId,
|
|
108
|
-
vendor_name: vendorName,
|
|
109
|
-
};
|
|
110
|
-
const jeScheduleDetails = computeNewScheduleJeDetails(localData, scheduleTransaction.amount, vendorName);
|
|
111
|
-
const postingDate = localData.selectedDayOfMonth ??
|
|
112
|
-
(localData.lastDayOfMonth === true ? LAST_SCHEDULE_DAY_OF_MONTH : null);
|
|
113
|
-
const firstJEScheduleDate = jeScheduleDetails.length > 0
|
|
114
|
-
? jeScheduleDetails[0].postingDate.format(DEFAULT_DATE_FORMAT)
|
|
115
|
-
: null;
|
|
116
|
-
const lastJEScheduleDate = jeScheduleDetails.length > 0
|
|
117
|
-
? jeScheduleDetails[jeScheduleDetails.length - 1].postingDate.format(DEFAULT_DATE_FORMAT)
|
|
118
|
-
: null;
|
|
119
|
-
const isFixedAssets = scheduleType === 'fixed_assets';
|
|
120
|
-
const assetId = 'assetId' in localData ? localData.assetId : undefined;
|
|
121
|
-
const selectedAccumulatedDepreciationCategory = 'selectedAccumulatedDepreciationCategory' in localData
|
|
122
|
-
? localData.selectedAccumulatedDepreciationCategory
|
|
123
|
-
: undefined;
|
|
124
|
-
const status = { code: 'new', label: 'New' };
|
|
125
|
-
const jeSchedulePayload = {
|
|
126
|
-
status,
|
|
127
|
-
vendor,
|
|
128
|
-
currency_code: scheduleTransaction.currency.currencyCode,
|
|
129
|
-
currency_symbol: scheduleTransaction.currency.currencySymbol,
|
|
130
|
-
period: localData.selectedMonths ?? null,
|
|
131
|
-
je_schedule_type: scheduleType,
|
|
132
|
-
posting_date: postingDate,
|
|
133
|
-
balance: scheduleTransaction.amount.amount,
|
|
134
|
-
start_date: firstJEScheduleDate,
|
|
135
|
-
end_date: lastJEScheduleDate,
|
|
136
|
-
je_credit_accounting_class_id: scheduleTransaction.classBase?.classId ?? null,
|
|
137
|
-
je_credit_account_id: isFixedAssets
|
|
138
|
-
? (selectedAccumulatedDepreciationCategory ?? null)
|
|
139
|
-
: scheduleTransaction.account.accountId,
|
|
140
|
-
je_debit_account_id: localData.selectedAccount ?? null,
|
|
141
|
-
je_debit_accounting_class_id: localData.selectedClass ?? null,
|
|
142
|
-
other_attributes: assetId != null ? { asset_id: assetId } : {},
|
|
143
|
-
base_transaction: mapScheduleTransactionToBaseScheduleTransactionPayload(scheduleTransaction),
|
|
144
|
-
};
|
|
145
|
-
return {
|
|
146
|
-
ok: true,
|
|
147
|
-
payload: {
|
|
148
|
-
je_schedules: [jeSchedulePayload],
|
|
149
|
-
scheduled_journal_entries: mapNewJeDetailsToScheduledJournalEntryPayload(jeScheduleDetails),
|
|
150
|
-
},
|
|
151
|
-
};
|
|
152
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { getAccountIdsForTypes } from '../../../entity/account/accountSelector';
|
|
2
|
-
import { getSupportedTransactionsByIds } 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
|
-
import { isSupportedTransactionSelectableForNewSchedule } from '../helpers/newScheduleLocalDataHelper';
|
|
9
|
-
/**
|
|
10
|
-
* The Base Transaction search is shared across schedule types (one search
|
|
11
|
-
* box, not one per prepaid_expenses/fixed_assets) — split out from
|
|
12
|
-
* getNewScheduleView so a consumer can read it without supplying an
|
|
13
|
-
* otherwise-irrelevant scheduleType.
|
|
14
|
-
*/
|
|
15
|
-
export const getNewScheduleSearchTransactionsView = (state) => {
|
|
16
|
-
const { searchTransactions } = state.expenseAutomationJESchedulesViewState.newSchedule;
|
|
17
|
-
const searchTransactionsResults = getSupportedTransactionsByIds(state.transactionState, searchTransactions.searchResults);
|
|
18
|
-
return {
|
|
19
|
-
searchTransactionsResults,
|
|
20
|
-
selectableBaseTransactionIds: searchTransactionsResults
|
|
21
|
-
.filter(isSupportedTransactionSelectableForNewSchedule)
|
|
22
|
-
.map((transaction) => transaction.id),
|
|
23
|
-
searchTransactionsFetchState: {
|
|
24
|
-
fetchState: searchTransactions.fetchState,
|
|
25
|
-
error: searchTransactions.error,
|
|
26
|
-
},
|
|
27
|
-
searchTransactionsString: searchTransactions.searchString,
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
export const getNewScheduleView = (state, scheduleType) => {
|
|
31
|
-
const { accountState, accountListState, classState, classListState } = state;
|
|
32
|
-
const { newSchedule } = state.expenseAutomationJESchedulesViewState;
|
|
33
|
-
const searchTransactionsView = getNewScheduleSearchTransactionsView(state);
|
|
34
|
-
const accountType = getAccountsTypesForScheduleEpics();
|
|
35
|
-
const newScheduleAccountTypes = getAccountsTypesForScheduleDetails(scheduleType);
|
|
36
|
-
const newScheduleAccountIds = getAccountIdsForTypes(accountState, newScheduleAccountTypes);
|
|
37
|
-
const allAccountList = getAccountList(accountState, accountListState, accountType.accountListKey);
|
|
38
|
-
const filteredAccounts = allAccountList.accounts.filter((account) => newScheduleAccountIds.includes(account.accountId));
|
|
39
|
-
const accountListNestedAccountHierarchy = filterNestedAccountHierarchyById(getNestedAccountListHierarchy(accountListState, accountType.accountListKey), filteredAccounts.map((account) => account.accountId));
|
|
40
|
-
const allClassList = getClassList(classState, classListState);
|
|
41
|
-
const classListNestedAccountHierarchy = getNestedClassListHierarchy(classListState);
|
|
42
|
-
let allDepreciationAccountList;
|
|
43
|
-
let allDepreciationAccountListNestedAccountHierarchy;
|
|
44
|
-
if (scheduleType === 'fixed_assets') {
|
|
45
|
-
const depreciationCategoryIds = getAccountIdsForTypes(accountState, [
|
|
46
|
-
'fixed_assets',
|
|
47
|
-
'other_assets',
|
|
48
|
-
]);
|
|
49
|
-
const accountLabel = getAccountLabelForScheduleType('fixed_assets');
|
|
50
|
-
const fixedAssetLabelAccountIds = accountLabel != null
|
|
51
|
-
? getAccountIdsForLabel(accountListState, accountType.accountListKey, accountLabel)
|
|
52
|
-
: [];
|
|
53
|
-
allDepreciationAccountList = allAccountList.accounts.filter((account) => depreciationCategoryIds.includes(account.accountId) &&
|
|
54
|
-
!fixedAssetLabelAccountIds.includes(account.accountId));
|
|
55
|
-
allDepreciationAccountListNestedAccountHierarchy =
|
|
56
|
-
filterNestedAccountHierarchyById(getNestedAccountListHierarchy(accountListState, accountType.accountListKey), allDepreciationAccountList.map((account) => account.accountId));
|
|
57
|
-
}
|
|
58
|
-
return {
|
|
59
|
-
scheduleType,
|
|
60
|
-
accountListNestedAccountHierarchy,
|
|
61
|
-
allAccountList: filteredAccounts,
|
|
62
|
-
allClassList: allClassList.classes,
|
|
63
|
-
allDepreciationAccountList,
|
|
64
|
-
allDepreciationAccountListNestedAccountHierarchy,
|
|
65
|
-
classListNestedAccountHierarchy,
|
|
66
|
-
newScheduleLocalData: newSchedule.newScheduleState[scheduleType],
|
|
67
|
-
...searchTransactionsView,
|
|
68
|
-
fetchState: newSchedule.fetchState,
|
|
69
|
-
error: newSchedule.error,
|
|
70
|
-
};
|
|
71
|
-
};
|