Skip to content

fix: emit the buyer legal registration identifier (BT-47) - #122

Open
davidkessas-m-oi wants to merge 1 commit into
jslno:mainfrom
davidkessas-m-oi:fix/buyer-legal-registration-identifier
Open

davidkessas-m-oi wants to merge 1 commit into
jslno:mainfrom
davidkessas-m-oi:fix/buyer-legal-registration-identifier

Conversation

@davidkessas-m-oi

@davidkessas-m-oi davidkessas-m-oi commented Sep 23, 2026 •

Copy link
Copy Markdown

Problem

BT-47 (Buyer legal registration identifier, ram:BuyerTradeParty/ram:SpecifiedLegalOrganization/ram:ID) is accepted as input, validated, and then silently dropped — it never reaches the generated XML, in any profile.

The cause is a mask ↔ schema mismatch:

  • profiles/minimum/schema.ts declares the buyer's organization node and its registrationIdentifier without a key, while the seller counterparts carry key: "BT-30-00" and key: "BT-30".
  • All five masks (minimum, basic-wl, basic, en16931, extended) do reference "BT-47-00" and "BT-47".
  • applyMask resolves schema nodes by key (findFieldByKey). A key referenced by the mask but never declared in the schema resolves to undefined, so the whole node is left out of the effective schema.

The repo's own MINIMUM fixture (src/test-utils/data/minimum.ts) already sets registrationIdentifier on both parties, which makes the asymmetry visible in the current output: SellerTradeParty gets its <ram:SpecifiedLegalOrganization>, BuyerTradeParty gets only <ram:Name>.

This matters in practice for French Factur-X: for public entities (ChorusPro) the buyer identifier is a SIRET and is mandatory — the schema's own description says so. Downstream we currently patch the profile object at runtime to get BT-47 emitted at all.

Fix

Two key entries in profiles/minimum/schema.ts, mirroring the seller side. Every other profile extends MINIMUM, so this one change covers them all. Nothing else is touched — no XML shape change beyond the previously missing element, which is optional in the XSD.

Test

formatter.test.ts gets a test that builds the MINIMUM fixture and asserts both parties emit their <ram:SpecifiedLegalOrganization> ID.

  • on main: fails with expected '\n <ram:Name>Kunden AG Frankre…' to contain '<ram:ID schemeID="0002">registrationI…'
  • with the fix: passes

Full suite is green (12 → 13 tests), tsc --noEmit clean, biome check clean on both files.

Review in cubic

The buyer's `organization` node and its `registrationIdentifier` carried no
`key`, while their seller counterparts carry `BT-30-00` and `BT-30`. Every
profile mask references `BT-47-00` / `BT-47`, and `applyMask` resolves nodes
by key, so the lookup returned `undefined` and the whole node was dropped from
the effective schema: BT-47 was validated on input, then silently lost.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
node-zugferd-docs Skipped Skipped Sep 23, 2026 8:54am UTC

@pkg-pr-new

pkg-pr-new Bot commented Sep 23, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@node-zugferd/api@122
npm i https://pkg.pr.new/node-zugferd@122

commit: dd0036b

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Re-trigger cubic

This branch was previously deployed

1 inactive deployment
Preview — dd0036b0 Deployed Sep 23, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant