@zeniai/client-epic-state 4.19.98 → 4.19.99-beta15ND

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.

Potentially problematic release.


This version of @zeniai/client-epic-state might be problematic. Click here for more details.

Files changed (162) hide show
  1. package/lib/commonStateTypes/coaBalance/coaBalanceType.d.ts +2 -0
  2. package/lib/commonStateTypes/coaBalance/coaBalanceType.js +6 -0
  3. package/lib/commonStateTypes/currencyHelper.d.ts +3 -0
  4. package/lib/commonStateTypes/currencyHelper.js +6 -1
  5. package/lib/commonStateTypes/reduceFetchState.d.ts +9 -0
  6. package/lib/commonStateTypes/reduceFetchState.js +26 -0
  7. package/lib/entity/account/accountPayload.d.ts +2 -0
  8. package/lib/entity/account/accountPayload.js +2 -0
  9. package/lib/entity/account/accountState.d.ts +2 -0
  10. package/lib/entity/customer/customerState.d.ts +0 -2
  11. package/lib/entity/customer/customerState.js +0 -5
  12. package/lib/entity/depositAccount/depositAccount.d.ts +1 -1
  13. package/lib/entity/depositAccount/depositAccount.js +8 -1
  14. package/lib/entity/reimbursement/reimbursementPayload.d.ts +2 -0
  15. package/lib/entity/reimbursement/reimbursementPayload.js +7 -0
  16. package/lib/entity/reimbursement/reimbursementState.d.ts +2 -0
  17. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  18. package/lib/entity/snackbar/snackbarTypes.js +1 -0
  19. package/lib/entity/task/taskPayload.d.ts +1 -0
  20. package/lib/entity/task/taskPayload.js +1 -0
  21. package/lib/entity/task/taskState.d.ts +1 -0
  22. package/lib/entity/userGroups/userGroupsPayload.d.ts +7 -0
  23. package/lib/entity/userGroups/userGroupsPayload.js +10 -0
  24. package/lib/entity/userGroups/userGroupsReducer.d.ts +8 -0
  25. package/lib/entity/userGroups/userGroupsReducer.js +29 -0
  26. package/lib/entity/userGroups/userGroupsSelector.d.ts +4 -0
  27. package/lib/entity/userGroups/userGroupsSelector.js +12 -0
  28. package/lib/entity/userGroups/userGroupsState.d.ts +9 -0
  29. package/lib/entity/userGroups/userGroupsState.js +2 -0
  30. package/lib/epic.d.ts +12 -1
  31. package/lib/epic.js +12 -1
  32. package/lib/esm/commonStateTypes/coaBalance/coaBalanceType.js +5 -0
  33. package/lib/esm/commonStateTypes/currencyHelper.js +5 -0
  34. package/lib/esm/commonStateTypes/reduceFetchState.js +25 -0
  35. package/lib/esm/entity/account/accountPayload.js +2 -0
  36. package/lib/esm/entity/customer/customerState.js +1 -4
  37. package/lib/esm/entity/depositAccount/depositAccount.js +8 -1
  38. package/lib/esm/entity/reimbursement/reimbursementPayload.js +7 -0
  39. package/lib/esm/entity/snackbar/snackbarTypes.js +1 -0
  40. package/lib/esm/entity/task/taskPayload.js +1 -0
  41. package/lib/esm/entity/userGroups/userGroupsPayload.js +7 -0
  42. package/lib/esm/entity/userGroups/userGroupsReducer.js +25 -0
  43. package/lib/esm/entity/userGroups/userGroupsSelector.js +8 -0
  44. package/lib/esm/entity/userGroups/userGroupsState.js +1 -0
  45. package/lib/esm/epic.js +12 -1
  46. package/lib/esm/index.js +18 -10
  47. package/lib/esm/reducer.js +6 -0
  48. package/lib/esm/view/arAgingView/arAgingReport/arAgingReducer.js +1 -1
  49. package/lib/esm/view/arAgingView/arAgingReport/arAgingSelector.js +1 -1
  50. package/lib/esm/view/expenseAutomationView/bulkUploadTiming.js +10 -0
  51. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.js +29 -0
  52. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.js +49 -0
  53. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.js +40 -0
  54. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +47 -0
  55. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +61 -0
  56. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.js +33 -0
  57. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.js +56 -0
  58. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +77 -0
  59. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/uploadMissingReceiptSuccessEpic.js +7 -5
  60. package/lib/esm/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +79 -0
  61. package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/uploadTransactionReceiptSuccessEpic.js +24 -0
  62. package/lib/esm/view/expenseAutomationView/payload/missingReceiptsPayload.js +189 -1
  63. package/lib/esm/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +433 -2
  64. package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +23 -1
  65. package/lib/esm/view/expenseAutomationView/selectors/missingReceiptsSelector.js +244 -1
  66. package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +2 -1
  67. package/lib/esm/view/expenseAutomationView/types/missingReceiptsViewState.js +44 -0
  68. package/lib/esm/view/expenseAutomationView/types/transactionsViewState.js +2 -1
  69. package/lib/esm/view/financeStatement/financeStatementReducer.js +11 -8
  70. package/lib/esm/view/financeStatement/financeStatementSelector.js +24 -9
  71. package/lib/esm/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector.js +317 -0
  72. package/lib/esm/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelectorTypes.js +9 -0
  73. package/lib/esm/view/profitAndLossClassesView/profitAndLossClassesViewReducer.js +6 -1
  74. package/lib/esm/view/profitAndLossClassesView/profitAndLossClassesViewSelector.js +2 -29
  75. package/lib/esm/view/profitAndLossClassesView/profitAndLossForTimeframeClassesViewEpic.js +7 -5
  76. package/lib/esm/view/profitAndLossClassesView/profitAndLossHorizontalEnrichment.js +280 -0
  77. package/lib/esm/view/reportUIOptions/updateReportUIOptionCOABalancesRangeEpic.js +9 -7
  78. package/lib/esm/view/taskManager/taskDetailView/taskDetailSelector.js +1 -1
  79. package/lib/esm/view/taskManager/taskListView/epics/bulkUpdateTaskListEpic.js +1 -0
  80. package/lib/esm/view/taskManager/taskListView/taskListSelector.js +3 -1
  81. package/lib/esm/view/userGroupListView/userGroupListViewReducer.js +65 -0
  82. package/lib/esm/view/userGroupListView/userGroupListViewSelector.js +16 -0
  83. package/lib/esm/view/userGroupListView/userGroupListViewState.js +1 -0
  84. package/lib/esm/view/userListView/fetchUserListByTypeEpic.js +11 -0
  85. package/lib/esm/zeniAPI.js +0 -2
  86. package/lib/index.d.ts +19 -12
  87. package/lib/index.js +81 -23
  88. package/lib/reducer.d.ts +6 -0
  89. package/lib/reducer.js +6 -0
  90. package/lib/tsconfig.typecheck.tsbuildinfo +1 -1
  91. package/lib/view/arAgingView/arAgingReport/arAgingReducer.js +2 -2
  92. package/lib/view/arAgingView/arAgingReport/arAgingSelector.js +5 -5
  93. package/lib/view/expenseAutomationView/bulkUploadTiming.d.ts +10 -0
  94. package/lib/view/expenseAutomationView/bulkUploadTiming.js +13 -0
  95. package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.d.ts +18 -0
  96. package/lib/view/expenseAutomationView/epics/missingReceipts/bulkUploadReceiptsEpic.js +33 -0
  97. package/lib/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.d.ts +7 -0
  98. package/lib/view/expenseAutomationView/epics/missingReceipts/confirmBulkUploadMatchEpic.js +53 -0
  99. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.d.ts +8 -0
  100. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchDetailsEpic.js +44 -0
  101. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.d.ts +7 -0
  102. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchBulkUploadBatchesEpic.js +51 -0
  103. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.d.ts +8 -0
  104. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchCompletedTransactionsEpic.js +65 -0
  105. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.d.ts +8 -0
  106. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMoreBatchDetailsEpic.js +37 -0
  107. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.d.ts +9 -0
  108. package/lib/view/expenseAutomationView/epics/missingReceipts/fetchMultipleBatchDetailsEpic.js +61 -0
  109. package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.d.ts +14 -0
  110. package/lib/view/expenseAutomationView/epics/missingReceipts/searchTransactionsForManualMatchEpic.js +81 -0
  111. package/lib/view/expenseAutomationView/epics/missingReceipts/uploadMissingReceiptSuccessEpic.js +7 -5
  112. package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.d.ts +25 -0
  113. package/lib/view/expenseAutomationView/epics/missingReceipts/watchBulkUploadBatchStatusEpic.js +85 -0
  114. package/lib/view/expenseAutomationView/epics/transactionCategorization/uploadTransactionReceiptSuccessEpic.d.ts +7 -0
  115. package/lib/view/expenseAutomationView/epics/transactionCategorization/uploadTransactionReceiptSuccessEpic.js +28 -0
  116. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  117. package/lib/view/expenseAutomationView/payload/missingReceiptsPayload.d.ts +118 -0
  118. package/lib/view/expenseAutomationView/payload/missingReceiptsPayload.js +201 -0
  119. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +76 -3
  120. package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.js +434 -2
  121. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +11 -3
  122. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +24 -2
  123. package/lib/view/expenseAutomationView/selectorTypes/missingReceiptsSelectorTypes.d.ts +69 -1
  124. package/lib/view/expenseAutomationView/selectorTypes/transactionsViewSelectorTypes.d.ts +1 -0
  125. package/lib/view/expenseAutomationView/selectors/missingReceiptsSelector.d.ts +1 -1
  126. package/lib/view/expenseAutomationView/selectors/missingReceiptsSelector.js +243 -0
  127. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +2 -1
  128. package/lib/view/expenseAutomationView/types/missingReceiptsViewState.d.ts +142 -0
  129. package/lib/view/expenseAutomationView/types/missingReceiptsViewState.js +54 -1
  130. package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +2 -1
  131. package/lib/view/expenseAutomationView/types/transactionsViewState.js +2 -1
  132. package/lib/view/financeStatement/financeStatementReducer.js +11 -8
  133. package/lib/view/financeStatement/financeStatementSelector.d.ts +2 -0
  134. package/lib/view/financeStatement/financeStatementSelector.js +24 -9
  135. package/lib/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector.d.ts +13 -0
  136. package/lib/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector.js +321 -0
  137. package/lib/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelectorTypes.d.ts +111 -0
  138. package/lib/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelectorTypes.js +13 -0
  139. package/lib/view/profitAndLossClassesView/profitAndLossClassesViewReducer.d.ts +4 -2
  140. package/lib/view/profitAndLossClassesView/profitAndLossClassesViewReducer.js +7 -2
  141. package/lib/view/profitAndLossClassesView/profitAndLossClassesViewSelector.js +2 -29
  142. package/lib/view/profitAndLossClassesView/profitAndLossClassesViewState.d.ts +4 -0
  143. package/lib/view/profitAndLossClassesView/profitAndLossForTimeframeClassesViewEpic.js +7 -5
  144. package/lib/view/profitAndLossClassesView/profitAndLossHorizontalEnrichment.d.ts +6 -0
  145. package/lib/view/profitAndLossClassesView/profitAndLossHorizontalEnrichment.js +283 -0
  146. package/lib/view/reportUIOptions/updateReportUIOptionCOABalancesRangeEpic.js +8 -6
  147. package/lib/view/taskManager/taskDetailView/taskDetailSelector.js +1 -1
  148. package/lib/view/taskManager/taskListView/epics/bulkUpdateTaskListEpic.d.ts +1 -0
  149. package/lib/view/taskManager/taskListView/epics/bulkUpdateTaskListEpic.js +1 -0
  150. package/lib/view/taskManager/taskListView/taskListSelector.d.ts +2 -0
  151. package/lib/view/taskManager/taskListView/taskListSelector.js +3 -1
  152. package/lib/view/userGroupListView/userGroupListViewReducer.d.ts +23 -0
  153. package/lib/view/userGroupListView/userGroupListViewReducer.js +69 -0
  154. package/lib/view/userGroupListView/userGroupListViewSelector.d.ts +7 -0
  155. package/lib/view/userGroupListView/userGroupListViewSelector.js +20 -0
  156. package/lib/view/userGroupListView/userGroupListViewState.d.ts +8 -0
  157. package/lib/view/userGroupListView/userGroupListViewState.js +2 -0
  158. package/lib/view/userListView/fetchUserListByTypeEpic.d.ts +3 -1
  159. package/lib/view/userListView/fetchUserListByTypeEpic.js +11 -0
  160. package/lib/view/userListView/userListViewPayload.d.ts +2 -0
  161. package/lib/zeniAPI.js +0 -2
  162. package/package.json +2 -2
