ubl

package module
v0.103.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 34 Imported by: 7 modules, 3 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

GOBL.UBL

GOBL conversion into UBL XML format and vice versa.

codecov Ask DeepWiki

Copyright Invopop Ltd. 2025. Released publicly under the Apache License Version 2.0. For commercial licenses, please contact the dev team at invopop. To accept contributions to this library, we require transferring copyrights to Invopop Ltd.

Usage

Go Package

Usage of the GOBL to UBL conversion library is straightforward and supports bidirectional conversion:

  1. Convert GOBL to UBL XML: You must first have a GOBL Envelope, including an invoice, ready to convert. There are some samples in the test/data directory.

  2. Parse UBL XML into GOBL: You need to have a valid UBL XML document that you want to convert to GOBL format.

Both conversion directions are supported, allowing you to seamlessly transform between GOBL and UBL XML formats as needed.

The package uses the same terms as GOBL's convert package: export maps a GOBL envelope into a UBL document and import maps it back, while encode and decode turn UBL documents into XML bytes and back.

Export GOBL to UBL
package main

import (
    "os"

    "github.com/invopop/gobl"
    ubl "github.com/invopop/gobl.ubl"
)

func main() {
    data, _ := os.ReadFile("./test/data/invoice-sample.json")

    env := new(gobl.Envelope)
    if err := json.Unmarshal(data, env); err != nil {
        panic(err)
    }

    // Export the UBL document
    doc, err := ubl.Export(env)
    if err != nil {
        panic(err)
    }

    // Encode the XML output
    out, err := ubl.Encode(doc)
    if err != nil {
        panic(err)
    }

}

To export into a format other than the default EN 16931, add it as an option. ExportInvoice does the same when an invoice is expected. For example, with the Peppol BIS 3 format from gobl.peppol (peppolubl "github.com/invopop/gobl.peppol/ubl"):

doc, err := ubl.ExportInvoice(env, ubl.WithFormat(peppolubl.FormatBIS))

To embed files in an invoice, such as a PDF version of it, add them with WithAttachments. Each is written as an AdditionalDocumentReference with an EmbeddedDocumentBinaryObject. Other documents, such as Invoice Responses, cannot embed files and return ErrUnsupportedAttachments:

doc, err := ubl.Export(env,
    ubl.WithFormat(peppolubl.FormatBIS),
    ubl.WithAttachments(ubl.BinaryAttachment{
        ID:          "INV-001-PDF",
        Description: "Invoice INV-001",
        Data:        pdf,
        MimeCode:    "application/pdf",
        Filename:    "INV-001.pdf",
    }),
)

Through the GOBL convert register, pass them with convert.WithAttachments. Every UBL format embeds them, using the attachment's name as its ID when it has none. The ubl+peppol+bis-v3 format below is registered by importing gobl.peppol:

out, err := convert.Export(env, "ubl+peppol+bis-v3", convert.WithAttachments(&convert.Attachment{
    Name: "INV-001.pdf",
    MIME: "application/pdf",
    Data: pdf,
}))
Formats

This package provides the base UBL import and export, and the format that applies in any country:

Key Format
ubl+en16931-v2017 FormatEN16931

A format lists the GOBL schemas it imports into and exports from in Import and Export. Formats without Import schemas are export-only and never detected, as is needed for formats whose documents only differ from another format's by their container.

A format can write documents for more than one specification, choosing from the GOBL document. Its own CustomizationID, ProfileID, Addons and VESIDs define its main specification, and Specifications lists the others, each with an Applies function. On export, the first specification that applies to the document is used, or else the main one; SpecificationFor and VESID provide them for a document. Every specification's identifiers are recognised on import. The GOBL convert register only exports documents that include the addons of the specification they are exported with, and otherwise refuses them with a fault on $addons, such as UBL-PEPPOL-BIS-V3-BILL-INVOICE-01. For example, the Peppol BIS 3 format in gobl.peppol writes invoices with Peppol BIS Billing 3.0, self-billed invoices with Peppol BIS Self-Billing 3.0, and statuses with Peppol Invoice Response 3.

The base import and export have no format-specific behavior. A format adds the rules of its specification with ExportFuncs and ImportFuncs, which adjust the finished document in order: an export function receives the GOBL envelope and the exported UBL document, and an import function the UBL document and the imported envelope, before it is calculated. InvoiceParties lists each GOBL party alongside its UBL party, for rules that apply to every party. Formats that allow sub-invoice lines, such as EXTENDED-CTC-FR, set SubLines: line breakdowns are then written as sub-invoice lines, and read back from the line billing references that name the invoice itself.

Regional and network formats live in their own modules, which register them with ubl.RegisterFormats when imported, making them available to FindFormat, Import, and the GOBL convert register. Without them, documents of these formats are still imported as generic UBL:

Key Module
ubl+peppol+bis-v3, ubl+peppol+pint-v1, ubl+peppol+pint+aunz-v1 gobl.peppol (_ "github.com/invopop/gobl.peppol/ubl")
ubl+fr-ctc-cius-v1, ubl+fr-ctc-extended-v1 gobl.fr.ctc (_ "github.com/invopop/gobl.fr.ctc/ubl")
ubl+sa-zatca-v1 gobl.sa.zatca (_ "github.com/invopop/gobl.sa.zatca/ubl")
ubl+de-xrechnung-v3 gobl.de.xinvoice
Import UBL to GOBL
package main

import (
    "encoding/json"
    "os"

    ubl "github.com/invopop/gobl.ubl"
)

func main() {
    // Read the UBL XML file
    inData, err := os.ReadFile("path/to/ubl_invoice.xml")
    if err != nil {
        panic(err)
    }

    // Decode the UBL document
    doc, err := ubl.Decode(inData)
    if err != nil {
        panic(err)
    }

    // Import into a GOBL envelope
    env, err := ubl.Import(doc)
    if err != nil {
        panic(err)
    }

    // Extract binary attachments if needed
    if inv, ok := doc.(*ubl.Invoice); ok {
        attachments := inv.ExtractBinaryAttachments()
    }

    // Marshal to JSON
    outputData, err := json.MarshalIndent(env, "", "  ")
    if err != nil {
        panic(err)
    }
}

Through the GOBL convert register, convert.Import returns the files embedded in an invoice as Attachments, alongside the envelope:

res, err := convert.Import(data)
for _, a := range res.Attachments {
    // store a.Data as a.Name
}

Command Line

This package no longer includes a command-line tool. The gobl CLI from gobl.dev converts between GOBL and every format registered with the GOBL convert register, including UBL:

go install github.com/invopop/gobl.dev/cmd/gobl@latest

gobl convert invoice.json invoice.xml --to ubl+en16931-v2017   # export
gobl convert invoice.xml                                       # import, format detected
gobl convert --list                                            # registered formats

Testing

testify

The library uses testify for testing. To run the tests, you can use the following command:

go test ./...
Schematron validation

Beyond the golden-file comparisons, the generated XML can be pushed through the real EN 16931 schematron rule sets. Validation runs against phorm, the standalone validation service that replaced the now-archived invopop/phive gRPC wrapper, using the invopop/phorm HTTP client.

Start a service locally:

docker run -d --name phorm -p 8080:8080 phelger/phorm

Use phelger/phorm-arm64 on Apple Silicon. Note the image is phelger/phorm, not phax/phorm — the latter does not exist, despite what the invopop/phorm README says.

It takes a few seconds to boot. It is ready once this returns HTTP 200:

curl -s -o /dev/null -w '%{http_code}\n' \
  -H 'X-Token: phorm-dev-token' \
  'http://localhost:8080/api/get/vesids?include-deprecated=true'

Then run the suite with -validate:

go test ./... -validate

