facturae

package module
v0.31.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: 28 Imported by: 2 modules, 0 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 FacturaE

Convert GOBL invoices to and from Spain's FacturaE 3.2.2 format, and define the es-facturae-v3 GOBL addon.

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

Lint Test Go Go Report Card GoDoc Latest Tag

Addon

The addon package defines the es-facturae-v3 GOBL addon: the FacturaE extensions (document type, invoice class, correction reason and subsidy), the scenarios that set them from the invoice type and tags, and the validation rules. Documents that declare the addon need the package imported to be calculated or validated. Importing the root package imports it too:

import _ "github.com/invopop/gobl.es.facturae/addon"

Usage

The package uses the same terms as the other GOBL converters:

Function Direction
Export(env, opts...) GOBL envelope to FacturaE document
Encode(doc) FacturaE document to XML bytes
Decode(data) XML bytes to FacturaE document
Import(doc) FacturaE document to GOBL envelope
Export
doc, err := facturae.Export(env)
if err != nil {
    panic(err)
}

data, err := facturae.Encode(doc)
if err != nil {
    panic(err)
}

The envelope is not changed: taxes included in prices are removed, and credit notes inverted, on a copy.

FacturaE documents are usually signed. Use a certificate to sign the document as follows:

// import from github.com/invopop/xmldsig
cert, err := xmldsig.LoadCertificate(filename, password)
if err != nil {
    panic(err)
}

doc, err := facturae.Export(env, facturae.WithCertificate(cert))

WithTimestamp, WithThirdParty and WithSigning add a timestamp, an issuing third party, and further signing options.

Import
doc, err := facturae.Decode(data)
if err != nil {
    panic(err)
}

env, err := facturae.Import(doc)

Import provides a calculated envelope with an invoice that declares the es-facturae-v3 addon. Signatures are read but not verified.

GOBL convert register

Importing this package registers the es-facturae-v3 format with the GOBL convert register, for importing and exporting invoices:

import (
    "github.com/invopop/gobl/convert"
    _ "github.com/invopop/gobl.es.facturae"
)

out, err := convert.Export(env, "es-facturae-v3")
res, err := convert.Import(data) // res.Envelope

Invoices must include the es-facturae-v3 addon and a customer to be exported. Otherwise the export is refused with convert.ErrNotSupported and rules faults, such as ES-FACTURAE-V3-BILL-INVOICE-01 on $addons. Documents exported through the register are not signed: use Export with WithCertificate to sign them. Attachments are not embedded yet, so exports with convert.WithAttachments are refused.

Command line

This package no longer includes a command-line tool. The gobl CLI from gobl.dev converts to and from FacturaE through the GOBL convert register. Its output is not signed.

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

gobl convert invoice.json invoice.xml --to es-facturae-v3
gobl convert invoice.xml

Import limitations

Import covers the FacturaE 3.2.2 that this package exports. Documents from other issuers may use parts of the schema it does not read yet.

  • Only FacturaE 3.2.2 is detected. FacturaE 3.2.1 uses a different namespace.
  • Documents must contain a single invoice. Batches of several invoices are refused with ErrUnsupportedBatch.
  • Tax rates are read as percentages. For Spanish suppliers, the rate key, such as general or general+eqs, is recovered when the percentage and surcharge match a rate on the invoice's date.
  • Address lines are read as the street, the number, and any further parts as extra street details.
  • Some details are not written to FacturaE, so they cannot be read back: the names of FACe administrative centres, due date percentages, descriptions of payments on account, and the order of advances.
  • Totals are calculated by GOBL rather than taken from the document.

Testing

