@zeniai/client-epic-state 4.19.88-beta1ND → 4.19.88-beta2ND
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/esm/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector.js
CHANGED
|
@@ -52,7 +52,7 @@ export const getProfitAndLossClassesHorizontalView = (filter, accountState, clas
|
|
|
52
52
|
sectionIds.forEach((sectionId) => {
|
|
53
53
|
const sectionReport = sectionReports[sectionId];
|
|
54
54
|
if (sectionReport != null) {
|
|
55
|
-
sections[sectionId] = pivotSectionToHorizontal(sectionReport, classColumns,
|
|
55
|
+
sections[sectionId] = pivotSectionToHorizontal(sectionReport, classColumns, SECTION_TITLES[sectionId] ?? sectionId);
|
|
56
56
|
}
|
|
57
57
|
});
|
|
58
58
|
// Calculate derived sections
|
|
@@ -116,7 +116,7 @@ function buildClassColumns(classHierarchy, classesToFilterOut) {
|
|
|
116
116
|
/**
|
|
117
117
|
* Pivot a section from class→account→balances to account→class→balance (single period).
|
|
118
118
|
*/
|
|
119
|
-
function pivotSectionToHorizontal(section, classColumns,
|
|
119
|
+
function pivotSectionToHorizontal(section, classColumns, title) {
|
|
120
120
|
// Map: accountId -> { accountName, classId -> balance }
|
|
121
121
|
const accountMap = new Map();
|
|
122
122
|
// Also track class totals
|
|
@@ -129,11 +129,11 @@ function pivotSectionToHorizontal(section, classColumns, selectedPeriod, title)
|
|
|
129
129
|
if (!classColumns.some((col) => col.classId === classId)) {
|
|
130
130
|
return;
|
|
131
131
|
}
|
|
132
|
-
//
|
|
133
|
-
const classBalance =
|
|
132
|
+
// Sum all sliced period balances (same slice as vertical columns; multi-period = range total)
|
|
133
|
+
const classBalance = sumBalancesInSlice(classReport.childrenBalancesTotal.balances);
|
|
134
134
|
classTotalMap.set(classId, classBalance);
|
|
135
135
|
// Iterate through accounts in this class
|
|
136
|
-
collectAccountsFromClass(classReport, classId,
|
|
136
|
+
collectAccountsFromClass(classReport, classId, accountMap);
|
|
137
137
|
});
|
|
138
138
|
// Build account rows
|
|
139
139
|
const accounts = [];
|
|
@@ -166,19 +166,19 @@ function pivotSectionToHorizontal(section, classColumns, selectedPeriod, title)
|
|
|
166
166
|
/**
|
|
167
167
|
* Recursively collect account balances from a NestedClassReportV2 into accountMap.
|
|
168
168
|
*/
|
|
169
|
-
function collectAccountsFromClass(classReport, classId,
|
|
169
|
+
function collectAccountsFromClass(classReport, classId, accountMap) {
|
|
170
170
|
// Process accounts directly on this class
|
|
171
171
|
classReport.class.accounts.forEach((nestedAccount) => {
|
|
172
|
-
collectAccountsFromNestedAccount(nestedAccount, classId,
|
|
172
|
+
collectAccountsFromNestedAccount(nestedAccount, classId, accountMap);
|
|
173
173
|
});
|
|
174
174
|
}
|
|
175
175
|
/**
|
|
176
176
|
* Recursively collect accounts from NestedAccountReport (handles sub-accounts).
|
|
177
177
|
*/
|
|
178
|
-
function collectAccountsFromNestedAccount(nestedAccount, classId,
|
|
178
|
+
function collectAccountsFromNestedAccount(nestedAccount, classId, accountMap) {
|
|
179
179
|
const accountId = nestedAccount.account.accountId;
|
|
180
180
|
const accountName = nestedAccount.account.accountName;
|
|
181
|
-
const balance =
|
|
181
|
+
const balance = sumBalancesInSlice(nestedAccount.account.balancesInTimeframe.balances);
|
|
182
182
|
if (!accountMap.has(accountId)) {
|
|
183
183
|
accountMap.set(accountId, {
|
|
184
184
|
accountName,
|
|
@@ -193,27 +193,22 @@ function collectAccountsFromNestedAccount(nestedAccount, classId, selectedPeriod
|
|
|
193
193
|
accountData.classBalances.set(classId, existing + balance);
|
|
194
194
|
// Process sub-accounts
|
|
195
195
|
nestedAccount.children.forEach((child) => {
|
|
196
|
-
collectAccountsFromNestedAccount(child, classId,
|
|
196
|
+
collectAccountsFromNestedAccount(child, classId, accountMap);
|
|
197
197
|
});
|
|
198
198
|
}
|
|
199
199
|
/**
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
*
|
|
200
|
+
* Total amount for the current report slice. `balances` is already narrowed by
|
|
201
|
+
* `getCOABalances` / `sliceCOABalances` to the selected range; summing matches
|
|
202
|
+
* multi-period selections and avoids mismatches when `thisPeriod` does not
|
|
203
|
+
* align with a row (e.g. slice fallback) or when several period rows are shown.
|
|
204
204
|
*/
|
|
205
|
-
function
|
|
205
|
+
function sumBalancesInSlice(balances) {
|
|
206
|
+
let sum = 0;
|
|
206
207
|
for (const bal of balances) {
|
|
207
208
|
const b = bal;
|
|
208
|
-
|
|
209
|
-
if (b.startDate.isSame(selectedPeriod.startDate, 'day') &&
|
|
210
|
-
(b.endDate.isSame(selectedPeriod.endDate, 'day') ||
|
|
211
|
-
b.endDate.isAfter(selectedPeriod.endDate, 'day'))) {
|
|
212
|
-
return b.balance?.amount ?? 0;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
209
|
+
sum += b.balance?.amount ?? 0;
|
|
215
210
|
}
|
|
216
|
-
return
|
|
211
|
+
return sum;
|
|
217
212
|
}
|
|
218
213
|
/**
|
|
219
214
|
* Compute a calculated section by adding or subtracting two sets of class totals.
|