@zeniai/client-epic-state 4.20.1-beta11ND → 4.20.1
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 +1 -2
- package/lib/esm/view/profitAndLossClassesView/profitAndLossHorizontalEnrichment.js +28 -20
- package/lib/index.d.ts +1 -2
- package/lib/index.js +25 -27
- package/lib/tsconfig.typecheck.tsbuildinfo +1 -1
- package/lib/view/profitAndLossClassesView/profitAndLossHorizontalEnrichment.js +28 -20
- package/package.json +1 -1
- package/lib/esm/view/profitAndLossClassesView/horizontalSectionEmptyBalancesSlice.js +0 -17
- package/lib/view/profitAndLossClassesView/horizontalSectionEmptyBalancesSlice.d.ts +0 -9
- package/lib/view/profitAndLossClassesView/horizontalSectionEmptyBalancesSlice.js +0 -20
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.enrichProfitAndLossByClassHorizontalReport = enrichProfitAndLossByClassHorizontalReport;
|
|
4
4
|
const currencyHelper_1 = require("../../commonStateTypes/currencyHelper");
|
|
5
|
-
const horizontalSectionEmptyBalancesSlice_1 = require("./horizontalSectionEmptyBalancesSlice");
|
|
6
5
|
const profitAndLossClassesByClassHorizontalSelectorTypes_1 = require("./profitAndLossClassesByClassHorizontalSelectorTypes");
|
|
7
6
|
/**
|
|
8
7
|
* Populates `sectionHeaderBalancesSlice`, and per-account `accountReportData`, so the
|
|
@@ -43,17 +42,17 @@ function enrichHorizontalSection(report, section) {
|
|
|
43
42
|
};
|
|
44
43
|
const siblingsPerRow = buildSiblingIndicesPerRow(section.accounts, parentIndices);
|
|
45
44
|
const hasChildFlags = computeHorizontalHasChildFlags(parentIndices);
|
|
46
|
-
for (let
|
|
47
|
-
const row = section.accounts[
|
|
45
|
+
for (let i = 0; i < section.accounts.length; i++) {
|
|
46
|
+
const row = section.accounts[i];
|
|
48
47
|
// Same column order as `report.classColumns` (see `pivotSectionToHorizontal`).
|
|
49
|
-
const classRowAmounts = row.classBalances.map((
|
|
48
|
+
const classRowAmounts = row.classBalances.map((b) => b.balance.amount);
|
|
50
49
|
row.accountReportData = {
|
|
51
50
|
accountId: row.accountId,
|
|
52
51
|
accountName: row.accountName,
|
|
53
52
|
accountType: row.accountType,
|
|
54
53
|
depth: row.depth,
|
|
55
54
|
balancesInTimeframe: buildHorizontalClassColumnBalancesSlice(report, classRowAmounts, row.rowTotal.amount),
|
|
56
|
-
horizontalTreeView: buildHorizontalTreeViewFromPrecomputed(section.accounts,
|
|
55
|
+
horizontalTreeView: buildHorizontalTreeViewFromPrecomputed(section.accounts, i, parentIndices, siblingsPerRow, hasChildFlags),
|
|
57
56
|
};
|
|
58
57
|
}
|
|
59
58
|
}
|
|
@@ -71,14 +70,23 @@ function buildHorizontalClassColumnBalancesSlice(report, classAmounts, totalAmou
|
|
|
71
70
|
const currencyCode = firstHeader?.balance.currencyCode ?? fallback.currencyCode;
|
|
72
71
|
const currencySymbol = firstHeader?.balance.currencySymbol ?? fallback.currencySymbol;
|
|
73
72
|
const timeframe = firstHeader?.balanceTimeFrame ?? 'month';
|
|
74
|
-
const emptySlice =
|
|
73
|
+
const emptySlice = {
|
|
74
|
+
balances: [],
|
|
75
|
+
additionalBalances: [],
|
|
76
|
+
filter: {
|
|
77
|
+
firstMonthOfFY: report.firstMonthOfFY,
|
|
78
|
+
timeframe,
|
|
79
|
+
balancesRange: { numberOfPeriods: 0, orderBy: 'ascending_date' },
|
|
80
|
+
additionalBalances: [],
|
|
81
|
+
},
|
|
82
|
+
};
|
|
75
83
|
if (report.selectedPeriod == null) {
|
|
76
84
|
return emptySlice;
|
|
77
85
|
}
|
|
78
86
|
const { startDate, endDate } = report.selectedPeriod;
|
|
79
|
-
const balances = report.classColumns.map((col,
|
|
87
|
+
const balances = report.classColumns.map((col, i) => ({
|
|
80
88
|
balance: {
|
|
81
|
-
amount: classAmounts[
|
|
89
|
+
amount: classAmounts[i] ?? 0,
|
|
82
90
|
currencyCode,
|
|
83
91
|
currencySymbol,
|
|
84
92
|
},
|
|
@@ -129,22 +137,22 @@ function computeHorizontalAccountParentIndices(rows) {
|
|
|
129
137
|
if (accountRow == null) {
|
|
130
138
|
continue;
|
|
131
139
|
}
|
|
132
|
-
const
|
|
140
|
+
const d = accountRow.depth;
|
|
133
141
|
while (stack.length > 0) {
|
|
134
142
|
const topRow = rows[stack[stack.length - 1]];
|
|
135
143
|
if (topRow == null) {
|
|
136
144
|
stack.pop();
|
|
137
145
|
continue;
|
|
138
146
|
}
|
|
139
|
-
if (topRow.depth <
|
|
147
|
+
if (topRow.depth < d) {
|
|
140
148
|
break;
|
|
141
149
|
}
|
|
142
150
|
stack.pop();
|
|
143
151
|
}
|
|
144
|
-
if (
|
|
152
|
+
if (d > 2 && stack.length > 0) {
|
|
145
153
|
const peek = stack[stack.length - 1];
|
|
146
154
|
const parentRow = rows[peek];
|
|
147
|
-
if (parentRow != null && parentRow.depth ===
|
|
155
|
+
if (parentRow != null && parentRow.depth === d - 1) {
|
|
148
156
|
parentIndex[rowIndex] = peek;
|
|
149
157
|
}
|
|
150
158
|
}
|
|
@@ -163,12 +171,12 @@ function buildSiblingIndicesPerRow(rows, parentIndices) {
|
|
|
163
171
|
continue;
|
|
164
172
|
}
|
|
165
173
|
const key = `${parentRowIndex}:${accountRow.depth}`;
|
|
166
|
-
let
|
|
167
|
-
if (
|
|
168
|
-
|
|
169
|
-
keyToIndices.set(key,
|
|
174
|
+
let g = keyToIndices.get(key);
|
|
175
|
+
if (g == null) {
|
|
176
|
+
g = [];
|
|
177
|
+
keyToIndices.set(key, g);
|
|
170
178
|
}
|
|
171
|
-
|
|
179
|
+
g.push(rowIndex);
|
|
172
180
|
}
|
|
173
181
|
const siblingsPerRow = new Array(accountRowCount);
|
|
174
182
|
for (let rowIndex = 0; rowIndex < accountRowCount; rowIndex++) {
|
|
@@ -236,14 +244,14 @@ function buildHorizontalTreeViewFromPrecomputed(dfsOrderedAccountRows, currentRo
|
|
|
236
244
|
const hasChildrenFlag = hasChildFlags[currentRowIndex];
|
|
237
245
|
const treeDepth = accountRow != null ? Math.max(0, accountRow.depth - 2) : 0;
|
|
238
246
|
const hasChildren = hasChildrenFlag === true;
|
|
239
|
-
const
|
|
247
|
+
const sibs = siblingIndices ?? [currentRowIndex];
|
|
240
248
|
return {
|
|
241
249
|
subAccountAncestorMetadata: buildHorizontalSubAccountAncestorMetadataFromPrecomputed(dfsOrderedAccountRows, currentRowIndex, parentIndices, siblingsPerRow, hasChildFlags),
|
|
242
250
|
treeDepth,
|
|
243
251
|
hasChildren,
|
|
244
|
-
hasSiblings:
|
|
252
|
+
hasSiblings: sibs.length > 1,
|
|
245
253
|
isLeaf: !hasChildren,
|
|
246
|
-
isLastNode: currentRowIndex ===
|
|
254
|
+
isLastNode: currentRowIndex === sibs[sibs.length - 1],
|
|
247
255
|
};
|
|
248
256
|
}
|
|
249
257
|
function buildHorizontalAccountChildIndicesByParent(parentIndices) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "4.20.1
|
|
3
|
+
"version": "4.20.1",
|
|
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",
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Empty `COABalancesSlice` for horizontal P&L-by-class section / calculated headers when
|
|
3
|
-
* enrichment has not produced balances yet, or for UI mapping fallbacks.
|
|
4
|
-
* Structure matches {@link enrichProfitAndLossByClassHorizontalReport} output.
|
|
5
|
-
*/
|
|
6
|
-
export function getEmptyHorizontalSectionBalancesSlice(firstMonthOfFY, timeframe = 'month') {
|
|
7
|
-
return {
|
|
8
|
-
balances: [],
|
|
9
|
-
additionalBalances: [],
|
|
10
|
-
filter: {
|
|
11
|
-
firstMonthOfFY,
|
|
12
|
-
timeframe,
|
|
13
|
-
balancesRange: { numberOfPeriods: 0, orderBy: 'ascending_date' },
|
|
14
|
-
additionalBalances: [],
|
|
15
|
-
},
|
|
16
|
-
};
|
|
17
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
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;
|
|
@@ -1,20 +0,0 @@
|
|
|
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
|
-
}
|