Test data lives in test/data:

  • convert/*.json: GOBL envelopes, exported to the signed FacturaE documents in convert/out/*.xml.
  • parse/*.xml: FacturaE documents, imported to the GOBL envelopes in parse/out/*.json.

Run the tests, and update the expected output after a change, with:

go test ./...
go test ./... --update

Updating validates each exported document against the FacturaE schema in test/schema before writing it.

TestSignature checks each signed export as a receiver would, from the encoded bytes alone: every reference digest, the XAdES signing certificate and the signature value. It also checks that changed documents are refused, and that Decode reads the signature back. The documents in convert/out are indented for review, which breaks their signatures. Use Encode for documents that will be sent.

Test certificates are in test/certificates. The Spanish government validator checks documents and their signatures.

Considerations

  • FacturaE requires taxes separate from prices, so taxes included in prices are removed before export. This recalculates amounts from unit prices, and may differ by a cent from the original totals.
  • FacturaE requires a due date for each payment instruction. Payment instructions only appear in the document when the invoice has due dates.

Documentation

Index

Constants

View Source
const (
	NamespaceFacturaE = "http://www.facturae.gob.es/formato/Versiones/Facturaev3_2_2.xml"
	NamespaceDSig     = "http://www.w3.org/2000/09/xmldsig#"
)

Namespaces used for FacturaE. DSig stuff is handled in the signatures.

View Source
const (
	XAdESSupplier   xmldsig.XAdESSignerRole = "supplier"
	XAdESCustomer   xmldsig.XAdESSignerRole = "customer"
	XAdESThirdParty xmldsig.XAdESSignerRole = "third party"
)

XAdES Signer Roles used for FacturaE

View Source
const (
	ModalityIndividual = "I" // Individual
	ModalityBatch      = "L" // Batch or multiple invoices in on document
)

List of accepted Mobility Types

View Source
const (
	InvoiceIssuerSeller     = "EM"  // Seller
	InvoiceIssuerBuyer      = " RE" // Buyer
	InvoiceIssuerThirdParty = "TE"  // Third party
)

List of accepted Issuer Types

View Source
const (
	RoleTypeFiscal   = "01" // Oficina Contable
	RoleTypeReceiver = "02" // Órgano Gestor
	RoleTypePayer    = "03" // Unidad Tramitadora
)

Administrative centre role type codes for FACe

View Source
const ES string = "ESP"

ES is the ISO Alpha-3 code used for Spain

View Source
const KeyFacturaE cbc.Key = "es-facturae-v3"

KeyFacturaE identifies the FacturaE 3.2.2 format in the GOBL convert register.

Variables

View Source
var (
	ErrCertificateNotFound = errors.New("certificate-not-found")
)

Standard error messages for the repo

View Source
var ErrUnsupportedBatch = errors.New("facturae documents must contain a single invoice")

ErrUnsupportedBatch is returned when importing a document that does not contain exactly one invoice.

View Source
var ErrUnsupportedDocument = errors.New("unsupported document: expected FacturaE 3.2.2")

ErrUnsupportedDocument is returned when decoding data that is not a FacturaE 3.2.2 document.

Functions

func Encode added in v0.24.0

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

Encode provides the FacturaE XML document's bytes, including the XML declaration.

func Import added in v0.24.0

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

Import converts the FacturaE document into a GOBL envelope holding an invoice with the es-facturae-v3 addon, calculated but not validated. The document must contain a single invoice.

Types

type AdditionalData

type AdditionalData struct {
	InvoiceAdditionalInformation string `xml:"InvoiceAdditionalInformation,omitempty"`
}

AdditionalData stores notes that the provider of the invoice estimates are needed

type Address

type Address struct {
	Address     string `xml:"Address,omitempty"`
	PostCode    string `xml:"PostCode,omitempty"`
	Town        string `xml:"Town,omitempty"`
	Province    string `xml:"Province,omitempty"`
	CountryCode string `xml:"CountryCode,omitempty"`
}

Address stores location information for addresses in Spain

type AdministrativeCentre

type AdministrativeCentre struct {
	CentreCode      string           `xml:"CentreCode,omitempty"`
	RoleTypeCode    string           `xml:"RoleTypeCode,omitempty"`
	AddressInSpain  *Address         `xml:"AddressInSpain,omitempty"`
	OverseasAddress *OverseasAddress `xml:"OverseasAddress,omitempty"`
}

AdministrativeCentre represents an administrative unit within a public administration

type AdministrativeCentres

type AdministrativeCentres struct {
	Centres []*AdministrativeCentre `xml:"AdministrativeCentre"`
}

AdministrativeCentres contains a list of administrative centres required for invoicing Spanish public administrations (FACe)

type Amount

type Amount struct {
	TotalAmount       string `xml:"TotalAmount"`
	EquivalentInEuros string `xml:"EquivalentInEuros,omitempty"`
}

Amount wraps the Facturae AmountType. Monetary values rendered through amount are rounded to two decimals per Orden HAP/1650/2015 Annex II rule 6; unit prices and tax rates are the regulation's explicit exceptions and do not flow through this type.

type BankAccount

type BankAccount struct {
	IBAN                  string   `xml:"IBAN,omitempty"`
	AccountNumber         string   `xml:"AccountNumber,omitempty"`
	BranchInSpainAddress  *Address `xml:"BranchInSpainAddress,omitempty"`
	OverseasBranchAddress *Address `xml:"OverseasBranchAddress,omitempty"`
	BIC                   string   `xml:"BIC,omitempty"`
}

BankAccount contains info needed to pay by transfer or direct debit

type Batch

type Batch struct {
	BatchIdentifier        string `xml:"BatchIdentifier"`
	InvoicesCount          int    `xml:"InvoicesCount"`
	TotalInvoicesAmount    Amount `xml:"TotalInvoicesAmount"`
	TotalOutstandingAmount Amount `xml:"TotalOutstandingAmount"`
	TotalExecutableAmount  Amount `xml:"TotalExecutableAmount"`
	InvoiceCurrencyCode    string `xml:"InvoiceCurrencyCode"`
}

Batch would contain info about a group of invoices that are submitted at the same time, but we only allow one invoice at a time

type CertificateRepo

type CertificateRepo struct {
	// contains filtered or unexported fields
}

CertificateRepo is an implementation of the CertificateRepo that loads the certificate from a local file

func NewCertificateRepo

func NewCertificateRepo(path string) (*CertificateRepo, error)

NewCertificateRepo instantiates a new repository of certificates stored in a local directory. Each certificate found will be parsed and stored in a map of file names without extension to certificate instances.

func (*CertificateRepo) Get

func (repo *CertificateRepo) Get(id string) (*xmldsig.Certificate, error)

Get returns the local pre-loaded certificate

type Charge

type Charge struct {
	Reason string `xml:"ChargeReason"`
	Rate   string `xml:"ChargeRate,omitempty"`
	Amount string `xml:"ChargeAmount"`
}

Charge defines the basic data for a single surcharge.

type Charges

type Charges struct {
	Items []*Charge `xml:"Charge"`
}

Charges contains a list of charge instances. This is used both at a line and document level as per the FacturaE specification. Unfortunately, this implies that taxes will not be applied in the context of a global charge. We recommend avoiding using this in Spanish invoices.

type ContactDetails

type ContactDetails struct {
	Telephone                string `xml:"Telephone,omitempty"`
	TeleFax                  string `xml:"TeleFax,omitempty"`
	WebAddress               string `xml:"WebAddress,omitempty"`
	ElectronicMail           string `xml:"ElectronicMail,omitempty"`
	ContactPersons           string `xml:"ContactPersons,omitempty"`
	CnoCnae                  string `xml:"CnoCnae,omitempty"`     // Code of economic activity from INE
	INETownCode              string `xml:"INETownCode,omitempty"` // Code of town allocated by INE
	AdditionalContactDetails string `xml:"AdditionalContactDetails,omitempty"`
}

ContactDetails store info about how to contact the party

type Corrective

type Corrective struct {
	InvoiceNumber               string       `xml:"InvoiceNumber,omitempty"`
	InvoiceSeriesCode           string       `xml:"InvoiceSeriesCode,omitempty"`
	ReasonCode                  string       `xml:"ReasonCode"`
	ReasonDescription           string       `xml:"ReasonDescription"`
	TaxPeriod                   *PeriodDates `xml:"TaxPeriod"`
	CorrectionMethod            string       `xml:"CorrectionMethod"`
	CorrectionMethodDescription string       `xml:"CorrectionMethodDescription"`
	AdditionalReasonDescription string       `xml:"AdditionalReasonDescription,omitempty"`
	InvoiceIssueDate            string       `xml:"InvoiceIssueDate,omitempty"`
}

Corrective is used to represent the details of a previous invoice that this one serves to modify or replace. Details here are a bit sketchy as in practical usage, most companies don't demand this level of detail.

type Discount

type Discount struct {
	Reason string `xml:"DiscountReason"`
	Rate   string `xml:"DiscountRate,omitempty"`
	Amount string `xml:"DiscountAmount"`
}

Discount is used in general and line discounts. Unlike in GOBL, FacturaE does not differentiate between the two, which could potentially lead to confusion for handling taxes.

type Discounts

type Discounts struct {
	Items []*Discount `xml:"Discount"`
}

Discounts list discounts applied on a line or document level.

type Document

type Document struct {
	XMLName     xml.Name `xml:"fe:Facturae"`
	FeNamespace string   `xml:"xmlns:fe,attr"`

	FileHeader *FileHeader        `xml:"FileHeader"`
	Parties    *Parties           `xml:"Parties"`
	Invoices   *Invoices          `xml:"Invoices"`
	Signature  *xmldsig.Signature `xml:"ds:Signature,omitempty"`
	// contains filtered or unexported fields
}

Document is a pseudo-model for containing the XML document being created.

func Decode added in v0.24.0

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

Decode parses FacturaE 3.2.2 XML data into a document. Signatures are read but not verified.

func Export added in v0.24.0

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

Export converts the invoice in the GOBL envelope into a FacturaE document, signed when a certificate is provided.

func (*Document) BytesIndent

func (d *Document) BytesIndent() ([]byte, error)

BytesIndent returns the XML document bytes with indentation for readability. This is useful for debugging and testing purposes, but should not be used in production as it will not work correctly with digital signatures.

func (*Document) Canonical

func (d *Document) Canonical() ([]byte, error)

Canonical converts a struct representation of facturae to its canonical representation as defined in https://www.w3.org/TR/2001/REC-xml-c14n-20010315 (for a simpler explanation look at https://www.di-mgt.com.au/xmldsig-c14n.html) This is used when we need to create a hash for signing, timestamping, ...

type ExchangeRateDetails

type ExchangeRateDetails struct {
	ExchangeRate     string `xml:"ExchangeRate"`
	ExchangeRateDate string `xml:"ExchangeRateDate"`
}

ExchangeRateDetails describes how to exchange from the invoices currency to euros.

type FileHeader

type FileHeader struct {
	SchemaVersion     string      `xml:"SchemaVersion"`
	Modality          string      `xml:"Modality"`
	InvoiceIssuerType string      `xml:"InvoiceIssuerType"` // Who is signing the invoice?
	ThirdParty        *ThirdParty `xml:"ThirdParty,omitempty"`
	Batch             *Batch      `xml:"Batch"`
}

FileHeader contains the FileHeader element of a facturae invoice

type Individual

type Individual struct {
	Name            string           `xml:"Name"`
	FirstSurname    string           `xml:"FirstSurname,omitempty"`
	SecondSurname   string           `xml:"SecondSurname,omitempty"`
	AddressInSpain  *Address         `xml:"AddressInSpain,omitempty"`
	OverseasAddress *OverseasAddress `xml:"OverseasAddress,omitempty"`
	ContactDetails  *ContactDetails  `xml:"ContactDetails,omitempty"`
}

Individual stores party info for people

type Installment

type Installment struct {
	InstallmentDueDate              string       `xml:"InstallmentDueDate"`
	InstallmentAmount               string       `xml:"InstallmentAmount"`
	PaymentMeans                    string       `xml:"PaymentMeans,omitempty"`
	AccountToBeCredited             *BankAccount `xml:"AccountToBeCredited,omitempty"`
	AccountToBeDebited              *BankAccount `xml:"AccountToBeDebited,omitempty"`
	CollectionAdditionalInformation string       `xml:"CollectionAdditionalInformation,omitempty"`
	DebitReconciliationReference    string       `xml:"DebitReconciliationReference,omitempty"`
}

Installment contains info about each of the payment terms

type Invoice

type Invoice struct {
	InvoiceHeader    *InvoiceHeader    `xml:"InvoiceHeader"`
	InvoiceIssueData *InvoiceIssueData `xml:"InvoiceIssueData"`
	TaxesOutputs     *TaxSummary       `xml:"TaxesOutputs,omitempty"`
	TaxesWithheld    *TaxSummary       `xml:"TaxesWithheld,omitempty"`
	InvoiceTotals    *InvoiceTotals    `xml:"InvoiceTotals"`
	Items            *Items            `xml:"Items"`
	PaymentDetails   *PaymentDetails   `xml:"PaymentDetails,omitempty"`
	LegalLiterals    *LegalLiterals    `xml:"LegalLiterals,omitempty"`
	AdditionalData   *AdditionalData   `xml:"AdditionalData,omitempty"`
}

Invoice contains info about a single invoice

type InvoiceHeader

type InvoiceHeader struct {
	InvoiceNumber       string      `xml:"InvoiceNumber"`
	InvoiceSeriesCode   string      `xml:"InvoiceSeriesCode,omitempty"`
	InvoiceDocumentType string      `xml:"InvoiceDocumentType"`
	InvoiceClass        string      `xml:"InvoiceClass"`
	Corrective          *Corrective `xml:"Corrective,omitempty"`
}

InvoiceHeader contains general information of a single invoice

type InvoiceIssueData

type InvoiceIssueData struct {
	IssueDate                    string               `xml:"IssueDate"`
	OperationDate                string               `xml:"OperationDate,omitempty"`
	PlaceOfIssue                 string               `xml:"PlaceOfIssue,omitempty"`
	InvoiceingPeriod             *PeriodDates         `xml:"InvoiceingPeriod,omitempty"`
	InvoiceCurrencyCode          string               `xml:"InvoiceCurrencyCode"`
	ExchangeRateDetails          *ExchangeRateDetails `xml:"ExchangeRateDetails,omitempty"`
	TaxCurrencyCode              string               `xml:"TaxCurrencyCode"`
	LanguageName                 string               `xml:"LanguageName"`                           // FIXME: [JUANJO] are we going to support multiple languages?
	InvoiceDescription           string               `xml:"InvoiceDescription,omitempty"`           // TODO
	ReceiverTransactionReference string               `xml:"ReceiverTransactionReference,omitempty"` // TODO
	FileReference                string               `xml:"FileReference,omitempty"`                // TODO
	ReceiverContractReference    string               `xml:"ReceiverContractReference,omitempty"`    // TODO
}

InvoiceIssueData contains information about dates, lang and currencies

type InvoiceLine

type InvoiceLine struct {
	ItemDescription               string               `xml:"ItemDescription"`
	Quantity                      string               `xml:"Quantity"`
	UnitOfMeasure                 string               `xml:"UnitOfMeasure,omitempty"`
	UnitPriceWithoutTax           string               `xml:"UnitPriceWithoutTax"`
	TotalCost                     string               `xml:"TotalCost"` // Unit Price * quantity
	DiscountsAndRebates           *Discounts           `xml:"DiscountsAndRebates,omitempty"`
	Charges                       *Charges             `xml:"Charges,omitempty"`
	GrossAmount                   string               `xml:"GrossAmount"` // total cost - discount + charges
	TaxesWithheld                 *TaxSummary          `xml:"TaxesWithheld,omitempty"`
	TaxesOutputs                  *TaxSummary          `xml:"TaxesOutputs,omitempty"`
	AdditionalLineItemInformation string               `xml:"AdditionalLineItemInformation,omitempty"`
	SpecialTaxableEvent           *SpecialTaxableEvent `xml:"SpecialTaxableEvent,omitempty"`
}

InvoiceLine contains info about a specific line

type InvoiceTotals

type InvoiceTotals struct {
	TotalGrossAmount            string                `xml:"TotalGrossAmount"` // Without included taxes
	GeneralDiscounts            *Discounts            `xml:"GeneralDiscounts,omitempty"`
	GeneralSurcharges           *Charges              `xml:"GeneralSurcharges,omitempty"`
	TotalGeneralDiscounts       string                `xml:"TotalGeneralDiscounts,omitempty"`
	TotalGeneralSurcharges      string                `xml:"TotalGeneralSurcharges,omitempty"`
	TotalGrossAmountBeforeTaxes string                `xml:"TotalGrossAmountBeforeTaxes"`
	TotalTaxOutputs             string                `xml:"TotalTaxOutputs"`
	TotalTaxesWithheld          string                `xml:"TotalTaxesWithheld"`
	InvoiceTotal                string                `xml:"InvoiceTotal"`
	Subsidies                   *Subsidies            `xml:"Subsidies,omitempty"`
	PaymentsOnAccount           *PaymentsOnAccount    `xml:"PaymentsOnAccount,omitempty"`
	ReimbursableExpenses        *ReimbursableExpenses `xml:"ReimbursableExpenses,omitempty"`
	TotalOutstandingAmount      string                `xml:"TotalOutstandingAmount"` // InvoiceTotal - (Total subvenciones + TotalPaymentsOnAccount)
	TotalPaymentsOnAccount      string                `xml:"TotalPaymentsOnAccount,omitempty"`
	TotalExecutableAmount       string                `xml:"TotalExecutableAmount"`
	TotalReimbursableExpenses   string                `xml:"TotalReimbursableExpenses,omitempty"`
}

InvoiceTotals contains the summary of the amounts in an invoice

type Invoices

type Invoices struct {
	List []*Invoice `xml:"Invoice"`
}

Invoices contains info about a batch of invoices. In our case there will only be one invoice per batch

type Items

type Items struct {
	InvoiceLine []*InvoiceLine `xml:"InvoiceLine"`
}

Items contains info about all the lines in an invoice

type LegalEntity

type LegalEntity struct {
	CorporateName   string           `xml:"CorporateName"`
	AddressInSpain  *Address         `xml:"AddressInSpain,omitempty"`
	OverseasAddress *OverseasAddress `xml:"OverseasAddress,omitempty"`
	ContactDetails  *ContactDetails  `xml:"ContactDetails,omitempty"`
}

LegalEntity stores party info for companies, associations, ...

type LegalLiterals

type LegalLiterals struct {
	LegalReference []string `xml:"LegalReference"`
}

LegalLiterals contains an array of legal texts to add to the Invoice in certain situations.

type Option

type Option func(*options)

Option defines a callback configuration option used to customize the conversion to XML process

func WithCertificate

func WithCertificate(cert *xmldsig.Certificate) Option

WithCertificate will use the provided certificate to sign the XML document.

func WithSigning

func WithSigning(opts ...xmldsig.Option) Option

WithSigning allows passing additional xmldsig options that will be appended to the signing call. Useful to inject a deterministic signing time or other parameters in tests.

func WithThirdParty

func WithThirdParty(tp *ThirdParty) Option

WithThirdParty adds optional information about who is manipulating and signing the document.

func WithTimestamp

func WithTimestamp(val bool) Option

WithTimestamp will ensure the XML document is timestamped

type OverseasAddress

type OverseasAddress struct {
	Address         string `xml:"Address,omitempty"`
	PostCodeAndTown string `xml:"PostCodeAndTown,omitempty"`
	Province        string `xml:"Province,omitempty"`
	CountryCode     string `xml:"CountryCode,omitempty"`
}

OverseasAddress stores location information for addresses outside Spain

type Parties

type Parties struct {
	Seller *Party `xml:"SellerParty"`
	Buyer  *Party `xml:"BuyerParty"`
}

Parties stores emitter and receiver of the invoice

type Party

type Party struct {
	TaxID                 *TaxID                 `xml:"TaxIdentification,omitempty"`
	AdministrativeCentres *AdministrativeCentres `xml:"AdministrativeCentres,omitempty"`
	LegalEntity           *LegalEntity           `xml:"LegalEntity,omitempty"`
	Individual            *Individual            `xml:"Individual,omitempty"`
}

Party stores the info for one of the participants of the invoice

type PaymentDetails

type PaymentDetails struct {
	Installments []*Installment `xml:"Installment"`
}

PaymentDetails contains info about how the invoice should be paid

type PaymentOnAccount

type PaymentOnAccount struct {
	PaymentOnAccountDate   cal.Date `xml:"PaymentOnAccountDate"`
	PaymentOnAccountAmount string   `xml:"PaymentOnAccountAmount"`
}

PaymentOnAccount is a single advance payment.

type PaymentsOnAccount

type PaymentsOnAccount struct {
	PaymentOnAccount []*PaymentOnAccount `xml:"PaymentOnAccount"`
}

PaymentsOnAccount stores payments made in advance.

type PeriodDates

type PeriodDates struct {
	StartDate string `xml:"StartDate"`
	EndDate   string `xml:"EndDate"`
}

PeriodDates is used in corrective tax periods to define a date range.

type ReimbursableExpense

type ReimbursableExpense struct {
	ReimbursableExpensesSellerParty *TaxID    `xml:"ReimbursableExpensesSellerParty,omitempty"`
	ReimbursableExpensesBuyerParty  *TaxID    `xml:"ReimbursableExpensesBuyerParty,omitempty"` // never used!
	IssueDate                       *cal.Date `xml:"IssueDate,omitempty"`
	InvoiceNumber                   string    `xml:"InvoiceNumber,omitempty"`
	InvoiceSeriesCode               string    `xml:"InvoiceSeriesCode,omitempty"`
	ReimbursableExpensesAmount      string    `xml:"ReimbursableExpensesAmount"`
}

ReimbursableExpense stores info about a single reimbursable expense.

type ReimbursableExpenses

type ReimbursableExpenses struct {
	ReimbursableExpenses []*ReimbursableExpense `xml:"ReimbursableExpenses"`
}

ReimbursableExpenses is a group of reimbursable expenses.

type SpecialTaxableEvent

type SpecialTaxableEvent struct {
	SpecialTaxableEventCode   SpecialTaxableEventCode `xml:"SpecialTaxableEventCode"`
	SpecialTaxableEventReason string                  `xml:"SpecialTaxableEventReason"`
}

SpecialTaxableEvent stores details as to way the invoice line does not need taxes to be applied.

type SpecialTaxableEventCode

type SpecialTaxableEventCode string

SpecialTaxableEventCode used for special invoice lines that do not need taxes to be applied.

const (
	TaxableAndExemptCode SpecialTaxableEventCode = "01"
	NonTaxableCode       SpecialTaxableEventCode = "02"
)

Special taxable event codes

type Subsidies

type Subsidies struct {
	Subsidy []*Subsidy `xml:"Subsidy"`
}

Subsidies is currently a placeholder, as we don't use it yet.

type Subsidy

type Subsidy struct {
	SubsidyDescription string `xml:"SubsidyDescription"`
	SubsidyRate        string `xml:"SubsidyRate,omitempty"`
	SubsidyAmount      string `xml:"SubsidyAmount"`
}

Subsidy is a single subsidy entry

type Tax

type Tax struct {
	Code            string  `xml:"TaxTypeCode"`
	Rate            string  `xml:"TaxRate"`
	Base            Amount  `xml:"TaxableBase"`
	Amount          Amount  `xml:"TaxAmount"`
	Surcharge       string  `xml:"EquivalenceSurcharge,omitempty"` // must be with two decimal places
	SurchargeAmount *Amount `xml:"EquivalenceSurchargeAmount,omitempty"`
}

Tax contains the info of a particular tax type

type TaxID

type TaxID struct {
	PersonTypeCode          string `xml:"PersonTypeCode"`
	ResidenceTypeCode       string `xml:"ResidenceTypeCode"`
	TaxIdentificationNumber string `xml:"TaxIdentificationNumber"`
}

TaxID stores fiscal id

type TaxSummary

type TaxSummary struct {
	List []*Tax `xml:"Tax"`
}

TaxSummary contains a list with the info of each tax type

type ThirdParty

type ThirdParty struct {
	TaxIdentification *TaxID       `xml:"TaxIdentification"`
	LegalEntity       *LegalEntity `xml:"LegalEntity"`
}

ThirdParty is used to identify an intermediary building and issuing the invoice.

Directories

Path Synopsis
Package facturae provides the FacturaE addon for Spanish invoices.
Package facturae provides the FacturaE addon for Spanish invoices.

Jump to

Keyboard shortcuts

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