Without -validate the validating tests are skipped, so the plain go test ./... never needs a service and CI stays offline.

Pointing somewhere else

PHORM_URL and PHORM_TOKEN default to http://localhost:8080 and phorm's stock development token. Override them for a shared instance, or when port 8080 is already taken locally:

docker run -d --name phorm -p 8085:8080 phelger/phorm
PHORM_URL=http://localhost:8085 go test ./... -validate
Known failures

No fixture is currently known to fail. The Peppol rule sets are validated in gobl.peppol, which owns the Peppol formats.

Notes
  • A failed validation is not an error. phorm answers a document that breaks a rule with an HTTP 400 carrying the report, which it also uses for a request it rejects outright, so invopop/phorm separates the two by whether the body is a validation report (fixed in v0.1.5). An error from ValidateXml therefore means the validation never ran — unreachable service, rejected token, unresolvable VESID, or a body that is not XML — and the tests treat it as fatal, since nothing was checked.
  • phorm normalises VESID versions, so a spelling such as fr.ctc:ubl-invoice:1.4.0-03 resolves to its published fr.ctc:ubl-invoice:1.4-03 rule set. The resolved id comes back as ves.vesid, which is worth checking when a rule set behaves unexpectedly.
  • phive-rules keeps only a rolling window of releases. VESIDs that pass today are dropped a few releases later, so the VESIDs in format.go need periodic updating; GET /api/get/vesids?include-deprecated=true lists what a given phorm build actually carries, along with a deprecated flag.

Considerations

There are certain assumptions and lost information in the conversion from UBL to GOBL that should be considered:

  1. GOBL does not currently support additional embedded documents, so the AdditionalReferencedDocument field (BG-24 in EN 16931) is not supported and lost in the conversion.
  2. GOBL only supports a single period in the ordering, so only the first InvoicePeriod (BG-14) in the UBL is taken.
  3. Fields ProfileID (BT-23) and CustomizationID (BT-24) in UBL are not supported and lost in the conversion.
  4. The AccountingCost (BT-19, BT-133) fields are added as notes.
  5. Payment advances do not include their own tax rate, they use the global tax rate of the invoice.

Development

The main source of information for this project comes from the EN 16931 standard, developed by the EU for electronic invoicing. Part 1 of the standard defines the semantic data model that forms an invoice, but does not provide a concrete implementation. Part 3.2 defines the mappings from the semantic data model to the UBL 2.1 XML format covered in this repository.

Useful links:

Documentation

Overview

Package ubl helps convert GOBL into UBL documents and vice versa.

Index

Constants

View Source
const (
	NamespaceCBC  = "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
	NamespaceCAC  = "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
	NamespaceQDT  = "urn:oasis:names:specification:ubl:schema:xsd:QualifiedDataTypes-2"
	NamespaceUDT  = "urn:oasis:names:specification:ubl:schema:xsd:UnqualifiedDataTypes-2"
	NamespaceEXT  = "urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2"
	NamespaceCCTS = "urn:un:unece:uncefact:documentation:2"
	NamespaceSIG  = "urn:oasis:names:specification:ubl:schema:xsd:CommonSignatureComponents-2"
	NamespaceSAC  = "urn:oasis:names:specification:ubl:schema:xsd:SignatureAggregateComponents-2"
	NamespaceSBC  = "urn:oasis:names:specification:ubl:schema:xsd:SignatureBasicComponents-2"
	NamespaceXSI  = "http://www.w3.org/2001/XMLSchema-instance"
)

UBL schema constants

View Source
const (
	NamespaceUBLInvoice    = "urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"
	NamespaceUBLCreditNote = "urn:oasis:names:specification:ubl:schema:xsd:CreditNote-2"
)

Main UBL Invoice Namespace

View Source
const (
	SchemaLocationInvoice     = "" /* 128-byte string literal not displayed */
	SchemaLocationCrediteNote = "" /* 135-byte string literal not displayed */
)

Schema locationa and customization constants

View Source
const (
	SignatureInformationID = "urn:oasis:names:specification:ubl:signature:1"
	ReferenceSignatureID   = "urn:oasis:names:specification:ubl:signature:Invoice"
	SignatureMethod        = "urn:oasis:names:specification:ubl:dsig:enveloped:xades"
)

UBL signature constants.

View Source
const KeyUBL cbc.Key = "ubl"

KeyUBL identifies UBL documents that do not declare a known specification. They can be imported, but not exported.

View Source
const NamespaceUBLApplicationResponse = "urn:oasis:names:specification:ubl:schema:xsd:ApplicationResponse-2"

NamespaceUBLApplicationResponse is the UBL 2.1 ApplicationResponse root namespace.

View Source
const OrderReferenceNotApplicable = "NA"

OrderReferenceNotApplicable is the filler OIOUBL and Peppol accept when there is no order reference to give.

View Source
const SchemeIDEmail = "EM"

SchemeIDEmail is the EAS codelist value for email

View Source
const TaxSchemeTaxRegistration = "LOC"

TaxSchemeTaxRegistration is the default tax scheme code for BT-32, the party's tax registration identifier.

View Source
const TaxSchemeVAT = "VAT"

TaxSchemeVAT is the tax scheme code for VAT

View Source
const Version = "2.1"

Version is the version of UBL documents that will be generated by this package.

Variables

View Source
var (
	// ErrUnknownDocumentType is returned when the document type
	// is not recognized during parsing.
	ErrUnknownDocumentType = fmt.Errorf("unknown document type")

	// ErrUnsupportedDocumentType is returned when the document type
	// is not supported for conversion.
	ErrUnsupportedDocumentType = fmt.Errorf("unsupported document type")

	// ErrUnsupportedAttachments is returned when attachments are given for a
	// document that cannot embed them.
	ErrUnsupportedAttachments = fmt.Errorf("attachments are only embedded in invoices")
)
View Source
var FormatEN16931 = Format{
	Key:             "ubl+en16931-v2017",
	Name:            i18n.NewString("UBL EN 16931:2017"),
	Import:          []schema.ID{invoiceSchema},
	Export:          []schema.ID{invoiceSchema},
	CustomizationID: "urn:cen.eu:en16931:2017",
	Addons:          []cbc.Key{en16931.V2017},
	VESIDs: VESIDMapping{
		Invoice:    "eu.cen.en16931:ubl:1.3.16",
		CreditNote: "eu.cen.en16931:ubl-creditnote:1.3.16",
	},
}

FormatEN16931 is the default format for basic UBL documents.

View Source
var InvoiceTagMap = map[string][]cbc.Key{
	"389": {tax.TagSelfBilled},
	"326": {tax.TagPartial},
	"261": {tax.TagSelfBilled},
	"386": {tax.TagPrepayment},
	"393": {tax.TagFactoring},
	"396": {tax.TagFactoring},
}

InvoiceTagMap maps UBL invoice type codes to GOBL tax tags.

Functions

func CleanString added in v0.85.0

func CleanString(s string) string

CleanString removes the replacement characters left by broken text encodings from incoming text.

func Encode added in v0.85.0

func Encode(doc Document) ([]byte, error)

Encode returns the raw XML of the UBL document including the XML Header.

func EncodeCompact added in v0.85.0

func EncodeCompact(doc Document) ([]byte, error)

EncodeCompact returns the raw XML of the UBL document without indentation, including the XML Header.

func FormatDate added in v0.85.0

func FormatDate(date cal.Date) string

FormatDate formats the date as UBL expects it.

func Import added in v0.85.0

func Import(doc Document, opts ...Option) (*gobl.Envelope, error)

Import converts the UBL document into a GOBL envelope. The format is determined from the document's CustomizationID and ProfileID, unless a WithFormat option is provided. Binary attachments are ignored - use ExtractBinaryAttachments to retrieve them separately.