@@ -15,7 +15,7 @@ import { VendorBase } from '../../../entity/vendor/vendorState';
15
15
  import { ZeniDate } from '../../../zeniDayJS';
16
16
  import { EntityRecommendationKey } from '../../recommendation/recommendationState';
17
17
  import { TransactionDetailKey } from '../../transactionDetail/transactionDetailState';
18
- export declare const toTransactionsSortKey: (v: string) => "date" | "amount" | "vendor" | "category" | "class" | "memo" | "transaction_type";
18
+ export declare const toTransactionsSortKey: (v: string) => "date" | "amount" | "vendor" | "category" | "class" | "payment_account" | "transaction_type" | "memo_and_receipt";
19
19
  export type TransactionsSortKey = ReturnType<typeof toTransactionsSortKey>;
20
20
  export declare const TRANSACTIONS_TABS: readonly ["review", "autoCategorized"];
21
21
  export declare const toTransactionsTabKey: (v: string) => "review" | "autoCategorized";
@@ -97,6 +97,7 @@ export interface TransactionsTabViewState extends FetchedState {
97
97
  transactionIdsWithUnsavedData: ID[];
98
98
  transactionReviewLocalDataById: Record<ID | TransactionDetailKey, SupportedTransactionCategorization>;
99
99
  uiState: TransactionsViewUIState;
100
+ uploadReceiptStatusById: Record<ID, FetchStateAndError>;
100
101
  selectedTransactionId?: ID;
101
102
  selectedTransactionLineId?: ID;
102
103
  }
