Documentation
¶
Overview ¶
Package ubl helps convert GOBL into UBL documents and vice versa.
Index ¶
- Constants
- Variables
- func CleanString(s string) string
- func Encode(doc Document) ([]byte, error)
- func EncodeCompact(doc Document) ([]byte, error)
- func FormatDate(date cal.Date) string
- func Import(doc Document, opts ...Option) (*gobl.Envelope, error)
- func ParseParty(party *Party) *org.Party
- func RegisterFormats(fs ...Format)
- func TaxPointCode(point cbc.Key) (string, bool)
- type AdditionalItemProperty
- type AddressLine
- type AllowanceCharge
- type Amount
- type ApplicationResponse
- type Attachment
- type BillingReference
- type BillingReferenceLine
- type BinaryAttachment
- type BinaryObject
- type Branch
- type CardAccount
- type ClassifiedTaxCategory
- type CommodityClassification
- type Contact
- type Country
- type CreditAccount
- type CustomerParty
- type Delivery
- type DeliveryTerms
- type Document
- type DocumentResponse
- type DocumentSignatures
- type EndpointID
- type ExchangeRate
- type ExportFunc
- type Extension
- type ExtensionContent
- type Extensions
- type ExternalReference
- type FinancialAccount
- type FinancialInstitution
- type Format
- type Header
- type IDType
- type Identification
- type ImportFunc
- type Invoice
- func (ui *Invoice) AddAttachments(attachments []*org.Attachment)
- func (ui *Invoice) AddBinaryAttachment(attachment BinaryAttachment)
- func (ui *Invoice) AddExtension(extension *Extension)
- func (ui *Invoice) AddSignatureReference(signatureMethod, referenceSignatureID string)
- func (ui *Invoice) ExtractBinaryAttachments() []BinaryAttachment
- type InvoiceLine
- type Item
- type ItemIdentification
- type LineBillingReference
- type LineDocReference
- type LineDocumentStatusReference
- type Location
- type LocationCoordinate
- type MonetaryTotal
- type Option
- type OrderLineReference
- type OrderReference
- type Party
- type PartyLegalEntity
- type PartyName
- type PartyPair
- type PartyTaxScheme
- type PaymentMandate
- type PaymentMeans
- type PaymentTerms
- type Period
- type PostalAddress
- type PrepaidPayment
- type Price
- type ProjectReference
- type Quantity
- type Reference
- type Response
- type ResponseDocumentReference
- type ServiceProviderParty
- type Signature
- type SignatureInformation
- type Specification
- type Status
- type SupplierParty
- type TaxCategory
- type TaxScheme
- type TaxSubtotal
- type TaxTotal
- type VESIDMapping
Constants ¶
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
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
const ( SchemaLocationInvoice = "" /* 128-byte string literal not displayed */ SchemaLocationCrediteNote = "" /* 135-byte string literal not displayed */ )
Schema locationa and customization constants
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.
const KeyUBL cbc.Key = "ubl"
KeyUBL identifies UBL documents that do not declare a known specification. They can be imported, but not exported.
const NamespaceUBLApplicationResponse = "urn:oasis:names:specification:ubl:schema:xsd:ApplicationResponse-2"
NamespaceUBLApplicationResponse is the UBL 2.1 ApplicationResponse root namespace.
const OrderReferenceNotApplicable = "NA"
OrderReferenceNotApplicable is the filler OIOUBL and Peppol accept when there is no order reference to give.
const SchemeIDEmail = "EM"
SchemeIDEmail is the EAS codelist value for email
const TaxSchemeTaxRegistration = "LOC"
TaxSchemeTaxRegistration is the default tax scheme code for BT-32, the party's tax registration identifier.
const TaxSchemeVAT = "VAT"
TaxSchemeVAT is the tax scheme code for VAT
const Version = "2.1"
Version is the version of UBL documents that will be generated by this package.
Variables ¶
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") )
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.
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
CleanString removes the replacement characters left by broken text encodings from incoming text.
func Encode ¶ added in v0.85.0
Encode returns the raw XML of the UBL document including the XML Header.
func EncodeCompact ¶ added in v0.85.0
EncodeCompact returns the raw XML of the UBL document without indentation, including the XML Header.
func FormatDate ¶ added in v0.85.0
FormatDate formats the date as UBL expects it.
func Import ¶ added in v0.85.0
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
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.
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 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.
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
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
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
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:
- Formats whose Match function claims the document
- Tries to match on the full CustomizationID of any of the format's specifications (for external identification)
- If not found, tries to match on OutputCustomizationID (for parsing incoming documents)
- Formats whose Fallback function claims the document
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.
type Header ¶ added in v0.85.0
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
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
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
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
AddExtension adds a new extension to the ubl invoice
func (*Invoice) AddSignatureReference ¶ added in v0.48.0
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
WithFormat sets the format to use for the configuration and business profile.
func WithRouting ¶ added in v0.56.0
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
NewParty converts the GOBL party into a UBL party, without any format specific adjustments.
func (*Party) CountryCode ¶ added in v0.5.0
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
PartyPair links a GOBL party with the UBL party it maps to.
func InvoiceParties ¶ added in v0.85.0
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 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.
Source Files
¶
- applicationresponse.go
- applicationresponse_parse.go
- attachments.go
- attachments_parse.go
- charges.go
- charges_parse.go
- common.go
- converter.go
- date.go
- delivery.go
- delivery_parse.go
- extension.go
- format.go
- funcs.go
- invoice.go
- invoice_parse.go
- lines.go
- lines_parse.go
- ordering.go
- ordering_parse.go
- party.go
- party_parse.go
- payment.go
- payment_parse.go
- reconcile_parse.go
- signature.go
- totals.go
- ubl.go
- utils.go