func ParseParty added in v0.85.0

func ParseParty(party *Party) *org.Party

ParseParty converts the UBL party into a GOBL party, without any format specific adjustments.

func RegisterFormats added in v0.85.0

func RegisterFormats(fs ...Format)

RegisterFormats makes the formats available to FindFormat, and registers them with the GOBL convert register. Packages that implement regional formats call it from their init function.

func TaxPointCode added in v0.85.0

func TaxPointCode(point cbc.Key) (string, bool)

TaxPointCode provides the UNTDID 2005 code for the GOBL tax point key.

Types

type AdditionalItemProperty added in v0.5.0

type AdditionalItemProperty struct {
	Name          string    `xml:"cbc:Name"`
	Value         string    `xml:"cbc:Value,omitempty"`
	ValueQuantity *Quantity `xml:"cbc:ValueQuantity,omitempty"`
}

AdditionalItemProperty represents an additional property of an item

type AddressLine added in v0.5.0

type AddressLine struct {
	Line string `xml:"cbc:Line"`
}

AddressLine represents a line in an address

type AllowanceCharge added in v0.5.0

type AllowanceCharge struct {
	ChargeIndicator           bool           `xml:"cbc:ChargeIndicator"`
	AllowanceChargeReasonCode *string        `xml:"cbc:AllowanceChargeReasonCode"`
	AllowanceChargeReason     *string        `xml:"cbc:AllowanceChargeReason"`
	MultiplierFactorNumeric   *string        `xml:"cbc:MultiplierFactorNumeric"`
	Amount                    Amount         `xml:"cbc:Amount"`
	BaseAmount                *Amount        `xml:"cbc:BaseAmount"`
	TaxCategory               []*TaxCategory `xml:"cac:TaxCategory"`
}

AllowanceCharge represents an allowance or charge

type Amount added in v0.5.0

type Amount struct {
	CurrencyID *string `xml:"currencyID,attr"`
	Value      string  `xml:",chardata"`
}

Amount represents a monetary amount

func NewAmount added in v0.85.0

func NewAmount(a num.Amount, ccy string) Amount

NewAmount builds a monetary amount in the currency, rounded to the currency's precision.

type ApplicationResponse added in v0.65.0

type ApplicationResponse struct {
	XMLName      xml.Name
	CACNamespace string `xml:"xmlns:cac,attr"`
	CBCNamespace string `xml:"xmlns:cbc,attr"`
	UBLNamespace string `xml:"xmlns,attr"`

	UBLVersionID    string  `xml:"cbc:UBLVersionID,omitempty"`
	CustomizationID string  `xml:"cbc:CustomizationID,omitempty"`
	ProfileID       *IDType `xml:"cbc:ProfileID,omitempty"`
	ID              string  `xml:"cbc:ID"`
	UUID            string  `xml:"cbc:UUID,omitempty"`
	IssueDate       string  `xml:"cbc:IssueDate"`
	IssueTime       string  `xml:"cbc:IssueTime,omitempty"`

	Note []string `xml:"cbc:Note,omitempty"`

	SenderParty      *Party              `xml:"cac:SenderParty"`
	ReceiverParty    *Party              `xml:"cac:ReceiverParty"`
	DocumentResponse []*DocumentResponse `xml:"cac:DocumentResponse"`
}

ApplicationResponse represents a UBL 2.1 ApplicationResponse document, used to return a response (accept or reject) for a previously received document.

type Attachment added in v0.5.0

type Attachment struct {
	ExternalReference            *ExternalReference `xml:"cac:ExternalReference,omitempty"`
	EmbeddedDocumentBinaryObject *BinaryObject      `xml:"cbc:EmbeddedDocumentBinaryObject,omitempty"`
}

Attachment represents an attached document

type BillingReference added in v0.5.0

type BillingReference struct {
	InvoiceDocumentReference           *Reference `xml:"cac:InvoiceDocumentReference,omitempty"`
	SelfBilledInvoiceDocumentReference *Reference `xml:"cac:SelfBilledInvoiceDocumentReference,omitempty"`
	CreditNoteDocumentReference        *Reference `xml:"cac:CreditNoteDocumentReference,omitempty"`
	AdditionalDocumentReference        *Reference `xml:"cac:AdditionalDocumentReference,omitempty"`
}

BillingReference represents a reference to a billing document

type BillingReferenceLine added in v0.84.0

type BillingReferenceLine struct {
	ID IDType `xml:"cbc:ID"`
}

BillingReferenceLine names a sub-invoice line's parent.

type BinaryAttachment added in v0.18.0

type BinaryAttachment struct {
	// ID is the identifier for this attachment reference
	ID string
	// Description provides a human-readable description of the attachment
	Description string
	// Data contains the raw binary data (automatically base64-encoded/decoded as needed)
	Data []byte
	// MimeCode specifies the MIME type (e.g., "application/pdf")
	MimeCode string
	// Filename is the name of the file
	Filename string
	// CharacterSetCode specifies the character set if applicable
	CharacterSetCode string
	// URI can optionally reference where the document is located
	URI string
}

BinaryAttachment represents a binary attachment that can be extracted from or added to a UBL invoice.

type BinaryObject added in v0.5.0

type BinaryObject struct {
	MimeCode         *string `xml:"mimeCode,attr"`
	Filename         *string `xml:"filename,attr"`
	EncodingCode     *string `xml:"encodingCode,attr"`
	CharacterSetCode *string `xml:"characterSetCode,attr"`
	URI              *string `xml:"uri,attr"`
	Value            string  `xml:",chardata"`
}

BinaryObject represents binary data with associated metadata

type Branch added in v0.5.0

type Branch struct {
	ID                   *string               `xml:"cbc:ID"`
	Name                 *string               `xml:"cbc:Name"`
	FinancialInstitution *FinancialInstitution `xml:"cac:FinancialInstitution"`
}

Branch represents a branch of a financial institution

type CardAccount added in v0.5.0

type CardAccount struct {
	PrimaryAccountNumberID *string `xml:"cbc:PrimaryAccountNumberID"`
	NetworkID              *string `xml:"cbc:NetworkID"`
	HolderName             *string `xml:"cbc:HolderName"`
}

CardAccount represents a card account

type ClassifiedTaxCategory added in v0.5.0

type ClassifiedTaxCategory struct {
	ID        *IDType    `xml:"cbc:ID,omitempty"`
	Percent   *string    `xml:"cbc:Percent,omitempty"`
	TaxScheme *TaxScheme `xml:"cac:TaxScheme,omitempty"`
}

ClassifiedTaxCategory represents a classified tax category

type CommodityClassification added in v0.5.0

type CommodityClassification struct {
	ItemClassificationCode *IDType `xml:"cbc:ItemClassificationCode"`
}

CommodityClassification represents a commodity classification

type Contact added in v0.5.0

type Contact struct {
	ID             *string `xml:"cbc:ID"`
	Name           *string `xml:"cbc:Name"`
	Telephone      *string `xml:"cbc:Telephone"`
	ElectronicMail *string `xml:"cbc:ElectronicMail"`
}

Contact represents contact information

type Country added in v0.5.0

type Country struct {
	IdentificationCode string `xml:"cbc:IdentificationCode"`
}

Country represents a country

type CreditAccount added in v0.55.0

type CreditAccount struct {
	AccountID string `xml:"cbc:AccountID"`
}

CreditAccount represents a credit account (e.g. the Danish Giro/FIK account)

type CustomerParty added in v0.5.0

type CustomerParty struct {
	Party *Party `xml:"cac:Party"`
}

CustomerParty represents the customer party in a transaction

