@zeniai/client-epic-state 5.0.43-betaRR01 → 5.0.44-beta0ND
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/esm/index.js +2 -1
- package/lib/esm/view/profitAndLossClassesView/profitAndLossHorizontalEnrichment.js +44 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +29 -27
- package/lib/tsconfig.typecheck.tsbuildinfo +1 -1
- package/lib/view/profitAndLossClassesView/profitAndLossHorizontalEnrichment.d.ts +15 -1
- package/lib/view/profitAndLossClassesView/profitAndLossHorizontalEnrichment.js +45 -0
- package/package.json +1 -1
|
@@ -1,6 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { COABalance } from '../../commonStateTypes/coaBalance/coaBalance';
|
|
2
|
+
import { HorizontalAccountRow, ProfitAndLossByClassHorizontalReport } from './profitAndLossClassesByClassHorizontalSelectorTypes';
|
|
2
3
|
/**
|
|
3
4
|
* Populates `sectionHeaderBalancesSlice`, and per-account `accountReportData`, so the
|
|
4
5
|
* web layer only maps selector output to tree nodes.
|
|
5
6
|
*/
|
|
6
7
|
export declare function enrichProfitAndLossByClassHorizontalReport(report: ProfitAndLossByClassHorizontalReport): void;
|
|
8
|
+
/**
|
|
9
|
+
* Sum balances across descendant accounts (recursive).
|
|
10
|
+
*
|
|
11
|
+
* Parent rows in the horizontal pivot only carry their own direct postings
|
|
12
|
+
* (zero for "container" accounts), so callers rendering "Total {parent}" rows
|
|
13
|
+
* must aggregate from descendants to get the real per-class totals.
|
|
14
|
+
*
|
|
15
|
+
* Returns one `COABalance` per class column + total (same shape as the
|
|
16
|
+
* enriched `balancesInTimeframe.balances`), with `amount` summed and `type`
|
|
17
|
+
* set to `default_with_null_balance` for zeros. Returns `[]` when no
|
|
18
|
+
* descendants have enriched data.
|
|
19
|
+
*/
|
|
20
|
+
export declare function aggregateHorizontalDescendantBalances(accounts: readonly HorizontalAccountRow[], childIndices: readonly number[], childrenByParent: Readonly<Record<number, readonly number[]>>): COABalance[];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.enrichProfitAndLossByClassHorizontalReport = enrichProfitAndLossByClassHorizontalReport;
|
|
4
|
+
exports.aggregateHorizontalDescendantBalances = aggregateHorizontalDescendantBalances;
|
|
4
5
|
const currencyHelper_1 = require("../../commonStateTypes/currencyHelper");
|
|
5
6
|
const horizontalSectionEmptyBalancesSlice_1 = require("./horizontalSectionEmptyBalancesSlice");
|
|
6
7
|
const profitAndLossClassesByClassHorizontalSelectorTypes_1 = require("./profitAndLossClassesByClassHorizontalSelectorTypes");
|
|
@@ -118,6 +119,50 @@ function buildHorizontalClassColumnBalancesSlice(report, classAmounts, totalAmou
|
|
|
118
119
|
},
|
|
119
120
|
};
|
|
120
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* Sum balances across descendant accounts (recursive).
|
|
124
|
+
*
|
|
125
|
+
* Parent rows in the horizontal pivot only carry their own direct postings
|
|
126
|
+
* (zero for "container" accounts), so callers rendering "Total {parent}" rows
|
|
127
|
+
* must aggregate from descendants to get the real per-class totals.
|
|
128
|
+
*
|
|
129
|
+
* Returns one `COABalance` per class column + total (same shape as the
|
|
130
|
+
* enriched `balancesInTimeframe.balances`), with `amount` summed and `type`
|
|
131
|
+
* set to `default_with_null_balance` for zeros. Returns `[]` when no
|
|
132
|
+
* descendants have enriched data.
|
|
133
|
+
*/
|
|
134
|
+
function aggregateHorizontalDescendantBalances(accounts, childIndices, childrenByParent) {
|
|
135
|
+
let template;
|
|
136
|
+
const sums = new Map();
|
|
137
|
+
const walk = (idx) => {
|
|
138
|
+
const childRow = accounts[idx];
|
|
139
|
+
const childBalances = childRow?.accountReportData?.balancesInTimeframe.balances;
|
|
140
|
+
if (childBalances != null) {
|
|
141
|
+
if (template == null) {
|
|
142
|
+
template = childBalances;
|
|
143
|
+
}
|
|
144
|
+
childBalances.forEach((b, i) => {
|
|
145
|
+
sums.set(i, (sums.get(i) ?? 0) + (b.balance.amount ?? 0));
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
// Always recurse — a missing intermediate node should not prune its
|
|
149
|
+
// descendants from the aggregate.
|
|
150
|
+
const grandChildren = childrenByParent[idx] ?? [];
|
|
151
|
+
grandChildren.forEach(walk);
|
|
152
|
+
};
|
|
153
|
+
childIndices.forEach(walk);
|
|
154
|
+
if (template == null) {
|
|
155
|
+
return [];
|
|
156
|
+
}
|
|
157
|
+
return template.map((tpl, i) => {
|
|
158
|
+
const amount = sums.get(i) ?? 0;
|
|
159
|
+
return {
|
|
160
|
+
...tpl,
|
|
161
|
+
balance: { ...tpl.balance, amount },
|
|
162
|
+
type: amount === 0 ? 'default_with_null_balance' : 'default',
|
|
163
|
+
};
|
|
164
|
+
});
|
|
165
|
+
}
|
|
121
166
|
/**
|
|
122
167
|
* Parent index per DFS row — O(n). Matches the scan in the former
|
|
123
168
|
* `findHorizontalAccountParentIndex` (depth <= 2 rows have no parent).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.44-beta0ND",
|
|
4
4
|
"description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/esm/index.js",
|