Documentation
¶
Overview ¶
Package cii helps convert GOBL into Cross Industry Invoice documents and vice versa.
Index ¶
- Constants
- Variables
- func CleanString(s string) string
- func Encode(doc Document) ([]byte, error)
- func ExpandGroupLines(inv *bill.Invoice, out *Invoice)
- func Import(doc Document, opts ...Option) (*gobl.Envelope, error)
- func ParseParty(party *Party) *org.Party
- func RegisterFormats(fs ...Format)
- type AccountingAccount
- type AdditionalDocument
- type Advance
- type Agreement
- type AllowanceCharge
- type BinaryAttachment
- type BinaryObject
- type CDAR
- type CDARAcknowledgement
- type CDARBinaryObject
- type CDARDateTimeString
- type CDARDocumentCharacteristic
- type CDARDocumentContextParameter
- type CDARDocumentStatus
- type CDARExchangedContext
- type CDARExchangedDocument
- type CDARFormattedIssueDateTime
- type CDARGlobalID
- type CDARID
- type CDARIndicator
- type CDARIndicatorString
- type CDARIssueDateTime
- type CDARNote
- type CDARQDTDateTimeString
- type CDARReferencedDocument
- type CDARSpecifiedPeriod
- type CDARTradeAddress
- type CDARTradeContact
- type CDARTradeParty
- type CDARURIID
- type CDARUniversalCommunication
- type CDARValueAmount
- type Card
- type ChainEvent
- type Characteristic
- type Classification
- type Contact
- type Creditor
- type CreditorInstitution
- type Date
- type DebtorAccount
- type Delivery
- type DeliveryTerms
- type Document
- type Email
- type ExchangedContext
- type ExchangedContextParameter
- type ExportFunc
- type Format
- type FormattedIssueDate
- type GlobalID
- type GrossPrice
- type Header
- type HeaderInfo
- type ImportFunc
- type Indicator
- type Invoice
- type IssueDate
- type IssuerID
- type LegalOrganization
- type Line
- type LineAgreement
- type LineDelivery
- type LineDoc
- type LineDocReference
- type LineOrderReference
- type ListID
- type NetPrice
- type Note
- type Option
- type Party
- type PartyID
- type PaymentMeans
- type Period
- type PhoneNumber
- type PostalTradeAddress
- type Product
- type Project
- type Quantity
- type ReferencedDocument
- type Settlement
- type SpecifiedTaxRegistration
- type Summary
- type Summation
- type Tax
- type TaxTotalAmount
- type Terms
- type TradeLocation
- type TradeSettlement
- type Transaction
- type URIUniversalCommunication
Constants ¶
const ( NamespaceRSM = "urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100" NamespaceRAM = "urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100" NamespaceQDT = "urn:un:unece:uncefact:data:standard:QualifiedDataType:100" NamespaceUDT = "urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100" )
CII namespaces
const ( VersionD16B string = "D16B" VersionD22B string = "D22B" )
CII Versions
const ( AdditionalDocumentTypeTender = "50" AdditionalDocumentTypeProductInvoice = "130" )
Values for AdditionalReferencedDocument.TypeCode
const ( // SchemeIDEmail represents the Scheme ID for email addresses SchemeIDEmail = "EM" // SchemeIDVAT represents a VAT registration (BT-31, BT-48, BT-63) SchemeIDVAT = "VA" // SchemeIDTaxRegistration represents a non-VAT tax registration (BT-32) SchemeIDTaxRegistration = "FC" )
const AdditionalDocumentTypeAttachment = "916"
AdditionalDocumentTypeAttachment is the TypeCode for additional supporting documents
const GuidelineIDEN16931 = "urn:cen.eu:en16931:2017"
GuidelineIDEN16931 identifies plain EN 16931 documents (BT-24), which most specifications build on.
const KeyCII cbc.Key = "cii"
KeyCII identifies CII invoices that do not declare a known specification. They can be imported, but not exported.
const (
NamespaceCDARRSM = "urn:un:unece:uncefact:data:standard:CrossDomainAcknowledgementAndResponse:100"
)
CDAR namespaces
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") )
var FormatEN16931 = Format{ Key: "cii+en16931-v2017", Name: i18n.NewString("CII EN 16931:2017"), Import: []schema.ID{invoiceSchema}, Export: []schema.ID{invoiceSchema}, GuidelineID: GuidelineIDEN16931, Version: VersionD16B, Addons: []cbc.Key{en16931.V2017}, Attachments: true, VESID: vesIDEN16931CII, }
FormatEN16931 is used for EN 16931 documents, and is the default.
Functions ¶
func CleanString ¶ added in v0.67.0
CleanString removes the replacement characters left by broken text encodings from incoming text.
func ExpandGroupLines ¶ added in v0.67.0
ExpandGroupLines writes the breakdown of each invoice line as sub-lines after it, turning the line into a GROUP line, as the EXTENDED profiles allow. Formats that support sub-lines call it from their export functions.
func Import ¶ added in v0.67.0
Import converts the CII invoice into a GOBL envelope. The format is determined from the document's guideline and business process IDs, unless a WithFormat option is provided. Other documents, such as a CDAR, are imported by the packages that implement their formats.
func ParseParty ¶ added in v0.67.0
ParseParty converts the CII trade party into a GOBL party, without any format specific adjustments.
func RegisterFormats ¶ added in v0.67.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 AccountingAccount ¶ added in v0.28.0
type AccountingAccount struct {
ID string `xml:"ram:ID,omitempty"`
}
AccountingAccount defines the structure of ReceivableSpecifiedTradeAccountingAccount
type AdditionalDocument ¶ added in v0.7.0
type AdditionalDocument struct {
ID string `xml:"ram:IssuerAssignedID,omitempty"`
URIID string `xml:"ram:URIID,omitempty"`
TypeCode string `xml:"ram:TypeCode,omitempty"`
Name string `xml:"ram:Name,omitempty"`
AttachmentBinaryObject *BinaryObject `xml:"ram:AttachmentBinaryObject,omitempty"`
IssueDate *FormattedIssueDate `xml:"ram:FormattedIssueDateTime,omitempty"`
}
AdditionalDocument defines the structure of AdditionalReferencedDocument of the CII standard
type Advance ¶ added in v0.7.0
type Advance struct {
Amount string `xml:"ram:PaidAmount"`
Date *FormattedIssueDate `xml:"ram:FormattedReceivedDateTime,omitempty"`
}
Advance defines the structure of SpecifiedAdvancePayment of the CII standard
type Agreement ¶ added in v0.7.0
type Agreement struct {
BuyerReference string `xml:"ram:BuyerReference,omitempty"`
Seller *Party `xml:"ram:SellerTradeParty,omitempty"`
Buyer *Party `xml:"ram:BuyerTradeParty,omitempty"`
SalesAgent *Party `xml:"ram:SalesAgentTradeParty,omitempty"`
TaxRepresentative *Party `xml:"ram:SellerTaxRepresentativeTradeParty,omitempty"`
DeliveryTerms *DeliveryTerms `xml:"ram:ApplicableTradeDeliveryTerms,omitempty"`
Sales *IssuerID `xml:"ram:SellerOrderReferencedDocument,omitempty"`
Purchase *IssuerID `xml:"ram:BuyerOrderReferencedDocument,omitempty"`
Contract *IssuerID `xml:"ram:ContractReferencedDocument,omitempty"`
AdditionalDocument []*AdditionalDocument `xml:"ram:AdditionalReferencedDocument,omitempty"`
BuyerAgent *Party `xml:"ram:BuyerAgentTradeParty,omitempty"`
Project *Project `xml:"ram:SpecifiedProcurringProject,omitempty"`
}
Agreement defines the structure of the ApplicableHeaderTradeAgreement of the CII standard
type AllowanceCharge ¶ added in v0.7.0
type AllowanceCharge struct {
ChargeIndicator Indicator `xml:"ram:ChargeIndicator"`
Percent string `xml:"ram:CalculationPercent,omitempty"`
Base string `xml:"ram:BasisAmount,omitempty"`
Amount string `xml:"ram:ActualAmount,omitempty"`
ReasonCode string `xml:"ram:ReasonCode,omitempty"`
Reason string `xml:"ram:Reason,omitempty"`
Tax *Tax `xml:"ram:CategoryTradeTax,omitempty"`
}
AllowanceCharge defines the structure of SpecifiedTradeAllowanceCharge of the CII standard, also used for line items
type BinaryAttachment ¶ added in v0.28.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
}
BinaryAttachment represents a binary attachment that can be extracted from or added to a CII invoice.
type BinaryObject ¶ added in v0.28.0
type BinaryObject struct {
Value string `xml:",chardata"`
MimeCode string `xml:"mimeCode,attr,omitempty"`
Filename string `xml:"filename,attr,omitempty"`
}
BinaryObject represents binary data with associated metadata in CII
type CDAR ¶ added in v0.27.0
type CDAR struct {
XMLName xml.Name `xml:"rsm:CrossDomainAcknowledgementAndResponse"`
RSMNamespace string `xml:"xmlns:rsm,attr"`
RAMNamespace string `xml:"xmlns:ram,attr"`
QDTNamespace string `xml:"xmlns:qdt,attr"`
UDTNamespace string `xml:"xmlns:udt,attr"`
ExchangedDocumentContext *CDARExchangedContext `xml:"rsm:ExchangedDocumentContext,omitempty"`
ExchangedDocument *CDARExchangedDocument `xml:"rsm:ExchangedDocument"`
AcknowledgementDocuments []*CDARAcknowledgement `xml:"rsm:AcknowledgementDocument"`
}
CDAR represents the root structure for Cross Domain Acknowledgement and Response
type CDARAcknowledgement ¶ added in v0.27.0
type CDARAcknowledgement struct {
MultipleReferencesIndicator *CDARIndicator `xml:"ram:MultipleReferencesIndicator,omitempty"`
ID string `xml:"ram:ID,omitempty"`
TypeCode string `xml:"ram:TypeCode,omitempty"`
Name string `xml:"ram:Name,omitempty"`
IssueDateTime *CDARIssueDateTime `xml:"ram:IssueDateTime,omitempty"`
StatusCode string `xml:"ram:StatusCode,omitempty"`
AcknowledgementStatusCode string `xml:"ram:AcknowledgementStatusCode,omitempty"`
ItemIdentificationID string `xml:"ram:ItemIdentificationID,omitempty"`
ReasonInformation []string `xml:"ram:ReasonInformation,omitempty"`
ChannelCode string `xml:"ram:ChannelCode,omitempty"`
Status []string `xml:"ram:Status,omitempty"`
ReferenceReferencedDocument []*CDARReferencedDocument `xml:"ram:ReferenceReferencedDocument"`
}
CDARAcknowledgement represents an AcknowledgementDocument in the CDAR standard
type CDARBinaryObject ¶ added in v0.27.0
type CDARBinaryObject struct {
Value string `xml:",chardata"`
MimeCode string `xml:"mimeCode,attr,omitempty"`
Filename string `xml:"filename,attr,omitempty"`
CharacterSet string `xml:"characterSet,attr,omitempty"`
}
CDARBinaryObject represents a binary object attachment
type CDARDateTimeString ¶ added in v0.27.0
type CDARDateTimeString struct {
Value string `xml:",chardata"`
Format string `xml:"format,attr,omitempty"`
}
CDARDateTimeString defines a date-time with format attribute
type CDARDocumentCharacteristic ¶ added in v0.27.0
type CDARDocumentCharacteristic struct {
ID string `xml:"ram:ID,omitempty"`
TypeCode string `xml:"ram:TypeCode,omitempty"`
ValueChangedIndicator *CDARIndicatorString `xml:"ram:ValueChangedIndicator,omitempty"`
Name string `xml:"ram:Name,omitempty"`
Location string `xml:"ram:Location,omitempty"`
ValueAmount *CDARValueAmount `xml:"ram:ValueAmount,omitempty"`
ValuePercent string `xml:"ram:ValuePercent,omitempty"`
ValueDateTime *CDARIssueDateTime `xml:"ram:ValueDateTime,omitempty"`
}
CDARDocumentCharacteristic represents a characteristic attached to a document status
type CDARDocumentContextParameter ¶ added in v0.27.0
type CDARDocumentContextParameter struct {
ID string `xml:"ram:ID"`
}
CDARDocumentContextParameter defines the structure of DocumentContextParameter of the CDAR standard
type CDARDocumentStatus ¶ added in v0.27.0
type CDARDocumentStatus struct {
ReferenceDateTime *CDARIssueDateTime `xml:"ram:ReferenceDateTime,omitempty"`
ConditionCode string `xml:"ram:ConditionCode,omitempty"`
ReasonCode string `xml:"ram:ReasonCode,omitempty"`
Reason []string `xml:"ram:Reason,omitempty"`
RequestedActionCode string `xml:"ram:RequestedActionCode,omitempty"`
RequestedAction string `xml:"ram:RequestedAction,omitempty"`
SequenceNumeric string `xml:"ram:SequenceNumeric,omitempty"`
IncludedNotes []*CDARNote `xml:"ram:IncludedNote,omitempty"`
SpecifiedDocumentCharacteristics []*CDARDocumentCharacteristic `xml:"ram:SpecifiedDocumentCharacteristic,omitempty"`
}
CDARDocumentStatus represents a document status with conditions and reasons
type CDARExchangedContext ¶ added in v0.27.0
type CDARExchangedContext struct {
BusinessProcessParameter *CDARDocumentContextParameter `xml:"ram:BusinessProcessSpecifiedDocumentContextParameter,omitempty"`
GuidelineParameter *CDARDocumentContextParameter `xml:"ram:GuidelineSpecifiedDocumentContextParameter"`
}
CDARExchangedContext defines the structure of the ExchangedDocumentContext of the CDAR standard
type CDARExchangedDocument ¶ added in v0.27.0
type CDARExchangedDocument struct {
ID string `xml:"ram:ID,omitempty"`
Name string `xml:"ram:Name,omitempty"`
TypeCode string `xml:"ram:TypeCode,omitempty"`
StatusCode string `xml:"ram:StatusCode,omitempty"`
IssueDateTime *CDARIssueDateTime `xml:"ram:IssueDateTime,omitempty"`
LanguageID string `xml:"ram:LanguageID,omitempty"`
ElectronicPresentation *CDARIndicator `xml:"ram:ElectronicPresentationIndicator,omitempty"`
VersionID string `xml:"ram:VersionID,omitempty"`
GlobalID string `xml:"ram:GlobalID,omitempty"`
IncludedNotes []*CDARNote `xml:"ram:IncludedNote,omitempty"`
EffectivePeriod *CDARSpecifiedPeriod `xml:"ram:EffectiveSpecifiedPeriod,omitempty"`
SenderTradeParty *CDARTradeParty `xml:"ram:SenderTradeParty,omitempty"`
IssuerTradeParty *CDARTradeParty `xml:"ram:IssuerTradeParty,omitempty"`
RecipientTradeParties []*CDARTradeParty `xml:"ram:RecipientTradeParty,omitempty"`
}
CDARExchangedDocument defines the structure of the ExchangedDocument of the CDAR standard
type CDARFormattedIssueDateTime ¶ added in v0.27.0
type CDARFormattedIssueDateTime struct {
DateTimeString *CDARQDTDateTimeString `xml:"qdt:DateTimeString"`
}
CDARFormattedIssueDateTime defines formatted issue date time with qdt namespace
type CDARGlobalID ¶ added in v0.27.0
type CDARGlobalID struct {
Value string `xml:",chardata"`
SchemeID string `xml:"schemeID,attr,omitempty"`
}
CDARGlobalID represents global identifier with scheme
type CDARID ¶ added in v0.27.0
type CDARID struct {
Value string `xml:",chardata"`
SchemeID string `xml:"schemeID,attr,omitempty"`
}
CDARID represents an identifier
type CDARIndicator ¶ added in v0.27.0
type CDARIndicator struct {
Value bool `xml:"udt:Indicator"`
}
CDARIndicator represents a boolean indicator
type CDARIndicatorString ¶ added in v0.27.0
type CDARIndicatorString struct {
Value string `xml:"udt:IndicatorString"`
}
CDARIndicatorString represents a boolean indicator using udt:IndicatorString
type CDARIssueDateTime ¶ added in v0.27.0
type CDARIssueDateTime struct {
DateTimeString *CDARDateTimeString `xml:"udt:DateTimeString"`
}
CDARIssueDateTime defines the structure of IssueDateTime of the CDAR standard
type CDARNote ¶ added in v0.27.0
type CDARNote struct {
ContentCode string `xml:"ram:ContentCode,omitempty"`
Content []string `xml:"ram:Content,omitempty"`
SubjectCode string `xml:"ram:SubjectCode,omitempty"`
}
CDARNote defines note in the RAM structure
type CDARQDTDateTimeString ¶ added in v0.27.0
type CDARQDTDateTimeString struct {
Value string `xml:",chardata"`
Format string `xml:"format,attr,omitempty"`
}
CDARQDTDateTimeString defines a date-time in qdt namespace with format attribute
type CDARReferencedDocument ¶ added in v0.27.0
type CDARReferencedDocument struct {
IssuerAssignedID string `xml:"ram:IssuerAssignedID,omitempty"`
StatusCode string `xml:"ram:StatusCode,omitempty"`
CopyIndicator *CDARIndicator `xml:"ram:CopyIndicator,omitempty"`
LineID string `xml:"ram:LineID,omitempty"`
TypeCode string `xml:"ram:TypeCode,omitempty"`
GlobalID string `xml:"ram:GlobalID,omitempty"`
RevisionID string `xml:"ram:RevisionID,omitempty"`
Name string `xml:"ram:Name,omitempty"`
ReceiptDateTime *CDARIssueDateTime `xml:"ram:ReceiptDateTime,omitempty"`
AttachmentBinaryObjects []*CDARBinaryObject `xml:"ram:AttachmentBinaryObject,omitempty"`
ReferenceTypeCode string `xml:"ram:ReferenceTypeCode,omitempty"`
FormattedIssueDateTime *CDARFormattedIssueDateTime `xml:"ram:FormattedIssueDateTime,omitempty"`
ProcessConditionCode string `xml:"ram:ProcessConditionCode,omitempty"`
ProcessCondition string `xml:"ram:ProcessCondition,omitempty"`
IssuerTradeParty *CDARTradeParty `xml:"ram:IssuerTradeParty,omitempty"`
RecipientTradeParties []*CDARTradeParty `xml:"ram:RecipientTradeParty,omitempty"`
SpecifiedDocumentStatuses []*CDARDocumentStatus `xml:"ram:SpecifiedDocumentStatus,omitempty"`
}
CDARReferencedDocument represents a referenced document in the CDAR standard
type CDARSpecifiedPeriod ¶ added in v0.27.0
type CDARSpecifiedPeriod struct {
StartDateTime *CDARIssueDateTime `xml:"ram:StartDateTime,omitempty"`
EndDateTime *CDARIssueDateTime `xml:"ram:EndDateTime,omitempty"`
}
CDARSpecifiedPeriod defines a period with start and end dates
type CDARTradeAddress ¶ added in v0.27.0
type CDARTradeAddress struct {
PostcodeCode string `xml:"ram:PostcodeCode,omitempty"`
LineOne string `xml:"ram:LineOne,omitempty"`
LineTwo string `xml:"ram:LineTwo,omitempty"`
LineThree string `xml:"ram:LineThree,omitempty"`
LineFour string `xml:"ram:LineFour,omitempty"`
LineFive string `xml:"ram:LineFive,omitempty"`
StreetName string `xml:"ram:StreetName,omitempty"`
CityName string `xml:"ram:CityName,omitempty"`
CountryID string `xml:"ram:CountryID,omitempty"`
CountryName string `xml:"ram:CountryName,omitempty"`
}
CDARTradeAddress represents address information
type CDARTradeContact ¶ added in v0.27.0
type CDARTradeContact struct {
ID string `xml:"ram:ID,omitempty"`
PersonName string `xml:"ram:PersonName,omitempty"`
DepartmentName string `xml:"ram:DepartmentName,omitempty"`
TypeCode string `xml:"ram:TypeCode,omitempty"`
TelephoneUniversalCommunication []*CDARUniversalCommunication `xml:"ram:TelephoneUniversalCommunication,omitempty"`
FaxUniversalCommunication []*CDARUniversalCommunication `xml:"ram:FaxUniversalCommunication,omitempty"`
EmailURIUniversalCommunication *CDARUniversalCommunication `xml:"ram:EmailURIUniversalCommunication,omitempty"`
}
CDARTradeContact represents contact details
type CDARTradeParty ¶ added in v0.27.0
type CDARTradeParty struct {
IDs []*CDARID `xml:"ram:ID,omitempty"`
GlobalIDs []*CDARGlobalID `xml:"ram:GlobalID,omitempty"`
Name string `xml:"ram:Name,omitempty"`
RoleCode string `xml:"ram:RoleCode,omitempty"`
DefinedTradeContacts []*CDARTradeContact `xml:"ram:DefinedTradeContact,omitempty"`
PostalTradeAddress *CDARTradeAddress `xml:"ram:PostalTradeAddress,omitempty"`
URIUniversalCommunication *CDARUniversalCommunication `xml:"ram:URIUniversalCommunication,omitempty"`
}
CDARTradeParty represents party information (sender, issuer, recipient)
type CDARURIID ¶ added in v0.27.0
type CDARURIID struct {
Value string `xml:",chardata"`
SchemeID string `xml:"schemeID,attr,omitempty"`
}
CDARURIID represents electronic address identifier with scheme
type CDARUniversalCommunication ¶ added in v0.27.0
type CDARUniversalCommunication struct {
URIID *CDARURIID `xml:"ram:URIID,omitempty"`
CompleteNumber string `xml:"ram:CompleteNumber,omitempty"`
}
CDARUniversalCommunication represents electronic communication details
type CDARValueAmount ¶ added in v0.37.0
type CDARValueAmount struct {
Value string `xml:",chardata"`
CurrencyID string `xml:"currencyID,attr,omitempty"`
}
CDARValueAmount represents a monetary value with the currencyID attribute required by the CDAR XSD for ValueAmount elements.
type Card ¶ added in v0.7.0
type Card struct {
ID string `xml:"ram:ID,omitempty"`
Name string `xml:"ram:CardholderName,omitempty"`
}
Card defines the structure of ApplicableTradeSettlementFinancialCard of the CII standard
type ChainEvent ¶ added in v0.7.0
type ChainEvent struct {
OccurrenceDate *IssueDate `xml:"ram:OccurrenceDateTime"`
}
ChainEvent defines the structure of the OccurrenceDateTime of the CII standard
type Characteristic ¶ added in v0.7.0
type Characteristic struct {
Description string `xml:"ram:Description,omitempty"`
ValueMeasure *Quantity `xml:"ram:ValueMeasure,omitempty"`
Value string `xml:"ram:Value,omitempty"`
}
Characteristic defines the structure of the ApplicableProductCharacteristic of the CII standard. ValueMeasure is only ever read: documents from senders using the CII extended profile may carry one, but the EN 16931 profiles do not accept it on output.
type Classification ¶ added in v0.7.0
type Classification struct {
Code *ListID `xml:"ram:ClassCode,omitempty"`
}
Classification defines the structure of the DesignatedProductClassification of the CII standard
type Contact ¶ added in v0.7.0
type Contact struct {
PersonName string `xml:"ram:PersonName,omitempty"`
Department string `xml:"ram:DepartmentName,omitempty"`
Phone *PhoneNumber `xml:"ram:TelephoneUniversalCommunication,omitempty"`
Email *Email `xml:"ram:EmailURIUniversalCommunication,omitempty"`
}
Contact defines the structure of the DefinedTradeContact of the CII standard
type Creditor ¶ added in v0.7.0
type Creditor struct {
IBAN string `xml:"ram:IBANID,omitempty"`
Name string `xml:"ram:AccountName,omitempty"`
Number string `xml:"ram:ProprietaryID,omitempty"`
}
Creditor defines the structure of PayeePartyCreditorFinancialAccount of the CII standard
type CreditorInstitution ¶ added in v0.7.0
type CreditorInstitution struct {
BIC string `xml:"ram:BICID,omitempty"`
}
CreditorInstitution defines the structure of PayeeSpecifiedCreditorFinancialInstitution of the CII standard
type DebtorAccount ¶ added in v0.7.0
type DebtorAccount struct {
IBAN string `xml:"ram:IBANID,omitempty"`
}
DebtorAccount defines the structure of PayerPartyDebtorFinancialAccount of the CII standard
type Delivery ¶ added in v0.7.0
type Delivery struct {
Receiver *Party `xml:"ram:ShipToTradeParty,omitempty"`
Event *ChainEvent `xml:"ram:ActualDeliverySupplyChainEvent,omitempty"`
Despatch *IssuerID `xml:"ram:DespatchAdviceReferencedDocument,omitempty"`
Receiving *IssuerID `xml:"ram:ReceivingAdviceReferencedDocument,omitempty"`
}
Delivery defines the structure of ApplicableHeaderTradeDelivery of the CII standard
type DeliveryTerms ¶ added in v0.81.0
type DeliveryTerms struct {
Code string `xml:"ram:DeliveryTypeCode,omitempty"`
Location *TradeLocation `xml:"ram:RelevantTradeLocation,omitempty"`
}
DeliveryTerms defines the structure of the ApplicableTradeDeliveryTerms of the CII standard. EN 16931 has no business term for it, so the formats that define it, such as the French CTC Extended profile, map it themselves.
type Document ¶ added in v0.67.0
type Document interface {
// contains filtered or unexported methods
}
Document is a UN/CEFACT document: an *Invoice (Cross Industry Invoice) or a *CDAR (Cross Domain Acknowledgement and Response).
type Email ¶ added in v0.7.0
type Email struct {
URIID string `xml:"ram:URIID,omitempty"`
}
Email defines the structure of the EmailURIUniversalCommunication of the CII standard
type ExchangedContext ¶ added in v0.7.0
type ExchangedContext struct {
BusinessContext *ExchangedContextParameter `xml:"ram:BusinessProcessSpecifiedDocumentContextParameter,omitempty"`
GuidelineContext *ExchangedContextParameter `xml:"ram:GuidelineSpecifiedDocumentContextParameter"`
}
ExchangedContext defines the structure of the ExchangedDocumentContext of the CII standard
type ExchangedContextParameter ¶ added in v0.7.0
type ExchangedContextParameter struct {
ID string `xml:"ram:ID"`
}
ExchangedContextParameter defines the structure of the ExchangedDocumentContextParameter of the CII standard
type ExportFunc ¶ added in v0.67.0
ExportFunc adjusts the CII document exported from the GOBL envelope for a format.
type Format ¶ added in v0.67.0
type Format struct {
// Key identifies the format in the GOBL convert register, with one layer
// for each specification it builds on, e.g. "cii+fr-ctc-cius-v1".
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
// GuidelineID identifies the specification (BT-24).
GuidelineID string
// BusinessID identifies the business process (BT-23).
BusinessID string
// OutputGuidelineID optionally specifies a different GuidelineID
// to use in the actual generated CII XML document. If empty, GuidelineID
// is used. This allows the format to be identified by one ID externally while
// generating different values in the XML output.
OutputGuidelineID string
// Version of the CII syntax the format uses.
Version string
// Addons required by the format.
Addons []cbc.Key
// Attachments is true when the format's documents can embed files, such
// as a PDF version of the invoice, in additional referenced documents.
// The GOBL convert register only passes attachments to these formats.
Attachments bool
// VESID is the Validation Exchange Specification ID used for validation
VESID string
// Match optionally identifies the format's documents before the
// GuidelineID and BusinessID are compared.
Match func(guidelineID, businessID string) bool
// Fallback optionally claims documents that no format matched.
Fallback func(guidelineID, businessID string) bool
// OnRequest formats are never detected: they import only when asked for
// by key, as their documents can't be told from another format's by
// their contents, only by their container.
OnRequest bool
// ExportFuncs adjust the CII document exported from GOBL, in order, after
// the base export.
ExportFuncs []ExportFunc
// ImportFuncs adjust the GOBL envelope imported from CII, in order, after
// the base import and before the document is calculated.
ImportFuncs []ImportFunc
}
Format defines a CII format: the guideline and business process its documents carry, and the functions that adjust the base import and export for the specification it represents.
func FindFormat ¶ added in v0.67.0
FindFormat looks up a registered format by GuidelineID and optionally BusinessID, 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 GuidelineID (for external identification)
- If not found, tries to match on OutputGuidelineID (for parsing incoming documents)
- Formats whose Fallback function claims the document
type FormattedIssueDate ¶ added in v0.7.0
type FormattedIssueDate struct {
DateFormat *Date `xml:"qdt:DateTimeString"`
}
FormattedIssueDate defines the structure of the FormattedIssueDateTime of the CII standard
type GrossPrice ¶ added in v0.68.0
type GrossPrice struct {
Amount string `xml:"ram:ChargeAmount"`
BaseQuantity *Quantity `xml:"ram:BasisQuantity,omitempty"`
AllowanceCharge *AllowanceCharge `xml:"ram:AppliedTradeAllowanceCharge,omitempty"`
}
GrossPrice defines the structure of the GrossPriceProductTradePrice in the CII standard: the list price (BT-148) and the price discount (BT-147).
type Header ¶ added in v0.7.0
type Header struct {
ID string `xml:"ram:ID"`
TypeCode string `xml:"ram:TypeCode"`
IssueDate *IssueDate `xml:"ram:IssueDateTime"`
IncludedNote []*Note `xml:"ram:IncludedNote,omitempty"`
}
Header a collection of data for a Cross Industry Invoice Header that is exchanged between two or more parties in written, printed or electronic form.
type HeaderInfo ¶ added in v0.67.0
type HeaderInfo struct {
// Namespace of the root element.
Namespace string
// GuidelineID declares the specification the document follows.
GuidelineID string
// BusinessID declares the business process.
BusinessID string
// Err is set if the identifiers could not be read.
Err error
}
HeaderInfo holds the identifiers at the start of a CII or CDAR document that determine its format.
func ReadHeader ¶ added in v0.67.0
func ReadHeader(in *convert.Input) *HeaderInfo
ReadHeader provides the root namespace and the guideline and business process identifiers of the input, reading them only once for all the converters that ask.
type ImportFunc ¶ added in v0.67.0
ImportFunc adjusts the GOBL envelope imported from the CII document for a format, before the envelope is calculated.
type Indicator ¶ added in v0.7.0
type Indicator struct {
Value bool `xml:"udt:Indicator"`
}
Indicator defines the structure of Indicator of the CII standard
type Invoice ¶ added in v0.7.0
type Invoice struct {
XMLName xml.Name `xml:"rsm:CrossIndustryInvoice"`
RSMNamespace string `xml:"xmlns:rsm,attr"`
RAMNamespace string `xml:"xmlns:ram,attr"`
QDTNamespace string `xml:"xmlns:qdt,attr"`
UDTNamespace string `xml:"xmlns:udt,attr"`
ExchangedContext *ExchangedContext `xml:"rsm:ExchangedDocumentContext"`
ExchangedDocument *Header `xml:"rsm:ExchangedDocument"`
Transaction *Transaction `xml:"rsm:SupplyChainTradeTransaction"`
}
Invoice is a pseudo-model for containing the XML document being created
func ExportInvoice ¶ added in v0.67.0
ExportInvoice is a convenience function that exports a GOBL envelope containing an invoice into a CII Invoice.
func (*Invoice) AddBinaryAttachment ¶ added in v0.28.0
func (out *Invoice) AddBinaryAttachment(att BinaryAttachment)
AddBinaryAttachment adds an embedded binary attachment to the CII Invoice. The binary data will be automatically base64-encoded.
func (*Invoice) ExtractBinaryAttachments ¶ added in v0.28.0
func (out *Invoice) ExtractBinaryAttachments() []BinaryAttachment
ExtractBinaryAttachments extracts all binary attachments from the CII Invoice. It returns a slice of BinaryAttachment containing the ID, description, and decoded binary data.
type IssueDate ¶ added in v0.7.0
type IssueDate struct {
DateFormat *Date `xml:"udt:DateTimeString"`
}
IssueDate defines the structure of the IssueDateTime of the CII standard
type IssuerID ¶ added in v0.7.0
type IssuerID struct {
ID string `xml:"ram:IssuerAssignedID,omitempty"`
ReferenceTypeCode string `xml:"ram:ReferenceTypeCode,omitempty"`
}
IssuerID defines the structure of IssuerAssignedID of the CII standard. ReferenceTypeCode (UNCL 1153) is left for profiles that define it, such as the French contract type.
type LegalOrganization ¶ added in v0.7.0
type LegalOrganization struct {
ID *PartyID `xml:"ram:ID"`
Name string `xml:"ram:TradingBusinessName,omitempty"`
}
LegalOrganization defines the structure of the SpecifiedLegalOrganization of the CII standard
type Line ¶ added in v0.7.0
type Line struct {
LineDoc *LineDoc `xml:"ram:AssociatedDocumentLineDocument"`
Product *Product `xml:"ram:SpecifiedTradeProduct"`
Agreement *LineAgreement `xml:"ram:SpecifiedLineTradeAgreement"`
Quantity *LineDelivery `xml:"ram:SpecifiedLineTradeDelivery"`
TradeSettlement *TradeSettlement `xml:"ram:SpecifiedLineTradeSettlement"`
}
Line defines the structure of the IncludedSupplyChainTradeLineItem in the CII standard
type LineAgreement ¶ added in v0.7.0
type LineAgreement struct {
OrderReference *LineOrderReference `xml:"ram:BuyerOrderReferencedDocument,omitempty"`
AdditionalReference *LineDocReference `xml:"ram:AdditionalReferencedDocument,omitempty"`
GrossPrice *GrossPrice `xml:"ram:GrossPriceProductTradePrice,omitempty"`
NetPrice *NetPrice `xml:"ram:NetPriceProductTradePrice"`
// The XSD sequence places the item seller after the prices, before
// ItemBuyerTradeParty.
ItemSellerParty *Party `xml:"ram:ItemSellerTradeParty,omitempty"`
}
LineAgreement defines the structure of the SpecifiedLineTradeAgreement in the CII standard
type LineDelivery ¶ added in v0.7.0
type LineDelivery struct {
Quantity *Quantity `xml:"ram:BilledQuantity"`
}
LineDelivery defines the structure of the SpecifiedLineTradeDelivery in the CII standard
type LineDoc ¶ added in v0.7.0
type LineDoc struct {
ID string `xml:"ram:LineID"`
// EXT-FR-FE-162/163. LineStatusCode is only read.
ParentLineID string `xml:"ram:ParentLineID,omitempty"`
LineStatusCode string `xml:"ram:LineStatusCode,omitempty"`
LineStatusReasonCode string `xml:"ram:LineStatusReasonCode,omitempty"`
Note []*Note `xml:"ram:IncludedNote,omitempty"`
}
LineDoc defines the structure of the AssociatedDocumentLineDocument in the CII standard
type LineDocReference ¶ added in v0.28.0
type LineDocReference struct {
ID string `xml:"ram:IssuerAssignedID"`
TypeCode string `xml:"ram:TypeCode"`
RefCode *string `xml:"ram:ReferenceTypeCode,omitempty"`
}
LineDocReference defines the structure of AdditionalReferencedDocument at line level
type LineOrderReference ¶ added in v0.28.0
type LineOrderReference struct {
LineID string `xml:"ram:LineID,omitempty"`
}
LineOrderReference defines the structure of BuyerOrderReferencedDocument at line level
type NetPrice ¶ added in v0.7.0
type NetPrice struct {
Amount string `xml:"ram:ChargeAmount"`
BaseQuantity *Quantity `xml:"ram:BasisQuantity,omitempty"`
}
NetPrice defines the structure of the NetPriceProductTradePrice in the CII standard
type Note ¶ added in v0.7.0
type Note struct {
Content string `xml:"ram:Content,omitempty"`
SubjectCode string `xml:"ram:SubjectCode,omitempty"`
}
Note defines note in the RAM structure
type Option ¶ added in v0.7.0
type Option func(*options)
Option is used to define configuration options to use during the import and export processes.
func WithAttachments ¶ added in v0.75.0
func WithAttachments(atts ...BinaryAttachment) Option
WithAttachments embeds files, such as a PDF version of the invoice, in the exported invoice.
func WithFormat ¶ added in v0.67.0
WithFormat sets the format to use instead of the default on export, or the one detected on import.
func WithRouting ¶ added in v0.37.0
WithRouting supplies the transport addresses a received document was routed with — the Peppol SBD From / To — as fully-qualified participant URIs (e.g. "iso6523-actorid-upis::0225:code"). They are recorded verbatim on the envelope's Head.From / Head.To to mark who sent and who received the document.
type Party ¶ added in v0.7.0
type Party struct {
ID []*PartyID `xml:"ram:ID,omitempty"`
GlobalID []*PartyID `xml:"ram:GlobalID,omitempty"`
Name string `xml:"ram:Name,omitempty"`
RoleCode string `xml:"ram:RoleCode,omitempty"`
Description string `xml:"ram:Description,omitempty"`
LegalOrganization *LegalOrganization `xml:"ram:SpecifiedLegalOrganization,omitempty"`
Contact *Contact `xml:"ram:DefinedTradeContact,omitempty"`
PostalTradeAddress *PostalTradeAddress `xml:"ram:PostalTradeAddress,omitempty"`
URIUniversalCommunication *URIUniversalCommunication `xml:"ram:URIUniversalCommunication,omitempty"`
SpecifiedTaxRegistration []*SpecifiedTaxRegistration `xml:"ram:SpecifiedTaxRegistration,omitempty"`
}
Party defines the structure of the TradePartyType of the CII standard
func NewDeliveryParty ¶ added in v0.67.0
NewDeliveryParty creates a Party with only the BTs available for the delivery party (BT-70 name, BG-15 address).
type PartyID ¶ added in v0.7.0
type PartyID struct {
SchemeID string `xml:"schemeID,attr,omitempty"`
Value string `xml:",chardata"`
}
PartyID defines the structure of the ID of the CII standard
type PaymentMeans ¶ added in v0.7.0
type PaymentMeans struct {
TypeCode string `xml:"ram:TypeCode"`
Information string `xml:"ram:Information,omitempty"`
Card *Card `xml:"ram:ApplicableTradeSettlementFinancialCard,omitempty"`
Debtor *DebtorAccount `xml:"ram:PayerPartyDebtorFinancialAccount,omitempty"`
Creditor *Creditor `xml:"ram:PayeePartyCreditorFinancialAccount,omitempty"`
CreditorInstitution *CreditorInstitution `xml:"ram:PayeeSpecifiedCreditorFinancialInstitution,omitempty"`
}
PaymentMeans defines the structure of SpecifiedTradeSettlementPaymentMeans of the CII standard
type Period ¶ added in v0.7.0
type Period struct {
Description *string `xml:"ram:Description,omitempty"`
Start *IssueDate `xml:"ram:StartDateTime"`
End *IssueDate `xml:"ram:EndDateTime"`
}
Period defines the structure of the ExpectedDeliveryPeriod of the CII standard
type PhoneNumber ¶ added in v0.7.0
type PhoneNumber struct {
CompleteNumber string `xml:"ram:CompleteNumber,omitempty"`
}
PhoneNumber defines the structure of the TelephoneUniversalCommunication of the CII standard
type PostalTradeAddress ¶ added in v0.7.0
type PostalTradeAddress struct {
Postcode string `xml:"ram:PostcodeCode,omitempty"`
LineOne string `xml:"ram:LineOne,omitempty"`
LineTwo string `xml:"ram:LineTwo,omitempty"`
City string `xml:"ram:CityName,omitempty"`
CountryID string `xml:"ram:CountryID"`
Region string `xml:"ram:CountrySubDivisionName,omitempty"`
}
PostalTradeAddress defines the structure of the PostalTradeAddress of the CII standard
type Product ¶ added in v0.7.0
type Product struct {
GlobalID *GlobalID `xml:"ram:GlobalID,omitempty"`
SellerAssignedID *string `xml:"ram:SellerAssignedID,omitempty"`
BuyerAssignedID *string `xml:"ram:BuyerAssignedID,omitempty"`
Name string `xml:"ram:Name"`
Description *string `xml:"ram:Description,omitempty"`
Characteristics []*Characteristic `xml:"ram:ApplicableProductCharacteristic,omitempty"`
Classification *Classification `xml:"ram:DesignatedProductClassification,omitempty"`
Origin *string `xml:"ram:OriginTradeCountry>ram:ID,omitempty"`
}
Product defines the structure of the SpecifiedTradeProduct of the CII standard
type Project ¶ added in v0.7.0
Project defines common architecture of document reference fields in the CII standard
type Quantity ¶ added in v0.7.0
Quantity defines the structure of the quantity with its attributes for the CII standard
type ReferencedDocument ¶ added in v0.7.0
type ReferencedDocument struct {
IssuerAssignedID string `xml:"ram:IssuerAssignedID,omitempty"`
IssueDate *FormattedIssueDate `xml:"ram:FormattedIssueDateTime,omitempty"`
}
ReferencedDocument defines the structure of InvoiceReferencedDocument of the CII standard
type Settlement ¶ added in v0.7.0
type Settlement struct {
CreditorRefID string `xml:"ram:CreditorReferenceID,omitempty"`
PaymentReference string `xml:"ram:PaymentReference,omitempty"`
Currency string `xml:"ram:InvoiceCurrencyCode"`
Invoicer *Party `xml:"ram:InvoicerTradeParty,omitempty"`
Invoicee *Party `xml:"ram:InvoiceeTradeParty,omitempty"`
Payee *Party `xml:"ram:PayeeTradeParty,omitempty"`
Payer *Party `xml:"ram:PayerTradeParty,omitempty"`
PaymentMeans []*PaymentMeans `xml:"ram:SpecifiedTradeSettlementPaymentMeans"`
Tax []*Tax `xml:"ram:ApplicableTradeTax"`
Period *Period `xml:"ram:BillingSpecifiedPeriod,omitempty"`
AllowanceCharges []*AllowanceCharge `xml:"ram:SpecifiedTradeAllowanceCharge,omitempty"`
PaymentTerms []*Terms `xml:"ram:SpecifiedTradePaymentTerms,omitempty"`
Summary *Summary `xml:"ram:SpecifiedTradeSettlementHeaderMonetarySummation"`
ReferencedDocument []*ReferencedDocument `xml:"ram:InvoiceReferencedDocument,omitempty"`
AccountingAccount *AccountingAccount `xml:"ram:ReceivableSpecifiedTradeAccountingAccount,omitempty"`
Advance []*Advance `xml:"ram:SpecifiedAdvancePayment,omitempty"`
}
Settlement defines the structure of ApplicableHeaderTradeSettlement of the CII standard
type SpecifiedTaxRegistration ¶ added in v0.7.0
type SpecifiedTaxRegistration struct {
ID *PartyID `xml:"ram:ID"`
}
SpecifiedTaxRegistration defines the structure of the SpecifiedTaxRegistration of the CII standard
type Summary ¶ added in v0.7.0
type Summary struct {
LineTotalAmount string `xml:"ram:LineTotalAmount"`
Charges string `xml:"ram:ChargeTotalAmount,omitempty"`
Discounts string `xml:"ram:AllowanceTotalAmount,omitempty"`
TaxBasisTotalAmount string `xml:"ram:TaxBasisTotalAmount"`
TaxTotalAmount []*TaxTotalAmount `xml:"ram:TaxTotalAmount"`
RoundingAmount string `xml:"ram:RoundingAmount,omitempty"`
GrandTotalAmount string `xml:"ram:GrandTotalAmount"`
TotalPrepaidAmount string `xml:"ram:TotalPrepaidAmount,omitempty"`
DuePayableAmount string `xml:"ram:DuePayableAmount"`
}
Summary defines the structure of SpecifiedTradeSettlementHeaderMonetarySummation of the CII standard
type Summation ¶ added in v0.7.0
type Summation struct {
Amount string `xml:"ram:LineTotalAmount"`
}
Summation defines the structure of the SpecifiedTradeSettlementLineMonetarySummation of the CII standard
type Tax ¶ added in v0.7.0
type Tax struct {
CalculatedAmount string `xml:"ram:CalculatedAmount,omitempty"`
TypeCode string `xml:"ram:TypeCode,omitempty"`
ExemptionReason string `xml:"ram:ExemptionReason,omitempty"`
BasisAmount string `xml:"ram:BasisAmount,omitempty"`
CategoryCode string `xml:"ram:CategoryCode,omitempty"`
ExemptionReasonCode string `xml:"ram:ExemptionReasonCode,omitempty"`
DueDateTypeCode string `xml:"ram:DueDateTypeCode,omitempty"`
TaxPointDate *IssueDate `xml:"ram:TaxPointDate,omitempty"`
RateApplicablePercent string `xml:"ram:RateApplicablePercent,omitempty"`
}
Tax defines the structure of ApplicableTradeTax of the CII standard
type TaxTotalAmount ¶ added in v0.7.0
type TaxTotalAmount struct {
Amount string `xml:",chardata"`
Currency string `xml:"currencyID,attr"`
}
TaxTotalAmount defines the structure of the TaxTotalAmount of the CII standard
type Terms ¶ added in v0.7.0
type Terms struct {
Description string `xml:"ram:Description,omitempty"`
DueDate *IssueDate `xml:"ram:DueDateDateTime,omitempty"`
Mandate string `xml:"ram:DirectDebitMandateID,omitempty"`
// Amount and Percent are parse-only: present in some CII documents but not emitted
// as PartialPaymentAmount is not in the EN16931/Factur-X/ZUGFeRD schema.
Amount string `xml:"ram:PartialPaymentAmount,omitempty"`
Percent string `xml:"ram:PartialPaymentPercent,omitempty"`
}
Terms defines the structure of SpecifiedTradePaymentTerms of the CII standard
type TradeLocation ¶ added in v0.81.0
type TradeLocation struct {
Name string `xml:"ram:Name,omitempty"`
}
TradeLocation defines the structure of a RelevantTradeLocation of the CII standard.
type TradeSettlement ¶ added in v0.7.0
type TradeSettlement struct {
ApplicableTradeTax []*Tax `xml:"ram:ApplicableTradeTax"`
Period *Period `xml:"ram:BillingSpecifiedPeriod,omitempty"`
AllowanceCharge []*AllowanceCharge `xml:"ram:SpecifiedTradeAllowanceCharge,omitempty"`
Sum *Summation `xml:"ram:SpecifiedTradeSettlementLineMonetarySummation"`
AccountingAccount *AccountingAccount `xml:"ram:ReceivableSpecifiedTradeAccountingAccount,omitempty"`
}
TradeSettlement defines the structure of the SpecifiedLineTradeSettlement of the CII standard
type Transaction ¶ added in v0.7.0
type Transaction struct {
Lines []*Line `xml:"ram:IncludedSupplyChainTradeLineItem"`
Agreement *Agreement `xml:"ram:ApplicableHeaderTradeAgreement"`
Delivery *Delivery `xml:"ram:ApplicableHeaderTradeDelivery"`
Settlement *Settlement `xml:"ram:ApplicableHeaderTradeSettlement"`
}
Transaction defines the structure of the transaction in the CII standard
type URIUniversalCommunication ¶ added in v0.7.0
type URIUniversalCommunication struct {
ID *PartyID `xml:"ram:URIID"`
}
URIUniversalCommunication defines the structure of URIUniversalCommunication of the CII standard
Source Files
¶
- agreement.go
- allowance_charge.go
- allowance_charge_parse.go
- amounts.go
- attachments.go
- cdar.go
- cdar_acknowledgement.go
- cdar_document.go
- cdar_party.go
- cii.go
- converter.go
- delivery.go
- delivery_parse.go
- format.go
- funcs.go
- header.go
- header_parse.go
- invoice.go
- invoice_parse.go
- lines.go
- lines_parse.go
- ordering_parse.go
- party.go
- party_parse.go
- reconcile_parse.go
- settlement.go
- settlement_parse.go
- utils.go
- utils_parse.go