es

package
v0.20.2 Latest Latest
Warning

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

Go to latest
Published: May 9, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

README

Spanish GOBL Tax Definitions

Documentation

Index

Constants

View Source
const (
	TaxCategoryVATSurcharge tax.Code = "VATEQS"
	TaxCategoryIRPF         tax.Code = "IRPF"
	TaxCategoryIGIC         tax.Code = "IGIC"
	TaxCategoryIPSI         tax.Code = "IPSI"
)

Local tax category definitions which are not considered standard.

View Source
const (
	// VAT non-standard Rates
	TaxRateTobacco tax.Key = "tobacco"

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

Specific tax rate codes.

View Source
const (
	SchemeSimplified      tax.Key = "simplified"
	SchemeCustomerIssued  tax.Key = "customer-issued"
	SchemeTravelAgency    tax.Key = "travel-agency"
	SchemeSecondHandGoods tax.Key = "second-hand-goods"
	SchemeArt             tax.Key = "art"
	SchemeAntiques        tax.Key = "antiques"
	SchemeCashBasis       tax.Key = "cash-basis"
)

Scheme key definitions

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 CorrectionMethodMap = map[bill.CorrectionMethodKey]*CorrectionMethod{
	bill.CompleteCorrectionMethodKey: {
		Code: "01",
		Desc: i18n.String{
			i18n.EN: "Complete",
			i18n.ES: "Rectificaticón íntegra",
		},
	},
	bill.PartialCorrectionMethodKey: {
		Code: "02",
		Desc: i18n.String{
			i18n.EN: "Corrected items only",
			i18n.ES: "Rectificación por diferencias",
		},
	},
	bill.DiscountCorrectionMethodKey: {
		Code: "03",
		Desc: i18n.String{
			i18n.EN: "Bulk deal in a given period",
			i18n.ES: "Rectificación por descuento por volumen de operaciones durante un periodo",
		},
	},
	bill.AuthorizedCorrectionMethodKey: {
		Code: "04",
		Desc: i18n.String{
			i18n.EN: "Authorized by the Tax Agency",
			i18n.ES: "Autorizadas por la Agencia Tributaria",
		},
	},
}

CorrectionMethodMap defines the codes and texts expected by Spanish electronic invoices for the types of corrections being made to an invoice.

View Source
var CorrectionReasonMap = map[bill.CorrectionKey]*CorrectionReason{
	bill.CodeCorrectionKey: {
		Code: "01",
		Desc: i18n.String{
			i18n.EN: "Invoice Number",
			i18n.ES: "Número de la factura",
		},
	},
	bill.SeriesCorrectionKey: {
		Code: "02",
		Desc: i18n.String{
			i18n.EN: "Invoice serial number",
			i18n.ES: "Serie de la factura",
		},
	},
	bill.IssueDateCorrectionKey: {
		Code: "03",
		Desc: i18n.String{
			i18n.EN: "Issue date",
			i18n.ES: "Fecha expedición",
		},
	},
	bill.SupplierNameCorrectionKey: {
		Code: "04",
		Desc: i18n.String{
			i18n.EN: "Name and surnames/Corporate name – Issuer (Sender)",
			i18n.ES: "Nombre y apellidos/Razón Social-Emisor",
		},
	},
	bill.CustomerNameCorrectionKey: {
		Code: "05",
		Desc: i18n.String{
			i18n.EN: "Name and surnames/Corporate name - Receiver",
			i18n.ES: "Nombre y apellidos/Razón Social-Receptor",
		},
	},
	bill.SupplierTaxIDCorrectionKey: {
		Code: "06",
		Desc: i18n.String{
			i18n.EN: "Issuer's Tax Identification Number",
			i18n.ES: "Identificación fiscal Emisor/obligado",
		},
	},
	bill.CustomerTaxIDCorrectionKey: {
		Code: "07",
		Desc: i18n.String{
			i18n.EN: "Receiver's Tax Identification Number",
			i18n.ES: "Identificación fiscal Receptor",
		},
	},
	bill.SupplierAddressCorrectionKey: {
		Code: "08",
		Desc: i18n.String{
			i18n.EN: "Issuer's address",
			i18n.ES: "Domicilio Emisor/Obligado",
		},
	},
	bill.CustomerAddressCorrectionKey: {
		Code: "09",
		Desc: i18n.String{
			i18n.EN: "Receiver's address",
			i18n.ES: "Domicilio Receptor",
		},
	},
	bill.LineCorrectionKey: {
		Code: "10",
		Desc: i18n.String{
			i18n.EN: "Item line",
			i18n.ES: "Detalle Operación",
		},
	},
	bill.TaxRateCorrectionKey: {
		Code: "11",
		Desc: i18n.String{
			i18n.EN: "Applicable Tax Rate",
			i18n.ES: "Porcentaje impositivo a aplicar",
		},
	},
	bill.TaxAmountCorrectionKey: {
		Code: "12",
		Desc: i18n.String{
			i18n.EN: "Applicable Tax Amount",
			i18n.ES: "Cuota tributaria a aplicar",
		},
	},
	bill.PeriodCorrectionKey: {
		Code: "13",
		Desc: i18n.String{
			i18n.EN: "Applicable Date/Period",
			i18n.ES: "Fecha/Periodo a aplicar",
		},
	},
	bill.TypeCorrectionKey: {
		Code: "14",
		Desc: i18n.String{
			i18n.EN: "Invoice Class",
			i18n.ES: "Clase de factura",
		},
	},
	bill.LegalDetailsCorrectionKey: {
		Code: "15",
		Desc: i18n.String{
			i18n.EN: "Legal literals",
			i18n.ES: "Literales legales",
		},
	},
	bill.TaxBaseCorrectionKey: {
		Code: "16",
		Desc: i18n.String{
			i18n.EN: "Taxable Base",
			i18n.ES: "Base imponible",
		},
	},
	bill.TaxCorrectionKey: {
		Code: "80",
		Desc: i18n.String{
			i18n.EN: "Calculation of tax outputs",
			i18n.ES: "Cálculo de cuotas repercutidas",
		},
	},
	bill.TaxRetainedCorrectionKey: {
		Code: "81",
		Desc: i18n.String{
			i18n.EN: "Calculation of tax inputs",
			i18n.ES: "Cálculo de cuotas retenidas",
		},
	},
	bill.RefundCorrectionKey: {
		Code: "82",
		Desc: i18n.String{
			i18n.EN: "Taxable Base modified due to return of packages and packaging materials",
			i18n.ES: "Base imponible modificada por devolución de envases / embalajes",
		},
	},
	bill.DiscountCorrectionKey: {
		Code: "83",
		Desc: i18n.String{
			i18n.EN: "Taxable Base modified due to discounts and rebates",
			i18n.ES: "Base imponible modificada por descuentos y bonificaciones",
		},
	},
	bill.JudicialCorrectionKey: {
		Code: "84",
		Desc: i18n.String{
			i18n.EN: "Taxable Base modified due to firm court ruling or administrative decision",
			i18n.ES: "Base imponible modificada por resolución firme, judicial o administrativa",
		},
	},
	bill.InsolvencyCorrectionKey: {
		Code: "85",
		Desc: i18n.String{
			i18n.EN: "Taxable Base modified due to unpaid outputs where there is a judgement opening insolvency proceedings",
			i18n.ES: "Base imponible modificada cuotas repercutidas no satisfechas. Auto de declaración de concurso",
		},
	},
}

CorrectionReasonMap maps GOBL Correction Codes to reason models acceptable for spanish invoices.

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

	"exempt": {
		Key:  org.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:  org.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.

View Source
var ValidTaxID = new(validTaxID)

ValidTaxID complies with the ozzo validation Rule definition to be able to confirm that the Tax ID is indeed spanish and valid.

Functions

func CleanTaxCode

func CleanTaxCode(code string) string

CleanTaxCode removes any whitespace or separation characters and ensures all letters are uppercase. It'll also remove the "ES" part at beginning if present such as required for EU VIES system which is redundant and not used in the validation process.

func New

func New() *tax.Region

New provides the Spanish region definition

func Validate added in v0.20.0

func Validate(doc interface{}) error

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

func VerifyTaxCode

func VerifyTaxCode(code string) error

VerifyTaxCode looks at the provided code, determines the type, and performs the calculations required to determine if it is valid. These methods assume the code has already been cleaned and only contains upper-case letters and numbers.

Types

type BillInvoiceLineMeta added in v0.20.0

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 CorrectionMethod added in v0.16.0

type CorrectionMethod struct {
	Code string      `json:"code"`
	Desc i18n.String `json:"desc"`
}

CorrectionMethod is used to define a correction method considered acceptable.

type CorrectionReason added in v0.16.0

type CorrectionReason struct {
	Code string      `json:"code"`
	Desc i18n.String `json:"desc"`
}

CorrectionReason defines expected correction reasons in Spanish invoices.

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.

func DetermineTaxCodeType

func DetermineTaxCodeType(code string) (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