type Delivery added in v0.5.0

type Delivery struct {
	ActualDeliveryDate      *string   `xml:"cbc:ActualDeliveryDate"`
	LatestDeliveryDate      *string   `xml:"cbc:LatestDeliveryDate"`
	DeliveryLocation        *Location `xml:"cac:DeliveryLocation"`
	RequestedDeliveryPeriod *Period   `xml:"cac:RequestedDeliveryPeriod"`
	EstimatedDeliveryPeriod *Period   `xml:"cac:EstimatedDeliveryPeriod"`
	DeliveryParty           *Party    `xml:"cac:DeliveryParty"`
}

Delivery represents delivery information

type DeliveryTerms added in v0.5.0

type DeliveryTerms struct {
	ID               string    `xml:"cbc:ID"`
	DeliveryLocation *Location `xml:"cac:DeliveryLocation,omitempty"`
}

DeliveryTerms represents the terms of delivery

type Document added in v0.85.0

type Document interface {
	// contains filtered or unexported methods
}

Document is a UBL document: an *Invoice, which also covers credit notes, or an *ApplicationResponse.

func Decode added in v0.85.0

func Decode(data []byte) (Document, error)

Decode reads raw UBL data into the Document it contains.

Supported types:

  • *Invoice (for both Invoice and CreditNote documents)
  • *ApplicationResponse

Example usage:

doc, err := ubl.Decode(data)
if err != nil {
    // handle error
}
env, err := ubl.Import(doc)

func Export added in v0.85.0

func Export(env *gobl.Envelope, opts ...Option) (Document, error)

Export converts the GOBL envelope into a UBL document of one of the supported types.

Add a WithFormat option to specify the desired UBL format. If none is provided, EN 16931 will be used by default.

type DocumentResponse added in v0.65.0

type DocumentResponse struct {
	Response          *Response                  `xml:"cac:Response"`
	DocumentReference *ResponseDocumentReference `xml:"cac:DocumentReference"`
}

DocumentResponse pairs one Response with the document it concerns. An ApplicationResponse may carry several (generic UBL allows one per status line), though a format may restrict them to one per message.

type DocumentSignatures added in v0.48.0

type DocumentSignatures struct {
	SIGNamespace         string                `xml:"xmlns:sig,attr"`
	SACNamespace         string                `xml:"xmlns:sac,attr"`
	SBCNamespace         string                `xml:"xmlns:sbc,attr"`
	SignatureInformation *SignatureInformation `xml:"sac:SignatureInformation"`
}

DocumentSignatures contains the signature information block.

type EndpointID added in v0.5.0

type EndpointID struct {
	SchemeID string `xml:"schemeID,attr"`
	Value    string `xml:",chardata"`
}

EndpointID represents an endpoint identifier

type ExchangeRate added in v0.5.0

type ExchangeRate struct {
	SourceCurrencyCode *string `xml:"cbc:SourceCurrencyCode"`
	TargetCurrencyCode *string `xml:"cbc:TargetCurrencyCode"`
	CalculationRate    *string `xml:"cbc:CalculationRate"`
	Date               *string `xml:"cbc:Date"`
}

ExchangeRate represents an exchange rate

type ExportFunc added in v0.85.0

type ExportFunc func(f *Format, env *gobl.Envelope, doc Document) error

ExportFunc adjusts the UBL document exported from the GOBL envelope for a format.

type Extension added in v0.5.0

type Extension struct {
	ExtensionURI     *string           `xml:"ext:ExtensionURI"`
	ExtensionContent *ExtensionContent `xml:"ext:ExtensionContent"`
}

Extension represents a single UBL extension.

func NewExtension added in v0.48.0

func NewExtension() *Extension

NewExtension creates a new extension

type ExtensionContent added in v0.48.0

type ExtensionContent struct {
	UBLDocumentSignatures *DocumentSignatures `xml:"sig:UBLDocumentSignatures"`
}

ExtensionContent wraps the content of a UBL extension.

type Extensions added in v0.5.0

type Extensions struct {
	Extension []Extension `xml:"ext:UBLExtension"`
}

Extensions wraps a list of UBL extensions.

type ExternalReference added in v0.18.0

type ExternalReference struct {
	URI                 string `xml:"cbc:URI,omitempty"`
	DocumentHash        string `xml:"cbc:DocumentHash,omitempty"`
	HashAlgorithmMethod string `xml:"cbc:HashAlgorithmMethod,omitempty"`
	ExpiryDate          string `xml:"cbc:ExpiryDate,omitempty"`
	ExpiryTime          string `xml:"cbc:ExpiryTime,omitempty"`
	MimeCode            string `xml:"cbc:MimeCode,omitempty"`
	FormatCode          string `xml:"cbc:FormatCode,omitempty"`
	EncodingCode        string `xml:"cbc:EncodingCode,omitempty"`
	CharacterSetCode    string `xml:"cbc:CharacterSetCode,omitempty"`
	FileName            string `xml:"cbc:FileName,omitempty"`
	Description         string `xml:"cbc:Description,omitempty"`
}

ExternalReference represents a reference to an external resource

type FinancialAccount added in v0.5.0

type FinancialAccount struct {
	ID                         *string `xml:"cbc:ID"`
	Name                       *string `xml:"cbc:Name"`
	FinancialInstitutionBranch *Branch `xml:"cac:FinancialInstitutionBranch"`
	AccountTypeCode            *string `xml:"cbc:AccountTypeCode"`
}

FinancialAccount represents a financial account

type FinancialInstitution added in v0.55.0

type FinancialInstitution struct {
	ID *string `xml:"cbc:ID"`
}

FinancialInstitution identifies a financial institution by its BIC in cbc:ID.

type Format added in v0.85.0

type Format struct {
	// Key identifies the format in the GOBL convert register, with one layer
	// for each specification it builds on, e.g. "ubl+peppol+bis-v3".
	Key cbc.Key
	// Name of the format.
	Name i18n.String
	// Countries where the format applies. Empty means no restriction.
	Countries []l10n.Code
	// Import lists the schemas of the GOBL documents the format's documents
	// are imported into. Formats without any are never detected, such as
	// those whose documents only differ from another format's by their
	// container.
	Import []schema.ID
	// Export lists the schemas of the GOBL documents the format exports.
	Export []schema.ID
	// CustomizationID identifies specific characteristics in the
	// document which need to be present for local differences.
	CustomizationID string
	// ProfileID determines the business process context or scenario
	// for the exchange of the document.
	ProfileID string
	// OutputCustomizationID optionally specifies a different CustomizationID
	// to use in the actual generated UBL XML document. If empty, CustomizationID
	// is used. This allows the format to be identified by one ID externally while
	// generating different values in the XML output.
	OutputCustomizationID string
	// Addons contains the list of Addons required for this CustomizationID
	// and ProfileID.
	Addons []cbc.Key
	// VESIDs contains the VESID (Validation Exchange Specification ID) mappings
	// for different document types and scenarios within this format.
	VESIDs VESIDMapping
	// Match optionally identifies the format's documents before the
	// CustomizationID and ProfileID are compared.
	Match func(customizationID, profileID string) bool
	// Fallback optionally claims documents that no format matched.
	Fallback func(customizationID, profileID string) bool
	// SubLines writes line breakdowns as EXTENDED-CTC-FR sub-invoice lines,
	// and reads them back from the line billing references that name the
	// invoice itself.
	SubLines bool
	// ExportFuncs adjust the UBL document exported from GOBL, in order, after
	// the base export.
	ExportFuncs []ExportFunc
	// ImportFuncs adjust the GOBL envelope imported from UBL, in order, after
	// the base import and before the document is calculated.
	ImportFuncs []ImportFunc
	// Specifications lists the other specifications of the format, for GOBL
	// documents its own identifiers do not cover. On export, the first that
	// applies to the document is used, or else the format's own identifiers.
	Specifications []Specification
}

