@zeniai/client-epic-state 4.19.86-betaSS2 → 4.19.87-beta0ND
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 -35
- package/lib/entity/jeSchedules/jeSchedulesPayload.js +0 -44
- package/lib/entity/jeSchedules/jeSchedulesSelector.d.ts +1 -2
- package/lib/entity/jeSchedules/jeSchedulesSelector.js +1 -2
- package/lib/entity/jeSchedules/jeSchedulesState.d.ts +0 -13
- package/lib/esm/entity/jeSchedules/jeSchedulesPayload.js +0 -44
- package/lib/esm/entity/jeSchedules/jeSchedulesSelector.js +1 -2
- package/lib/esm/index.js +6 -6
- package/lib/esm/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +1 -17
- package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +3 -46
- package/lib/esm/view/expenseAutomationView/types/jeSchedulesViewState.js +1 -15
- package/lib/esm/view/financeStatement/financeStatementSelector.js +5 -0
- package/lib/esm/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector.js +282 -0
- package/lib/esm/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelectorTypes.js +1 -0
- package/lib/esm/view/profitAndLossClassesView/profitAndLossClassesViewReducer.js +5 -1
- package/lib/esm/view/spendManagement/billPay/billList/billListSelector.js +0 -10
- package/lib/esm/view/spendManagement/billPay/billList/billListState.js +0 -1
- package/lib/esm/view/spendManagement/chargeCards/chargeCardList/chargeCardList.js +0 -1
- package/lib/esm/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.js +0 -2
- package/lib/esm/view/spendManagement/reimbursement/remiListView/remiListSelector.js +0 -12
- package/lib/esm/view/spendManagement/reimbursement/remiListView/remiListState.js +0 -1
- package/lib/esm/view/taskManager/taskDetailView/taskDetailSelector.js +2 -2
- package/lib/index.d.ts +10 -9
- package/lib/index.js +28 -28
- package/lib/tsconfig.typecheck.tsbuildinfo +1 -0
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +2 -2
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +2 -18
- package/lib/view/expenseAutomationView/selectorTypes/jeSchedulesSelectorTypes.d.ts +0 -2
- package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +3 -46
- package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +0 -5
- package/lib/view/expenseAutomationView/types/jeSchedulesViewState.js +0 -17
- package/lib/view/financeStatement/financeStatementSelector.d.ts +2 -0
- package/lib/view/financeStatement/financeStatementSelector.js +5 -0
- package/lib/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector.d.ts +13 -0
- package/lib/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector.js +286 -0
- package/lib/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelectorTypes.d.ts +56 -0
- package/lib/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelectorTypes.js +2 -0
- package/lib/view/profitAndLossClassesView/profitAndLossClassesViewReducer.d.ts +4 -2
- package/lib/view/profitAndLossClassesView/profitAndLossClassesViewReducer.js +6 -2
- package/lib/view/profitAndLossClassesView/profitAndLossClassesViewState.d.ts +2 -0
- package/lib/view/scheduleView/scheduleListView/scheduleListTypes.d.ts +1 -1
- package/lib/view/spendManagement/billPay/billList/billListSelector.js +0 -10
- package/lib/view/spendManagement/billPay/billList/billListState.d.ts +1 -1
- package/lib/view/spendManagement/billPay/billList/billListState.js +0 -1
- package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardList.d.ts +1 -1
- package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardList.js +0 -1
- package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.js +0 -2
- package/lib/view/spendManagement/reimbursement/remiListView/remiListSelector.d.ts +0 -1
- package/lib/view/spendManagement/reimbursement/remiListView/remiListSelector.js +0 -12
- package/lib/view/spendManagement/reimbursement/remiListView/remiListState.d.ts +1 -1
- package/lib/view/spendManagement/reimbursement/remiListView/remiListState.js +0 -1
- package/lib/view/taskManager/taskDetailView/taskDetailSelector.js +2 -2
- package/package.json +1 -1
|
@@ -5,7 +5,7 @@ import { JEScheduledTransactionPayload } from '../../../entity/jeSchedules/jeSch
|
|
|
5
5
|
import { JEScheduleTransactionKey } from '../../../entity/jeSchedules/jeSchedulesTypes';
|
|
6
6
|
import { ZeniAPIStatus } from '../../../responsePayload';
|
|
7
7
|
import { AccountTypeRecommendationPayload } from '../../accountMappingView/accountTypeRecommendation/accountTypeRecommendationPayload';
|
|
8
|
-
import { AccountSettingsLocalData, AccountSettingsState, JEScheduleLocalData, JESchedulesViewState
|
|
8
|
+
import { AccountSettingsLocalData, AccountSettingsState, JEScheduleLocalData, JESchedulesViewState } from '../types/jeSchedulesViewState';
|
|
9
9
|
export declare const accountSettingsInitialState: AccountSettingsState;
|
|
10
10
|
export declare const initialState: JESchedulesViewState;
|
|
11
11
|
export declare const clearExpenseAutomationJESchedulesView: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"expenseAutomationJESchedulesView/clearExpenseAutomationJESchedulesView">, clearJeAccountSettingsLocalData: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"expenseAutomationJESchedulesView/clearJeAccountSettingsLocalData">, clearJeScheduleLocalData: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"expenseAutomationJESchedulesView/clearJeScheduleLocalData">, fetchAccountSettingsListForAccountTypes: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"expenseAutomationJESchedulesView/fetchAccountSettingsListForAccountTypes">, fetchJeSchedules: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[period: TimePeriod, refreshViewInBackground?: any], {
|
|
@@ -56,7 +56,7 @@ export declare const clearExpenseAutomationJESchedulesView: import("@reduxjs/too
|
|
|
56
56
|
accountPayload: AccountMetadataPayload[];
|
|
57
57
|
}, "expenseAutomationJESchedulesView/updateAccountSettingsListForAccountTypes">, updateAccountSettingsListForAccountTypesFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
58
58
|
status: ZeniAPIStatus;
|
|
59
|
-
}, "expenseAutomationJESchedulesView/updateAccountSettingsListForAccountTypesFailure">,
|
|
59
|
+
}, "expenseAutomationJESchedulesView/updateAccountSettingsListForAccountTypesFailure">, updateJeScheduleLocalDataById: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
60
60
|
localData: Partial<JEScheduleLocalData>;
|
|
61
61
|
scheduledJournalEntryID: ID;
|
|
62
62
|
}, "expenseAutomationJESchedulesView/updateJeScheduleLocalDataById">, updateJeScheduleTransactionKeys: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[jeScheduleKeys: (`${string}_bill` | `${string}_expense` | `${string}_check` | `${string}_refund` | `${string}_invoice` | `${string}_payment` | `${string}_credit_memo` | `${string}_sales_receipt` | `${string}_delayed_credit` | `${string}_delayed_charge` | `${string}_bill_payment` | `${string}_bill_payment_check` | `${string}_bill_payment_credit_card` | `${string}_vendor_credit` | `${string}_credit_card_credit` | `${string}_transfer` | `${string}_credit_card_payment` | `${string}_deposit` | `${string}_journal_entry`)[], selectedPeriod: MonthYearPeriod], {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.updateRecommendationForAccountSettingsFailure = exports.updateRecommendationForAccountSettings = exports.updateJeScheduleTransactionKeys = exports.updateJeScheduleLocalDataById = exports.
|
|
4
|
+
exports.updateRecommendationForAccountSettingsFailure = exports.updateRecommendationForAccountSettings = exports.updateJeScheduleTransactionKeys = exports.updateJeScheduleLocalDataById = exports.updateAccountSettingsListForAccountTypesFailure = exports.updateAccountSettingsListForAccountTypes = exports.saveAccountSettingsSuccess = exports.saveAccountSettingsLocalData = exports.saveAccountSettingsFailure = exports.saveAccountSettings = exports.retryJeScheduleSuccess = exports.retryJeScheduleFailure = exports.retryJeSchedule = exports.removeJeScheduleTransactionKey = exports.removeJeScheduleLocalDataById = exports.removeFailedJeScheduleTransactionKey = exports.initializeJeScheduleLocalData = exports.initializeAccountSettingsView = exports.ignoreRecommendedJeScheduleSuccess = exports.ignoreRecommendedJeScheduleFailure = exports.ignoreRecommendedJeSchedule = exports.fetchRecommendationForAccountSettings = exports.fetchJeSchedulesSuccess = exports.fetchJeSchedulesPage = exports.fetchJeSchedulesFailure = exports.fetchJeSchedules = exports.fetchAccountSettingsListForAccountTypes = exports.clearJeScheduleLocalData = exports.clearJeAccountSettingsLocalData = exports.clearExpenseAutomationJESchedulesView = exports.initialState = exports.accountSettingsInitialState = void 0;
|
|
5
5
|
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
6
|
const getNestedAccountIDHierarchyForReport_1 = require("../../../commonStateTypes/accountView/getNestedAccountIDHierarchyForReport");
|
|
7
7
|
const timePeriod_1 = require("../../../commonStateTypes/timePeriod");
|
|
@@ -50,8 +50,6 @@ exports.initialState = {
|
|
|
50
50
|
uiState: {
|
|
51
51
|
searchString: '',
|
|
52
52
|
scrollPosition: { scrollTop: 0, scrollLeft: undefined },
|
|
53
|
-
sortKey: 'startMonth',
|
|
54
|
-
sortOrder: 'descending',
|
|
55
53
|
totalCount: 0,
|
|
56
54
|
limit: 10,
|
|
57
55
|
},
|
|
@@ -379,26 +377,12 @@ const expenseAutomationJESchedulesView = (0, toolkit_1.createSlice)({
|
|
|
379
377
|
clearJeAccountSettingsLocalData(draft) {
|
|
380
378
|
draft.accountSettings.localData = exports.accountSettingsInitialState.localData;
|
|
381
379
|
},
|
|
382
|
-
updateJESchedulesUIState(draft, action) {
|
|
383
|
-
if (action.payload.sortKey != null) {
|
|
384
|
-
draft.uiState.sortKey = action.payload.sortKey;
|
|
385
|
-
}
|
|
386
|
-
if (action.payload.sortOrder != null) {
|
|
387
|
-
draft.uiState.sortOrder = action.payload.sortOrder;
|
|
388
|
-
}
|
|
389
|
-
if (action.payload.searchString != null) {
|
|
390
|
-
draft.uiState.searchString = action.payload.searchString;
|
|
391
|
-
}
|
|
392
|
-
if (action.payload.scrollPosition != null) {
|
|
393
|
-
draft.uiState.scrollPosition = action.payload.scrollPosition;
|
|
394
|
-
}
|
|
395
|
-
},
|
|
396
380
|
clearExpenseAutomationJESchedulesView(draft) {
|
|
397
381
|
Object.assign(draft, exports.initialState);
|
|
398
382
|
},
|
|
399
383
|
},
|
|
400
384
|
});
|
|
401
|
-
_a = expenseAutomationJESchedulesView.actions, exports.clearExpenseAutomationJESchedulesView = _a.clearExpenseAutomationJESchedulesView, exports.clearJeAccountSettingsLocalData = _a.clearJeAccountSettingsLocalData, exports.clearJeScheduleLocalData = _a.clearJeScheduleLocalData, exports.fetchAccountSettingsListForAccountTypes = _a.fetchAccountSettingsListForAccountTypes, exports.fetchJeSchedules = _a.fetchJeSchedules, exports.fetchJeSchedulesFailure = _a.fetchJeSchedulesFailure, exports.fetchJeSchedulesPage = _a.fetchJeSchedulesPage, exports.fetchJeSchedulesSuccess = _a.fetchJeSchedulesSuccess, exports.fetchRecommendationForAccountSettings = _a.fetchRecommendationForAccountSettings, exports.ignoreRecommendedJeSchedule = _a.ignoreRecommendedJeSchedule, exports.ignoreRecommendedJeScheduleFailure = _a.ignoreRecommendedJeScheduleFailure, exports.ignoreRecommendedJeScheduleSuccess = _a.ignoreRecommendedJeScheduleSuccess, exports.initializeAccountSettingsView = _a.initializeAccountSettingsView, exports.initializeJeScheduleLocalData = _a.initializeJeScheduleLocalData, exports.removeFailedJeScheduleTransactionKey = _a.removeFailedJeScheduleTransactionKey, exports.removeJeScheduleLocalDataById = _a.removeJeScheduleLocalDataById, exports.removeJeScheduleTransactionKey = _a.removeJeScheduleTransactionKey, exports.retryJeSchedule = _a.retryJeSchedule, exports.retryJeScheduleFailure = _a.retryJeScheduleFailure, exports.retryJeScheduleSuccess = _a.retryJeScheduleSuccess, exports.saveAccountSettings = _a.saveAccountSettings, exports.saveAccountSettingsFailure = _a.saveAccountSettingsFailure, exports.saveAccountSettingsLocalData = _a.saveAccountSettingsLocalData, exports.saveAccountSettingsSuccess = _a.saveAccountSettingsSuccess, exports.updateAccountSettingsListForAccountTypes = _a.updateAccountSettingsListForAccountTypes, exports.updateAccountSettingsListForAccountTypesFailure = _a.updateAccountSettingsListForAccountTypesFailure, exports.
|
|
385
|
+
_a = expenseAutomationJESchedulesView.actions, exports.clearExpenseAutomationJESchedulesView = _a.clearExpenseAutomationJESchedulesView, exports.clearJeAccountSettingsLocalData = _a.clearJeAccountSettingsLocalData, exports.clearJeScheduleLocalData = _a.clearJeScheduleLocalData, exports.fetchAccountSettingsListForAccountTypes = _a.fetchAccountSettingsListForAccountTypes, exports.fetchJeSchedules = _a.fetchJeSchedules, exports.fetchJeSchedulesFailure = _a.fetchJeSchedulesFailure, exports.fetchJeSchedulesPage = _a.fetchJeSchedulesPage, exports.fetchJeSchedulesSuccess = _a.fetchJeSchedulesSuccess, exports.fetchRecommendationForAccountSettings = _a.fetchRecommendationForAccountSettings, exports.ignoreRecommendedJeSchedule = _a.ignoreRecommendedJeSchedule, exports.ignoreRecommendedJeScheduleFailure = _a.ignoreRecommendedJeScheduleFailure, exports.ignoreRecommendedJeScheduleSuccess = _a.ignoreRecommendedJeScheduleSuccess, exports.initializeAccountSettingsView = _a.initializeAccountSettingsView, exports.initializeJeScheduleLocalData = _a.initializeJeScheduleLocalData, exports.removeFailedJeScheduleTransactionKey = _a.removeFailedJeScheduleTransactionKey, exports.removeJeScheduleLocalDataById = _a.removeJeScheduleLocalDataById, exports.removeJeScheduleTransactionKey = _a.removeJeScheduleTransactionKey, exports.retryJeSchedule = _a.retryJeSchedule, exports.retryJeScheduleFailure = _a.retryJeScheduleFailure, exports.retryJeScheduleSuccess = _a.retryJeScheduleSuccess, exports.saveAccountSettings = _a.saveAccountSettings, exports.saveAccountSettingsFailure = _a.saveAccountSettingsFailure, exports.saveAccountSettingsLocalData = _a.saveAccountSettingsLocalData, exports.saveAccountSettingsSuccess = _a.saveAccountSettingsSuccess, exports.updateAccountSettingsListForAccountTypes = _a.updateAccountSettingsListForAccountTypes, exports.updateAccountSettingsListForAccountTypesFailure = _a.updateAccountSettingsListForAccountTypesFailure, exports.updateJeScheduleLocalDataById = _a.updateJeScheduleLocalDataById, exports.updateJeScheduleTransactionKeys = _a.updateJeScheduleTransactionKeys, exports.updateRecommendationForAccountSettings = _a.updateRecommendationForAccountSettings, exports.updateRecommendationForAccountSettingsFailure = _a.updateRecommendationForAccountSettingsFailure;
|
|
402
386
|
exports.default = expenseAutomationJESchedulesView.reducer;
|
|
403
387
|
const doUpdateRecommendationForAccountSettings = (draft, payload) => {
|
|
404
388
|
const { prepaidExpensesRecommendations, fixedAssetsRecommendations, accruedExpensesRecommendations, } = (0, accountTypeRecommendationPayload_1.mapAccountTypeRecommendationPayloadToAccountRecommendationByType)(payload);
|
|
@@ -18,12 +18,10 @@ export interface ExpenseAutomationJESchedulesViewSelector extends SelectorView {
|
|
|
18
18
|
allDepreciationAccountList: AccountBase[];
|
|
19
19
|
allDepreciationAccountListNestedAccountHierarchy: NestedAccountHierarchyForReport[];
|
|
20
20
|
classListNestedAccountHierarchy: NestedClassHierarchyForReport[];
|
|
21
|
-
completedSchedules: JEScheduledTransaction[];
|
|
22
21
|
completionStatus: CompletionStatusType;
|
|
23
22
|
draftSchedules: JEScheduledTransaction[];
|
|
24
23
|
ignoreStatusById: Record<JEScheduleTransactionKey, FetchStateAndError>;
|
|
25
24
|
jeScheduleLocalDataById: Record<ID, JEScheduleLocalData>;
|
|
26
|
-
ongoingSchedules: JEScheduledTransaction[];
|
|
27
25
|
postStatusById: Record<ID, FetchStateAndError>;
|
|
28
26
|
refreshStatus: FetchStateAndError;
|
|
29
27
|
resolveSchedules: JEScheduledTransactionWithFailedEntries[];
|
|
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getExpenseAutomationJESchedulesView = getExpenseAutomationJESchedulesView;
|
|
7
7
|
const omit_1 = __importDefault(require("lodash/omit"));
|
|
8
|
-
const orderBy_1 = __importDefault(require("lodash/orderBy"));
|
|
9
8
|
const timePeriod_1 = require("../../../commonStateTypes/timePeriod");
|
|
10
9
|
const accountSelector_1 = require("../../../entity/account/accountSelector");
|
|
11
10
|
const jeSchedulesSelector_1 = require("../../../entity/jeSchedules/jeSchedulesSelector");
|
|
@@ -17,38 +16,6 @@ const scheduleDetailSelector_1 = require("../../scheduleView/scheduleDetailView/
|
|
|
17
16
|
const scheduleListHelper_1 = require("../../scheduleView/scheduleListView/scheduleListHelper");
|
|
18
17
|
const expenseAutomationViewSelectorTypes_1 = require("../selectorTypes/expenseAutomationViewSelectorTypes");
|
|
19
18
|
const jeAccountSettingsViewSelector_1 = require("./jeAccountSettingsViewSelector");
|
|
20
|
-
function getJEScheduleSortAccessor(sortKey) {
|
|
21
|
-
switch (sortKey) {
|
|
22
|
-
case 'vendor':
|
|
23
|
-
return (s) => s.vendor.name?.toLowerCase();
|
|
24
|
-
case 'category':
|
|
25
|
-
return (s) => s.jeDebit.account?.accountName?.toLowerCase();
|
|
26
|
-
case 'class':
|
|
27
|
-
return (s) => s.jeDebit.accountingClass?.className?.toLowerCase();
|
|
28
|
-
case 'scheduleCategory':
|
|
29
|
-
return (s) => s.jeScheduleType;
|
|
30
|
-
case 'startMonth':
|
|
31
|
-
return (s) => s.startDate?.valueOf();
|
|
32
|
-
case 'type':
|
|
33
|
-
return (s) => s.baseTransaction.typeOfTransaction;
|
|
34
|
-
case 'amortizationPeriod':
|
|
35
|
-
return (s) => s.period;
|
|
36
|
-
case 'jePostingDate':
|
|
37
|
-
return (s) => s.dayOfPostingDate;
|
|
38
|
-
case 'remainingMonths':
|
|
39
|
-
return (s) => s.period;
|
|
40
|
-
case 'runningBalance':
|
|
41
|
-
return (s) => s.balanceAsOfToday?.amount;
|
|
42
|
-
case 'totalAmount':
|
|
43
|
-
return (s) => s.baseTransaction.amount.amount;
|
|
44
|
-
default:
|
|
45
|
-
return (s) => s.startDate?.valueOf();
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
function sortJEScheduledTransactions(transactions, sortKey, sortOrder) {
|
|
49
|
-
const accessor = getJEScheduleSortAccessor(sortKey);
|
|
50
|
-
return (0, orderBy_1.default)(transactions, [accessor], [sortOrder === 'ascending' ? 'asc' : 'desc']);
|
|
51
|
-
}
|
|
52
19
|
function getExpenseAutomationJESchedulesView(state) {
|
|
53
20
|
const jeScheduledTransaction = [];
|
|
54
21
|
const failedJeScheduledTransaction = [];
|
|
@@ -98,21 +65,13 @@ function getExpenseAutomationJESchedulesView(state) {
|
|
|
98
65
|
const jeScheduleDetails = (0, jeSchedulesSelector_1.getJEScheduledTransactionByJEScheduleTransactionKey)(jeScheduleKey, state);
|
|
99
66
|
failedJeScheduledTransaction.push(jeScheduleDetails);
|
|
100
67
|
});
|
|
101
|
-
const
|
|
102
|
-
const
|
|
103
|
-
const ongoingSchedules = sortJEScheduledTransactions(jeScheduledTransaction.filter((schedule) => schedule.status.code === 'ongoing'), sortKey, sortOrder);
|
|
104
|
-
const completedSchedules = sortJEScheduledTransactions(jeScheduledTransaction.filter((schedule) => schedule.status.code === 'completed' ||
|
|
105
|
-
schedule.status.code === 'marked_as_completed'), sortKey, sortOrder);
|
|
106
|
-
const unsortedResolveSchedules = [];
|
|
68
|
+
const draftSchedules = jeScheduledTransaction.filter((schedule) => schedule.status.code === 'draft');
|
|
69
|
+
const resolveSchedules = [];
|
|
107
70
|
failedJeScheduledTransaction.forEach((schedule) => {
|
|
108
71
|
schedule.scheduledJournalEntry.forEach((journalEntry) => {
|
|
109
|
-
|
|
110
|
-
...schedule,
|
|
111
|
-
scheduledJournalEntry: journalEntry,
|
|
112
|
-
});
|
|
72
|
+
resolveSchedules.push({ ...schedule, scheduledJournalEntry: journalEntry });
|
|
113
73
|
});
|
|
114
74
|
});
|
|
115
|
-
const resolveSchedules = sortJEScheduledTransactions(unsortedResolveSchedules, sortKey, sortOrder);
|
|
116
75
|
const allSteps = monthYearPeriodId != null
|
|
117
76
|
? (0, expenseAutomationViewSelectorTypes_1.getAllSteps)(monthEndCloseChecksState, monthYearPeriodId, currentTenant.tenantId)
|
|
118
77
|
: [];
|
|
@@ -126,9 +85,7 @@ function getExpenseAutomationJESchedulesView(state) {
|
|
|
126
85
|
allAccountList: filteredAccounts,
|
|
127
86
|
accountListNestedAccountHierarchy,
|
|
128
87
|
allClassList: allClasses,
|
|
129
|
-
completedSchedules,
|
|
130
88
|
draftSchedules,
|
|
131
|
-
ongoingSchedules,
|
|
132
89
|
resolveSchedules: resolveSchedules,
|
|
133
90
|
accountSettingsView,
|
|
134
91
|
postStatusById: postStatusById,
|
|
@@ -1,21 +1,16 @@
|
|
|
1
1
|
import { NestedAccountHierarchyForReport } from '../../../commonStateTypes/accountView/nestedAccountID';
|
|
2
2
|
import { FetchStateAndError, FetchedState, ID } from '../../../commonStateTypes/common';
|
|
3
3
|
import { Recommendation } from '../../../commonStateTypes/recommendationBase';
|
|
4
|
-
import { SortOrder } from '../../../commonStateTypes/selectorTypes/sortOrderTypes';
|
|
5
4
|
import { MonthYearPeriodId } from '../../../commonStateTypes/timePeriod';
|
|
6
5
|
import { AccountBase } from '../../../entity/account/accountState';
|
|
7
6
|
import { JEScheduleTransactionKey, ScheduleTypes } from '../../../entity/jeSchedules/jeSchedulesTypes';
|
|
8
7
|
import { VendorBase } from '../../../entity/vendor/vendorState';
|
|
9
|
-
export declare const toJEScheduleSortKey: (v: string) => "vendor" | "type" | "category" | "class" | "totalAmount" | "runningBalance" | "scheduleCategory" | "startMonth" | "amortizationPeriod" | "jePostingDate" | "remainingMonths";
|
|
10
|
-
export type JEScheduleSortKey = ReturnType<typeof toJEScheduleSortKey>;
|
|
11
8
|
export interface JESchedulesViewUIState {
|
|
12
9
|
scrollPosition: {
|
|
13
10
|
scrollTop: number;
|
|
14
11
|
scrollLeft?: number;
|
|
15
12
|
} | undefined;
|
|
16
13
|
searchString: string;
|
|
17
|
-
sortKey: JEScheduleSortKey;
|
|
18
|
-
sortOrder: SortOrder;
|
|
19
14
|
totalCount: number;
|
|
20
15
|
limit?: number;
|
|
21
16
|
}
|
|
@@ -1,19 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toJEScheduleSortKey = void 0;
|
|
4
|
-
const stringToUnion_1 = require("../../../commonStateTypes/stringToUnion");
|
|
5
|
-
const JE_SCHEDULE_SORT_KEYS = [
|
|
6
|
-
'vendor',
|
|
7
|
-
'category',
|
|
8
|
-
'class',
|
|
9
|
-
'scheduleCategory',
|
|
10
|
-
'startMonth',
|
|
11
|
-
'type',
|
|
12
|
-
'amortizationPeriod',
|
|
13
|
-
'jePostingDate',
|
|
14
|
-
'remainingMonths',
|
|
15
|
-
'runningBalance',
|
|
16
|
-
'totalAmount',
|
|
17
|
-
];
|
|
18
|
-
const toJEScheduleSortKey = (v) => (0, stringToUnion_1.stringToUnion)(v, JE_SCHEDULE_SORT_KEYS);
|
|
19
|
-
exports.toJEScheduleSortKey = toJEScheduleSortKey;
|
|
@@ -8,6 +8,7 @@ import { RootState } from '../../reducer';
|
|
|
8
8
|
import { BalanceSheetReport } from '../balanceSheet/balanceSheetSelectorTypes';
|
|
9
9
|
import { CashFlowReport } from '../cashFlow/cashFlowSelectorTypes';
|
|
10
10
|
import { ProfitAndLossReport } from '../profitAndLoss/profitAndLossSelector';
|
|
11
|
+
import { ProfitAndLossByClassHorizontalReport } from '../profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelectorTypes';
|
|
11
12
|
import { ProfitAndLossClassesViewReport } from '../profitAndLossClassesView/profitAndLossClassesViewSelectorTypes';
|
|
12
13
|
export interface FinanceStatementReport extends SelectorReport {
|
|
13
14
|
allTimeframeTicks: TimeframeTickWithMetaData[];
|
|
@@ -18,6 +19,7 @@ export interface FinanceStatementReport extends SelectorReport {
|
|
|
18
19
|
downloadState: FetchState;
|
|
19
20
|
filter: COABalancesFilter;
|
|
20
21
|
isCompareModeOn: boolean;
|
|
22
|
+
profitAndLossByClassHorizontalReport: ProfitAndLossByClassHorizontalReport;
|
|
21
23
|
profitAndLossByClassReport: ProfitAndLossClassesViewReport;
|
|
22
24
|
profitAndLossReport: ProfitAndLossReport;
|
|
23
25
|
reportFormat: ReportFormat;
|
|
@@ -11,6 +11,7 @@ const thisPeriodHelpers_1 = require("../../commonStateTypes/viewAndReport/thisPe
|
|
|
11
11
|
const balanceSheetSelector_1 = require("../balanceSheet/balanceSheetSelector");
|
|
12
12
|
const cashFlowSelector_1 = require("../cashFlow/cashFlowSelector");
|
|
13
13
|
const profitAndLossSelector_1 = require("../profitAndLoss/profitAndLossSelector");
|
|
14
|
+
const profitAndLossClassesByClassHorizontalSelector_1 = require("../profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector");
|
|
14
15
|
const profitAndLossClassesViewSelector_1 = require("../profitAndLossClassesView/profitAndLossClassesViewSelector");
|
|
15
16
|
function getDateRangeForFinanceReports(profitAndLossState, balanceSheetState, cashFlowState) {
|
|
16
17
|
const datesSorted = [
|
|
@@ -63,6 +64,9 @@ exports.getFinanceStatement = (0, toolkit_1.createSelector)((state) => state.acc
|
|
|
63
64
|
const profitAndLossReport = (0, profitAndLossSelector_1.getProfitAndLossReport)(filter, undefined, accountState, accountGroupState, sectionAccountsViewState, profitAndLossState, forecastState);
|
|
64
65
|
const classFilter = (0, coaBalancesFilterClassesView_1.newBalancesFilterClassesView)(filter.firstMonthOfFY, filter.timeframe, filter.balancesRange.numberOfPeriods, filter.balancesRange.thisPeriod, filter.balancesRange.orderBy, filter.additionalBalances, profitAndLossClassesViewState.uiState.classesToFilterOut);
|
|
65
66
|
const profitAndLossByClassReport = (0, profitAndLossClassesViewSelector_1.getProfitAndLossClassesView)(classFilter, accountState, classState, sectionsState, profitAndLossClassesViewState);
|
|
67
|
+
const profitAndLossByClassHorizontalReport = profitAndLossClassesViewState.uiState.classViewLayout === 'horizontal'
|
|
68
|
+
? (0, profitAndLossClassesByClassHorizontalSelector_1.getProfitAndLossClassesHorizontalView)(classFilter, accountState, classState, sectionsState, profitAndLossClassesViewState, thisPeriod)
|
|
69
|
+
: (0, profitAndLossClassesByClassHorizontalSelector_1.getProfitAndLossClassesHorizontalView)(classFilter, accountState, classState, sectionsState, profitAndLossClassesViewState, undefined);
|
|
66
70
|
const balanceSheetReport = (0, balanceSheetSelector_1.getBalanceSheet)(filter, accountState, accountGroupState, sectionAccountsViewState, balanceSheetState);
|
|
67
71
|
const cashFlowReport = (0, cashFlowSelector_1.getCashFlow)(filter, accountState, accountGroupState, sectionAccountsViewState, cashFlowState);
|
|
68
72
|
const allReports = [
|
|
@@ -110,6 +114,7 @@ exports.getFinanceStatement = (0, toolkit_1.createSelector)((state) => state.acc
|
|
|
110
114
|
dataAvailable,
|
|
111
115
|
profitAndLossReport,
|
|
112
116
|
profitAndLossByClassReport,
|
|
117
|
+
profitAndLossByClassHorizontalReport,
|
|
113
118
|
balanceSheetReport,
|
|
114
119
|
cashFlowReport,
|
|
115
120
|
filter,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { COABalancesFilterClassesView } from '../../commonStateTypes/coaBalance/coaBalancesFilterClassesView';
|
|
2
|
+
import { AccountState } from '../../entity/account/accountState';
|
|
3
|
+
import { ClassState } from '../../entity/class/classState';
|
|
4
|
+
import { SectionClassesViewStateV2 } from '../../entity/sectionClassesViewV2/sectionClassesViewState';
|
|
5
|
+
import { ZeniDate } from '../../zeniDayJS';
|
|
6
|
+
import { ProfitAndLossByClassHorizontalReport } from './profitAndLossClassesByClassHorizontalSelectorTypes';
|
|
7
|
+
import { PandLReportViewCalculatedSectionID, PandLReportViewSectionID } from './profitAndLossClassesViewSelectorTypes';
|
|
8
|
+
import { ProfitAndLossClassesViewState } from './profitAndLossClassesViewState';
|
|
9
|
+
export declare const profitAndLossHorizontalIdsInOrder: (PandLReportViewSectionID | PandLReportViewCalculatedSectionID)[];
|
|
10
|
+
export declare const getProfitAndLossClassesHorizontalView: (filter: COABalancesFilterClassesView, accountState: AccountState, classState: ClassState, sectionsState: SectionClassesViewStateV2, profitAndLossClassesViewState: ProfitAndLossClassesViewState, selectedPeriod: {
|
|
11
|
+
endDate: ZeniDate;
|
|
12
|
+
startDate: ZeniDate;
|
|
13
|
+
} | undefined) => ProfitAndLossByClassHorizontalReport;
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getProfitAndLossClassesHorizontalView = exports.profitAndLossHorizontalIdsInOrder = void 0;
|
|
4
|
+
const amount_1 = require("../../commonStateTypes/amount");
|
|
5
|
+
const sectionClassesViewSelector_1 = require("../../entity/sectionClassesViewV2/sectionClassesViewSelector");
|
|
6
|
+
const profitAndLossClassesViewSelectorTypes_1 = require("./profitAndLossClassesViewSelectorTypes");
|
|
7
|
+
const DEFAULT_CURRENCY = { currencyCode: 'USD', currencySymbol: '$' };
|
|
8
|
+
exports.profitAndLossHorizontalIdsInOrder = [
|
|
9
|
+
'income',
|
|
10
|
+
'cogs',
|
|
11
|
+
'grossProfit',
|
|
12
|
+
'expenses',
|
|
13
|
+
'earningsBeforeInterestAndTax',
|
|
14
|
+
'otherIncome',
|
|
15
|
+
'otherExpenses',
|
|
16
|
+
'netOtherIncome',
|
|
17
|
+
'netIncome',
|
|
18
|
+
];
|
|
19
|
+
const SECTION_TITLES = {
|
|
20
|
+
income: 'Income',
|
|
21
|
+
cogs: 'Cost of Goods Sold',
|
|
22
|
+
grossProfit: 'Gross Profit',
|
|
23
|
+
expenses: 'Expenses',
|
|
24
|
+
earningsBeforeInterestAndTax: 'Net Operating Income',
|
|
25
|
+
otherIncome: 'Other Income',
|
|
26
|
+
otherExpenses: 'Other Expenses',
|
|
27
|
+
netOtherIncome: 'Net Other Income',
|
|
28
|
+
netIncome: 'Net Income',
|
|
29
|
+
};
|
|
30
|
+
const getProfitAndLossClassesHorizontalView = (filter, accountState, classState, sectionsState, profitAndLossClassesViewState, selectedPeriod) => {
|
|
31
|
+
const fetchState = reduceFetchState([
|
|
32
|
+
profitAndLossClassesViewState.fetchState.month,
|
|
33
|
+
profitAndLossClassesViewState.fetchState.quarter,
|
|
34
|
+
profitAndLossClassesViewState.fetchState.year,
|
|
35
|
+
]);
|
|
36
|
+
const reportId = 'profit_and_loss_by_classes';
|
|
37
|
+
// Build class columns from the class hierarchy (top-level only)
|
|
38
|
+
const classColumns = buildClassColumns(profitAndLossClassesViewState.classHierarchy, profitAndLossClassesViewState.uiState.classesToFilterOut);
|
|
39
|
+
const sections = {};
|
|
40
|
+
const calculatedSections = {};
|
|
41
|
+
if (fetchState.fetchState === 'Completed' && selectedPeriod != null) {
|
|
42
|
+
// Get section reports using existing selector infrastructure
|
|
43
|
+
const sectionReports = {};
|
|
44
|
+
profitAndLossClassesViewSelectorTypes_1.ALL_PANDL_REPORT_VIEW_SECTION_IDS.forEach((sectionId) => {
|
|
45
|
+
sectionReports[sectionId] = (0, sectionClassesViewSelector_1.getSectionClassesViewReport)(accountState, classState, sectionsState, { reportId, sectionId }, filter);
|
|
46
|
+
});
|
|
47
|
+
// Pivot each section from class→account to account→class
|
|
48
|
+
const sectionIds = [
|
|
49
|
+
'income',
|
|
50
|
+
'cogs',
|
|
51
|
+
'expenses',
|
|
52
|
+
'otherIncome',
|
|
53
|
+
'otherExpenses',
|
|
54
|
+
];
|
|
55
|
+
sectionIds.forEach((sectionId) => {
|
|
56
|
+
const sectionReport = sectionReports[sectionId];
|
|
57
|
+
if (sectionReport != null) {
|
|
58
|
+
sections[sectionId] = pivotSectionToHorizontal(sectionReport, classColumns, selectedPeriod, SECTION_TITLES[sectionId] ?? sectionId);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
// Calculate derived sections
|
|
62
|
+
const incomeSection = sections['income'];
|
|
63
|
+
const cogsSection = sections['cogs'];
|
|
64
|
+
const expensesSection = sections['expenses'];
|
|
65
|
+
const otherIncomeSection = sections['otherIncome'];
|
|
66
|
+
const otherExpensesSection = sections['otherExpenses'];
|
|
67
|
+
// Gross Profit = Income - COGS
|
|
68
|
+
if (incomeSection != null && cogsSection != null) {
|
|
69
|
+
calculatedSections['grossProfit'] = computeCalculatedSection(incomeSection.classTotals, cogsSection.classTotals, incomeSection.sectionTotal, cogsSection.sectionTotal, 'subtract', SECTION_TITLES['grossProfit']);
|
|
70
|
+
}
|
|
71
|
+
// EBIT = Gross Profit - Expenses
|
|
72
|
+
const grossProfit = calculatedSections['grossProfit'];
|
|
73
|
+
if (grossProfit != null && expensesSection != null) {
|
|
74
|
+
calculatedSections['earningsBeforeInterestAndTax'] =
|
|
75
|
+
computeCalculatedSection(grossProfit.classTotals, expensesSection.classTotals, grossProfit.sectionTotal, expensesSection.sectionTotal, 'subtract', SECTION_TITLES['earningsBeforeInterestAndTax']);
|
|
76
|
+
}
|
|
77
|
+
// Net Other Income = Other Income - Other Expenses
|
|
78
|
+
if (otherIncomeSection != null && otherExpensesSection != null) {
|
|
79
|
+
calculatedSections['netOtherIncome'] = computeCalculatedSection(otherIncomeSection.classTotals, otherExpensesSection.classTotals, otherIncomeSection.sectionTotal, otherExpensesSection.sectionTotal, 'subtract', SECTION_TITLES['netOtherIncome']);
|
|
80
|
+
}
|
|
81
|
+
// Net Income = EBIT + Net Other Income
|
|
82
|
+
const ebit = calculatedSections['earningsBeforeInterestAndTax'];
|
|
83
|
+
const netOtherIncome = calculatedSections['netOtherIncome'];
|
|
84
|
+
if (ebit != null && netOtherIncome != null) {
|
|
85
|
+
calculatedSections['netIncome'] = computeCalculatedSection(ebit.classTotals, netOtherIncome.classTotals, ebit.sectionTotal, netOtherIncome.sectionTotal, 'add', SECTION_TITLES['netIncome']);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
// Build synthetic header COABalances for rendering class names as column headers
|
|
89
|
+
const headerBalances = buildHeaderBalances(classColumns, filter.timeframe, selectedPeriod);
|
|
90
|
+
return {
|
|
91
|
+
reportId,
|
|
92
|
+
reportTitle: 'Profit and Loss by Class',
|
|
93
|
+
firstMonthOfFY: profitAndLossClassesViewState.firstMonthOfFY,
|
|
94
|
+
fetchState: fetchState.fetchState,
|
|
95
|
+
bookCloseDate: profitAndLossClassesViewState.bookCloseDate,
|
|
96
|
+
dataAvailable: profitAndLossClassesViewState.dataAvailable,
|
|
97
|
+
selectedPeriod,
|
|
98
|
+
classColumns,
|
|
99
|
+
sections,
|
|
100
|
+
calculatedSections,
|
|
101
|
+
idsInOrder: exports.profitAndLossHorizontalIdsInOrder,
|
|
102
|
+
uiState: profitAndLossClassesViewState.uiState,
|
|
103
|
+
headerBalances,
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
exports.getProfitAndLossClassesHorizontalView = getProfitAndLossClassesHorizontalView;
|
|
107
|
+
/**
|
|
108
|
+
* Build column definitions from class hierarchy (top-level classes only).
|
|
109
|
+
*/
|
|
110
|
+
function buildClassColumns(classHierarchy, classesToFilterOut) {
|
|
111
|
+
return classHierarchy
|
|
112
|
+
.filter((c) => !classesToFilterOut.some((filteredId) => filteredId[0] === c.classId[0]))
|
|
113
|
+
.map((c) => ({
|
|
114
|
+
classId: c.classId[0],
|
|
115
|
+
className: c.className,
|
|
116
|
+
nestedClassId: c.classId,
|
|
117
|
+
qboId: c.qboId,
|
|
118
|
+
}));
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Pivot a section from class→account→balances to account→class→balance (single period).
|
|
122
|
+
*/
|
|
123
|
+
function pivotSectionToHorizontal(section, classColumns, selectedPeriod, title) {
|
|
124
|
+
// Map: accountId -> { accountName, classId -> balance }
|
|
125
|
+
const accountMap = new Map();
|
|
126
|
+
// Also track class totals
|
|
127
|
+
const classTotalMap = new Map();
|
|
128
|
+
classColumns.forEach((col) => classTotalMap.set(col.classId, 0));
|
|
129
|
+
// Iterate over each class in the section
|
|
130
|
+
section.classes.forEach((classReport) => {
|
|
131
|
+
const classId = classReport.id[0];
|
|
132
|
+
// Only process classes that are in our columns
|
|
133
|
+
if (!classColumns.some((col) => col.classId === classId)) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
// Get the class-level balance for this period (total for the class in this section)
|
|
137
|
+
const classBalance = findBalanceForPeriod(classReport.childrenBalancesTotal.balances, selectedPeriod);
|
|
138
|
+
classTotalMap.set(classId, classBalance);
|
|
139
|
+
// Iterate through accounts in this class
|
|
140
|
+
collectAccountsFromClass(classReport, classId, selectedPeriod, accountMap);
|
|
141
|
+
});
|
|
142
|
+
// Build account rows
|
|
143
|
+
const accounts = [];
|
|
144
|
+
accountMap.forEach((accountData, accountId) => {
|
|
145
|
+
const classBalances = classColumns.map((col) => ({
|
|
146
|
+
classId: col.classId,
|
|
147
|
+
balance: (0, amount_1.toAmountWC)(accountData.classBalances.get(col.classId) ?? 0, DEFAULT_CURRENCY),
|
|
148
|
+
}));
|
|
149
|
+
const rowTotal = classBalances.reduce((sum, cb) => sum + cb.balance.amount, 0);
|
|
150
|
+
accounts.push({
|
|
151
|
+
accountId,
|
|
152
|
+
accountName: accountData.accountName,
|
|
153
|
+
classBalances,
|
|
154
|
+
rowTotal: (0, amount_1.toAmountWC)(rowTotal, DEFAULT_CURRENCY),
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
// Build class totals
|
|
158
|
+
const classTotals = classColumns.map((col) => ({
|
|
159
|
+
classId: col.classId,
|
|
160
|
+
balance: (0, amount_1.toAmountWC)(classTotalMap.get(col.classId) ?? 0, DEFAULT_CURRENCY),
|
|
161
|
+
}));
|
|
162
|
+
const sectionTotal = classTotals.reduce((sum, ct) => sum + ct.balance.amount, 0);
|
|
163
|
+
return {
|
|
164
|
+
title,
|
|
165
|
+
accounts,
|
|
166
|
+
classTotals,
|
|
167
|
+
sectionTotal: (0, amount_1.toAmountWC)(sectionTotal, DEFAULT_CURRENCY),
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Recursively collect account balances from a NestedClassReportV2 into accountMap.
|
|
172
|
+
*/
|
|
173
|
+
function collectAccountsFromClass(classReport, classId, selectedPeriod, accountMap) {
|
|
174
|
+
// Process accounts directly on this class
|
|
175
|
+
classReport.class.accounts.forEach((nestedAccount) => {
|
|
176
|
+
collectAccountsFromNestedAccount(nestedAccount, classId, selectedPeriod, accountMap);
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Recursively collect accounts from NestedAccountReport (handles sub-accounts).
|
|
181
|
+
*/
|
|
182
|
+
function collectAccountsFromNestedAccount(nestedAccount, classId, selectedPeriod, accountMap) {
|
|
183
|
+
const accountId = nestedAccount.account.accountId;
|
|
184
|
+
const accountName = nestedAccount.account.accountName;
|
|
185
|
+
const balance = findBalanceForPeriod(nestedAccount.account.balancesInTimeframe.balances, selectedPeriod);
|
|
186
|
+
if (!accountMap.has(accountId)) {
|
|
187
|
+
accountMap.set(accountId, {
|
|
188
|
+
accountName,
|
|
189
|
+
classBalances: new Map(),
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
const accountData = accountMap.get(accountId);
|
|
193
|
+
if (accountData == null) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
const existing = accountData.classBalances.get(classId) ?? 0;
|
|
197
|
+
accountData.classBalances.set(classId, existing + balance);
|
|
198
|
+
// Process sub-accounts
|
|
199
|
+
nestedAccount.children.forEach((child) => {
|
|
200
|
+
collectAccountsFromNestedAccount(child, classId, selectedPeriod, accountMap);
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Find the balance amount for a specific period from a COABalance array.
|
|
205
|
+
*/
|
|
206
|
+
function findBalanceForPeriod(balances, selectedPeriod) {
|
|
207
|
+
for (const bal of balances) {
|
|
208
|
+
const b = bal;
|
|
209
|
+
if (b.startDate != null && b.endDate != null) {
|
|
210
|
+
if (b.startDate.isSame(selectedPeriod.startDate, 'day') &&
|
|
211
|
+
b.endDate.isSame(selectedPeriod.endDate, 'day')) {
|
|
212
|
+
return b.balance?.amount ?? 0;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return 0;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Compute a calculated section by adding or subtracting two sets of class totals.
|
|
220
|
+
*/
|
|
221
|
+
function computeCalculatedSection(aTotals, bTotals, aTotal, bTotal, operation, title) {
|
|
222
|
+
const classTotals = aTotals.map((a) => {
|
|
223
|
+
const bMatch = bTotals.find((b) => b.classId === a.classId);
|
|
224
|
+
const bAmount = bMatch?.balance.amount ?? 0;
|
|
225
|
+
const resultAmount = operation === 'add'
|
|
226
|
+
? a.balance.amount + bAmount
|
|
227
|
+
: a.balance.amount - bAmount;
|
|
228
|
+
return {
|
|
229
|
+
classId: a.classId,
|
|
230
|
+
balance: (0, amount_1.toAmountWC)(resultAmount, DEFAULT_CURRENCY),
|
|
231
|
+
};
|
|
232
|
+
});
|
|
233
|
+
const sectionTotalAmount = operation === 'add'
|
|
234
|
+
? aTotal.amount + bTotal.amount
|
|
235
|
+
: aTotal.amount - bTotal.amount;
|
|
236
|
+
return {
|
|
237
|
+
title,
|
|
238
|
+
classTotals,
|
|
239
|
+
sectionTotal: (0, amount_1.toAmountWC)(sectionTotalAmount, DEFAULT_CURRENCY),
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Build synthetic COABalance array for header rendering.
|
|
244
|
+
* One entry per class column + one for "Total".
|
|
245
|
+
*/
|
|
246
|
+
function buildHeaderBalances(classColumns, timeframe, selectedPeriod) {
|
|
247
|
+
if (selectedPeriod == null) {
|
|
248
|
+
return [];
|
|
249
|
+
}
|
|
250
|
+
const { endDate, startDate } = selectedPeriod;
|
|
251
|
+
const balances = classColumns.map((col) => ({
|
|
252
|
+
balance: (0, amount_1.toAmountWC)(0, DEFAULT_CURRENCY),
|
|
253
|
+
balanceTimeFrame: timeframe,
|
|
254
|
+
endDate,
|
|
255
|
+
startDate,
|
|
256
|
+
type: 'default',
|
|
257
|
+
label: col.className,
|
|
258
|
+
}));
|
|
259
|
+
// Add a "Total" column
|
|
260
|
+
balances.push({
|
|
261
|
+
balance: (0, amount_1.toAmountWC)(0, DEFAULT_CURRENCY),
|
|
262
|
+
balanceTimeFrame: timeframe,
|
|
263
|
+
endDate,
|
|
264
|
+
startDate,
|
|
265
|
+
type: 'default',
|
|
266
|
+
label: 'Total',
|
|
267
|
+
});
|
|
268
|
+
return balances;
|
|
269
|
+
}
|
|
270
|
+
function reduceFetchState(fetchStateList) {
|
|
271
|
+
const isAnyProgress = fetchStateList.some((s) => s.fetchState === 'In-Progress');
|
|
272
|
+
const isAllCompleted = fetchStateList.every((s) => s.fetchState === 'Completed');
|
|
273
|
+
const isAnyError = fetchStateList.some((s) => s.fetchState === 'Error');
|
|
274
|
+
const error = fetchStateList.find((s) => s.error != null)?.error;
|
|
275
|
+
let fetchState = 'Not-Started';
|
|
276
|
+
if (isAnyProgress) {
|
|
277
|
+
fetchState = 'In-Progress';
|
|
278
|
+
}
|
|
279
|
+
else if (isAllCompleted) {
|
|
280
|
+
fetchState = 'Completed';
|
|
281
|
+
}
|
|
282
|
+
else if (isAnyError) {
|
|
283
|
+
fetchState = 'Error';
|
|
284
|
+
}
|
|
285
|
+
return { fetchState, error };
|
|
286
|
+
}
|
package/lib/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelectorTypes.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Amount } from '../../commonStateTypes/amount';
|
|
2
|
+
import { NestedClassID } from '../../commonStateTypes/classesView/nestedClassID';
|
|
3
|
+
import { COABalance } from '../../commonStateTypes/coaBalance/coaBalance';
|
|
4
|
+
import { FetchState, ID } from '../../commonStateTypes/common';
|
|
5
|
+
import { DataAvailable } from '../../commonStateTypes/dataAvailable';
|
|
6
|
+
import { Month } from '../../commonStateTypes/timePeriod';
|
|
7
|
+
import { ZeniDate } from '../../zeniDayJS';
|
|
8
|
+
import { PandLReportViewCalculatedSectionID, PandLReportViewSectionID } from './profitAndLossClassesViewSelectorTypes';
|
|
9
|
+
import { ProfitAndLossClassesViewUIState } from './profitAndLossClassesViewState';
|
|
10
|
+
export interface ClassColumnDefinition {
|
|
11
|
+
classId: string;
|
|
12
|
+
className: string;
|
|
13
|
+
nestedClassId: NestedClassID;
|
|
14
|
+
qboId?: ID;
|
|
15
|
+
}
|
|
16
|
+
export interface HorizontalClassBalance {
|
|
17
|
+
balance: Amount;
|
|
18
|
+
classId: string;
|
|
19
|
+
}
|
|
20
|
+
export interface HorizontalAccountRow {
|
|
21
|
+
accountId: string;
|
|
22
|
+
accountName: string;
|
|
23
|
+
classBalances: HorizontalClassBalance[];
|
|
24
|
+
rowTotal: Amount;
|
|
25
|
+
}
|
|
26
|
+
export interface HorizontalSectionReport {
|
|
27
|
+
accounts: HorizontalAccountRow[];
|
|
28
|
+
classTotals: HorizontalClassBalance[];
|
|
29
|
+
sectionTotal: Amount;
|
|
30
|
+
title: string;
|
|
31
|
+
}
|
|
32
|
+
export interface HorizontalCalculatedSection {
|
|
33
|
+
classTotals: HorizontalClassBalance[];
|
|
34
|
+
sectionTotal: Amount;
|
|
35
|
+
title: string;
|
|
36
|
+
}
|
|
37
|
+
export interface ProfitAndLossByClassHorizontalReport {
|
|
38
|
+
calculatedSections: Partial<Record<PandLReportViewCalculatedSectionID, HorizontalCalculatedSection>>;
|
|
39
|
+
classColumns: ClassColumnDefinition[];
|
|
40
|
+
fetchState: FetchState;
|
|
41
|
+
firstMonthOfFY: Month;
|
|
42
|
+
/** Synthetic COABalance array for header rendering — one per class column + total */
|
|
43
|
+
headerBalances: COABalance[];
|
|
44
|
+
idsInOrder: (PandLReportViewSectionID | PandLReportViewCalculatedSectionID)[];
|
|
45
|
+
reportId: string;
|
|
46
|
+
reportTitle: string;
|
|
47
|
+
sections: Partial<Record<PandLReportViewSectionID, HorizontalSectionReport>>;
|
|
48
|
+
selectedPeriod: {
|
|
49
|
+
endDate: ZeniDate;
|
|
50
|
+
startDate: ZeniDate;
|
|
51
|
+
label?: string;
|
|
52
|
+
} | undefined;
|
|
53
|
+
uiState: ProfitAndLossClassesViewUIState;
|
|
54
|
+
bookCloseDate?: ZeniDate;
|
|
55
|
+
dataAvailable?: DataAvailable;
|
|
56
|
+
}
|
|
@@ -2,7 +2,7 @@ import { NestedClassID } from '../../commonStateTypes/classesView/nestedClassID'
|
|
|
2
2
|
import { AccountViewMode, ID } from '../../commonStateTypes/common';
|
|
3
3
|
import { ZeniAPIStatus, ZeniReportData } from '../../responsePayload';
|
|
4
4
|
import { ProfitAndLossClassesViewPayload } from './profitAndLossClassesViewPayload';
|
|
5
|
-
import { ProfitAndLossClassesViewState } from './profitAndLossClassesViewState';
|
|
5
|
+
import { ClassViewLayout, ProfitAndLossClassesViewState } from './profitAndLossClassesViewState';
|
|
6
6
|
export declare const initialState: ProfitAndLossClassesViewState;
|
|
7
7
|
export declare const fetchProfitAndLossClassesView: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[cacheOverride?: boolean | undefined], {
|
|
8
8
|
cacheOverride: boolean;
|
|
@@ -30,6 +30,8 @@ export declare const fetchProfitAndLossClassesView: import("@reduxjs/toolkit").A
|
|
|
30
30
|
};
|
|
31
31
|
}, "profitAndLossClassesView/updateProfitAndLossClassesViewUIState">, updateAccountViewMode: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
32
32
|
viewMode: AccountViewMode;
|
|
33
|
-
}, "profitAndLossClassesView/updateAccountViewMode">,
|
|
33
|
+
}, "profitAndLossClassesView/updateAccountViewMode">, updateClassViewLayout: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
34
|
+
classViewLayout: ClassViewLayout;
|
|
35
|
+
}, "profitAndLossClassesView/updateClassViewLayout">, resetProfitAndLossClassesNodeCollapseState: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"profitAndLossClassesView/resetProfitAndLossClassesNodeCollapseState">, clearProfitAndLossClassesView: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"profitAndLossClassesView/clearProfitAndLossClassesView">;
|
|
34
36
|
declare const _default: import("redux").Reducer<ProfitAndLossClassesViewState>;
|
|
35
37
|
export default _default;
|