@@ -7,10 +7,11 @@ const TRANSACTIONS_SORT_KEYS = [
7
7
  'vendor',
8
8
  'amount',
9
9
  'transaction_type',
10
+ 'payment_account',
10
11
  'date',
11
12
  'category',
12
13
  'class',
13
- 'memo',
14
+ 'memo_and_receipt',
14
15
  ];
15
16
  const toTransactionsSortKey = (v) => (0, stringToUnion_1.stringToUnion)(v, TRANSACTIONS_SORT_KEYS);
16
17
  exports.toTransactionsSortKey = toTransactionsSortKey;
@@ -48,19 +48,20 @@ const financeStatement = (0, toolkit_1.createSlice)({
48
48
  updateFinanceStatementThisPeriod(draft, action) {
49
49
  const { firstMonthOfFY, coaBalances, maxNumOfPeriodsToHighlight } = action.payload;
50
50
  const { timeframe, selectedCOABalancesRange } = draft;
51
- if (coaBalances.length > 0) {
52
- const prevThisPeriod = (0, thisPeriodHelpers_1.extractThisPeriod)(action.payload.firstMonthOfFY, timeframe, selectedCOABalancesRange, coaBalances);
51
+ const safeCoaBalances = coaBalances != null ? coaBalances : [];
52
+ if (safeCoaBalances.length > 0) {
53
+ const prevThisPeriod = (0, thisPeriodHelpers_1.extractThisPeriod)(action.payload.firstMonthOfFY, timeframe, selectedCOABalancesRange, safeCoaBalances);
53
54
  if (prevThisPeriod != null) {
54
55
  const selectedCoaBalancesRangeWithThisPeriod = {
55
56
  ...selectedCOABalancesRange,
56
57
  thisPeriod: prevThisPeriod,
57
58
  };
58
- const newThisPeriod = (0, thisPeriodHelpers_1.getMatchingThisPeriod)(action.payload.firstMonthOfFY, timeframe, action.payload.thisPeriod, coaBalances);
59
+ const newThisPeriod = (0, thisPeriodHelpers_1.getMatchingThisPeriod)(action.payload.firstMonthOfFY, timeframe, action.payload.thisPeriod, safeCoaBalances);
59
60
  if (newThisPeriod != null) {
60
61
  const selectionRanges = (0, getSelectedAndHighlightedRanges_1.getSelectedAndHighlightedRangesForThisPeriod)({
61
62
  firstMonthOfFY,
62
63
  thisPeriod: newThisPeriod,
63
- coaBalances,
64
+ coaBalances: safeCoaBalances,
64
65
  timeframe,
65
66
  maxNumOfPeriodsToSelect: maxNumOfPeriodsToHighlight,
66
67
  currentSelection: {
@@ -79,7 +80,9 @@ const financeStatement = (0, toolkit_1.createSlice)({
79
80
  draft.selectedReportId = action.payload;
80
81
  },
81
82
  updateFinanceStatementAdditionalBalancesSelection(draft, action) {
82
- const { firstMonthOfFY, additionalBalances, coaBalances, maxNumOfPeriodsToHighlight, } = action.payload;
83
+ const { firstMonthOfFY, additionalBalances: additionalBalancesPayload, coaBalances, maxNumOfPeriodsToHighlight, } = action.payload;
84
+ const safeCoaBalances = coaBalances != null ? coaBalances : [];
85
+ const additionalBalances = additionalBalancesPayload ?? [];
83
86
  let tempAdditionalBalances = [...additionalBalances];
84
87
  if (additionalBalances.includes('this_period_vs_last_period') ||
85
88
  additionalBalances.includes('this_period_vs_last_period_percent')) {
@@ -95,8 +98,8 @@ const financeStatement = (0, toolkit_1.createSlice)({
95
98
  draft.isAdditionalBalancesShown =
96
99
  additionalBalances.length != 0 ? true : false;
97
100
  const { timeframe, selectedCOABalancesRange } = draft;
98
- if (coaBalances.length > 0) {
99
- const thisPeriod = (0, thisPeriodHelpers_1.extractThisPeriod)(action.payload.firstMonthOfFY, timeframe, selectedCOABalancesRange, coaBalances);
101
+ if (safeCoaBalances.length > 0) {
102
+ const thisPeriod = (0, thisPeriodHelpers_1.extractThisPeriod)(action.payload.firstMonthOfFY, timeframe, selectedCOABalancesRange, safeCoaBalances);
100
103
  if (thisPeriod != null) {
101
104
  const selectedCoaBalancesRangeWithThisPeriod = {
102
105
  ...selectedCOABalancesRange,
@@ -105,7 +108,7 @@ const financeStatement = (0, toolkit_1.createSlice)({
105
108
  const selectionRanges = (0, getSelectedAndHighlightedRanges_1.getSelectedAndHighlightedRangesForThisPeriod)({
106
109
  firstMonthOfFY,
107
110
  thisPeriod: thisPeriod,
108
- coaBalances,
111
+ coaBalances: safeCoaBalances,
109
112
  timeframe,
110
113
  maxNumOfPeriodsToHighlight: maxNumOfPeriodsToHighlight,
111
114
  currentSelection: {
@@ -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;
@@ -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
- if (profitAndLossForTimeframeTicks.sections.expenses != null) {
49
- balancesInTimeframe =
50
- profitAndLossForTimeframeTicks.sections.expenses.balances.length > 0
51
- ? profitAndLossForTimeframeTicks.sections['expenses'].balances
52
- : profitAndLossForTimeframeTicks.sections['income'].balances;
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 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', financeStatementState.isAdditionalBalancesShown === true
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: financeStatementState.selectedAdditionalBalances.includes('this_period_vs_last_period') ||
119
- financeStatementState.selectedAdditionalBalances.includes('this_period_vs_last_period_percent'),
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,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,321 @@
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 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
+ exports.profitAndLossHorizontalIdsInOrder = [
11
+ 'income',
12
+ 'cogs',
13
+ 'grossProfit',
14
+ 'expenses',
15
+ 'earningsBeforeInterestAndTax',
16
+ 'otherIncome',
17
+ 'otherExpenses',
18
+ 'netOtherIncome',
19
+ 'netIncome',
20
+ ];
21
+ const SECTION_TITLES = {
22
+ income: 'Income',
23
+ cogs: 'Cost of Goods Sold',
24
+ grossProfit: 'Gross Profit',
25
+ expenses: 'Expenses',
26
+ earningsBeforeInterestAndTax: 'Net Operating Income',
27
+ otherIncome: 'Other Income',
28
+ otherExpenses: 'Other Expenses',
29
+ netOtherIncome: 'Net Other Income',
30
+ netIncome: 'Net Income',
31
+ };
32
+ /** Sections fetched and pivoted for horizontal layout (excludes e.g. `netOperatingIncome`). */
33
+ const HORIZONTAL_PANDL_SECTION_IDS = [
34
+ 'income',
35
+ 'cogs',
36
+ 'expenses',
37
+ 'otherIncome',
38
+ 'otherExpenses',
39
+ ];
40
+ const getProfitAndLossClassesHorizontalView = (filter, accountState, classState, sectionsState, profitAndLossClassesViewState, selectedPeriod) => {
41
+ const fetchState = (0, reduceFetchState_1.reduceFetchStateParallelTimeframes)([
42
+ profitAndLossClassesViewState.fetchState.month,
43
+ profitAndLossClassesViewState.fetchState.quarter,
44
+ profitAndLossClassesViewState.fetchState.year,
45
+ ]);
46
+ const reportId = 'profit_and_loss_by_classes';
47
+ // Build class columns from the class hierarchy (top-level only).
48
+ // Use `filter.classesToFilterOut` so PDF/Excel downloads (fresh store, empty UI state)
49
+ // respect `classes_to_filter_out` from the request; in-app `classFilter` mirrors uiState.
50
+ const classColumns = buildClassColumns(profitAndLossClassesViewState.classHierarchy, filter.classesToFilterOut);
51
+ const sections = {};
52
+ const calculatedSections = {};
53
+ let reportCurrency = currencyHelper_1.defaultCustomerCurrency;
54
+ if (fetchState.fetchState === 'Completed' && selectedPeriod != null) {
55
+ reportCurrency =
56
+ profitAndLossClassesViewState.currency ?? currencyHelper_1.defaultCustomerCurrency;
57
+ // Fetch each section and pivot class→account to account→class in one pass
58
+ HORIZONTAL_PANDL_SECTION_IDS.forEach((sectionId) => {
59
+ const sectionReport = (0, sectionClassesViewSelector_1.getSectionClassesViewReport)(accountState, classState, sectionsState, { reportId, sectionId }, filter);
60
+ if (sectionReport != null) {
61
+ sections[sectionId] = pivotSectionToHorizontal(sectionReport, classColumns, SECTION_TITLES[sectionId] ?? sectionId, reportCurrency);
62
+ }
63
+ });
64
+ // Calculate derived sections
65
+ const incomeSection = sections['income'];
66
+ const cogsSection = sections['cogs'];
67
+ const expensesSection = sections['expenses'];
68
+ const otherIncomeSection = sections['otherIncome'];
69
+ const otherExpensesSection = sections['otherExpenses'];
70
+ // Gross Profit = Income - COGS
71
+ if (incomeSection != null && cogsSection != null) {
72
+ calculatedSections['grossProfit'] = computeCalculatedSection(incomeSection.classTotals, cogsSection.classTotals, incomeSection.sectionTotal, cogsSection.sectionTotal, 'subtract', SECTION_TITLES['grossProfit']);
73
+ }
74
+ // EBIT = Gross Profit - Expenses
75
+ const grossProfit = calculatedSections['grossProfit'];
76
+ if (grossProfit != null && expensesSection != null) {
77
+ calculatedSections['earningsBeforeInterestAndTax'] =
78
+ computeCalculatedSection(grossProfit.classTotals, expensesSection.classTotals, grossProfit.sectionTotal, expensesSection.sectionTotal, 'subtract', SECTION_TITLES['earningsBeforeInterestAndTax']);
79
+ }
80
+ // Net Other Income = Other Income - Other Expenses
81
+ if (otherIncomeSection != null && otherExpensesSection != null) {
82
+ calculatedSections['netOtherIncome'] = computeCalculatedSection(otherIncomeSection.classTotals, otherExpensesSection.classTotals, otherIncomeSection.sectionTotal, otherExpensesSection.sectionTotal, 'subtract', SECTION_TITLES['netOtherIncome']);
83
+ }
84
+ // Net Income = EBIT + Net Other Income
85
+ const ebit = calculatedSections['earningsBeforeInterestAndTax'];
86
+ const netOtherIncome = calculatedSections['netOtherIncome'];
87
+ if (ebit != null && netOtherIncome != null) {
88
+ calculatedSections['netIncome'] = computeCalculatedSection(ebit.classTotals, netOtherIncome.classTotals, ebit.sectionTotal, netOtherIncome.sectionTotal, 'add', SECTION_TITLES['netIncome']);
89
+ }
90
+ }
91
+ // Build synthetic header COABalances for rendering class names as column headers
92
+ const headerBalances = buildHeaderBalances(classColumns, filter.timeframe, selectedPeriod, reportCurrency);
93
+ const report = {
94
+ reportId,
95
+ reportTitle: 'Profit and Loss by Class',
96
+ firstMonthOfFY: profitAndLossClassesViewState.firstMonthOfFY,
97
+ fetchState: fetchState.fetchState,
98
+ bookCloseDate: profitAndLossClassesViewState.bookCloseDate,
99
+ dataAvailable: profitAndLossClassesViewState.dataAvailable,
100
+ selectedPeriod,
101
+ classColumns,
102
+ sections,
103
+ calculatedSections,
104
+ idsInOrder: exports.profitAndLossHorizontalIdsInOrder,
105
+ uiState: profitAndLossClassesViewState.uiState,
106
+ headerBalances,
107
+ };
108
+ (0, profitAndLossHorizontalEnrichment_1.enrichProfitAndLossByClassHorizontalReport)(report);
109
+ return report;
110
+ };
111
+ exports.getProfitAndLossClassesHorizontalView = getProfitAndLossClassesHorizontalView;
112
+ /**
113
+ * Build column definitions from class hierarchy (top-level classes only).
114
+ */
115
+ function buildClassColumns(classHierarchy, classesToFilterOut) {
116
+ const filteredIds = new Set(classesToFilterOut.map((id) => id[0]));
117
+ return classHierarchy
118
+ .filter((c) => !filteredIds.has(c.classId[0]))
119
+ .map((c) => ({
120
+ classId: c.classId[0],
121
+ className: c.className,
122
+ nestedClassId: c.classId,
123
+ qboId: c.qboId,
124
+ }))
125
+ .sort((a, b) => a.className.localeCompare(b.className, [], { sensitivity: 'base' }));
126
+ }
127
+ /**
128
+ * Pivot a section from class→account→balances to account→class→balance (single period).
129
+ */
130
+ function pivotSectionToHorizontal(section, classColumns, title, currency) {
131
+ // Map: accountId -> { accountName, classId -> balance }
132
+ const accountMap = new Map();
133
+ // Also track class totals
134
+ const classTotalMap = new Map();
135
+ classColumns.forEach((col) => classTotalMap.set(col.classId, 0));
136
+ // Iterate over each class in the section
137
+ section.classes.forEach((classReport) => {
138
+ const classId = classReport.id[0];
139
+ // Only process classes that are in our columns
140
+ if (!classTotalMap.has(classId)) {
141
+ return;
142
+ }
143
+ // Sum all sliced period balances (same slice as vertical columns; multi-period = range total)
144
+ const classBalance = sumBalancesInSlice(classReport.childrenBalancesTotal.balances);
145
+ classTotalMap.set(classId, classBalance);
146
+ // Iterate through accounts in this class
147
+ collectAccountsFromClass(classReport, classId, accountMap);
148
+ });
149
+ // Build account rows in COA tree order (same parent/child ordering as vertical P&L by class).
150
+ // Sorting by depth + name flattened the hierarchy and broke sub-account grouping.
151
+ const orderedIds = collectAccountIdsInTreeOrder(section, classColumns);
152
+ const usedIds = new Set();
153
+ const accounts = [];
154
+ const pushAccountRow = (accountId) => {
155
+ const accountData = accountMap.get(accountId);
156
+ if (accountData == null) {
157
+ return;
158
+ }
159
+ usedIds.add(accountId);
160
+ const classBalances = classColumns.map((col) => ({
161
+ classId: col.classId,
162
+ balance: (0, amount_1.toAmountWC)(accountData.classBalances.get(col.classId) ?? 0, currency),
163
+ }));
164
+ const rowTotal = classBalances.reduce((sum, cb) => sum + cb.balance.amount, 0);
165
+ accounts.push({
166
+ accountId,
167
+ accountName: accountData.accountName,
168
+ accountType: accountData.accountType,
169
+ depth: accountData.depth,
170
+ classBalances,
171
+ rowTotal: (0, amount_1.toAmountWC)(rowTotal, currency),
172
+ });
173
+ };
174
+ for (const id of orderedIds) {
175
+ pushAccountRow(id);
176
+ }
177
+ for (const accountId of accountMap.keys()) {
178
+ if (!usedIds.has(accountId)) {
179
+ pushAccountRow(accountId);
180
+ }
181
+ }
182
+ // Build class totals
183
+ const classTotals = classColumns.map((col) => ({
184
+ classId: col.classId,
185
+ balance: (0, amount_1.toAmountWC)(classTotalMap.get(col.classId) ?? 0, currency),
186
+ }));
187
+ const sectionTotal = classTotals.reduce((sum, ct) => sum + ct.balance.amount, 0);
188
+ return {
189
+ title,
190
+ accounts,
191
+ classTotals,
192
+ sectionTotal: (0, amount_1.toAmountWC)(sectionTotal, currency),
193
+ };
194
+ }
195
+ /**
196
+ * DFS account ids in the same order as vertical P&L by class, using the first class
197
+ * column that appears in this section as the canonical tree (structure is identical per class).
198
+ */
199
+ function collectAccountIdsInTreeOrder(section, classColumns) {
200
+ const ids = [];
201
+ const visitNested = (nested) => {
202
+ ids.push(nested.account.accountId);
203
+ nested.children.forEach(visitNested);
204
+ };
205
+ for (const col of classColumns) {
206
+ const classReport = section.classes.find((c) => c.id[0] === col.classId);
207
+ if (classReport == null) {
208
+ continue;
209
+ }
210
+ classReport.class.accounts.forEach(visitNested);
211
+ return ids;
212
+ }
213
+ return ids;
214
+ }
215
+ /**
216
+ * Recursively collect account balances from a NestedClassReportV2 into accountMap.
217
+ */
218
+ function collectAccountsFromClass(classReport, classId, accountMap) {
219
+ // Process accounts directly on this class (depth 2 matches vertical `AccountsSection` first level)
220
+ classReport.class.accounts.forEach((nestedAccount) => {
221
+ collectAccountsFromNestedAccount(nestedAccount, classId, accountMap, 2);
222
+ });
223
+ }
224
+ /**
225
+ * Recursively collect accounts from NestedAccountReport (handles sub-accounts).
226
+ */
227
+ function collectAccountsFromNestedAccount(nestedAccount, classId, accountMap, depth) {
228
+ const accountId = nestedAccount.account.accountId;
229
+ const accountName = nestedAccount.account.accountName;
230
+ const balance = sumBalancesInSlice(nestedAccount.account.balancesInTimeframe.balances);
231
+ if (!accountMap.has(accountId)) {
232
+ accountMap.set(accountId, {
233
+ accountName,
234
+ accountType: nestedAccount.account.accountType,
235
+ depth,
236
+ classBalances: new Map(),
237
+ });
238
+ }
239
+ const accountData = accountMap.get(accountId);
240
+ if (accountData == null) {
241
+ return;
242
+ }
243
+ accountData.depth = Math.max(accountData.depth, depth);
244
+ if (accountData.accountType == null &&
245
+ nestedAccount.account.accountType != null) {
246
+ accountData.accountType = nestedAccount.account.accountType;
247
+ }
248
+ const existing = accountData.classBalances.get(classId) ?? 0;
249
+ accountData.classBalances.set(classId, existing + balance);
250
+ // Process sub-accounts
251
+ nestedAccount.children.forEach((child) => {
252
+ collectAccountsFromNestedAccount(child, classId, accountMap, depth + 1);
253
+ });
254
+ }
255
+ /**
256
+ * Total `balance.amount` for the current COA slice (same aggregation as
257
+ * `getSummationFreeRangeTotalBalance`, used for class totals and account rows).
258
+ */
259
+ function sumBalancesInSlice(balances) {
260
+ if (balances.length === 0) {
261
+ return 0;
262
+ }
263
+ const summed = (0, getSummationBalance_1.getSummationFreeRangeTotalBalance)(balances);
264
+ return summed?.balance.amount ?? 0;
265
+ }
266
+ /**
267
+ * Compute a calculated section by adding or subtracting two sets of class totals.
268
+ */
269
+ function computeCalculatedSection(aTotals, bTotals, aTotal, bTotal, operation, title) {
270
+ const currency = {
271
+ currencyCode: aTotal.currencyCode,
272
+ currencySymbol: aTotal.currencySymbol,
273
+ };
274
+ const bTotalsMap = new Map(bTotals.map((b) => [b.classId, b.balance.amount]));
275
+ const classTotals = aTotals.map((a) => {
276
+ const bAmount = bTotalsMap.get(a.classId) ?? 0;
277
+ const resultAmount = operation === 'add'
278
+ ? a.balance.amount + bAmount
279
+ : a.balance.amount - bAmount;
280
+ return {
281
+ classId: a.classId,
282
+ balance: (0, amount_1.toAmountWC)(resultAmount, currency),
283
+ };
284
+ });
285
+ const sectionTotalAmount = operation === 'add'
286
+ ? aTotal.amount + bTotal.amount
287
+ : aTotal.amount - bTotal.amount;
288
+ return {
289
+ title,
290
+ classTotals,
291
+ sectionTotal: (0, amount_1.toAmountWC)(sectionTotalAmount, currency),
292
+ };
293
+ }
294
+ /**
295
+ * Build synthetic COABalance array for header rendering.
296
+ * One entry per class column + one for "Total".
297
+ */
298
+ function buildHeaderBalances(classColumns, timeframe, selectedPeriod, currency) {
299
+ if (selectedPeriod == null) {
300
+ return [];
301
+ }
302
+ const { endDate, startDate } = selectedPeriod;
303
+ const balances = classColumns.map((col) => ({
304
+ balance: (0, amount_1.toAmountWC)(0, currency),
305
+ balanceTimeFrame: timeframe,
306
+ endDate,
307
+ startDate,
308
+ type: 'default',
309
+ label: col.className,
310
+ }));
311
+ // Add a "Total" column
312
+ balances.push({
313
+ balance: (0, amount_1.toAmountWC)(0, currency),
314
+ balanceTimeFrame: timeframe,
315
+ endDate,
316
+ startDate,
317
+ type: 'default',
318
+ label: 'Total',
319
+ });
320
+ return balances;
321
+ }
@@ -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
+ }
@@ -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
+ }