es

package
v0.114.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2024 License: Apache-2.0 Imports: 15 Imported by: 3

README

🇪🇸 GOBL Spain Tax Regime

Example ES GOBL files can be found in the examples and examples/out (JSON calculated envelopes) subdirectories.

Corrective Invoices

According to Spanish law on invoicing Real Decreto 1619/2012, de 30 de noviembre, only "rectified" invoices are recognized. There are in fact no mentions of internationally credit or debit notes at all.

To figure out how to map GOBL correction types to Spanish requirements, we've used the FacturaE format which defines a list of Correction Methods. The following assumptions are made on the key corrective invoice types:

  • corrective - the previous invoice has been completely replaced and for accounting purposes can be discarded. This maps to code 01 (Rectificación modelo integro) in FacturaE.
  • credit-note - some or potentially all of the line items in the previous invoice have been cancelled. In GOBL the quantities of line items will be positive, but for presentation in Spain should be inverted to reflect negative values. This maps to 02 in FacturaE (Rectificación modelo por diferencias.)
  • debit-note - effectively the same as for credit-note, with the exception that values do not need to be inverted. Debit notes are very rarely used, its often easier to just issue a new invoice.

The FacturaE format defines two other correction methods which are currently considered out of scope for GOBL.

Previous versions of GOBL attempted to automatically invert corrective invoices instead of issuing credit notes, however, this was deemed to be confusing and not compatible with internationally recognized credit notes. The GOBL to FacturaE and GOBL to TicketBAI convertors will automatically invert quantities in a Credit Note.

Documentation

Overview

Package es provides tax regime support for Spain.

Index

Constants

View Source
const (
	TaxCategoryIRPF cbc.Code = "IRPF"
	TaxCategoryIGIC cbc.Code = "IGIC"
	TaxCategoryIPSI cbc.Code = "IPSI"
)

Local tax category definitions which are not considered standard.

View Source
const (
	// IRPF non-standard Rates (usually for self-employed)
	TaxRatePro                cbc.Key = "pro"                 // Professional Services
	TaxRateProStart           cbc.Key = "pro-start"           // Professionals, first 2 years
	TaxRateModules            cbc.Key = "modules"             // Module system
	TaxRateAgriculture        cbc.Key = "agriculture"         // Agricultural
	TaxRateAgricultureSpecial cbc.Key = "agriculture-special" // Agricultural special
	TaxRateCapital            cbc.Key = "capital"             // Rental or Interest

	// Special tax rate surcharge extension
	TaxRateEquivalence cbc.Key = "eqs"
)

Specific tax rate codes.

View Source
const (
	// TicketBAI (Basque Country) codes used for stamps.
	StampProviderTBAICode cbc.Key = "tbai-code"
	StampProviderTBAIQR   cbc.Key = "tbai-qr"
)

Official stamps or codes validated by government agencies

View Source
const (
	InboxKeyFACE cbc.Key = "face"

	// Main roles defined in FACE
	InboxRoleFiscal    cbc.Key = "fiscal"    // Fiscal / 01
	InboxRoleRecipient cbc.Key = "recipient" // Receptor / 02
	InboxRolePayer     cbc.Key = "payer"     // Pagador / 03
	InboxRoleCustomer  cbc.Key = "customer"  // Comprador / 04

)

Inbox key and role definitions

View Source
const (
	KeyAddressCode                 cbc.Key = "post"
	KeyFacturaE                    cbc.Key = "facturae"
	KeyFacturaETaxTypeCode         cbc.Key = "facturae-tax-type-code"
	KeyFacturaEInvoiceDocumentType cbc.Key = "facturae-invoice-document-type"
	KeyFacturaEInvoiceClass        cbc.Key = "facturae-invoice-class"
	KeyTicketBAICausaExencion      cbc.Key = "ticketbai-causa-exencion"
	KeyTicketBAIIDType             cbc.Key = "ticketbai-id-type"
)

Custom keys used typically in meta information.

