Skip to content

Commit 8f561c8

Browse files
committed
nbb-cbso 0.7.0: datapoint labels in all four filing languages
The generator kept only the English standard label; it now emits every xml:lang under Datapoint.labels, with label staying the English entry. Regenerated the four modules from nbb-cbso-26.0.15 (byte-identical apart from the added labels). Also repairs the generator, which no longer ran after the key -> bindingKey rename.
1 parent 8859932 commit 8f561c8

10 files changed

Lines changed: 29329 additions & 16 deletions

File tree

bun.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/nbb-cbso/CHANGELOG.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
# Changelog
22

3-
## Unreleased
3+
## 0.7.0
4+
5+
### Added
6+
7+
- **Every datapoint carries its label in the four filing languages.** `Datapoint.labels` is keyed by the taxonomy's `xml:lang` (`de`, `en`, `fr`, `nl`); `label` stays the English entry. A finding can now be presented in the language the accounts are filed in rather than in English.
8+
- `NbbCbsoError` and `NbbBuildError` are exported.
49

510
### Changed
611

712
- **`NbbCbsoError` is the base class of every error the package throws.** `ExpressionError` now extends it and sets `name`; `buildNbbFiling` throws `NbbBuildError` (also an `NbbCbsoError`) instead of a plain `Error` for an unknown rubric code or a contradicted figure.
813

9-
### Added
14+
### Fixed
1015

11-
- `NbbCbsoError` and `NbbBuildError` are exported.
16+
- `scripts/generate-taxonomy.ts` ran again: a rename in the lint cleanup left one call to the old `key` helper.
1217

1318
## 0.6.1
1419

packages/nbb-cbso/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@financica/nbb-cbso",
3-
"version": "0.6.1",
3+
"version": "0.7.0",
44
"description": "Belgian annual-accounts filing for the NBB/BNB Central Balance Sheet Office: build, validate and render NBB-CBSO XBRL instance documents.",
55
"keywords": [
66
"accounting",

packages/nbb-cbso/scripts/generate-taxonomy.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,10 @@ function readTable(path: string): Axis[] {
275275
}
276276

277277
/** Reads a section's generic labels, keyed by the id they are attached to. */
278-
function readLabels(path: string): Map<string, { rubric?: string; english?: string }> {
279-
const result = new Map<string, { rubric?: string; english?: string }>();
278+
type SectionLabel = { rubric?: string; labels?: Record<string, string> };
279+
280+
function readLabels(path: string): Map<string, SectionLabel> {
281+
const result = new Map<string, SectionLabel>();
280282
if (!existsSync(path)) return result;
281283
const doc = readXml(path);
282284

@@ -316,11 +318,9 @@ function readLabels(path: string): Map<string, { rubric?: string; english?: stri
316318
const entry = result.get(target) ?? {};
317319
if (resource.role === RUBRIC_LABEL_ROLE) {
318320
entry.rubric = resource.value;
319-
} else if (
320-
resource.role === STANDARD_LABEL_ROLE &&
321-
resource.lang === "en"
322-
) {
323-
entry.english ??= resource.value;
321+
} else if (resource.role === STANDARD_LABEL_ROLE && resource.lang) {
322+
entry.labels ??= {};
323+
entry.labels[resource.lang] ??= resource.value;
324324
}
325325
result.set(target, entry);
326326
}
@@ -645,7 +645,7 @@ function mergeBindings(
645645
const anchored = new Set(Object.values(stated));
646646
return inferred.filter(
647647
(binding) =>
648-
key(binding) === wanted ||
648+
bindingKey(binding) === wanted ||
649649
(Object.keys(binding).length === Object.keys(stated).length &&
650650
Object.values(binding).every((code) => !anchored.has(code))),
651651
);
@@ -772,7 +772,8 @@ function generateModule(options: Options, model: string, part: string) {
772772
dimensions: merged,
773773
...(openDimensions.length ? { openDimensions } : {}),
774774
...(label?.rubric ? { code: label.rubric } : {}),
775-
...(label?.english ? { label: label.english } : {}),
775+
...(label?.labels?.["en"] ? { label: label.labels["en"] } : {}),
776+
...(label?.labels ? { labels: sortedRecord(label.labels) } : {}),
776777
} satisfies Datapoint);
777778
if (!existing) datapoints.push(target);
778779

@@ -1054,6 +1055,13 @@ function stripDefaultMembers(
10541055
return result;
10551056
}
10561057

1058+
/** Keys in a fixed order, so a regenerate is byte-stable. */
1059+
function sortedRecord(record: Record<string, string>): Record<string, string> {
1060+
return Object.fromEntries(
1061+
Object.entries(record).sort(([a], [b]) => a.localeCompare(b)),
1062+
);
1063+
}
1064+
10571065
function sameDimensions(a: Record<string, string>, b: Record<string, string>): boolean {
10581066
const keys = Object.keys(a);
10591067
if (keys.length !== Object.keys(b).length) return false;

0 commit comments

Comments
 (0)