Format defines a UBL format: the CustomizationID and ProfileID its documents carry, and the functions that adjust the base import and export for the specification it represents.

func FindFormat added in v0.85.0

func FindFormat(customizationID string, profileID string) *Format

FindFormat looks up a registered format by CustomizationID and optionally ProfileID, among those with Import schemas. Returns nil if no matching format is found.

The lookup logic works as follows:

  1. Formats whose Match function claims the document
  2. Tries to match on the full CustomizationID of any of the format's specifications (for external identification)
  3. If not found, tries to match on OutputCustomizationID (for parsing incoming documents)
  4. Formats whose Fallback function claims the document

func (*Format) Is added in v0.85.0

func (f *Format) Is(f2 Format) bool

Is checks if two formats are the same.

func (*Format) SpecificationFor added in v0.85.0

func (f *Format) SpecificationFor(doc any) *Specification

SpecificationFor provides the specification the format exports the GOBL document with.

func (*Format) VESID added in v0.85.0

func (f *Format) VESID(doc any) string

VESID provides the VESID to validate the UBL document exported from the GOBL document with.

type Header struct {
	// Namespace of the root element.
	Namespace string
	// CustomizationID declares the specification the document follows.
	CustomizationID string
	// ProfileID declares the business process.
	ProfileID string
	// Err is set if the identifiers could not be read.
	Err error
}

Header holds the identifiers at the start of a UBL document that determine its format.

func ReadHeader added in v0.85.0

func ReadHeader(in *convert.Input) *Header

ReadHeader provides the root namespace and the specification and business process identifiers of the input, reading them only once for all the converters that ask.

type IDType added in v0.5.0

type IDType struct {
	SchemeAgencyID *string `xml:"schemeAgencyID,attr"`
	ListAgencyID   *string `xml:"listAgencyID,attr"`
	ListID         *string `xml:"listID,attr"`
	ListVersionID  *string `xml:"listVersionID,attr"`
	SchemeID       *string `xml:"schemeID,attr"`
	SchemeName     *string `xml:"schemeName,attr"`
	Name           *string `xml:"name,attr"`
	Value          string  `xml:",chardata"`
}

IDType represents an ID with optional scheme attributes

type Identification added in v0.5.0

type Identification struct {
	ID *IDType `xml:"cbc:ID"`
}

Identification represents an identification

type ImportFunc added in v0.85.0

type ImportFunc func(f *Format, doc Document, env *gobl.Envelope) error

ImportFunc adjusts the GOBL envelope imported from the UBL document for a format, before the envelope is calculated.

type Invoice added in v0.5.0

type Invoice struct {
	// Attributes
	XMLName        xml.Name
	CACNamespace   string `xml:"xmlns:cac,attr"`
	CBCNamespace   string `xml:"xmlns:cbc,attr"`
	QDTNamespace   string `xml:"xmlns:qdt,attr"`
	UDTNamespace   string `xml:"xmlns:udt,attr"`
	CCTSNamespace  string `xml:"xmlns:ccts,attr"`
	UBLNamespace   string `xml:"xmlns,attr"`
	XSINamespace   string `xml:"xmlns:xsi,attr"`
	EXTNamespace   string `xml:"xmlns:ext,attr"`
	SchemaLocation string `xml:"xsi:schemaLocation,attr,omitempty"`

	Extensions         *Extensions `xml:"ext:UBLExtensions,omitempty"`
	UBLVersionID       string      `xml:"cbc:UBLVersionID,omitempty"`
	CustomizationID    string      `xml:"cbc:CustomizationID,omitempty"`
	ProfileID          *IDType     `xml:"cbc:ProfileID,omitempty"`
	ProfileExecutionID string      `xml:"cbc:ProfileExecutionID,omitempty"`
	ID                 string      `xml:"cbc:ID"`
	CopyIndicator      bool        `xml:"cbc:CopyIndicator,omitempty"`
	UUID               string      `xml:"cbc:UUID,omitempty"`
	IssueDate          string      `xml:"cbc:IssueDate"`
	IssueTime          string      `xml:"cbc:IssueTime,omitempty"`
	DueDate            string      `xml:"cbc:DueDate,omitempty"`

	InvoiceTypeCode    *IDType `xml:"cbc:InvoiceTypeCode,omitempty"`
	CreditNoteTypeCode *IDType `xml:"cbc:CreditNoteTypeCode,omitempty"`

	Note                           []string            `xml:"cbc:Note,omitempty"`
	TaxPointDate                   string              `xml:"cbc:TaxPointDate,omitempty"`
	DocumentCurrencyCode           string              `xml:"cbc:DocumentCurrencyCode,omitempty"`
	TaxCurrencyCode                string              `xml:"cbc:TaxCurrencyCode,omitempty"`
	PricingCurrencyCode            string              `xml:"cbc:PricingCurrencyCode,omitempty"`
	PaymentCurrencyCode            string              `xml:"cbc:PaymentCurrencyCode,omitempty"`
	PaymentAlternativeCurrencyCode string              `xml:"cbc:PaymentAlternativeCurrencyCode,omitempty"`
	AccountingCost                 string              `xml:"cbc:AccountingCost,omitempty"`
	LineCountNumeric               int                 `xml:"cbc:LineCountNumeric,omitempty"`
	BuyerReference                 string              `xml:"cbc:BuyerReference,omitempty"`
	InvoicePeriod                  []Period            `xml:"cac:InvoicePeriod,omitempty"`
	OrderReference                 *OrderReference     `xml:"cac:OrderReference,omitempty"`
	BillingReference               []*BillingReference `xml:"cac:BillingReference,omitempty"`
	DespatchDocumentReference      []Reference         `xml:"cac:DespatchDocumentReference,omitempty"`
	ReceiptDocumentReference       []Reference         `xml:"cac:ReceiptDocumentReference,omitempty"`
	StatementDocumentReference     []Reference         `xml:"cac:StatementDocumentReference,omitempty"`
	OriginatorDocumentReference    []Reference         `xml:"cac:OriginatorDocumentReference,omitempty"`
	ContractDocumentReference      []Reference         `xml:"cac:ContractDocumentReference,omitempty"`
	AdditionalDocumentReference    []Reference         `xml:"cac:AdditionalDocumentReference,omitempty"`
	ProjectReference               []ProjectReference  `xml:"cac:ProjectReference,omitempty"`
	Signature                      []Signature         `xml:"cac:Signature,omitempty"`
	AccountingSupplierParty        SupplierParty       `xml:"cac:AccountingSupplierParty"`
	AccountingCustomerParty        CustomerParty       `xml:"cac:AccountingCustomerParty"`
	PayeeParty                     *Party              `xml:"cac:PayeeParty,omitempty"`
	BuyerCustomerParty             *CustomerParty      `xml:"cac:BuyerCustomerParty,omitempty"`
	SellerSupplierParty            *SupplierParty      `xml:"cac:SellerSupplierParty,omitempty"`
	TaxRepresentativeParty         *Party              `xml:"cac:TaxRepresentativeParty,omitempty"`
	Delivery                       []*Delivery         `xml:"cac:Delivery,omitempty"`
	DeliveryTerms                  *DeliveryTerms      `xml:"cac:DeliveryTerms,omitempty"`
	PaymentMeans                   []PaymentMeans      `xml:"cac:PaymentMeans,omitempty"`
	PaymentTerms                   *PaymentTerms       `xml:"cac:PaymentTerms,omitempty"`
	PrepaidPayment                 []PrepaidPayment    `xml:"cac:PrepaidPayment,omitempty"`
	AllowanceCharge                []AllowanceCharge   `xml:"cac:AllowanceCharge,omitempty"`
	TaxExchangeRate                *ExchangeRate       `xml:"cac:TaxExchangeRate,omitempty"`
	PricingExchangeRate            *ExchangeRate       `xml:"cac:PricingExchangeRate,omitempty"`
	PaymentExchangeRate            *ExchangeRate       `xml:"cac:PaymentExchangeRate,omitempty"`
	PaymentAlternativeExchangeRate *ExchangeRate       `xml:"cac:PaymentAlternativeExchangeRate,omitempty"`
	TaxTotal                       []TaxTotal          `xml:"cac:TaxTotal,omitempty"`
	WithholdingTaxTotal            []TaxTotal          `xml:"cac:WithholdingTaxTotal,omitempty"`
	LegalMonetaryTotal             MonetaryTotal       `xml:"cac:LegalMonetaryTotal"`
	InvoiceLines                   []InvoiceLine       `xml:"cac:InvoiceLine,omitempty"`
	CreditNoteLines                []InvoiceLine       `xml:"cac:CreditNoteLine,omitempty"`
}