View Source
const (
	ExtKeyTBAIExemption      = "es-tbai-exemption"
	ExtKeyTBAIProduct        = "es-tbai-product"
	ExtKeyTBAICorrection     = "es-tbai-correction"
	ExtKeyFacturaECorrection = "es-facturae-correction"
)

Spanish regime extension codes for local electronic formats.

View Source
const (
	IdentityKeyPassport  cbc.Key = "es-passport"
	IdentityKeyForeignID cbc.Key = "es-foreign-id"
	IdentityKeyResident  cbc.Key = "es-resident"
	IdentityKeyOther     cbc.Key = "es-other"
)

The tax identity type is required for TicketBAI documents in the Basque Country.

View Source
const (
	TagCopy             cbc.Key = "copy"
	TagSummary          cbc.Key = "summary"
	TagSimplifiedScheme cbc.Key = "simplified-scheme"
	TagCustomerIssued   cbc.Key = "customer-issued"
	TagTravelAgency     cbc.Key = "travel-agency"
	TagSecondHandGoods  cbc.Key = "second-hand-goods"
	TagArt              cbc.Key = "art"
	TagAntiques         cbc.Key = "antiques"
	TagCashBasis        cbc.Key = "cash-basis"
	TagFacturaE         cbc.Key = "facturae"
	TagTicketBAI        cbc.Key = "ticketbai"
)

Universal tax tags

Variables

View Source
var (
	ErrTaxCodeNoMatch      = errors.New("no match")
	ErrTaxCodeUnknownType  = errors.New("unknown type")
	ErrTaxCodeInvalidCheck = errors.New("check letter is invalid")
)

Standard simplified errors messages

View Source
var InvoiceLegalNoteExamples = map[string]*cbc.Note{

	"exempt": {
		Key:  cbc.NoteKeyLegal,
		Text: "Operación exenta por aplicación del artículo [indicar el articulo] de la Ley 37/1992, del 28 de diciembre, del Impuesto sobre el Valor Añadido.",
	},

	"transport": {
		Key:  cbc.NoteKeyLegal,
		Text: "Medio de transporte [describir el medio, por ejemplo automóvil turismo Seat Ibiza TDI 2.0] fecha 1ª puesta en servicio [indicar la fecha] distancias/horas recorridas [indicar la distancia o las horas, por ejemplo, 5.900 km o 48 horas].",
	},
}

InvoiceLegalNoteExamples defines a list of notes which may be required by Spanish law. These are expected to be used in user interfaces as examples that can be modified according to the details of the invoice. Most of this data has now been moved to scheme definitions, but some examples require a bit more effort from the user side.

Functions

func Calculate

func Calculate(doc interface{}) error

Calculate will perform any regime specific calculations.

func New

func New() *tax.Regime

New provides the Spanish tax regime definition

func Validate

func Validate(doc interface{}) error

Validate checks the document type and determines if it can be validated.

Types

type BillInvoiceLineMeta

type BillInvoiceLineMeta struct {
	// When true, this line should be considered as being sourced from a provider
	// under a "Equivalence Surcharge VAT" regime.
	Supplied bool `json:"supplied,omitempty" jsonschema:"title=Supplied"`

	// Message that explains why this line is exempt of taxes.
	Exempt string `json:"exempt,omitempty" jsonschema:"title=Exempt"`
}

BillInvoiceLineMeta defines additional fields that may be added and used in an invoice line.

type TaxCodeType

type TaxCodeType string

TaxCodeType represents the types of tax code which are issued in Spain. The same general format with variations is used for national individuals, foreigners, and legal organizations.

const (
	NationalTaxCode     TaxCodeType = "N"
	ForeignTaxCode      TaxCodeType = "X"
	OrganizationTaxCode TaxCodeType = "B"
	OtherTaxCode        TaxCodeType = "O"
	UnknownTaxCode      TaxCodeType = "NA"
)

Supported tax code types, from code itself.

func DetermineTaxCodeType

func DetermineTaxCodeType(code cbc.Code) (TaxCodeType, error)

DetermineTaxCodeType takes a valid code and determines the type. If the code is not valid, the `UnknownTaxCode` type will be returned.

Jump to

Keyboard shortcuts

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