Documentation
¶
Index ¶
Constants ¶
const ( TaxCategoryIRPF org.Code = "IRPF" TaxCategoryIGIC org.Code = "IGIC" TaxCategoryIPSI org.Code = "IPSI" )
Local tax category definitions which are not considered standard.
const ( // IRPF non-standard Rates (usually for self-employed) TaxRatePro org.Key = "pro" // Professional Services TaxRateProStart org.Key = "pro-start" // Professionals, first 2 years TaxRateModules org.Key = "modules" // Module system TaxRateAgriculture org.Key = "agriculture" // Agricultural TaxRateAgricultureSpecial org.Key = "agriculture-special" // Agricultural special TaxRateCapital org.Key = "capital" // Rental or Interest // Special tax rate surcharge extension TaxRateEquivalence org.Key = "eqs" )
Specific tax rate codes.
const ( SchemeSimplified org.Key = "simplified" SchemeCustomerIssued org.Key = "customer-issued" SchemeTravelAgency org.Key = "travel-agency" SchemeSecondHandGoods org.Key = "second-hand-goods" SchemeArt org.Key = "art" SchemeAntiques org.Key = "antiques" SchemeCashBasis org.Key = "cash-basis" )
Scheme key definitions
const ( InboxKeyFACE org.Key = "face" // Main roles defined in FACE InboxRoleFiscal org.Key = "fiscal" // Fiscal / 01 InboxRoleRecipient org.Key = "recipient" // Receptor / 02 InboxRolePayer org.Key = "payer" // Pagador / 03 InboxRoleCustomer org.Key = "customer" // Comprador / 04 )
Inbox key and role definitions
const ( LocalityVI l10n.Code = "VI" // (01) Álava LocalityAB l10n.Code = "AB" // (02) Albacete LocalityA l10n.Code = "A" // (03) Alicante LocalityAL l10n.Code = "AL" // (04) Almería LocalityAV l10n.Code = "AV" // (05) Ávila LocalityBA l10n.Code = "BA" // (06) Badajoz LocalityPM l10n.Code = "PM" // (07) Baleares LocalityIB l10n.Code = "IB" // (07) Baleares LocalityB l10n.Code = "B" // (08) Barcelona LocalityBU l10n.Code = "BU" // (09) Burgos LocalityCC l10n.Code = "CC" // (10) Cáceres LocalityCA l10n.Code = "CA" // (11) Cádiz LocalityCS l10n.Code = "CS" // (12) Castellon LocalityCR l10n.Code = "CR" // (13) Ciudad Real LocalityCO l10n.Code = "CO" // (14) Cordoba LocalityC l10n.Code = "C" // (15) La Coruña LocalityCU l10n.Code = "CU" // (16) Cuenca LocalityGE l10n.Code = "GE" // (17) Gerona LocalityGI l10n.Code = "GI" // (17) Girona LocalityGR l10n.Code = "GR" // (18) Granada LocalityGU l10n.Code = "GU" // (19) Guadalajara LocalitySS l10n.Code = "SS" // (20) Guipúzcoa LocalityH l10n.Code = "H" // (21) Huelva LocalityHU l10n.Code = "HU" // (22) Huesca LocalityJ l10n.Code = "J" // (23) Jaén LocalityLE l10n.Code = "LE" // (24) León LocalityL l10n.Code = "L" // (25) Lérida / Lleida LocalityLO l10n.Code = "LO" // (26) La Rioja LocalityLU l10n.Code = "LU" // (27) Lugo LocalityM l10n.Code = "M" // (28) Madrid LocalityMA l10n.Code = "MA" // (29) Málaga LocalityMU l10n.Code = "MU" // (30) Murcia LocalityNA l10n.Code = "NA" // (31) Navarra LocalityOR l10n.Code = "OR" // (32) Orense LocalityOU l10n.Code = "OU" // (32) Orense LocalityO l10n.Code = "O" // (33) Asturias LocalityP l10n.Code = "P" // (34) Palencia LocalityGC l10n.Code = "GC" // (35) Las Palmas LocalityPO l10n.Code = "PO" // (36) Pontevedra LocalitySA l10n.Code = "SA" // (37) Salamanca LocalityTF l10n.Code = "TF" // (38) Santa Cruz de Tenerife LocalityS l10n.Code = "S" // (39) Cantabria LocalitySG l10n.Code = "SG" // (40) Segovia LocalitySE l10n.Code = "SE" // (41) Sevilla LocalitySO l10n.Code = "SO" // (42) Soria LocalityT l10n.Code = "T" // (43) Tarragona LocalityTE l10n.Code = "TE" // (44) Teruel LocalityTO l10n.Code = "TO" // (45) Toledo LocalityV l10n.Code = "V" // (46) Valencia LocalityVA l10n.Code = "VA" // (47) Valladolid LocalityBI l10n.Code = "BI" // (48) Vizcaya LocalityZA l10n.Code = "ZA" // (49) Zamora LocalityZ l10n.Code = "Z" // (50) Zaragoza LocalityCE l10n.Code = "CE" // (51) Ceuta LocalityML l10n.Code = "ML" // (52) Melilla )
Locality code definitions for Spain
const (
KeyPost org.Key = "post"
)
Custom keys used typically in meta information.
Variables ¶
var ( ErrTaxCodeNoMatch = errors.New("no match") ErrTaxCodeUnknownType = errors.New("unknown type") ErrTaxCodeInvalidCheck = errors.New("check letter is invalid") )
Standard simplified errors messages
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.
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.
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.
var ValidTaxID = 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 ¶
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 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 ¶
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
CorrectionMethod is used to define a correction method considered acceptable.
type CorrectionReason ¶ added in v0.16.0
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.