cfdi

package module
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: AGPL-3.0 Imports: 10 Imported by: 0

README

GOBL to CFDI Conversion

Convert GOBL documents in the Mexican CFDI (Comprobante Fiscal Digital por Internet) format.

Copyright Invopop Ltd. 2023. Released publicly under the GNU Affero General Public License v3.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

Documentation

Overview

Package cfdi implements the conversion from GOBL to CFDI XML

Index

Constants

View Source
const (
	CFDINamespace  = "http://www.sat.gob.mx/cfd/4"
	XSINamespace   = "http://www.w3.org/2001/XMLSchema-instance"
	SchemaLocation = "http://www.sat.gob.mx/cfd/4 http://www.sat.gob.mx/sitio_internet/cfd/4/cfdv40.xsd"
	CFDIVersion    = "4.0"
)

CFDI schema constants

View Source
const (
	FakeNoCertificado             = "00000000000000000000"
	TipoDeComprobanteIngreso      = "I"
	ExportacionNoAplica           = "01"
	MetodoPagoUnaExhibicion       = "PUE"
	FormaPagoPorDefinir           = "99"
	ClaveProdServNoExiste         = "01010101"
	ClaveUnidadMutuamenteDefinida = "H87"
	ObjetoImpSi                   = "02"
	ImpuestoIVA                   = "002"
	TipoFactorTasa                = "Tasa"
	UsoCFDIGastosGenerales        = "G03"
	RegimenFiscalGeneral          = "601"
)

Hard-coded values for (yet) unsupported mappings

Variables

This section is empty.

Functions

This section is empty.

Types

type Concepto

type Concepto struct {
	ClaveProdServ string `xml:",attr"`
	Cantidad      string `xml:",attr"`
	ClaveUnidad   string `xml:",attr"`
	Descripcion   string `xml:",attr"` // nolint:misspell
	ValorUnitario string `xml:",attr"`
	Importe       string `xml:",attr"`
	ObjetoImp     string `xml:",attr"`

	Impuestos *Impuestos `xml:"cfdi:Impuestos,omitempty"`
}

Concepto stores an invoice line data

type Conceptos

type Conceptos struct {
	Concepto []*Concepto `xml:"cfdi:Concepto"`
}

Conceptos list invoice lines nolint:misspell

type Document

type Document struct {
	XMLName        xml.Name `xml:"cfdi:Comprobante"`
	CFDINamespace  string   `xml:"xmlns:cfdi,attr"`
	XSINamespace   string   `xml:"xmlns:xsi,attr"`
	SchemaLocation string   `xml:"xsi:schemaLocation,attr"`
	Version        string   `xml:"Version,attr"`

	TipoDeComprobante string `xml:",attr"`
	Serie             string `xml:",attr,omitempty"`
	Folio             string `xml:",attr,omitempty"`
	Fecha             string `xml:",attr"`
	LugarExpedicion   string `xml:",attr"`
	SubTotal          string `xml:",attr"`
	Total             string `xml:",attr"`
	Moneda            string `xml:",attr"`
	Exportacion       string `xml:",attr"`
	MetodoPago        string `xml:",attr,omitempty"`
	FormaPago         string `xml:",attr,omitempty"`
	Sello             string `xml:",attr"`
	NoCertificado     string `xml:",attr"`
	Certificado       string `xml:",attr"`

	Emisor    *Emisor    `xml:"cfdi:Emisor"`
	Receptor  *Receptor  `xml:"cfdi:Receptor"`
	Conceptos *Conceptos `xml:"cfdi:Conceptos"` //nolint:misspell
	Impuestos *Impuestos `xml:"cfdi:Impuestos,omitempty"`
}

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

func NewDocument

func NewDocument(env *gobl.Envelope) (*Document, error)

NewDocument converts a GOBL envelope into a CFDI document

func (*Document) Bytes

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

Bytes returns the XML representation of the document in bytes

type Emisor

type Emisor struct {
	Rfc           string `xml:",attr"`
	Nombre        string `xml:",attr"`
	RegimenFiscal string `xml:",attr"`
}

Emisor stores the invoice supplier data

type Impuestos

type Impuestos struct {
	TotalImpuestosTrasladados string     `xml:",attr,omitempty"`
	Traslados                 *Traslados `xml:"cfdi:Traslados,omitempty"`
}

Impuestos store the invoice tax totals

type Receptor

type Receptor struct {
	Rfc                     string `xml:",attr"`
	Nombre                  string `xml:",attr"`
	DomicilioFiscalReceptor string `xml:",attr"`
	RegimenFiscalReceptor   string `xml:",attr"`
	UsoCFDI                 string `xml:",attr"`
}

Receptor stores the invoice customer data

type Traslado

type Traslado struct {
	Base       string `xml:",attr"`
	Importe    string `xml:",attr,omitempty"`
	Impuesto   string `xml:",attr"`
	TasaOCuota string `xml:",attr,omitempty"`
	TipoFactor string `xml:",attr"`
}

Traslado stores the tax data of the invoice or a line

type Traslados

type Traslados struct {
	Traslado []*Traslado `xml:"cfdi:Traslado"`
}

Traslados list the applicable taxes of the invoice or a line

Directories

Path Synopsis
Package test provides tools for testing the library
Package test provides tools for testing the library

Jump to

Keyboard shortcuts

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