This page documents the data structures and functions responsible for converting trading party information between GOBL's org.Party and the CII TradePartyType. It covers both the GOBL-to-CII direction (newParty and helpers in party.go) and the CII-to-GOBL direction (goblNewParty, goblNewAddress in party_parse.go).
Party data appears in several places in a CII document: as the seller, buyer, payee, and tax representative within ApplicableHeaderTradeAgreement. The agreement-level wiring of these party roles is covered in Agreement Processing. This page focuses on how a single party record is constructed and parsed, independent of which role it fills.
The following structs model the CII TradePartyType and its nested elements.
CII Party Struct Hierarchy
Sources: party.go14-74
newPartynewParty(party *org.Party) *Party is the entry point for converting a GOBL org.Party into a CII Party. It is called from addAgreement for the seller, buyer, payee, and tax representative roles.
Conversion flow
Sources: party.go80-131
mapGOBLTaxIDScheme converts a GOBL tax.Identity scheme to the CII schemeID attribute on ram:SpecifiedTaxRegistration/ram:ID.
GOBL tax.Category | CII schemeID |
|---|---|
tax.CategoryVAT | "VA" |
| Any other | Raw scheme string |
Sources: party.go133-142
newContact(p *org.Party) *Contact assembles a Contact from the first entry in party.People. If no person is present, it falls back to the party-level telephone and email lists. The contact is returned as nil if all three fields (name, email, phone) are empty.
| CII Field | GOBL Source |
|---|---|
PersonName | People[0].Name formatted by contactName() |
Department | People[0].Role |
Phone.CompleteNumber | People[0].Telephones[0].Number or party.Telephones[0].Number |
Email.URIID | People[0].Emails[0].Address or party.Emails[0].Address |
Sources: party.go144-191
newURIUniversalCommunication(inboxes []*org.Inbox) maps the first inbox entry to a URIUniversalCommunication. The SchemeIDEmail constant ("EM") is used when the inbox contains an email address.
| Inbox field populated | CII URIID.SchemeID | CII URIID.Value |
|---|---|---|
Email | "EM" | email address |
Code | Inbox.Scheme | Inbox.Code |
Sources: party.go76-77 party.go193-214
When the GOBL party carries the choruspro.ExtKeyScheme extension, newParty creates a LegalOrganization and populates its ID.SchemeID from the extension value. The ID.Value is then filled from the party's TaxID (if present) or from an identity of type fr.IdentityTypeSIRET.
Sources: party.go91-127
goblNewPartygoblNewParty(party *Party) *org.Party reconstructs a GOBL org.Party from a CII Party struct.
Parse flow
Sources: party_parse.go11-109
The parser handles two schemeID values on SpecifiedTaxRegistration/ID:
CII schemeID | GOBL output |
|---|---|
"VA" | p.TaxID via tax.ParseIdentity(); fallback constructs tax.Identity with country from PostalTradeAddress |
"FC" | Appended to p.Identities as org.Identity with Country from PostalTradeAddress |
| Other | Ignored |
Sources: party_parse.go65-93
The GlobalID field (used for GLN and similar scheme-qualified identifiers) is mapped to a GOBL org.Identity with the scheme stored in the iso.ExtKeySchemeID extension key rather than directly in a typed field.
CII: ram:GlobalID schemeID="0088" → 3456789012098
GOBL: org.Identity{ Code: "3456789012098", Ext: { iso-scheme-id: "0088" } }
Sources: party_parse.go96-106
goblNewAddressgoblNewAddress(address *PostalTradeAddress) *org.Address maps the flat CII address fields to a GOBL org.Address.
| CII Field | GOBL Field |
|---|---|
CountryID | Country (l10n.ISOCountryCode) |
LineOne | Street |
LineTwo | StreetExtra |
City | Locality |
Postcode | Code |
Region | Region |
Sources: party_parse.go111-141
The following diagram shows the complete bidirectional mapping between GOBL org.Party and the CII Party struct, with the functions that perform each direction.
Bidirectional Party Field Mapping
Sources: party.go80-214 party_parse.go11-141
| Constant | Value | Purpose |
|---|---|---|
SchemeIDEmail | "EM" | schemeID for email-based URIUniversalCommunication |
Sources: party.go77
newParty results are wired into the seller, buyer, payee, and tax representative roles within ApplicableHeaderTradeAgreement.choruspro.ExtKeyScheme, SIRET identity handling, and the fr-choruspro-scheme extension in depth.mapGOBLTaxIDScheme output values and iso.ExtKeySchemeID alongside other code tables.Refresh this wiki