Skip to content

feat: map CompanyLegalForm to/from party registration (BT-33) - #110

Open
alvarolivie wants to merge 1 commit into
mainfrom
feat/bt33-company-legal-form
Open

feat: map CompanyLegalForm to/from party registration (BT-33)#110
alvarolivie wants to merge 1 commit into
mainfrom
feat/bt33-company-legal-form

Conversation

@alvarolivie

Copy link
Copy Markdown
Collaborator

What

Maps the UBL cac:PartyLegalEntity/cbc:CompanyLegalForm element — BT-33 "Seller additional legal information" in the EN 16931 semantic model — to and from GOBL's org.Party.Registration, for both the supplier and customer parties.

How

  • GOBL → UBL (newParty in party.go): when party.Registration.Other is set, emit it as cbc:CompanyLegalForm (creating PartyLegalEntity if needed).
  • UBL → GOBL (goblParty in party_parse.go): when cbc:CompanyLegalForm is present, populate party.registration.other.

Both the supplier and the customer flow through these shared helpers, so the mapping covers both at once ($.doc.supplier.registration and $.doc.customer.registration).

The free-text value lands in registration.other, the catch-all field of org.Registration — the natural fit for BT-33's free-text legal information.

Tests

  • Added a round-trip unit test asserting CompanyLegalForm is emitted for both supplier and customer.
  • Regenerated four parse golden files whose source XML already carried cbc:CompanyLegalForm (e.g. b2b-reg.xml"other": "SARL AU CAPITAL DE 50 000 EUROS"), confirming the UBL → GOBL direction.
  • Full suite + golangci-lint pass.

🤖 Generated with Claude Code

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>
Copilot AI review requested due to automatic review settings July 16, 2026 10:33
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 71.42857% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.88%. Comparing base (7669190) to head (b0b2c9d).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
party.go 50.00% 1 Missing and 1 partial ⚠️
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.
📢 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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 CompanyLegalForm when party.Registration.Other is set (creating PartyLegalEntity when needed).
  • UBL → GOBL: parse CompanyLegalForm into party.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.

Comment thread party_parse.go
Comment on lines +21 to +26
// BT-33: additional legal information (cbc:CompanyLegalForm)
if party.PartyLegalEntity != nil && party.PartyLegalEntity.CompanyLegalForm != nil {
p.Registration = &org.Registration{
Other: cleanString(*party.PartyLegalEntity.CompanyLegalForm),
}
}
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.

3 participants