feat: map CompanyLegalForm to/from party registration (BT-33) - #110
feat: map CompanyLegalForm to/from party registration (BT-33)#110alvarolivie wants to merge 1 commit into
Conversation
Map the UBL PartyLegalEntity/cbc:CompanyLegalForm element (BT-33, "Seller additional legal information") to and from GOBL's org.Party.Registration for both the supplier and customer parties. Since both parties flow through the shared newParty / goblParty helpers, mapping there covers supplier and customer at once. The free-text legal form is stored in registration.other, the catch-all field of org.Registration. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #110 +/- ##
==========================================
- Coverage 80.91% 80.88% -0.04%
==========================================
Files 28 28
Lines 2117 2124 +7
==========================================
+ Hits 1713 1718 +5
- Misses 267 268 +1
- Partials 137 138 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds bidirectional mapping between EN 16931 BT-33 (“Seller additional legal information”) and GOBL party registration data by writing/reading UBL cac:PartyLegalEntity/cbc:CompanyLegalForm via org.Party.Registration.Other. This mapping is implemented in the shared party helpers, so it applies to both supplier and customer parties.
Changes:
- GOBL → UBL: emit
CompanyLegalFormwhenparty.Registration.Otheris set (creatingPartyLegalEntitywhen needed). - UBL → GOBL: parse
CompanyLegalFormintoparty.registration.other. - Update unit tests and regenerate affected parse golden outputs to reflect the new field.
Reviewed changes
Copilot reviewed 3 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| party.go | Emit cbc:CompanyLegalForm from party.Registration.Other during UBL generation. |
| party_parse.go | Parse cbc:CompanyLegalForm into org.Party.Registration.Other. |
| party_test.go | Add a unit test asserting supplier/customer CompanyLegalForm emission. |
| test/data/parse/peppol/out/Vat-category-S.json | Golden update: parsed registration.other now includes AdditionalLegalInformation. |
| test/data/parse/peppol/out/Allowance-example.json | Golden update: parsed registration.other now includes AdditionalLegalInformation. |
| test/data/parse/france-cius/out/b2b-reg.json | Golden update: parsed registration.other now includes the legal-form string. |
| test/data/parse/en16931/out/ubl-example5.json | Golden update: parsed registration.other now includes Export. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // BT-33: additional legal information (cbc:CompanyLegalForm) | ||
| if party.PartyLegalEntity != nil && party.PartyLegalEntity.CompanyLegalForm != nil { | ||
| p.Registration = &org.Registration{ | ||
| Other: cleanString(*party.PartyLegalEntity.CompanyLegalForm), | ||
| } | ||
| } |
What
Maps the UBL
cac:PartyLegalEntity/cbc:CompanyLegalFormelement — BT-33 "Seller additional legal information" in the EN 16931 semantic model — to and from GOBL'sorg.Party.Registration, for both the supplier and customer parties.How
newPartyinparty.go): whenparty.Registration.Otheris set, emit it ascbc:CompanyLegalForm(creatingPartyLegalEntityif needed).goblPartyinparty_parse.go): whencbc:CompanyLegalFormis present, populateparty.registration.other.Both the supplier and the customer flow through these shared helpers, so the mapping covers both at once (
$.doc.supplier.registrationand$.doc.customer.registration).The free-text value lands in
registration.other, the catch-all field oforg.Registration— the natural fit for BT-33's free-text legal information.Tests
CompanyLegalFormis emitted for both supplier and customer.parsegolden files whose source XML already carriedcbc:CompanyLegalForm(e.g.b2b-reg.xml→"other": "SARL AU CAPITAL DE 50 000 EUROS"), confirming the UBL → GOBL direction.golangci-lintpass.🤖 Generated with Claude Code