Invoice represents the root element of a UBL Invoice **or** Credit Note; the structures between the two types are so similar, that it doesn't make much sense to separate.

func ExportInvoice added in v0.85.0

func ExportInvoice(env *gobl.Envelope, opts ...Option) (*Invoice, error)

ExportInvoice is a convenience function that exports a GOBL envelope containing an invoice into a UBL Invoice or CreditNote document.

func (*Invoice) AddAttachments added in v0.48.0

func (ui *Invoice) AddAttachments(attachments []*org.Attachment)

AddAttachments adds an attachment to the UBL Invoice. This is useful for including documents like invoice counter values or URLs

func (*Invoice) AddBinaryAttachment added in v0.25.0

func (ui *Invoice) AddBinaryAttachment(attachment BinaryAttachment)

AddBinaryAttachment adds an embedded binary attachment to the UBL Invoice. This is useful for including documents like PDFs directly within the UBL XML. The binary data will be automatically base64-encoded.

func (*Invoice) AddExtension added in v0.48.0

func (ui *Invoice) AddExtension(extension *Extension)

AddExtension adds a new extension to the ubl invoice

func (*Invoice) AddSignatureReference added in v0.48.0

func (ui *Invoice) AddSignatureReference(signatureMethod, referenceSignatureID string)

AddSignatureReference adds a reference to a signature

func (*Invoice) ExtractBinaryAttachments added in v0.18.0

func (ui *Invoice) ExtractBinaryAttachments() []BinaryAttachment

ExtractBinaryAttachments extracts all binary attachments from the UBL Invoice. It returns a slice of BinaryAttachment containing the ID, description, and decoded binary data. External reference attachments are not included in the result.

type InvoiceLine added in v0.5.0

type InvoiceLine struct {
	ID                  string              `xml:"cbc:ID"`
	Note                []string            `xml:"cbc:Note"`
	InvoicedQuantity    *Quantity           `xml:"cbc:InvoicedQuantity,omitempty"` // or CreditNoteQuantity
	CreditedQuantity    *Quantity           `xml:"cbc:CreditedQuantity,omitempty"`
	LineExtensionAmount Amount              `xml:"cbc:LineExtensionAmount"`
	AccountingCost      *string             `xml:"cbc:AccountingCost"`
	InvoicePeriod       *Period             `xml:"cac:InvoicePeriod"`
	OrderLineReference  *OrderLineReference `xml:"cac:OrderLineReference"`
	// Only the reference naming the invoice itself carries the sub-line type and parent.
	BillingReference  []*LineBillingReference `xml:"cac:BillingReference,omitempty"`
	DocumentReference *LineDocReference       `xml:"cac:DocumentReference,omitempty"`
	AllowanceCharge   []*AllowanceCharge      `xml:"cac:AllowanceCharge"`
	TaxTotal          []TaxTotal              `xml:"cac:TaxTotal,omitempty"`
	Item              *Item                   `xml:"cac:Item"`
	Price             *Price                  `xml:"cac:Price"`
	// contains filtered or unexported fields
}

InvoiceLine represents a line item in an invoice and credit note

type Item added in v0.5.0

type Item struct {
	Description                *string                    `xml:"cbc:Description"`
	Name                       string                     `xml:"cbc:Name"`
	BuyersItemIdentification   *ItemIdentification        `xml:"cac:BuyersItemIdentification"`
	SellersItemIdentification  *ItemIdentification        `xml:"cac:SellersItemIdentification"`
	StandardItemIdentification *ItemIdentification        `xml:"cac:StandardItemIdentification"`
	OriginCountry              *Country                   `xml:"cac:OriginCountry"`
	CommodityClassification    *[]CommodityClassification `xml:"cac:CommodityClassification"`
	ClassifiedTaxCategory      *ClassifiedTaxCategory     `xml:"cac:ClassifiedTaxCategory"`
	AdditionalItemProperty     *[]AdditionalItemProperty  `xml:"cac:AdditionalItemProperty"`
	ManufacturerParty          *Party                     `xml:"cac:ManufacturerParty,omitempty"`
}

Item represents an item in an invoice line

type ItemIdentification added in v0.5.0

type ItemIdentification struct {
	ID *IDType `xml:"cbc:ID"`
}

ItemIdentification represents an item identification

type LineBillingReference added in v0.84.0

type LineBillingReference struct {
	InvoiceDocumentReference *LineDocumentStatusReference `xml:"cac:InvoiceDocumentReference,omitempty"`
	BillingReferenceLine     *BillingReferenceLine        `xml:"cac:BillingReferenceLine,omitempty"`
}

LineBillingReference carries EXT-FR-FE-162/163 when its ID is the invoice's own (BT-1).

type LineDocReference added in v0.36.0

type LineDocReference struct {
	ID               IDType  `xml:"cbc:ID"`
	DocumentTypeCode *string `xml:"cbc:DocumentTypeCode,omitempty"`
}

LineDocReference defines a document reference at line level (BT-128)

type LineDocumentStatusReference added in v0.84.0

type LineDocumentStatusReference struct {
	ID                 IDType `xml:"cbc:ID"`
	DocumentStatusCode string `xml:"cbc:DocumentStatusCode,omitempty"`
}

LineDocumentStatusReference names the invoice and the line's type.

type Location added in v0.5.0

type Location struct {
	ID      *IDType        `xml:"cbc:ID"`
	Name    *string        `xml:"cbc:Name,omitempty"`
	Address *PostalAddress `xml:"cac:Address"`
}

Location represents a location

type LocationCoordinate added in v0.5.0

type LocationCoordinate struct {
	LatitudeDegreesMeasure  *string `xml:"cbc:LatitudeDegreesMeasure"`
	LatitudeMinutesMeasure  *string `xml:"cbc:LatitudeMinutesMeasure"`
	LongitudeDegreesMeasure *string `xml:"cbc:LongitudeDegreesMeasure"`
	LongitudeMinutesMeasure *string `xml:"cbc:LongitudeMinutesMeasure"`
}

LocationCoordinate represents a location coordinate

type MonetaryTotal added in v0.5.0

type MonetaryTotal struct {
	LineExtensionAmount   Amount  `xml:"cbc:LineExtensionAmount"`
	TaxExclusiveAmount    Amount  `xml:"cbc:TaxExclusiveAmount"`
	TaxInclusiveAmount    Amount  `xml:"cbc:TaxInclusiveAmount"`
	AllowanceTotalAmount  *Amount `xml:"cbc:AllowanceTotalAmount,omitempty"`
	ChargeTotalAmount     *Amount `xml:"cbc:ChargeTotalAmount,omitempty"`
	PrepaidAmount         *Amount `xml:"cbc:PrepaidAmount,omitempty"`
	PayableRoundingAmount *Amount `xml:"cbc:PayableRoundingAmount,omitempty"`
	PayableAmount         *Amount `xml:"cbc:PayableAmount,omitempty"`
}

