Documentation
¶
Overview ¶
Package doc provides the VeriFactu document mappings from GOBL
Index ¶
- Constants
- Variables
- type Body
- type Cabecera
- type ChainData
- type Desglose
- type Destinatario
- type DetalleDesglose
- type Encadenamiento
- type Envelope
- func (d *Envelope) Bytes() ([]byte, error)
- func (d *Envelope) BytesIndent() ([]byte, error)
- func (d *Envelope) ChainData() Encadenamiento
- func (d *Envelope) ChainDataCancel() Encadenamiento
- func (d *Envelope) Fingerprint(prev *ChainData) error
- func (d *Envelope) FingerprintCancel(prev *ChainData) error
- func (d *Envelope) QRCodes(production bool) string
- type Error
- type FacturaRectificada
- type FacturaSustituida
- type IDFactura
- type IDFacturaAnulada
- type IDOtro
- type ImporteRectificacion
- type IssuerRole
- type Obligado
- type Options
- type Party
- type RegFactuSistemaFacturacion
- type RegistroAlta
- type RegistroAnterior
- type RegistroAnulacion
- type RegistroFactura
- type RemisionRequerimiento
- type RemisionVoluntaria
- type Software
Constants ¶
const ( SUM = "https://www2.agenciatributaria.gob.es/static_files/common/internet/dep/aplicaciones/es/aeat/tike/cont/ws/SuministroLR.xsd" SUM1 = "" /* 130-byte string literal not displayed */ EnvNamespace = "http://schemas.xmlsoap.org/soap/envelope/" )
SUM is the namespace for the main VeriFactu schema
const (
// CurrentVersion is the current version of the VeriFactu document
CurrentVersion = "1.0"
)
const TipoHuella = "01"
TipoHuella is the SHA-256 fingerprint type for Verifactu - L12 Might include support for other encryption types in the future.
Variables ¶
var ( ErrConnection = newError("connection") ErrValidation = newError("validation") ErrDuplicate = newError("duplicate") )
Standard gateway error responses
var ( ErrNotSpanish = ErrValidation.WithMessage("only spanish invoices are supported") ErrAlreadyProcessed = ErrValidation.WithMessage("already processed") ErrOnlyInvoices = ErrValidation.WithMessage("only invoices are supported") )
Standard error responses.
Functions ¶
This section is empty.
Types ¶
type Body ¶
type Body struct {
VeriFactu *RegFactuSistemaFacturacion `xml:"sum:RegFactuSistemaFacturacion"`
}
Body is the body of the SOAP envelope
type Cabecera ¶
type Cabecera struct {
Obligado Obligado `xml:"sum1:ObligadoEmision"`
Representante *Obligado `xml:"sum1:Representante,omitempty"`
RemisionVoluntaria *RemisionVoluntaria `xml:"sum1:RemisionVoluntaria,omitempty"`
RemisionRequerimiento *RemisionRequerimiento `xml:"sum1:RemisionRequerimiento,omitempty"`
}
Cabecera contains the header information for a VeriFactu document
type ChainData ¶
type ChainData struct {
IDIssuer string `json:"issuer"`
NumSeries string `json:"num_series"`
IssueDate string `json:"issue_date"`
Fingerprint string `json:"fingerprint"`
}
ChainData contains the fields of this invoice that will be required for fingerprinting the next invoice. JSON tags are provided to help with serialization.
type Desglose ¶
type Desglose struct {
DetalleDesglose []*DetalleDesglose `xml:"sum1:DetalleDesglose"`
}
Desglose contains the breakdown details
type Destinatario ¶
type Destinatario struct {
IDDestinatario *Party `xml:"sum1:IDDestinatario"`
}
Destinatario represents a recipient in the document
type DetalleDesglose ¶
type DetalleDesglose struct {
Impuesto string `xml:"sum1:Impuesto,omitempty"`
ClaveRegimen string `xml:"sum1:ClaveRegimen,omitempty"`
CalificacionOperacion string `xml:"sum1:CalificacionOperacion,omitempty"`
OperacionExenta string `xml:"sum1:OperacionExenta,omitempty"`
TipoImpositivo string `xml:"sum1:TipoImpositivo,omitempty"`
BaseImponibleOImporteNoSujeto string `xml:"sum1:BaseImponibleOimporteNoSujeto"`
BaseImponibleACoste string `xml:"sum1:BaseImponibleACoste,omitempty"`
CuotaRepercutida string `xml:"sum1:CuotaRepercutida,omitempty"`
TipoRecargoEquivalencia string `xml:"sum1:TipoRecargoEquivalencia,omitempty"`
CuotaRecargoEquivalencia string `xml:"sum1:CuotaRecargoEquivalencia,omitempty"`
}
DetalleDesglose contains detailed breakdown information
type Encadenamiento ¶
type Encadenamiento struct {
PrimerRegistro string `xml:"sum1:PrimerRegistro,omitempty"`
RegistroAnterior *RegistroAnterior `xml:"sum1:RegistroAnterior,omitempty"`
}
Encadenamiento contains chaining information between documents
type Envelope ¶
type Envelope struct {
XMLName xml.Name `xml:"soapenv:Envelope"`
XMLNs string `xml:"xmlns:soapenv,attr"`
SUM string `xml:"xmlns:sum,attr"`
SUM1 string `xml:"xmlns:sum1,attr"`
Body *Body `xml:"soapenv:Body"`
}
Envelope is the SOAP envelope wrapper
func NewCancel ¶
NewCancel creates a new VeriFactu cancellation document from the provided GOBL Invoice.
func NewInvoice ¶
NewInvoice creates a new VeriFactu invoice document from the provided GOBL Invoice.
func (*Envelope) BytesIndent ¶
BytesIndent returns the indented XML document bytes
func (*Envelope) ChainData ¶
func (d *Envelope) ChainData() Encadenamiento
ChainData generates the data to be used to link to this one in the next entry.
func (*Envelope) ChainDataCancel ¶
func (d *Envelope) ChainDataCancel() Encadenamiento
ChainDataCancel generates the data to be used to link to this one in the next entry for cancelling invoices.
func (*Envelope) Fingerprint ¶
Fingerprint generates the SHA-256 fingerprint for the document
func (*Envelope) FingerprintCancel ¶
FingerprintCancel generates the SHA-256 fingerprint for the document
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error allows for structured responses from the gateway to be able to response codes and messages.
func NewErrorFrom ¶
NewErrorFrom attempts to wrap the provided error into the Error type.
func (*Error) Is ¶
Is checks to see if the target error is the same as the current one or forms part of the chain.
func (*Error) WithMessage ¶
WithMessage duplicates and adds the message to the error.
type FacturaRectificada ¶
type FacturaRectificada struct {
IDFactura IDFactura `xml:"sum1:IDFacturaRectificada"`
}
FacturaRectificada represents a rectified invoice
type FacturaSustituida ¶
type FacturaSustituida struct {
IDFactura IDFactura `xml:"sum1:IDFacturaSustituida"`
}
FacturaSustituida represents a substituted invoice
type IDFactura ¶
type IDFactura struct {
IDEmisorFactura string `xml:"sum1:IDEmisorFactura"`
NumSerieFactura string `xml:"sum1:NumSerieFactura"`
FechaExpedicionFactura string `xml:"sum1:FechaExpedicionFactura"`
}
IDFactura contains the identifying information for an invoice
type IDFacturaAnulada ¶
type IDFacturaAnulada struct {
IDEmisorFactura string `xml:"sum1:IDEmisorFacturaAnulada"`
NumSerieFactura string `xml:"sum1:NumSerieFacturaAnulada"`
FechaExpedicionFactura string `xml:"sum1:FechaExpedicionFacturaAnulada"`
}
IDFacturaAnulada contains the identifying information for an invoice
type IDOtro ¶
type IDOtro struct {
CodigoPais string `xml:"sum1:CodigoPais"`
IDType string `xml:"sum1:IDType"`
ID string `xml:"sum1:ID"`
}
IDOtro contains alternative identifying information
type ImporteRectificacion ¶
type ImporteRectificacion struct {
BaseRectificada num.Amount `xml:"sum1:BaseRectificada"`
CuotaRectificada num.Amount `xml:"sum1:CuotaRectificada"`
CuotaRecargoRectificado num.Amount `xml:"sum1:CuotaRecargoRectificado,omitempty"`
}
ImporteRectificacion contains rectification amounts
type IssuerRole ¶
type IssuerRole string
IssuerRole defines the role of the issuer in the invoice.
const ( IssuerRoleSupplier IssuerRole = "E" IssuerRoleCustomer IssuerRole = "D" IssuerRoleThirdParty IssuerRole = "T" )
IssuerRole constants
type Options ¶ added in v0.3.0
type Options struct {
// Software defines the software used to generate the document.
Software *Software
// IssuerRole defines the role of the issuer in the document.
IssuerRole IssuerRole
// Representative defines the legal representative of the entity
// legally obliged to issue the invoice, usually the supplier.
Representative *Obligado
// Timestamp defines the current time to use when signing the
// document.
Timestamp time.Time
}
Options defines the set of options to be used when building a new VeriFactu document.
type Party ¶
type Party struct {
NombreRazon string `xml:"sum1:NombreRazon"`
NIF string `xml:"sum1:NIF,omitempty"`
IDOtro *IDOtro `xml:"sum1:IDOtro,omitempty"`
}
Party represents a in the document, covering fields Generador, Tercero and IDDestinatario
type RegFactuSistemaFacturacion ¶
type RegFactuSistemaFacturacion struct {
// XMLName xml.Name `xml:"sum:RegFactuSistemaFacturacion"`
Cabecera *Cabecera `xml:"sum:Cabecera"`
RegistroFactura *RegistroFactura `xml:"sum:RegistroFactura"`
}
RegFactuSistemaFacturacion represents the root element of a RegFactuSistemaFacturacion document
func (*RegFactuSistemaFacturacion) Bytes ¶
func (d *RegFactuSistemaFacturacion) Bytes() ([]byte, error)
Bytes returns the XML document bytes
type RegistroAlta ¶
type RegistroAlta struct {
IDVersion string `xml:"sum1:IDVersion"`
IDFactura *IDFactura `xml:"sum1:IDFactura"`
RefExterna string `xml:"sum1:RefExterna,omitempty"`
NombreRazonEmisor string `xml:"sum1:NombreRazonEmisor"`
Subsanacion string `xml:"sum1:Subsanacion,omitempty"`
RechazoPrevio string `xml:"sum1:RechazoPrevio,omitempty"`
TipoFactura string `xml:"sum1:TipoFactura"`
TipoRectificativa string `xml:"sum1:TipoRectificativa,omitempty"`
FacturasRectificadas []*FacturaRectificada `xml:"sum1:FacturasRectificadas,omitempty"`
FacturasSustituidas []*FacturaSustituida `xml:"sum1:FacturasSustituidas,omitempty"`
ImporteRectificacion *ImporteRectificacion `xml:"sum1:ImporteRectificacion,omitempty"`
FechaOperacion string `xml:"sum1:FechaOperacion,omitempty"`
DescripcionOperacion string `xml:"sum1:DescripcionOperacion"`
FacturaSimplificadaArt7273 string `xml:"sum1:FacturaSimplificadaArt7273,omitempty"`
FacturaSinIdentifDestinatarioArt61d string `xml:"sum1:FacturaSinIdentifDestinatarioArt61d,omitempty"`
Macrodato string `xml:"sum1:Macrodato,omitempty"`
EmitidaPorTerceroODestinatario string `xml:"sum1:EmitidaPorTerceroODestinatario,omitempty"`
Tercero *Party `xml:"sum1:Tercero,omitempty"`
Destinatarios []*Destinatario `xml:"sum1:Destinatarios,omitempty"`
Cupon string `xml:"sum1:Cupon,omitempty"`
Desglose *Desglose `xml:"sum1:Desglose"`
CuotaTotal string `xml:"sum1:CuotaTotal"`
ImporteTotal string `xml:"sum1:ImporteTotal"`
Encadenamiento *Encadenamiento `xml:"sum1:Encadenamiento"`
SistemaInformatico *Software `xml:"sum1:SistemaInformatico"`
FechaHoraHusoGenRegistro string `xml:"sum1:FechaHoraHusoGenRegistro"`
NumRegistroAcuerdoFacturacion string `xml:"sum1:NumRegistroAcuerdoFacturacion,omitempty"`
IdAcuerdoSistemaInformatico string `xml:"sum1:IdAcuerdoSistemaInformatico,omitempty"` //nolint:revive
TipoHuella string `xml:"sum1:TipoHuella"`
Huella string `xml:"sum1:Huella"`
}
RegistroAlta contains the details of an invoice registration
type RegistroAnterior ¶
type RegistroAnterior struct {
IDEmisorFactura string `xml:"sum1:IDEmisorFactura"`
NumSerieFactura string `xml:"sum1:NumSerieFactura"`
FechaExpedicionFactura string `xml:"sum1:FechaExpedicionFactura"`
Huella string `xml:"sum1:Huella"`
}
RegistroAnterior contains information about the previous registration
type RegistroAnulacion ¶
type RegistroAnulacion struct {
IDVersion string `xml:"sum1:IDVersion"`
IDFactura *IDFacturaAnulada `xml:"sum1:IDFactura"`
RefExterna string `xml:"sum1:RefExterna,omitempty"`
SinRegistroPrevio string `xml:"sum1:SinRegistroPrevio,omitempty"`
RechazoPrevio string `xml:"sum1:RechazoPrevio,omitempty"`
GeneradoPor string `xml:"sum1:GeneradoPor,omitempty"`
Generador *Party `xml:"sum1:Generador,omitempty"`
Encadenamiento *Encadenamiento `xml:"sum1:Encadenamiento"`
SistemaInformatico *Software `xml:"sum1:SistemaInformatico"`
FechaHoraHusoGenRegistro string `xml:"sum1:FechaHoraHusoGenRegistro"`
TipoHuella string `xml:"sum1:TipoHuella"`
Huella string `xml:"sum1:Huella"`
}
RegistroAnulacion contains the details of an invoice cancellation
type RegistroFactura ¶
type RegistroFactura struct {
RegistroAlta *RegistroAlta `xml:"sum1:RegistroAlta,omitempty"`
RegistroAnulacion *RegistroAnulacion `xml:"sum1:RegistroAnulacion,omitempty"`
}
RegistroFactura contains either an invoice registration or cancellation
type RemisionRequerimiento ¶
type RemisionRequerimiento struct {
RefRequerimiento string `xml:"sum1:RefRequerimiento"`
FinRequerimiento string `xml:"sum1:FinRequerimiento,omitempty"`
}
RemisionRequerimiento contains requirement submission details
type RemisionVoluntaria ¶
type RemisionVoluntaria struct {
FechaFinVerifactu string `xml:"sum1:FechaFinVerifactu,omitempty"`
Incidencia string `xml:"sum1:Incidencia,omitempty"`
}
RemisionVoluntaria contains voluntary submission details
type Software ¶
type Software struct {
NombreRazon string `xml:"sum1:NombreRazon"`
NIF string `xml:"sum1:NIF"`
NombreSistemaInformatico string `xml:"sum1:NombreSistemaInformatico"`
IdSistemaInformatico string `xml:"sum1:IdSistemaInformatico"` //nolint:revive
Version string `xml:"sum1:Version"`
NumeroInstalacion string `xml:"sum1:NumeroInstalacion"`
TipoUsoPosibleSoloVerifactu string `xml:"sum1:TipoUsoPosibleSoloVerifactu,omitempty"`
TipoUsoPosibleMultiOT string `xml:"sum1:TipoUsoPosibleMultiOT,omitempty"`
IndicadorMultiplesOT string `xml:"sum1:IndicadorMultiplesOT,omitempty"`
}
Software contains the details about the software that is using this library to generate VeriFactu documents. These details are included in the final document.