feat: map party electronic address via the endpoint object - #111
Open
alvarolivie wants to merge 3 commits into
Open
feat: map party electronic address via the endpoint object#111alvarolivie wants to merge 3 commits into
alvarolivie wants to merge 3 commits into
Conversation
Read and write the UBL cbc:EndpointID from org.Party.Endpoints (the org.Endpoint URI) instead of the deprecated org.Party.Inboxes. - Serialize: newEndpointID reads the party's first endpoint and maps "mailto:<addr>" -> schemeID "EM", and "iso6523-actorid-upis::<scheme>:<code>" -> schemeID "<scheme>". - Parse: goblEndpoint writes the inverse as an org.Endpoint URI. Convert fixtures gain endpoints migrated from their inboxes so the generated UBL stays byte-identical (no golden XML changes). Four France fixtures carried stale endpoints (schemeID 9957) that disagreed with both their inbox and the validated golden (schemeID 0225, added later alongside the APP-546 French validation work); these are reconciled to 0225 to preserve the reviewed output. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Parsed party inboxes become endpoints, and the envelope head gains the from/to routing now derivable from those endpoints. Mechanically regenerated with `go test -run TestParseInvoice -update`. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the UBL party electronic address mapping to use GOBL’s org.Party.Endpoints (URI-based) for UBL cbc:EndpointID serialization/parsing, replacing the legacy inbox-based approach and updating fixture expectations accordingly.
Changes:
- Serialize UBL
cbc:EndpointIDfromparty.FirstEndpoint()(URI forms:mailto:andiso6523-actorid-upis::). - Parse UBL
cbc:EndpointIDintoorg.Party.Endpointsvia a newgoblEndpointmapper. - Regenerate/adjust parse and convert fixtures to reflect endpoints and envelope
head.from/head.torouting.
Reviewed changes
Copilot reviewed 15 out of 36 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| party.go | Serialize cbc:EndpointID from the party’s first endpoint URI; adds endpoint URI scheme constants and parsing helper. |
| party_parse.go | Parse cbc:EndpointID into org.Party.Endpoints (URI form) via goblEndpoint. |
| party_parse_test.go | Updates party parsing assertions to validate endpoints URIs instead of inbox fields. |
| test/data/parse/peppol/out/vat-category-Z.json | Updates parsed party addressing from inboxes to endpoints; adds envelope from/to. |
| test/data/parse/peppol/out/Vat-category-S.json | Updates parsed party addressing from inboxes to endpoints; adds envelope from/to. |
| test/data/parse/peppol/out/vat-category-O.json | Updates parsed party addressing from inboxes to endpoints; adds envelope from/to. |
| test/data/parse/peppol/out/vat-category-O-invalid-bytes.json | Updates parsed party addressing from inboxes to endpoints; adds envelope from/to. |
| test/data/parse/peppol/out/vat-category-E.json | Updates parsed party addressing from inboxes to endpoints; adds envelope from/to. |
| test/data/parse/peppol/out/sg-invoice.json | Updates parsed party addressing from inboxes to endpoints; adds envelope from/to. |
| test/data/parse/peppol/out/self-billed-invoice.json | Updates parsed party addressing from inboxes to endpoints; adds envelope from/to. |
| test/data/parse/peppol/out/self-billed-creditnote.json | Updates parsed party addressing from inboxes to endpoints; adds envelope from/to. |
| test/data/parse/peppol/out/sales-order-example.json | Updates parsed party addressing from inboxes to endpoints; adds envelope from/to. |
| test/data/parse/peppol/out/proforma-invoice.json | Updates parsed party addressing from inboxes to endpoints; adds envelope from/to. |
| test/data/parse/peppol/out/partial-invoice.json | Updates parsed party addressing from inboxes to endpoints; adds envelope from/to. |
| test/data/parse/peppol/out/nbio-stuck-ubl.json | Updates parsed party addressing from inboxes to endpoints; adds envelope from/to. |
| test/data/parse/peppol/out/invoice-peppol.json | Updates parsed party addressing from inboxes to endpoints; adds envelope from/to. |
| test/data/parse/peppol/out/example-encoding.json | Updates parsed party addressing from inboxes to endpoints; adds envelope from/to. |
| test/data/parse/peppol/out/base-negative-inv-correction.json | Updates parsed party addressing from inboxes to endpoints; adds envelope from/to. |
| test/data/parse/peppol/out/base-example.json | Updates parsed party addressing from inboxes to endpoints; adds envelope from/to. |
| test/data/parse/peppol/out/base-creditnote-correction.json | Updates parsed party addressing from inboxes to endpoints; adds envelope from/to. |
| test/data/parse/peppol/out/Allowance-example.json | Updates parsed party addressing from inboxes to endpoints; adds envelope from/to. |
| test/data/parse/france-cius/out/b2b-reg.json | Removes parsed inboxes in favor of endpoints (and aligns routing). |
| test/data/parse/en16931/out/ubl-example5.json | Switches parsed email inboxes to mailto: endpoints; adds envelope routing. |
| test/data/parse/en16931/out/ubl-example2.json | Switches parsed email inboxes to mailto: endpoints. |
| test/data/convert/xrechnung/invoice-xr-minimal.json | Adds endpoint URIs to parties to keep wire output stable while moving off inboxes. |
| test/data/convert/xrechnung/invoice-due-date-with-notes.json | Adds endpoint URIs to parties to keep wire output stable while moving off inboxes. |
| test/data/convert/xrechnung/credit-note-xr.json | Adds endpoint URIs to parties to keep wire output stable while moving off inboxes. |
| test/data/convert/peppol/invoice-intra-comunity.json | Adds Peppol participant endpoint URI to keep wire output stable while moving off inboxes. |
| test/data/convert/invoice-complete.json | Adds mailto: endpoint URI to keep wire output stable while moving off inboxes. |
| test/data/convert/invoice-attachments.json | Adds mailto: endpoint URI to keep wire output stable while moving off inboxes. |
| test/data/convert/france-extended/invoice-fr-extended.json | Reconciles France endpoint scheme in endpoint URIs (and keeps inbox scheme aligned). |
| test/data/convert/france-extended/invoice-fr-extended-detailed.json | Reconciles France endpoint scheme in endpoint URIs (and keeps inbox scheme aligned). |
| test/data/convert/france-cius/invoice-fr-cius.json | Reconciles France endpoint scheme in endpoint URI (and keeps inbox scheme aligned). |
| test/data/convert/france-cius/credit-note-fr.json | Reconciles France endpoint scheme in endpoint URI (and keeps inbox scheme aligned). |
| test/data/convert/en16931/invoice-complete.json | Adds mailto: endpoint URI to keep wire output stable while moving off inboxes. |
| test/data/convert/en16931/invoice-attachments.json | Adds mailto: endpoint URI to keep wire output stable while moving off inboxes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+78
to
+87
| if eID == nil || eID.Value == "" || eID.SchemeID == "" { | ||
| return nil | ||
| } | ||
| var uri cbc.URI | ||
| switch eID.SchemeID { | ||
| case SchemeIDEmail: // email | ||
| uri = cbc.URI(mailtoScheme + ":" + eID.Value) | ||
| default: | ||
| uri = cbc.URI(peppolEndpointScheme + "::" + eID.SchemeID + ":" + eID.Value) | ||
| } |
The envelope head from/to routing in the France fixtures still pointed at the same participants via the stale schemeID 9957; move them to 0225 to match the reconciled party endpoints. No output change (goldens are untouched). 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 #111 +/- ##
==========================================
- Coverage 81.05% 81.01% -0.05%
==========================================
Files 28 28
Lines 2143 2154 +11
==========================================
+ Hits 1737 1745 +8
- Misses 268 270 +2
- Partials 138 139 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Comment on lines
+60
to
+76
| func newEndpointID(party *org.Party) *EndpointID { | ||
| ep := party.FirstEndpoint() | ||
| if ep == nil { | ||
| return nil | ||
| } | ||
| switch ep.URI.Scheme() { | ||
| case mailtoScheme: | ||
| if addr := ep.URI.Opaque(); addr != "" { | ||
| return &EndpointID{SchemeID: SchemeIDEmail, Value: addr} | ||
| } | ||
| case peppolEndpointScheme: | ||
| if scheme, code, ok := splitPeppolEndpoint(ep.URI.Opaque()); ok { | ||
| return &EndpointID{SchemeID: scheme, Value: code} | ||
| } | ||
| } | ||
| return nil | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Map the UBL
cbc:EndpointID(BT-34 / BT-49, the party's electronicaddress) to and from GOBL's
org.Party.Endpoints— theorg.EndpointURI — instead of the deprecated
org.Party.Inboxes.Mapping
EndpointIDmailto:<address>schemeID="EM"value<address>iso6523-actorid-upis::<scheme>:<code>schemeID="<scheme>"value<code>This matches the URI convention GOBL's
eu/en16931addon uses when itnormalizes Peppol inboxes into endpoints, extended to email (
mailto:).newEndpointIDreadsparty.FirstEndpoint().goblEndpointwrites the inverse as anorg.Endpoint.Test data
supplier/customer fixture gains an
endpointcarrying exactly thevalue the old inbox-based serializer emitted, so switching the source
is a no-op on the wire.
france-cius/{credit-note-fr,invoice-fr-cius},france-extended/invoice-fr-extended{,-detailed}) carried a staleendpoint
schemeID="9957"that disagreed with both their inbox andthe committed golden (
schemeID="0225"). The0225value is newer —it arrived with the APP-546 French-validation work, after the
9957endpoints — so I reconciled the endpoints to
0225to keep thereviewed output. Please confirm
0225is the intended French EASscheme; if
9957is correct instead, it's a one-line fixture changeplus a golden regen.
become endpoints, and the envelope head gains the
from/toroutingnow derivable from the endpoints.
Notes
Depends on GOBL's endpoint model; new builds normalized through the
en16931addon already carry endpoints. Paired with the equivalentchange in
gobl.cii.🤖 Generated with Claude Code