MonetaryTotal represents the monetary totals of the invoice

type Option added in v0.5.0

type Option func(*options)

Option is used to define configuration options to use during conversion processes.

func WithAttachments added in v0.93.0

func WithAttachments(atts ...BinaryAttachment) Option

WithAttachments embeds files, such as a PDF version of the invoice, in an exported invoice. Other documents cannot embed them.

func WithFormat added in v0.85.0

func WithFormat(f Format) Option

WithFormat sets the format to use for the configuration and business profile.

func WithRouting added in v0.56.0

func WithRouting(from, to cbc.URI) Option

WithRouting supplies the transport addresses the receiving app was routed with (the Peppol SBD From / To — who sent the document, who received it). They are recorded verbatim on the parsed envelope's Head.From / Head.To, regardless of the document type, so a received document is never mislabelled with GOBL's document-derived, outgoing-direction guess. See Import.

type OrderLineReference added in v0.5.0

type OrderLineReference struct {
	LineID string `xml:"cbc:LineID"`
}

OrderLineReference represents a reference to an order line

type OrderReference added in v0.5.0

type OrderReference struct {
	ID                string `xml:"cbc:ID"`
	SalesOrderID      string `xml:"cbc:SalesOrderID,omitempty"`
	IssueDate         string `xml:"cbc:IssueDate,omitempty"`
	CustomerReference string `xml:"cbc:CustomerReference,omitempty"`
}

OrderReference represents a reference to an order

type Party added in v0.5.0

type Party struct {
	EndpointID                 *EndpointID           `xml:"cbc:EndpointID"`
	IndustryClassificationCode string                `xml:"cbc:IndustryClassificationCode,omitempty"`
	PartyIdentification        []Identification      `xml:"cac:PartyIdentification"`
	PartyName                  *PartyName            `xml:"cac:PartyName"`
	PostalAddress              *PostalAddress        `xml:"cac:PostalAddress"`
	PartyTaxScheme             []PartyTaxScheme      `xml:"cac:PartyTaxScheme"`
	PartyLegalEntity           *PartyLegalEntity     `xml:"cac:PartyLegalEntity"`
	Contact                    *Contact              `xml:"cac:Contact"`
	AgentParty                 *Party                `xml:"cac:AgentParty"`
	ServiceProviderParty       *ServiceProviderParty `xml:"cac:ServiceProviderParty"`
}

Party represents a party involved in a transaction

func NewParty added in v0.85.0

func NewParty(party *org.Party) *Party

NewParty converts the GOBL party into a UBL party, without any format specific adjustments.

func (*Party) CountryCode added in v0.5.0

func (p *Party) CountryCode() string

CountryCode tries to determine the most appropriate tax country code for the party.

type PartyLegalEntity added in v0.5.0

type PartyLegalEntity struct {
	RegistrationName *string `xml:"cbc:RegistrationName"`
	CompanyID        *IDType `xml:"cbc:CompanyID"`
	CompanyLegalForm *string `xml:"cbc:CompanyLegalForm"`
}

PartyLegalEntity represents the legal entity of a party

type PartyName added in v0.5.0

type PartyName struct {
	Name string `xml:"cbc:Name"`
}

PartyName represents the name of a party

type PartyPair added in v0.85.0

type PartyPair struct {
	GOBL *org.Party
	UBL  *Party
}

PartyPair links a GOBL party with the UBL party it maps to.

func InvoiceParties added in v0.85.0

func InvoiceParties(inv *bill.Invoice, doc *Invoice) []PartyPair

InvoiceParties lists the parties of the GOBL invoice alongside the UBL parties they map to in the UBL invoice, in either direction. Agents follow the party they act for, and parties missing on either side are left out.

type PartyTaxScheme added in v0.5.0

type PartyTaxScheme struct {
	CompanyID *IDType    `xml:"cbc:CompanyID"`
	TaxScheme *TaxScheme `xml:"cac:TaxScheme"`
}

PartyTaxScheme represents a party's tax scheme

type PaymentMandate added in v0.5.0

type PaymentMandate struct {
	ID                    *IDType           `xml:"cbc:ID"`
	PayerParty            *Party            `xml:"cac:PayerParty"`
	PayerFinancialAccount *FinancialAccount `xml:"cac:PayerFinancialAccount"`
}

PaymentMandate represents a payment mandate

type PaymentMeans added in v0.5.0

type PaymentMeans struct {
	PaymentMeansCode      IDType            `xml:"cbc:PaymentMeansCode"`
	PaymentDueDate        *string           `xml:"cbc:PaymentDueDate"`
	PaymentChannelCode    *IDType           `xml:"cbc:PaymentChannelCode,omitempty"`
	InstructionID         *string           `xml:"cbc:InstructionID"`
	InstructionNote       []string          `xml:"cbc:InstructionNote,omitempty"`
	PaymentID             *string           `xml:"cbc:PaymentID"`
	CardAccount           *CardAccount      `xml:"cac:CardAccount"`
	PayerFinancialAccount *FinancialAccount `xml:"cac:PayerFinancialAccount"`
	PayeeFinancialAccount *FinancialAccount `xml:"cac:PayeeFinancialAccount"`
	CreditAccount         *CreditAccount    `xml:"cac:CreditAccount"`
	PaymentMandate        *PaymentMandate   `xml:"cac:PaymentMandate"`
}

PaymentMeans represents the means of payment

type PaymentTerms added in v0.5.0

type PaymentTerms struct {
	Note   string  `xml:"cbc:Note,omitempty"`
	Amount *Amount `xml:"cbc:Amount,omitempty"`
}

PaymentTerms represents the terms of payment

type Period added in v0.5.0

type Period struct {
	StartDate       string `xml:"cbc:StartDate,omitempty"`
	EndDate         string `xml:"cbc:EndDate,omitempty"`
	DescriptionCode string `xml:"cbc:DescriptionCode,omitempty"`
}

Period represents a time period with start and end dates

type PostalAddress added in v0.5.0

type PostalAddress struct {
	ID                   *IDType             `xml:"cbc:ID,omitempty"`
	AddressFormatCode    *IDType             `xml:"cbc:AddressFormatCode"`
	Postbox              *string             `xml:"cbc:Postbox,omitempty"`
	StreetName           *string             `xml:"cbc:StreetName"`
	AdditionalStreetName *string             `xml:"cbc:AdditionalStreetName"`
	BuildingNumber       *string             `xml:"cbc:BuildingNumber,omitempty"`
	PlotIdentification   *string             `xml:"cbc:PlotIdentification,omitempty"`
	CitySubdivisionName  *string             `xml:"cbc:CitySubdivisionName,omitempty"`
	CityName             *string             `xml:"cbc:CityName"`
	PostalZone           *string             `xml:"cbc:PostalZone"`
	CountrySubentity     *string             `xml:"cbc:CountrySubentity"`
	Region               *string             `xml:"cbc:Region,omitempty"`
	District             *string             `xml:"cbc:District,omitempty"`
	AddressLine          []AddressLine       `xml:"cac:AddressLine"`
	Country              *Country            `xml:"cac:Country"`
	LocationCoordinate   *LocationCoordinate `xml:"cac:LocationCoordinate"`
}

PostalAddress represents a postal address

type PrepaidPayment added in v0.5.0

