Skip to content

Fix France B2G UBL: contract DocumentType and code routage scheme 0224 - #77

Open
pmenendz wants to merge 1 commit into
mainfrom
pylon-4850
Open

Fix France B2G UBL: contract DocumentType and code routage scheme 0224#77
pmenendz wants to merge 1 commit into
mainfrom
pylon-4850

Conversation

@pmenendz

@pmenendz pmenendz commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Ref: GBL-71 · Pylon #4850

Fixes two France B2G UBL serialization bugs reported by Brevo in Pylon ticket #4850 ("UAT Bug reporting 014 — B2G specificities").

Issue 1 — Contract type dropped (ordering.go)

addOrdering emitted only the contract code (cbc:ID, BT-12) and never the contract type, so cac:ContractDocumentReference/cbc:DocumentType (the France CTC/Chorus Pro extension EXT-FR-FE-01, "type de contrat") was missing from the output.

Fix: serialize contract.Type into cbc:DocumentType.

Note: type is a GOBL cbc.Key, so it must be lower-case — uppercase values like "MARCHE" are (correctly) rejected upstream with key must match the required pattern. EXT-FR-FE-01 has no fixed code list in XP Z12-012 (free text complementing BT-12), so the value is passed through verbatim.

Issue 3 — Code routage (scheme 0224) missing (party.go)

newParty derived PartyIdentification/schemeID solely from the iso-scheme-id extension. That extension is set during normalization only by the fr/ctc addon (B2B/CIUS). The France Extended / B2G profile uses the fr/facturx addon, which is a placeholder and never sets it — so the private-id (code routage / Chorus Pro "Code Service") identity serialized without schemeID="0224", violating BR-FR-CPRO-11.

Fix: add an identitySchemeID() resolver that prefers the explicit iso-scheme-id ext and falls back to mapping the private-id key → 0224. Now the 0224 identity is emitted in both the CIUS and Extended profiles, alongside 0009 (SIRET).

Caveat: the customer's invoice must actually carry the code routage as a private-id identity. Their current output has no 0224 at all, which suggests the Chargebee→Invopop workflow isn't mapping that field yet — worth confirming alongside this fix.

Not included

Issue 2 (#ADN footnote showing escompte text instead of B2G) is not a code bug — those notes are hardcoded in Brevo's Chargebee workflow (confirmed by Álvaro in Pylon #4781). gobl.ubl serializes notes faithfully (#ADN#B2G works). It needs a workflow-config change, not a code change here.

Tests

  • TestNewOrdering/contract type maps to cbc:DocumentType
  • TestNewParty/private-id key maps to scheme 0224 without ext

Both fixes are additive (DocumentType only emitted when type is set; the 0224 fallback only fires when the ext is absent), so no existing fixtures changed. go test ./..., gofmt, and go vet all pass.

🤖 Generated with Claude Code

Serialize ordering.contracts[].type into cac:ContractDocumentReference/
cbc:DocumentType (EXT-FR-FE-01). Previously only cbc:ID (BT-12) was emitted
and the contract type was dropped entirely.

Resolve PartyIdentification schemeID for the "private-id" identity (France
code routage / Chorus Pro Code Service), mapping it to ISO 6523 scheme 0224
when the iso-scheme-id extension is absent. The France Extended/B2G profile
uses the fr/facturx placeholder addon which, unlike fr/ctc, never sets that
extension, so the 0224 identity required by BR-FR-CPRO-11 was missing from
the UBL output.

Pylon #4850

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 78.65%. Comparing base (8b92e0a) to head (658abdc).

Files with missing lines Patch % Lines
party.go 87.50% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #77      +/-   ##
==========================================
+ Coverage   78.61%   78.65%   +0.03%     
==========================================
  Files          26       26              
  Lines        1927     1935       +8     
==========================================
+ Hits         1515     1522       +7     
- Misses        296      297       +1     
  Partials      116      116              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@pmenendz
pmenendz requested a review from alvarolivie June 10, 2026 16:16
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.

2 participants