@zeniai/client-epic-state 4.20.7 → 4.20.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonStateTypes/coaBalance/additionalBalances/getSummationBalance.d.ts +1 -1
- package/lib/commonStateTypes/coaBalance/coaBalanceType.d.ts +2 -0
- package/lib/commonStateTypes/coaBalance/coaBalanceType.js +6 -0
- package/lib/commonStateTypes/currencyHelper.d.ts +3 -0
- package/lib/commonStateTypes/currencyHelper.js +6 -1
- package/lib/commonStateTypes/reduceFetchState.d.ts +9 -0
- package/lib/commonStateTypes/reduceFetchState.js +26 -0
- package/lib/entity/account/accountPayload.d.ts +2 -0
- package/lib/entity/account/accountPayload.js +2 -0
- package/lib/entity/account/accountState.d.ts +2 -0
- package/lib/entity/customer/customerState.d.ts +0 -2
- package/lib/entity/customer/customerState.js +0 -5
- package/lib/entity/depositAccount/depositAccount.d.ts +1 -1
- package/lib/entity/depositAccount/depositAccount.js +8 -1
- package/lib/entity/reimbursement/reimbursementPayload.d.ts +2 -0
- package/lib/entity/reimbursement/reimbursementPayload.js +7 -0
- package/lib/entity/reimbursement/reimbursementState.d.ts +2 -0
- package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
- package/lib/entity/snackbar/snackbarTypes.js +2 -0
- package/lib/entity/task/taskPayload.d.ts +1 -0
- package/lib/entity/task/taskPayload.js +1 -0
- package/lib/entity/task/taskState.d.ts +1 -0
- package/lib/entity/userGroups/userGroupsPayload.d.ts +7 -0
- package/lib/entity/userGroups/userGroupsPayload.js +10 -0
- package/lib/entity/userGroups/userGroupsReducer.d.ts +8 -0
- package/lib/entity/userGroups/userGroupsReducer.js +29 -0
- package/lib/entity/userGroups/userGroupsSelector.d.ts +4 -0
- package/lib/entity/userGroups/userGroupsSelector.js +12 -0
- package/lib/entity/userGroups/userGroupsState.d.ts +9 -0
- package/lib/entity/userGroups/userGroupsState.js +2 -0
- package/lib/epic.d.ts +15 -1
- package/lib/epic.js +15 -1
- package/lib/esm/commonStateTypes/coaBalance/coaBalanceType.js +5 -0
- package/lib/esm/commonStateTypes/currencyHelper.js +5 -0
- package/lib/esm/commonStateTypes/reduceFetchState.js +25 -0
- package/lib/esm/entity/account/accountPayload.js +2 -0
- package/lib/esm/entity/customer/customerState.js +1 -4
- package/lib/esm/entity/depositAccount/depositAccount.js +8 -1
- package/lib/esm/entity/reimbursement/reimbursementPayload.js +7 -0
- package/lib/esm/entity/snackbar/snackbarTypes.js +2 -0
- package/lib/esm/entity/task/taskPayload.js +1 -0
- package/lib/esm/entity/userGroups/userGroupsPayload.js +7 -0
- package/lib/esm/entity/userGroups/userGroupsReducer.js +25 -0
- package/lib/esm/entity/userGroups/userGroupsSelector.js +8 -0
- package/lib/esm/entity/userGroups/userGroupsState.js +1 -0
- package/lib/esm/epic.js +15 -1
- package/lib/esm/index.js +19 -10
- package/lib/esm/reducer.js +6 -0
- package/lib/esm/view/arAgingView/arAgingReport/arAgingReducer.js +1 -1
- package/lib/esm/view/arAgingView/arAgingReport/arAgingSelector.js +1 -1
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/bulkUploadMatchResultToastEpic.js +33 -0
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.js +29 -0
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.js +49 -0
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.js +40 -0
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +49 -0
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +61 -0
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.js +33 -0
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.js +56 -0
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/refetchCompletedTransactionsOnBulkUploadSortEpic.js +12 -0
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/restoreBulkUploadAutomatchingOnMountEpic.js +98 -0
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +71 -0
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/uploadMissingReceiptSuccessEpic.js +7 -5
- package/lib/esm/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +86 -0
- package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/uploadTransactionReceiptSuccessEpic.js +24 -0
- package/lib/esm/view/expenseAutomationView/helpers/bulkUploadTiming.js +16 -0
- package/lib/esm/view/expenseAutomationView/helpers/rollingCalendarDateRangeInclusive.js +13 -0
- package/lib/esm/view/expenseAutomationView/payload/missingReceiptsPayload.js +198 -1
- package/lib/esm/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +456 -2
- package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +23 -1
- package/lib/esm/view/expenseAutomationView/selectors/missingReceiptsSelector.js +245 -1
- package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +2 -1
- package/lib/esm/view/expenseAutomationView/types/missingReceiptsViewState.js +44 -0
- package/lib/esm/view/expenseAutomationView/types/transactionsViewState.js +2 -1
- package/lib/esm/view/financeStatement/financeStatementReducer.js +11 -8
- package/lib/esm/view/financeStatement/financeStatementSelector.js +24 -9
- package/lib/esm/view/profitAndLossClassesView/horizontalSectionEmptyBalancesSlice.js +17 -0
- package/lib/esm/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector.js +331 -0
- package/lib/esm/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelectorTypes.js +9 -0
- package/lib/esm/view/profitAndLossClassesView/profitAndLossClassesViewReducer.js +6 -1
- package/lib/esm/view/profitAndLossClassesView/profitAndLossClassesViewSelector.js +2 -29
- package/lib/esm/view/profitAndLossClassesView/profitAndLossForTimeframeClassesViewEpic.js +7 -5
- package/lib/esm/view/profitAndLossClassesView/profitAndLossHorizontalEnrichment.js +262 -0
- package/lib/esm/view/reportUIOptions/updateReportUIOptionCOABalancesRangeEpic.js +9 -7
- package/lib/esm/view/taskManager/taskDetailView/taskDetailSelector.js +1 -1
- package/lib/esm/view/taskManager/taskListView/epics/bulkUpdateTaskListEpic.js +1 -0
- package/lib/esm/view/taskManager/taskListView/taskListSelector.js +3 -1
- package/lib/esm/view/userGroupListView/userGroupListViewReducer.js +65 -0
- package/lib/esm/view/userGroupListView/userGroupListViewSelector.js +16 -0
- package/lib/esm/view/userGroupListView/userGroupListViewState.js +1 -0
- package/lib/esm/view/userListView/fetchUserListByTypeEpic.js +11 -0
- package/lib/esm/zeniAPI.js +0 -2
- package/lib/index.d.ts +20 -12
- package/lib/index.js +97 -34
- package/lib/reducer.d.ts +6 -0
- package/lib/reducer.js +6 -0
- package/lib/tsconfig.typecheck.tsbuildinfo +1 -0
- package/lib/view/arAgingView/arAgingReport/arAgingReducer.js +2 -2
- package/lib/view/arAgingView/arAgingReport/arAgingSelector.js +5 -5
- package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadMatchResultToastEpic.d.ts +13 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadMatchResultToastEpic.js +37 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.d.ts +18 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.js +33 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.d.ts +7 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.js +53 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.d.ts +8 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.js +44 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.d.ts +7 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +53 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.d.ts +8 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +65 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.d.ts +8 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.js +37 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.d.ts +9 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.js +61 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/refetchCompletedTransactionsOnBulkUploadSortEpic.d.ts +10 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/refetchCompletedTransactionsOnBulkUploadSortEpic.js +16 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/restoreBulkUploadAutomatchingOnMountEpic.d.ts +18 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/restoreBulkUploadAutomatchingOnMountEpic.js +102 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.d.ts +14 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +75 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/uploadMissingReceiptSuccessEpic.js +7 -5
- package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.d.ts +25 -0
- package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +92 -0
- package/lib/view/expenseAutomationView/epics/transactionCategorization/uploadTransactionReceiptSuccessEpic.d.ts +7 -0
- package/lib/view/expenseAutomationView/epics/transactionCategorization/uploadTransactionReceiptSuccessEpic.js +28 -0
- package/lib/view/expenseAutomationView/helpers/bulkUploadTiming.d.ts +16 -0
- package/lib/view/expenseAutomationView/helpers/bulkUploadTiming.js +19 -0
- package/lib/view/expenseAutomationView/helpers/rollingCalendarDateRangeInclusive.d.ts +7 -0
- package/lib/view/expenseAutomationView/helpers/rollingCalendarDateRangeInclusive.js +16 -0
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
- package/lib/view/expenseAutomationView/payload/missingReceiptsPayload.d.ts +123 -0
- package/lib/view/expenseAutomationView/payload/missingReceiptsPayload.js +211 -0
- package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +86 -3
- package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +457 -2
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +11 -3
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +24 -2
- package/lib/view/expenseAutomationView/selectorTypes/missingReceiptsSelectorTypes.d.ts +70 -1
- package/lib/view/expenseAutomationView/selectorTypes/transactionsViewSelectorTypes.d.ts +1 -0
- package/lib/view/expenseAutomationView/selectors/missingReceiptsSelector.d.ts +1 -1
- package/lib/view/expenseAutomationView/selectors/missingReceiptsSelector.js +244 -0
- package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +2 -1
- package/lib/view/expenseAutomationView/types/missingReceiptsViewState.d.ts +146 -0
- package/lib/view/expenseAutomationView/types/missingReceiptsViewState.js +54 -1
- package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +2 -1
- package/lib/view/expenseAutomationView/types/transactionsViewState.js +2 -1
- package/lib/view/financeStatement/financeStatementReducer.js +11 -8
- package/lib/view/financeStatement/financeStatementSelector.d.ts +2 -0
- package/lib/view/financeStatement/financeStatementSelector.js +24 -9
- package/lib/view/profitAndLossClassesView/horizontalSectionEmptyBalancesSlice.d.ts +9 -0
- package/lib/view/profitAndLossClassesView/horizontalSectionEmptyBalancesSlice.js +20 -0
- package/lib/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector.d.ts +15 -0
- package/lib/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector.js +335 -0
- package/lib/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelectorTypes.d.ts +111 -0
- package/lib/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelectorTypes.js +13 -0
- package/lib/view/profitAndLossClassesView/profitAndLossClassesViewReducer.d.ts +4 -2
- package/lib/view/profitAndLossClassesView/profitAndLossClassesViewReducer.js +7 -2
- package/lib/view/profitAndLossClassesView/profitAndLossClassesViewSelector.js +2 -29
- package/lib/view/profitAndLossClassesView/profitAndLossClassesViewState.d.ts +4 -0
- package/lib/view/profitAndLossClassesView/profitAndLossForTimeframeClassesViewEpic.js +7 -5
- package/lib/view/profitAndLossClassesView/profitAndLossHorizontalEnrichment.d.ts +6 -0
- package/lib/view/profitAndLossClassesView/profitAndLossHorizontalEnrichment.js +265 -0
- package/lib/view/reportUIOptions/updateReportUIOptionCOABalancesRangeEpic.js +8 -6
- package/lib/view/taskManager/taskDetailView/taskDetailSelector.js +1 -1
- package/lib/view/taskManager/taskListView/epics/bulkUpdateTaskListEpic.d.ts +1 -0
- package/lib/view/taskManager/taskListView/epics/bulkUpdateTaskListEpic.js +1 -0
- package/lib/view/taskManager/taskListView/taskListSelector.d.ts +2 -0
- package/lib/view/taskManager/taskListView/taskListSelector.js +3 -1
- package/lib/view/userGroupListView/userGroupListViewReducer.d.ts +23 -0
- package/lib/view/userGroupListView/userGroupListViewReducer.js +69 -0
- package/lib/view/userGroupListView/userGroupListViewSelector.d.ts +7 -0
- package/lib/view/userGroupListView/userGroupListViewSelector.js +20 -0
- package/lib/view/userGroupListView/userGroupListViewState.d.ts +8 -0
- package/lib/view/userGroupListView/userGroupListViewState.js +2 -0
- package/lib/view/userListView/fetchUserListByTypeEpic.d.ts +3 -1
- package/lib/view/userListView/fetchUserListByTypeEpic.js +11 -0
- package/lib/view/userListView/userListViewPayload.d.ts +2 -0
- package/lib/zeniAPI.js +0 -2
- package/package.json +3 -3
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getFinanceStatement = void 0;
|
|
4
4
|
const toolkit_1 = require("@reduxjs/toolkit");
|
|
5
|
+
const coaBalanceType_1 = require("../../commonStateTypes/coaBalance/coaBalanceType");
|
|
5
6
|
const coaBalancesFilter_1 = require("../../commonStateTypes/coaBalance/coaBalancesFilter");
|
|
6
7
|
const coaBalancesFilterClassesView_1 = require("../../commonStateTypes/coaBalance/coaBalancesFilterClassesView");
|
|
7
8
|
const dataAvailable_1 = require("../../commonStateTypes/dataAvailable");
|
|
@@ -11,6 +12,7 @@ const thisPeriodHelpers_1 = require("../../commonStateTypes/viewAndReport/thisPe
|
|
|
11
12
|
const balanceSheetSelector_1 = require("../balanceSheet/balanceSheetSelector");
|
|
12
13
|
const cashFlowSelector_1 = require("../cashFlow/cashFlowSelector");
|
|
13
14
|
const profitAndLossSelector_1 = require("../profitAndLoss/profitAndLossSelector");
|
|
15
|
+
const profitAndLossClassesByClassHorizontalSelector_1 = require("../profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector");
|
|
14
16
|
const profitAndLossClassesViewSelector_1 = require("../profitAndLossClassesView/profitAndLossClassesViewSelector");
|
|
15
17
|
function getDateRangeForFinanceReports(profitAndLossState, balanceSheetState, cashFlowState) {
|
|
16
18
|
const datesSorted = [
|
|
@@ -45,11 +47,11 @@ exports.getFinanceStatement = (0, toolkit_1.createSelector)((state) => state.acc
|
|
|
45
47
|
if (dataAvailable != null) {
|
|
46
48
|
const noFilter = (0, coaBalancesFilter_1.newBalancesFilterForDateRange)(firstMonthOfFY, financeStatementState.timeframe, dataAvailable, 'ascending_date', []);
|
|
47
49
|
const profitAndLossForTimeframeTicks = (0, profitAndLossSelector_1.getProfitAndLossReport)(noFilter, undefined, accountState, accountGroupState, sectionAccountsViewState, profitAndLossState, forecastState);
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
const expensesBalances = profitAndLossForTimeframeTicks.sections.expenses?.balances ?? [];
|
|
51
|
+
const incomeBalances = profitAndLossForTimeframeTicks.sections.income?.balances ?? [];
|
|
52
|
+
balancesInTimeframe =
|
|
53
|
+
expensesBalances.length > 0 ? expensesBalances : incomeBalances;
|
|
54
|
+
if (balancesInTimeframe.length > 0) {
|
|
53
55
|
allTimeframeTicks = balancesInTimeframe.map((balance) => (0, timeframeTick_1.toTimeframeTick)(balance));
|
|
54
56
|
}
|
|
55
57
|
}
|
|
@@ -57,12 +59,22 @@ exports.getFinanceStatement = (0, toolkit_1.createSelector)((state) => state.acc
|
|
|
57
59
|
if (thisPeriod == null && balancesInTimeframe.length > 0) {
|
|
58
60
|
thisPeriod = (0, timeframeTick_1.toTimeframeTick)(balancesInTimeframe[balancesInTimeframe.length - 1]);
|
|
59
61
|
}
|
|
60
|
-
const
|
|
62
|
+
const rawAdditionalBalances = financeStatementState.isAdditionalBalancesShown === true
|
|
61
63
|
? financeStatementState.selectedAdditionalBalances
|
|
62
|
-
: []
|
|
64
|
+
: [];
|
|
65
|
+
const useHorizontalClassesLayout = profitAndLossClassesViewState.uiState.classViewLayout ===
|
|
66
|
+
'horizontal' &&
|
|
67
|
+
financeStatementState.selectedReportId === 'profit_and_loss_by_classes';
|
|
68
|
+
const additionalBalancesForFilter = useHorizontalClassesLayout
|
|
69
|
+
? (0, coaBalanceType_1.stripCompareAdditionalBalanceTypes)(rawAdditionalBalances)
|
|
70
|
+
: rawAdditionalBalances;
|
|
71
|
+
const filter = (0, coaBalancesFilter_1.newBalancesFilter)(firstMonthOfFY, financeStatementState.timeframe, Math.min((0, dataAvailable_1.getNumberOfPeriods)(firstMonthOfFY, financeStatementState.timeframe, dataAvailable) ?? financeStatementState.selectedCOABalancesRange.numberOfPeriods, financeStatementState.selectedCOABalancesRange.numberOfPeriods), thisPeriod, 'ascending_date', additionalBalancesForFilter);
|
|
63
72
|
const profitAndLossReport = (0, profitAndLossSelector_1.getProfitAndLossReport)(filter, undefined, accountState, accountGroupState, sectionAccountsViewState, profitAndLossState, forecastState);
|
|
64
73
|
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
74
|
const profitAndLossByClassReport = (0, profitAndLossClassesViewSelector_1.getProfitAndLossClassesView)(classFilter, accountState, classState, sectionsState, profitAndLossClassesViewState);
|
|
75
|
+
const profitAndLossByClassHorizontalReport = (0, profitAndLossClassesByClassHorizontalSelector_1.getProfitAndLossClassesHorizontalView)(classFilter, accountState, classState, sectionsState, profitAndLossClassesViewState, profitAndLossClassesViewState.uiState.classViewLayout === 'horizontal'
|
|
76
|
+
? thisPeriod
|
|
77
|
+
: undefined);
|
|
66
78
|
const balanceSheetReport = (0, balanceSheetSelector_1.getBalanceSheet)(filter, accountState, accountGroupState, sectionAccountsViewState, balanceSheetState);
|
|
67
79
|
const cashFlowReport = (0, cashFlowSelector_1.getCashFlow)(filter, accountState, accountGroupState, sectionAccountsViewState, cashFlowState);
|
|
68
80
|
const allReports = [
|
|
@@ -110,12 +122,15 @@ exports.getFinanceStatement = (0, toolkit_1.createSelector)((state) => state.acc
|
|
|
110
122
|
dataAvailable,
|
|
111
123
|
profitAndLossReport,
|
|
112
124
|
profitAndLossByClassReport,
|
|
125
|
+
profitAndLossByClassHorizontalReport,
|
|
113
126
|
balanceSheetReport,
|
|
114
127
|
cashFlowReport,
|
|
115
128
|
filter,
|
|
116
129
|
selectedReportId: financeStatementState.selectedReportId,
|
|
117
130
|
downloadState: financeStatementState.downloadState,
|
|
118
|
-
isCompareModeOn:
|
|
119
|
-
|
|
131
|
+
isCompareModeOn: useHorizontalClassesLayout
|
|
132
|
+
? false
|
|
133
|
+
: financeStatementState.selectedAdditionalBalances.includes('this_period_vs_last_period') ||
|
|
134
|
+
financeStatementState.selectedAdditionalBalances.includes('this_period_vs_last_period_percent'),
|
|
120
135
|
};
|
|
121
136
|
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { COABalanceTimeFrame } from '../../commonStateTypes/coaBalance/coaBalance';
|
|
2
|
+
import { COABalancesSlice } from '../../commonStateTypes/coaBalance/coaBalancesFilter';
|
|
3
|
+
import { Month } from '../../commonStateTypes/timePeriod';
|
|
4
|
+
/**
|
|
5
|
+
* Empty `COABalancesSlice` for horizontal P&L-by-class section / calculated headers when
|
|
6
|
+
* enrichment has not produced balances yet, or for UI mapping fallbacks.
|
|
7
|
+
* Structure matches {@link enrichProfitAndLossByClassHorizontalReport} output.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getEmptyHorizontalSectionBalancesSlice(firstMonthOfFY: Month, timeframe?: COABalanceTimeFrame): COABalancesSlice;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getEmptyHorizontalSectionBalancesSlice = getEmptyHorizontalSectionBalancesSlice;
|
|
4
|
+
/**
|
|
5
|
+
* Empty `COABalancesSlice` for horizontal P&L-by-class section / calculated headers when
|
|
6
|
+
* enrichment has not produced balances yet, or for UI mapping fallbacks.
|
|
7
|
+
* Structure matches {@link enrichProfitAndLossByClassHorizontalReport} output.
|
|
8
|
+
*/
|
|
9
|
+
function getEmptyHorizontalSectionBalancesSlice(firstMonthOfFY, timeframe = 'month') {
|
|
10
|
+
return {
|
|
11
|
+
balances: [],
|
|
12
|
+
additionalBalances: [],
|
|
13
|
+
filter: {
|
|
14
|
+
firstMonthOfFY,
|
|
15
|
+
timeframe,
|
|
16
|
+
balancesRange: { numberOfPeriods: 0, orderBy: 'ascending_date' },
|
|
17
|
+
additionalBalances: [],
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
/** Standard class ID returned by the accounting platform for transactions without an assigned class. */
|
|
10
|
+
export declare const NOT_SPECIFIED_CLASS_ID = "not_specified";
|
|
11
|
+
export declare const profitAndLossHorizontalIdsInOrder: (PandLReportViewSectionID | PandLReportViewCalculatedSectionID)[];
|
|
12
|
+
export declare const getProfitAndLossClassesHorizontalView: (filter: COABalancesFilterClassesView, accountState: AccountState, classState: ClassState, sectionsState: SectionClassesViewStateV2, profitAndLossClassesViewState: ProfitAndLossClassesViewState, selectedPeriod: {
|
|
13
|
+
endDate: ZeniDate;
|
|
14
|
+
startDate: ZeniDate;
|
|
15
|
+
} | undefined) => ProfitAndLossByClassHorizontalReport;
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getProfitAndLossClassesHorizontalView = exports.profitAndLossHorizontalIdsInOrder = exports.NOT_SPECIFIED_CLASS_ID = void 0;
|
|
4
|
+
const amount_1 = require("../../commonStateTypes/amount");
|
|
5
|
+
const getSummationBalance_1 = require("../../commonStateTypes/coaBalance/additionalBalances/getSummationBalance");
|
|
6
|
+
const currencyHelper_1 = require("../../commonStateTypes/currencyHelper");
|
|
7
|
+
const reduceFetchState_1 = require("../../commonStateTypes/reduceFetchState");
|
|
8
|
+
const sectionClassesViewSelector_1 = require("../../entity/sectionClassesViewV2/sectionClassesViewSelector");
|
|
9
|
+
const profitAndLossHorizontalEnrichment_1 = require("./profitAndLossHorizontalEnrichment");
|
|
10
|
+
/** Standard class ID returned by the accounting platform for transactions without an assigned class. */
|
|
11
|
+
exports.NOT_SPECIFIED_CLASS_ID = 'not_specified';
|
|
12
|
+
exports.profitAndLossHorizontalIdsInOrder = [
|
|
13
|
+
'income',
|
|
14
|
+
'cogs',
|
|
15
|
+
'grossProfit',
|
|
16
|
+
'expenses',
|
|
17
|
+
'earningsBeforeInterestAndTax',
|
|
18
|
+
'otherIncome',
|
|
19
|
+
'otherExpenses',
|
|
20
|
+
'netOtherIncome',
|
|
21
|
+
'netIncome',
|
|
22
|
+
];
|
|
23
|
+
const SECTION_TITLES = {
|
|
24
|
+
income: 'Income',
|
|
25
|
+
cogs: 'Cost of Goods Sold',
|
|
26
|
+
grossProfit: 'Gross Profit',
|
|
27
|
+
expenses: 'Expenses',
|
|
28
|
+
earningsBeforeInterestAndTax: 'Net Operating Income',
|
|
29
|
+
otherIncome: 'Other Income',
|
|
30
|
+
otherExpenses: 'Other Expenses',
|
|
31
|
+
netOtherIncome: 'Net Other Income',
|
|
32
|
+
netIncome: 'Net Income',
|
|
33
|
+
};
|
|
34
|
+
/** Sections fetched and pivoted for horizontal layout (excludes e.g. `netOperatingIncome`). */
|
|
35
|
+
const HORIZONTAL_PANDL_SECTION_IDS = [
|
|
36
|
+
'income',
|
|
37
|
+
'cogs',
|
|
38
|
+
'expenses',
|
|
39
|
+
'otherIncome',
|
|
40
|
+
'otherExpenses',
|
|
41
|
+
];
|
|
42
|
+
const getProfitAndLossClassesHorizontalView = (filter, accountState, classState, sectionsState, profitAndLossClassesViewState, selectedPeriod) => {
|
|
43
|
+
const fetchState = (0, reduceFetchState_1.reduceFetchStateParallelTimeframes)([
|
|
44
|
+
profitAndLossClassesViewState.fetchState.month,
|
|
45
|
+
profitAndLossClassesViewState.fetchState.quarter,
|
|
46
|
+
profitAndLossClassesViewState.fetchState.year,
|
|
47
|
+
]);
|
|
48
|
+
const reportId = 'profit_and_loss_by_classes';
|
|
49
|
+
// Build class columns from the class hierarchy (top-level only).
|
|
50
|
+
// Use `filter.classesToFilterOut` so PDF/Excel downloads (fresh store, empty UI state)
|
|
51
|
+
// respect `classes_to_filter_out` from the request; in-app `classFilter` mirrors uiState.
|
|
52
|
+
const classColumns = buildClassColumns(profitAndLossClassesViewState.classHierarchy, filter.classesToFilterOut);
|
|
53
|
+
const sections = {};
|
|
54
|
+
const calculatedSections = {};
|
|
55
|
+
let reportCurrency = currencyHelper_1.defaultCustomerCurrency;
|
|
56
|
+
if (fetchState.fetchState === 'Completed' && selectedPeriod != null) {
|
|
57
|
+
reportCurrency =
|
|
58
|
+
profitAndLossClassesViewState.currency ?? currencyHelper_1.defaultCustomerCurrency;
|
|
59
|
+
// Fetch each section and pivot class→account to account→class in one pass
|
|
60
|
+
HORIZONTAL_PANDL_SECTION_IDS.forEach((sectionId) => {
|
|
61
|
+
const sectionReport = (0, sectionClassesViewSelector_1.getSectionClassesViewReport)(accountState, classState, sectionsState, { reportId, sectionId }, filter);
|
|
62
|
+
if (sectionReport != null) {
|
|
63
|
+
sections[sectionId] = pivotSectionToHorizontal(sectionReport, classColumns, SECTION_TITLES[sectionId] ?? sectionId, reportCurrency);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
// Calculate derived sections
|
|
67
|
+
const incomeSection = sections['income'];
|
|
68
|
+
const cogsSection = sections['cogs'];
|
|
69
|
+
const expensesSection = sections['expenses'];
|
|
70
|
+
const otherIncomeSection = sections['otherIncome'];
|
|
71
|
+
const otherExpensesSection = sections['otherExpenses'];
|
|
72
|
+
// Gross Profit = Income - COGS
|
|
73
|
+
if (incomeSection != null && cogsSection != null) {
|
|
74
|
+
calculatedSections['grossProfit'] = computeCalculatedSection(incomeSection.classTotals, cogsSection.classTotals, incomeSection.sectionTotal, cogsSection.sectionTotal, 'subtract', SECTION_TITLES['grossProfit']);
|
|
75
|
+
}
|
|
76
|
+
// EBIT = Gross Profit - Expenses
|
|
77
|
+
const grossProfit = calculatedSections['grossProfit'];
|
|
78
|
+
if (grossProfit != null && expensesSection != null) {
|
|
79
|
+
calculatedSections['earningsBeforeInterestAndTax'] =
|
|
80
|
+
computeCalculatedSection(grossProfit.classTotals, expensesSection.classTotals, grossProfit.sectionTotal, expensesSection.sectionTotal, 'subtract', SECTION_TITLES['earningsBeforeInterestAndTax']);
|
|
81
|
+
}
|
|
82
|
+
// Net Other Income = Other Income - Other Expenses
|
|
83
|
+
if (otherIncomeSection != null && otherExpensesSection != null) {
|
|
84
|
+
calculatedSections['netOtherIncome'] = computeCalculatedSection(otherIncomeSection.classTotals, otherExpensesSection.classTotals, otherIncomeSection.sectionTotal, otherExpensesSection.sectionTotal, 'subtract', SECTION_TITLES['netOtherIncome']);
|
|
85
|
+
}
|
|
86
|
+
// Net Income = EBIT + Net Other Income
|
|
87
|
+
const ebit = calculatedSections['earningsBeforeInterestAndTax'];
|
|
88
|
+
const netOtherIncome = calculatedSections['netOtherIncome'];
|
|
89
|
+
if (ebit != null && netOtherIncome != null) {
|
|
90
|
+
calculatedSections['netIncome'] = computeCalculatedSection(ebit.classTotals, netOtherIncome.classTotals, ebit.sectionTotal, netOtherIncome.sectionTotal, 'add', SECTION_TITLES['netIncome']);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
// Build synthetic header COABalances for rendering class names as column headers
|
|
94
|
+
const headerBalances = buildHeaderBalances(classColumns, filter.timeframe, selectedPeriod, reportCurrency);
|
|
95
|
+
const report = {
|
|
96
|
+
reportId,
|
|
97
|
+
reportTitle: 'Profit and Loss by Class',
|
|
98
|
+
firstMonthOfFY: profitAndLossClassesViewState.firstMonthOfFY,
|
|
99
|
+
fetchState: fetchState.fetchState,
|
|
100
|
+
bookCloseDate: profitAndLossClassesViewState.bookCloseDate,
|
|
101
|
+
dataAvailable: profitAndLossClassesViewState.dataAvailable,
|
|
102
|
+
selectedPeriod,
|
|
103
|
+
classColumns,
|
|
104
|
+
sections,
|
|
105
|
+
calculatedSections,
|
|
106
|
+
idsInOrder: exports.profitAndLossHorizontalIdsInOrder,
|
|
107
|
+
uiState: profitAndLossClassesViewState.uiState,
|
|
108
|
+
headerBalances,
|
|
109
|
+
};
|
|
110
|
+
(0, profitAndLossHorizontalEnrichment_1.enrichProfitAndLossByClassHorizontalReport)(report);
|
|
111
|
+
return report;
|
|
112
|
+
};
|
|
113
|
+
exports.getProfitAndLossClassesHorizontalView = getProfitAndLossClassesHorizontalView;
|
|
114
|
+
/**
|
|
115
|
+
* Build column definitions from class hierarchy (top-level classes only).
|
|
116
|
+
*/
|
|
117
|
+
function buildClassColumns(classHierarchy, classesToFilterOut) {
|
|
118
|
+
const filteredIds = new Set(classesToFilterOut.map((id) => id[0]));
|
|
119
|
+
return classHierarchy
|
|
120
|
+
.filter((c) => !filteredIds.has(c.classId[0]))
|
|
121
|
+
.map((c) => ({
|
|
122
|
+
classId: c.classId[0],
|
|
123
|
+
className: c.className,
|
|
124
|
+
nestedClassId: c.classId,
|
|
125
|
+
qboId: c.qboId,
|
|
126
|
+
}))
|
|
127
|
+
.sort((a, b) => {
|
|
128
|
+
const aIsNotSpecified = a.classId === exports.NOT_SPECIFIED_CLASS_ID;
|
|
129
|
+
const bIsNotSpecified = b.classId === exports.NOT_SPECIFIED_CLASS_ID;
|
|
130
|
+
if (aIsNotSpecified && !bIsNotSpecified) {
|
|
131
|
+
return 1;
|
|
132
|
+
}
|
|
133
|
+
if (!aIsNotSpecified && bIsNotSpecified) {
|
|
134
|
+
return -1;
|
|
135
|
+
}
|
|
136
|
+
return a.className.localeCompare(b.className, [], {
|
|
137
|
+
sensitivity: 'base',
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Pivot a section from class→account→balances to account→class→balance (single period).
|
|
143
|
+
*/
|
|
144
|
+
function pivotSectionToHorizontal(section, classColumns, title, currency) {
|
|
145
|
+
// Map: accountId -> { accountName, classId -> balance }
|
|
146
|
+
const accountMap = new Map();
|
|
147
|
+
// Also track class totals
|
|
148
|
+
const classTotalMap = new Map();
|
|
149
|
+
classColumns.forEach((col) => classTotalMap.set(col.classId, 0));
|
|
150
|
+
// Iterate over each class in the section
|
|
151
|
+
section.classes.forEach((classReport) => {
|
|
152
|
+
const classId = classReport.id[0];
|
|
153
|
+
// Only process classes that are in our columns
|
|
154
|
+
if (!classTotalMap.has(classId)) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
// Sum all sliced period balances (same slice as vertical columns; multi-period = range total)
|
|
158
|
+
const classBalance = sumBalancesInSlice(classReport.childrenBalancesTotal.balances);
|
|
159
|
+
classTotalMap.set(classId, classBalance);
|
|
160
|
+
// Iterate through accounts in this class
|
|
161
|
+
collectAccountsFromClass(classReport, classId, accountMap);
|
|
162
|
+
});
|
|
163
|
+
// Build account rows in COA tree order (same parent/child ordering as vertical P&L by class).
|
|
164
|
+
// Sorting by depth + name flattened the hierarchy and broke sub-account grouping.
|
|
165
|
+
const orderedIds = collectAccountIdsInTreeOrder(section, classColumns);
|
|
166
|
+
const usedIds = new Set();
|
|
167
|
+
const accounts = [];
|
|
168
|
+
const pushAccountRow = (accountId) => {
|
|
169
|
+
const accountData = accountMap.get(accountId);
|
|
170
|
+
if (accountData == null) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
usedIds.add(accountId);
|
|
174
|
+
const classBalances = classColumns.map((col) => ({
|
|
175
|
+
classId: col.classId,
|
|
176
|
+
balance: (0, amount_1.toAmountWC)(accountData.classBalances.get(col.classId) ?? 0, currency),
|
|
177
|
+
}));
|
|
178
|
+
const rowTotal = classBalances.reduce((sum, cb) => sum + cb.balance.amount, 0);
|
|
179
|
+
accounts.push({
|
|
180
|
+
accountId,
|
|
181
|
+
accountName: accountData.accountName,
|
|
182
|
+
accountType: accountData.accountType,
|
|
183
|
+
depth: accountData.depth,
|
|
184
|
+
classBalances,
|
|
185
|
+
rowTotal: (0, amount_1.toAmountWC)(rowTotal, currency),
|
|
186
|
+
});
|
|
187
|
+
};
|
|
188
|
+
for (const id of orderedIds) {
|
|
189
|
+
pushAccountRow(id);
|
|
190
|
+
}
|
|
191
|
+
for (const accountId of accountMap.keys()) {
|
|
192
|
+
if (!usedIds.has(accountId)) {
|
|
193
|
+
pushAccountRow(accountId);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
// Build class totals
|
|
197
|
+
const classTotals = classColumns.map((col) => ({
|
|
198
|
+
classId: col.classId,
|
|
199
|
+
balance: (0, amount_1.toAmountWC)(classTotalMap.get(col.classId) ?? 0, currency),
|
|
200
|
+
}));
|
|
201
|
+
const sectionTotal = classTotals.reduce((sum, ct) => sum + ct.balance.amount, 0);
|
|
202
|
+
return {
|
|
203
|
+
title,
|
|
204
|
+
accounts,
|
|
205
|
+
classTotals,
|
|
206
|
+
sectionTotal: (0, amount_1.toAmountWC)(sectionTotal, currency),
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* DFS account ids in the same order as vertical P&L by class, using the first class
|
|
211
|
+
* column that appears in this section as the canonical tree (structure is identical per class).
|
|
212
|
+
*/
|
|
213
|
+
function collectAccountIdsInTreeOrder(section, classColumns) {
|
|
214
|
+
const ids = [];
|
|
215
|
+
const visitNested = (nested) => {
|
|
216
|
+
ids.push(nested.account.accountId);
|
|
217
|
+
nested.children.forEach(visitNested);
|
|
218
|
+
};
|
|
219
|
+
for (const col of classColumns) {
|
|
220
|
+
const classReport = section.classes.find((c) => c.id[0] === col.classId);
|
|
221
|
+
if (classReport == null) {
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
classReport.class.accounts.forEach(visitNested);
|
|
225
|
+
return ids;
|
|
226
|
+
}
|
|
227
|
+
return ids;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Recursively collect account balances from a NestedClassReportV2 into accountMap.
|
|
231
|
+
*/
|
|
232
|
+
function collectAccountsFromClass(classReport, classId, accountMap) {
|
|
233
|
+
// Process accounts directly on this class (depth 2 matches vertical `AccountsSection` first level)
|
|
234
|
+
classReport.class.accounts.forEach((nestedAccount) => {
|
|
235
|
+
collectAccountsFromNestedAccount(nestedAccount, classId, accountMap, 2);
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Recursively collect accounts from NestedAccountReport (handles sub-accounts).
|
|
240
|
+
*/
|
|
241
|
+
function collectAccountsFromNestedAccount(nestedAccount, classId, accountMap, depth) {
|
|
242
|
+
const accountId = nestedAccount.account.accountId;
|
|
243
|
+
const accountName = nestedAccount.account.accountName;
|
|
244
|
+
const balance = sumBalancesInSlice(nestedAccount.account.balancesInTimeframe.balances);
|
|
245
|
+
if (!accountMap.has(accountId)) {
|
|
246
|
+
accountMap.set(accountId, {
|
|
247
|
+
accountName,
|
|
248
|
+
accountType: nestedAccount.account.accountType,
|
|
249
|
+
depth,
|
|
250
|
+
classBalances: new Map(),
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
const accountData = accountMap.get(accountId);
|
|
254
|
+
if (accountData == null) {
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
accountData.depth = Math.max(accountData.depth, depth);
|
|
258
|
+
if (accountData.accountType == null &&
|
|
259
|
+
nestedAccount.account.accountType != null) {
|
|
260
|
+
accountData.accountType = nestedAccount.account.accountType;
|
|
261
|
+
}
|
|
262
|
+
const existing = accountData.classBalances.get(classId) ?? 0;
|
|
263
|
+
accountData.classBalances.set(classId, existing + balance);
|
|
264
|
+
// Process sub-accounts
|
|
265
|
+
nestedAccount.children.forEach((child) => {
|
|
266
|
+
collectAccountsFromNestedAccount(child, classId, accountMap, depth + 1);
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Total `balance.amount` for the current COA slice (same aggregation as
|
|
271
|
+
* `getSummationFreeRangeTotalBalance`, used for class totals and account rows).
|
|
272
|
+
*/
|
|
273
|
+
function sumBalancesInSlice(balances) {
|
|
274
|
+
if (balances.length === 0) {
|
|
275
|
+
return 0;
|
|
276
|
+
}
|
|
277
|
+
const summed = (0, getSummationBalance_1.getSummationFreeRangeTotalBalance)(balances);
|
|
278
|
+
return summed?.balance.amount ?? 0;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Compute a calculated section by adding or subtracting two sets of class totals.
|
|
282
|
+
*/
|
|
283
|
+
function computeCalculatedSection(aTotals, bTotals, aTotal, bTotal, operation, title) {
|
|
284
|
+
const currency = {
|
|
285
|
+
currencyCode: aTotal.currencyCode,
|
|
286
|
+
currencySymbol: aTotal.currencySymbol,
|
|
287
|
+
};
|
|
288
|
+
const bTotalsMap = new Map(bTotals.map((b) => [b.classId, b.balance.amount]));
|
|
289
|
+
const classTotals = aTotals.map((a) => {
|
|
290
|
+
const bAmount = bTotalsMap.get(a.classId) ?? 0;
|
|
291
|
+
const resultAmount = operation === 'add'
|
|
292
|
+
? a.balance.amount + bAmount
|
|
293
|
+
: a.balance.amount - bAmount;
|
|
294
|
+
return {
|
|
295
|
+
classId: a.classId,
|
|
296
|
+
balance: (0, amount_1.toAmountWC)(resultAmount, currency),
|
|
297
|
+
};
|
|
298
|
+
});
|
|
299
|
+
const sectionTotalAmount = operation === 'add'
|
|
300
|
+
? aTotal.amount + bTotal.amount
|
|
301
|
+
: aTotal.amount - bTotal.amount;
|
|
302
|
+
return {
|
|
303
|
+
title,
|
|
304
|
+
classTotals,
|
|
305
|
+
sectionTotal: (0, amount_1.toAmountWC)(sectionTotalAmount, currency),
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Build synthetic COABalance array for header rendering.
|
|
310
|
+
* One entry per class column + one for "Total".
|
|
311
|
+
*/
|
|
312
|
+
function buildHeaderBalances(classColumns, timeframe, selectedPeriod, currency) {
|
|
313
|
+
if (selectedPeriod == null) {
|
|
314
|
+
return [];
|
|
315
|
+
}
|
|
316
|
+
const { endDate, startDate } = selectedPeriod;
|
|
317
|
+
const balances = classColumns.map((col) => ({
|
|
318
|
+
balance: (0, amount_1.toAmountWC)(0, currency),
|
|
319
|
+
balanceTimeFrame: timeframe,
|
|
320
|
+
endDate,
|
|
321
|
+
startDate,
|
|
322
|
+
type: 'default',
|
|
323
|
+
label: col.className,
|
|
324
|
+
}));
|
|
325
|
+
// Add a "Total" column
|
|
326
|
+
balances.push({
|
|
327
|
+
balance: (0, amount_1.toAmountWC)(0, currency),
|
|
328
|
+
balanceTimeFrame: timeframe,
|
|
329
|
+
endDate,
|
|
330
|
+
startDate,
|
|
331
|
+
type: 'default',
|
|
332
|
+
label: 'Total',
|
|
333
|
+
});
|
|
334
|
+
return balances;
|
|
335
|
+
}
|
package/lib/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelectorTypes.d.ts
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { Amount } from '../../commonStateTypes/amount';
|
|
2
|
+
import { NestedClassID } from '../../commonStateTypes/classesView/nestedClassID';
|
|
3
|
+
import { COABalance } from '../../commonStateTypes/coaBalance/coaBalance';
|
|
4
|
+
import { COABalancesSlice } from '../../commonStateTypes/coaBalance/coaBalancesFilter';
|
|
5
|
+
import { FetchState, ID } from '../../commonStateTypes/common';
|
|
6
|
+
import { DataAvailable } from '../../commonStateTypes/dataAvailable';
|
|
7
|
+
import { Month } from '../../commonStateTypes/timePeriod';
|
|
8
|
+
import { ReportID } from '../../commonStateTypes/viewAndReport/viewAndReport';
|
|
9
|
+
import { AccountType } from '../../entity/account/accountState';
|
|
10
|
+
import { ZeniDate } from '../../zeniDayJS';
|
|
11
|
+
import { PandLReportViewCalculatedSectionID, PandLReportViewSectionID } from './profitAndLossClassesViewSelectorTypes';
|
|
12
|
+
import { ProfitAndLossClassesViewUIState } from './profitAndLossClassesViewState';
|
|
13
|
+
export interface ClassColumnDefinition {
|
|
14
|
+
classId: string;
|
|
15
|
+
className: string;
|
|
16
|
+
nestedClassId: NestedClassID;
|
|
17
|
+
qboId?: ID;
|
|
18
|
+
}
|
|
19
|
+
export interface HorizontalClassBalance {
|
|
20
|
+
balance: Amount;
|
|
21
|
+
classId: string;
|
|
22
|
+
}
|
|
23
|
+
/** Synthetic COABalance `id` for the horizontal class report Total column (transaction routing). */
|
|
24
|
+
export declare const HORIZONTAL_CLASS_TOTAL_BALANCE_ID = "__horizontal_total__";
|
|
25
|
+
/** One line in the account column tree chrome (same role as report-tree ancestor metadata). */
|
|
26
|
+
export interface HorizontalAccountTreeLineMetadata {
|
|
27
|
+
depth: number;
|
|
28
|
+
hasChildren: boolean;
|
|
29
|
+
hasSibling: boolean;
|
|
30
|
+
isLastNode: boolean;
|
|
31
|
+
name?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface HorizontalAccountTreeView {
|
|
34
|
+
hasChildren: boolean;
|
|
35
|
+
hasSiblings: boolean;
|
|
36
|
+
isLastNode: boolean;
|
|
37
|
+
isLeaf: boolean;
|
|
38
|
+
subAccountAncestorMetadata: HorizontalAccountTreeLineMetadata[];
|
|
39
|
+
treeDepth: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Row payload for horizontal P&L-by-class account cells (synthetic balances + tree chrome).
|
|
43
|
+
*/
|
|
44
|
+
export interface HorizontalAccountReportData {
|
|
45
|
+
accountId: string;
|
|
46
|
+
accountName: string;
|
|
47
|
+
balancesInTimeframe: COABalancesSlice;
|
|
48
|
+
/** Nesting depth in the section account tree (matches `HorizontalAccountRow.depth`). */
|
|
49
|
+
depth: number;
|
|
50
|
+
accountType?: AccountType;
|
|
51
|
+
horizontalTreeView?: HorizontalAccountTreeView;
|
|
52
|
+
}
|
|
53
|
+
export declare function isHorizontalAccountReportData(data: unknown): data is HorizontalAccountReportData;
|
|
54
|
+
export interface HorizontalAccountRow {
|
|
55
|
+
accountId: string;
|
|
56
|
+
accountName: string;
|
|
57
|
+
classBalances: HorizontalClassBalance[];
|
|
58
|
+
/** Matches vertical classes PDF account indentation (`depth * 6` pt); top-level rows use 2. */
|
|
59
|
+
depth: number;
|
|
60
|
+
rowTotal: Amount;
|
|
61
|
+
/**
|
|
62
|
+
* Filled by `enrichProfitAndLossByClassHorizontalReport` for UI tree mapping
|
|
63
|
+
* (balances slice + `TreeViewRow` metadata).
|
|
64
|
+
*/
|
|
65
|
+
accountReportData?: HorizontalAccountReportData;
|
|
66
|
+
/** COA account type (same as vertical `AccountReport.accountType`) for transaction links. */
|
|
67
|
+
accountType?: AccountType;
|
|
68
|
+
}
|
|
69
|
+
/** Nested account row structure for a horizontal section (flat rows → tree). */
|
|
70
|
+
export interface HorizontalSectionTreeLayout {
|
|
71
|
+
/** Parent row index → child row indices. */
|
|
72
|
+
childrenRowIndicesByParent: Record<number, number[]>;
|
|
73
|
+
rootAccountRowIndices: number[];
|
|
74
|
+
}
|
|
75
|
+
export interface HorizontalSectionReport {
|
|
76
|
+
accounts: HorizontalAccountRow[];
|
|
77
|
+
classTotals: HorizontalClassBalance[];
|
|
78
|
+
sectionTotal: Amount;
|
|
79
|
+
title: string;
|
|
80
|
+
/** Synthetic balances for the section header row (class columns + Total); set by enrichment. */
|
|
81
|
+
sectionHeaderBalancesSlice?: COABalancesSlice;
|
|
82
|
+
/** Row hierarchy for mapping to report-tree nodes; set by enrichment. */
|
|
83
|
+
treeLayout?: HorizontalSectionTreeLayout;
|
|
84
|
+
}
|
|
85
|
+
export interface HorizontalCalculatedSection {
|
|
86
|
+
classTotals: HorizontalClassBalance[];
|
|
87
|
+
sectionTotal: Amount;
|
|
88
|
+
title: string;
|
|
89
|
+
/** Synthetic balances for the calculated row; set by enrichment. */
|
|
90
|
+
sectionHeaderBalancesSlice?: COABalancesSlice;
|
|
91
|
+
}
|
|
92
|
+
export interface ProfitAndLossByClassHorizontalReport {
|
|
93
|
+
calculatedSections: Partial<Record<PandLReportViewCalculatedSectionID, HorizontalCalculatedSection>>;
|
|
94
|
+
classColumns: ClassColumnDefinition[];
|
|
95
|
+
fetchState: FetchState;
|
|
96
|
+
firstMonthOfFY: Month;
|
|
97
|
+
/** Synthetic COABalance array for header rendering — one per class column + total */
|
|
98
|
+
headerBalances: COABalance[];
|
|
99
|
+
idsInOrder: (PandLReportViewSectionID | PandLReportViewCalculatedSectionID)[];
|
|
100
|
+
reportId: ReportID;
|
|
101
|
+
reportTitle: string;
|
|
102
|
+
sections: Partial<Record<PandLReportViewSectionID, HorizontalSectionReport>>;
|
|
103
|
+
selectedPeriod: {
|
|
104
|
+
endDate: ZeniDate;
|
|
105
|
+
startDate: ZeniDate;
|
|
106
|
+
label?: string;
|
|
107
|
+
} | undefined;
|
|
108
|
+
uiState: ProfitAndLossClassesViewUIState;
|
|
109
|
+
bookCloseDate?: ZeniDate;
|
|
110
|
+
dataAvailable?: DataAvailable;
|
|
111
|
+
}
|
package/lib/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelectorTypes.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HORIZONTAL_CLASS_TOTAL_BALANCE_ID = void 0;
|
|
4
|
+
exports.isHorizontalAccountReportData = isHorizontalAccountReportData;
|
|
5
|
+
/** Synthetic COABalance `id` for the horizontal class report Total column (transaction routing). */
|
|
6
|
+
exports.HORIZONTAL_CLASS_TOTAL_BALANCE_ID = '__horizontal_total__';
|
|
7
|
+
function isHorizontalAccountReportData(data) {
|
|
8
|
+
return (typeof data === 'object' &&
|
|
9
|
+
data !== null &&
|
|
10
|
+
'depth' in data &&
|
|
11
|
+
typeof data.depth === 'number' &&
|
|
12
|
+
!('filter' in data));
|
|
13
|
+
}
|
|
@@ -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;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.clearProfitAndLossClassesView = exports.resetProfitAndLossClassesNodeCollapseState = exports.updateAccountViewMode = exports.updateProfitAndLossClassesViewUIState = exports.updateClassesToFilterOut = exports.updateProfitAndLossForTimeframeClassesViewFailure = exports.updateProfitAndLossForTimeframeClassesView = exports.fetchProfitAndLossForTimeframeClassesView = exports.fetchProfitAndLossClassesView = exports.initialState = void 0;
|
|
4
|
+
exports.clearProfitAndLossClassesView = exports.resetProfitAndLossClassesNodeCollapseState = exports.updateClassViewLayout = exports.updateAccountViewMode = exports.updateProfitAndLossClassesViewUIState = exports.updateClassesToFilterOut = exports.updateProfitAndLossForTimeframeClassesViewFailure = exports.updateProfitAndLossForTimeframeClassesView = exports.fetchProfitAndLossForTimeframeClassesView = exports.fetchProfitAndLossClassesView = exports.initialState = void 0;
|
|
5
5
|
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
6
|
const viewAndReportPayloadv2_1 = require("../../commonPayloadTypes/v2/viewAndReportPayloadv2");
|
|
7
7
|
const getNestedClassIDHierarchyForReport_1 = require("../../commonStateTypes/classesView/getNestedClassIDHierarchyForReport");
|
|
@@ -27,6 +27,7 @@ exports.initialState = {
|
|
|
27
27
|
nodeCollapseState: {},
|
|
28
28
|
scrollPosition: undefined,
|
|
29
29
|
accountViewMode: 'account_group',
|
|
30
|
+
classViewLayout: 'vertical',
|
|
30
31
|
classesToFilterOut: [],
|
|
31
32
|
},
|
|
32
33
|
firstMonthOfFY: 1,
|
|
@@ -98,6 +99,9 @@ const profitAndLossClassesView = (0, toolkit_1.createSlice)({
|
|
|
98
99
|
updateAccountViewMode(draft, action) {
|
|
99
100
|
draft.uiState.accountViewMode = action.payload.viewMode;
|
|
100
101
|
},
|
|
102
|
+
updateClassViewLayout(draft, action) {
|
|
103
|
+
draft.uiState.classViewLayout = action.payload.classViewLayout;
|
|
104
|
+
},
|
|
101
105
|
resetProfitAndLossClassesNodeCollapseState(draft) {
|
|
102
106
|
draft.uiState.nodeCollapseState = {};
|
|
103
107
|
},
|
|
@@ -106,10 +110,11 @@ const profitAndLossClassesView = (0, toolkit_1.createSlice)({
|
|
|
106
110
|
},
|
|
107
111
|
},
|
|
108
112
|
});
|
|
109
|
-
_a = profitAndLossClassesView.actions, exports.fetchProfitAndLossClassesView = _a.fetchProfitAndLossClassesView, exports.fetchProfitAndLossForTimeframeClassesView = _a.fetchProfitAndLossForTimeframeClassesView, exports.updateProfitAndLossForTimeframeClassesView = _a.updateProfitAndLossForTimeframeClassesView, exports.updateProfitAndLossForTimeframeClassesViewFailure = _a.updateProfitAndLossForTimeframeClassesViewFailure, exports.updateClassesToFilterOut = _a.updateClassesToFilterOut, exports.updateProfitAndLossClassesViewUIState = _a.updateProfitAndLossClassesViewUIState, exports.updateAccountViewMode = _a.updateAccountViewMode, exports.resetProfitAndLossClassesNodeCollapseState = _a.resetProfitAndLossClassesNodeCollapseState, exports.clearProfitAndLossClassesView = _a.clearProfitAndLossClassesView;
|
|
113
|
+
_a = profitAndLossClassesView.actions, exports.fetchProfitAndLossClassesView = _a.fetchProfitAndLossClassesView, exports.fetchProfitAndLossForTimeframeClassesView = _a.fetchProfitAndLossForTimeframeClassesView, exports.updateProfitAndLossForTimeframeClassesView = _a.updateProfitAndLossForTimeframeClassesView, exports.updateProfitAndLossForTimeframeClassesViewFailure = _a.updateProfitAndLossForTimeframeClassesViewFailure, exports.updateClassesToFilterOut = _a.updateClassesToFilterOut, exports.updateProfitAndLossClassesViewUIState = _a.updateProfitAndLossClassesViewUIState, exports.updateAccountViewMode = _a.updateAccountViewMode, exports.updateClassViewLayout = _a.updateClassViewLayout, exports.resetProfitAndLossClassesNodeCollapseState = _a.resetProfitAndLossClassesNodeCollapseState, exports.clearProfitAndLossClassesView = _a.clearProfitAndLossClassesView;
|
|
110
114
|
exports.default = profitAndLossClassesView.reducer;
|
|
111
115
|
const doUpdatedProfitAndLossClassesView = (draft, timeframe, pandLReport) => {
|
|
112
116
|
const report = (0, viewAndReportPayloadv2_1.mapReportPayloadV2ToReportV2)(pandLReport.report);
|
|
117
|
+
draft.currency = report.currency;
|
|
113
118
|
draft.dataAvailable = report.dataAvailable;
|
|
114
119
|
draft.firstMonthOfFY = report.firstMonthOfFY;
|
|
115
120
|
draft.bookCloseDate = report.bookCloseDate;
|