type PrepaidPayment struct {
	ID            string  `xml:"cbc:ID"`
	PaidAmount    *Amount `xml:"cbc:PaidAmount"`
	ReceivedDate  *string `xml:"cbc:ReceivedDate"`
	InstructionID *string `xml:"cbc:InstructionID"`
}

PrepaidPayment represents a prepaid payment

type Price added in v0.5.0

type Price struct {
	PriceAmount             Amount           `xml:"cbc:PriceAmount"`
	BaseQuantity            *Quantity        `xml:"cbc:BaseQuantity,omitempty"`
	OrderableUnitFactorRate *string          `xml:"cbc:OrderableUnitFactorRate,omitempty"`
	AllowanceCharge         *AllowanceCharge `xml:"cac:AllowanceCharge,omitempty"`
}

Price represents the price of an item

type ProjectReference added in v0.5.0

type ProjectReference struct {
	ID string `xml:"cbc:ID,omitempty"`
}

ProjectReference represents a reference to a project

type Quantity added in v0.5.0

type Quantity struct {
	UnitCode string `xml:"unitCode,attr"`
	Value    string `xml:",chardata"`
}

Quantity represents a quantity with a unit code

type Reference added in v0.5.0

type Reference struct {
	ID                  IDType      `xml:"cbc:ID"`
	UUID                string      `xml:"cbc:UUID,omitempty"`
	IssueDate           string      `xml:"cbc:IssueDate,omitempty"`
	DocumentTypeCode    string      `xml:"cbc:DocumentTypeCode,omitempty"`
	DocumentType        string      `xml:"cbc:DocumentType,omitempty"`
	DocumentDescription string      `xml:"cbc:DocumentDescription,omitempty"`
	Attachment          *Attachment `xml:"cac:Attachment,omitempty"`
	ValidityPeriod      *Period     `xml:"cac:ValidityPeriod,omitempty"`
}

Reference represents a reference to a document

type Response added in v0.65.0

type Response struct {
	ReferenceID   string    `xml:"cbc:ReferenceID,omitempty"`
	ResponseCode  *IDType   `xml:"cbc:ResponseCode"`
	Description   []string  `xml:"cbc:Description,omitempty"`
	EffectiveDate string    `xml:"cbc:EffectiveDate,omitempty"`
	Status        []*Status `xml:"cac:Status,omitempty"`
}

Response carries the response code and an optional human description. The ResponseCode value and its code-list attributes are profile-specific and are stamped by the matching format.

type ResponseDocumentReference added in v0.65.0

type ResponseDocumentReference struct {
	ID               string  `xml:"cbc:ID"`
	UUID             string  `xml:"cbc:UUID,omitempty"`
	IssueDate        string  `xml:"cbc:IssueDate,omitempty"`
	DocumentTypeCode *IDType `xml:"cbc:DocumentTypeCode"`
}

ResponseDocumentReference identifies the document being responded to. The DocumentTypeCode is profile-specific (drawn from a profile's code list) and is stamped by the matching format; the generic mapping leaves it unset.

type ServiceProviderParty added in v0.59.0

type ServiceProviderParty struct {
	Party *Party `xml:"cac:Party"`
}

ServiceProviderParty represents a service provider party in a transaction

type Signature added in v0.5.0

type Signature struct {
	ID                         string      `xml:"cbc:ID"`
	Note                       []string    `xml:"cbc:Note,omitempty"`
	ValidationDate             *string     `xml:"cbc:ValidationDate,omitempty"`
	ValidationTime             *string     `xml:"cbc:ValidationTime,omitempty"`
	ValidatorID                *string     `xml:"cbc:ValidatorID,omitempty"`
	CanonicalizationMethod     *string     `xml:"cbc:CanonicalizationMethod,omitempty"`
	SignatureMethod            *string     `xml:"cbc:SignatureMethod,omitempty"`
	SignatoryParty             *Party      `xml:"cac:SignatoryParty,omitempty"`
	DigitalSignatureAttachment *Attachment `xml:"cac:DigitalSignatureAttachment,omitempty"`
	OriginalDocumentReference  *Reference  `xml:"cac:OriginalDocumentReference,omitempty"`
}

Signature represents a digital signature

type SignatureInformation added in v0.48.0

type SignatureInformation struct {
	ID                    string             `xml:"cbc:ID"`
	ReferencedSignatureID string             `xml:"sbc:ReferencedSignatureID"`
	Signature             *xmldsig.Signature `xml:"ds:Signature"`
}

SignatureInformation holds the IDs and the ds:Signature.

type Specification added in v0.85.0

type Specification struct {
	// CustomizationID identifies the specification.
	CustomizationID string
	// ProfileID identifies the business process.
	ProfileID string
	// OutputCustomizationID optionally specifies a different CustomizationID
	// to write into the generated XML.
	OutputCustomizationID string
	// Addons required by the specification.
	Addons []cbc.Key
	// VESIDs used to validate the specification's documents.
	VESIDs VESIDMapping
	// Applies reports whether the specification applies to the GOBL
	// document. Nil applies to any document.
	Applies func(doc any) bool
}

Specification defines the identifiers a UBL document carries for one specification, and the GOBL documents it applies to.

type Status added in v0.65.0

type Status struct {
	StatusReasonCode *IDType  `xml:"cbc:StatusReasonCode,omitempty"`
	StatusReason     []string `xml:"cbc:StatusReason,omitempty"`
}

Status carries a coded clarification within a Response. The code list it draws from is identified by the StatusReasonCode listID and is profile-specific.

type SupplierParty added in v0.5.0

type SupplierParty struct {
	Party *Party `xml:"cac:Party"`
}

SupplierParty represents the supplier party in a transaction

type TaxCategory added in v0.5.0

type TaxCategory struct {
	ID                     *IDType    `xml:"cbc:ID,omitempty"`
	Percent                *string    `xml:"cbc:Percent,omitempty"`
	TaxExemptionReasonCode *string    `xml:"cbc:TaxExemptionReasonCode,omitempty"`
	TaxExemptionReason     *string    `xml:"cbc:TaxExemptionReason,omitempty"`
	TaxScheme              *TaxScheme `xml:"cac:TaxScheme,omitempty"`
}

TaxCategory represents a tax category

type TaxScheme added in v0.5.0

type TaxScheme struct {
	ID          IDType  `xml:"cbc:ID"`
	Name        *string `xml:"cbc:Name"`
	TaxTypeCode *IDType `xml:"cbc:TaxTypeCode,omitempty"`
}

TaxScheme represents a tax scheme

type TaxSubtotal added in v0.5.0

type TaxSubtotal struct {
	TaxableAmount                Amount      `xml:"cbc:TaxableAmount,omitempty"`
	TaxAmount                    Amount      `xml:"cbc:TaxAmount"`
	TransactionCurrencyTaxAmount *Amount     `xml:"cbc:TransactionCurrencyTaxAmount,omitempty"`
	TaxCategory                  TaxCategory `xml:"cac:TaxCategory"`
}

TaxSubtotal represents a tax subtotal

type TaxTotal added in v0.5.0

type TaxTotal struct {
	TaxAmount      Amount        `xml:"cbc:TaxAmount"`
	RoundingAmount *Amount       `xml:"cbc:RoundingAmount,omitempty"`
	TaxSubtotal    []TaxSubtotal `xml:"cac:TaxSubtotal"`
}

TaxTotal represents a tax total

type VESIDMapping added in v0.22.0

type VESIDMapping struct {
	// Invoice is the VESID for invoices
	Invoice string
	// CreditNote is the VESID for credit notes
	CreditNote string
	// Status is the VESID for status documents (UBL ApplicationResponses)
	Status string
}

VESIDMapping maps document types to their corresponding VESID values.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址