cfdi

package module
v0.69.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 27 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

GOBL ➡️ Mexico CFDI

Mexican CFDI (Comprobante Fiscal Digital por Internet) support for GOBL: the GOBL addon (extensions, normalizers, scenarios, and validation rules) plus the converter that turns a GOBL envelope into SAT-compliant CFDI XML — and parses it back.

Released publicly under the Apache 2.0 LICENSE, Copyright Invopop Ltd. 2023. 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 codecov GoDoc Latest Tag Ask DeepWiki

The addon/ package implements the extensions, normalizers, scenarios, and validation rules that GOBL documents need in order to comply with the Mexican tax authority (SAT) CFDI v4.0 standard:

  • CFDI v4 (mx-cfdi-v4) — invoices, payments, and the SAT extensions (mx-cfdi-*) required to issue and stamp a Comprobante Fiscal Digital por Internet.

It also ships the CFDI complements as GOBL documents:

  • FuelAccountBalance — Estado de Cuenta de Combustibles for electronic fuel wallets.
  • FoodVouchers — Vales de Despensa food voucher reports.

Layout

  • addon/ — the GOBL addon: extensions, normalizers, scenarios, validation rules, and the CFDI complement documents that register into GOBL on import. Importing it registers the mx-cfdi-* addon keys in GOBL's global registry.
  • the module root — the converter that turns a GOBL envelope into CFDI XML and parses CFDI XML back into GOBL, plus addendas and a command-line tool.

Usage

Addon

Unlike the converter, this is a true GOBL addon: it registers extensions, normalizers, and validation rules into GOBL's global registry. Add a blank import so it registers itself, then use GOBL as normal:

import (
    "github.com/invopop/gobl"
    _ "github.com/invopop/gobl.mx.cfdi/addon"
)

Declare the addon on a document (or let the regime/scenario add it) and Calculate + Validate will run the full CFDI normalization and rules. The converter imports the addon automatically, so consumers that only convert do not need the blank import.

Note: the mx-cfdi-* keys are listed in GOBL core's approved external-addon registry, so they are recognised as valid $addons values in the JSON Schema. The runtime check stays strict, however: a document declaring an mx-cfdi-* addon will fail validation with add-on must be registered unless this module (the addon package) is imported. Any service that processes Mexican CFDI documents must import it.

Converter

Usage of the CFDI conversion library is quite straightforward. You must first have a GOBL Envelope including an invoice or a payment for Mexico ready to convert. There are some samples here in the test/data directory.

package main

import (
    "os"

    "github.com/invopop/gobl"
    "github.com/invopop/gobl.mx.cfdi"
)

func main() {
    data, _ := os.ReadFile("./test/data/invoice.json")

    env := new(gobl.Envelope)
    if err := json.Unmarshal(data, env); err != nil {
        panic(err)
    }

    // Prepare the CFDI document
    doc, err := cfdi.Convert(env)
    if err != nil {
        panic(err)
    }

    // Create the XML output
    out, err := doc.Bytes()
    if err != nil {
        panic(err)
    }

    // TODO: do something with the output
}
Testing

The tests validate the generated documents against the SAT schemas in test/schema with lestrrat-go/helium, a pure-Go library, so they need no C dependencies. The schemas the SAT ones import by URL are kept there as local copies, so the tests don't download anything.

Addendas

For details on support for converting Addendas, please see the addendas package.

Command Line

The GOBL to CFDI tool also includes a command line helper. You can find pre-built gobl.mx.cfdi binaries in the github repository, or install manually in your Go environment with:

go install ./cmd/gobl.mx.cfdi

Usage is very straightforward:

gobl.mx.cfdi convert ./test/data/invoice-b2b-bare.json

Which should produce something like:

<?xml version="1.0" encoding="UTF-8"?>
<cfdi:Comprobante xmlns:cfdi="http://www.sat.gob.mx/cfd/4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sat.gob.mx/cfd/4 http://www.sat.gob.mx/sitio_internet/cfd/4/cfdv40.xsd" Version="4.0" TipoDeComprobante="I" Serie="LMC" Folio="0010" Fecha="2023-05-29T00:00:00" LugarExpedicion="26015" SubTotal="400.40" Descuento="200.20" Total="232.23" Moneda="MXN" Exportacion="01" MetodoPago="PUE" FormaPago="03" CondicionesDePago="Pago a 30 días." Sello="" NoCertificado="00000000000000000000" Certificado="">
  <cfdi:Emisor Rfc="EKU9003173C9" Nombre="ESCUELA KEMPER URGATE" RegimenFiscal="601"></cfdi:Emisor>
  <cfdi:Receptor Rfc="URE180429TM6" Nombre="UNIVERSIDAD ROBOTICA ESPAÑOLA" DomicilioFiscalReceptor="65000" RegimenFiscalReceptor="601" UsoCFDI="G01"></cfdi:Receptor>
  <cfdi:Conceptos>
    <cfdi:Concepto ClaveProdServ="50211502" Cantidad="2" ClaveUnidad="H87" Descripcion="Cigarros" ValorUnitario="200.2020" Importe="400.4040" Descuento="200.2020" ObjetoImp="02">
      <cfdi:Impuestos>
        <cfdi:Traslados>
          <cfdi:Traslado Base="200.2020" Importe="32.0323" Impuesto="002" TasaOCuota="0.160000" TipoFactor="Tasa"></cfdi:Traslado>
        </cfdi:Traslados>
      </cfdi:Impuestos>
    </cfdi:Concepto>
  </cfdi:Conceptos>
  <cfdi:Impuestos TotalImpuestosTrasladados="32.03">
    <cfdi:Traslados>
      <cfdi:Traslado Base="200.20" Importe="32.03" Impuesto="002" TasaOCuota="0.160000" TipoFactor="Tasa"></cfdi:Traslado>
    </cfdi:Traslados>
  </cfdi:Impuestos>
</cfdi:Comprobante>

License

Apache 2.0 — see LICENSE.

Documentation

Overview

Package cfdi implements the conversion from GOBL to CFDI XML

Package cfdi implements the conversion from CFDI XML to GOBL.

Index

Constants

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

CFDI schema constants

View Source
const (
	FakeNoCertificado   = "00000000000000000000"
	ExportacionNoAplica = "01"
	ImpuestoIVA         = "002"
)

Hard-coded values for (yet) unsupported mappings

View Source
const (
	NombreReceptorGenerico         = "PUBLICO EN GENERAL"
	NombreReceptorGenericoNoGlobal = "PÚBLICO EN GENERAL"
	RegimenFiscalSinObligaciones   = "616" // no tax obligations
)

Generic supplier constants

View Source
const (
	TipoFactorTasa   = "Tasa"
	TipoFactorCuota  = "Cuota" // Not supported
	TipoFactorExento = "Exento"
)

TipoFactor definitions.

View Source
const (
	ObjetoImpNo = "01" // not subject to tax
	ObjetoImpSi = "02" // subject to tax
)

Subject to tax constants

View Source
const (
	VDVersion        = "1.0"
	VDTipoOperacion  = "monedero electrónico"
	VDNamespace      = "http://www.sat.gob.mx/valesdedespensa"
	VDSchemaLocation = "http://www.sat.gob.mx/sitio_internet/cfd/valesdedespensa/valesdedespensa.xsd"
)

VD Schema constants

View Source
const (
	ECCVersion        = "1.2"
	ECCTipoOperacion  = "Tarjeta"
	ECCNamespace      = "http://www.sat.gob.mx/EstadoDeCuentaCombustible12"
	ECCSchemaLocation = "http://www.sat.gob.mx/sitio_internet/cfd/EstadoDeCuentaCombustible/ecc12.xsd"
)

ECC Schema constants

View Source
const (
	PagoMoneda        = "XXX"       // Moneda (no currency)
	PagoClaveProdServ = "84111506"  // ClaveProdServ (payment services)
	PagoCantidad      = "1"         // Cantidad (one unit)
	PagoClaveUnidad   = "ACT"       // ClaveUnidad (activity)
	PagoDescripcion   = "Pago"      // Descripcion (payment)
	PagoObjetoImp     = ObjetoImpNo // ObjetoImp (not subject to tax)
)

Fixed values for CFDI type "P" documents as per SAT fill-in guide

View Source
const (
	PagosVersion        = "2.0"
	PagosNamespace      = "http://www.sat.gob.mx/Pagos20"
	PagosSchemaLocation = "http://www.sat.gob.mx/sitio_internet/cfd/Pagos/Pagos20.xsd"
)

Pagos schema constants

View Source
const (
	TimbreNamespace      = "http://www.sat.gob.mx/TimbreFiscalDigital"
	TimbreSchemaLocation = "http://www.sat.gob.mx/sitio_internet/cfd/TimbreFiscalDigital/TimbreFiscalDigitalv11.xsd"
	TimbreVersion        = "1.1"
)

TimbreFiscalDigital namespace and schema constants

Variables

View Source
var ErrNotSupported = errors.New("not supported")

ErrNotSupported is returned when the conversion of the invoice is not supported

View Source
var (
	// ErrUnknownDocumentType is returned when the document namespace is not the expected one.
	ErrUnknownDocumentType = fmt.Errorf("unknown document namespace")
)
View Source
var (
	PagoCantidadCero = num.AmountZero // SubTotal, Total, ValorUnitario and Importe (zero amount)
)

Fixed values for CFDI type "P" documents as per SAT fill-in guide

Functions

func Parse

func Parse(data []byte) (*gobl.Envelope, error)

Parse parses a raw CFDI XML document and converts it into a GOBL envelope. The TimbreFiscalDigital, if present, is parsed as GOBL stamps. The resulting envelope must be signed to make it valid.

func Stamp

func Stamp(env *gobl.Envelope, doc *Document) error

Stamp takes the provided structured stamp data and applies it to the envelope. This should be done after the CFDI document has been processed and signed by a PAC (Proveedor Autorizado de Certificación) in Mexico.

Types

type CFDIRelacionado

type CFDIRelacionado struct {
	UUID string `xml:",attr"`
}

CFDIRelacionado stores the data of a preceding CFDI document

type CFDIRelacionados

type CFDIRelacionados struct {
	TipoRelacion    string            `xml:",attr"`
	CfdiRelacionado []CFDIRelacionado `xml:"cfdi:CfdiRelacionado"`
}

CFDIRelacionados list the preceding CFDI documents (e.g., the preceding invoices of a credit note)

type Concepto

type Concepto struct {
	ClaveProdServ string      `xml:",attr"`
	Ref           string      `xml:"NoIdentificacion,attr,omitempty"`
	Cantidad      string      `xml:",attr"`
	ClaveUnidad   string      `xml:",attr"`
	Desc          string      `xml:"Descripcion,attr"` // nolint:misspell
	ValorUnitario num.Amount  `xml:",attr"`
	Importe       num.Amount  `xml:",attr"`
	Descuento     *num.Amount `xml:",attr,omitempty"`
	ObjetoImp     string      `xml:",attr"`

	Impuestos  *ConceptoImpuestos `xml:"cfdi:Impuestos,omitempty"`
	ThirdParty *ThirdParty        `xml:"cfdi:ACuentaTerceros,omitempty"`
}

Concepto stores an invoice line data

type ConceptoImpuestos

type ConceptoImpuestos struct {
	Traslados   *Traslados   `xml:"cfdi:Traslados,omitempty"`
	Retenciones *Retenciones `xml:"cfdi:Retenciones,omitempty"`
}

ConceptoImpuestos store the line tax totals

type Conceptos

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

Conceptos list invoice lines nolint:misspell

type DoctoRelacionado added in v0.63.0

type DoctoRelacionado struct {
	// IDDocumento is the identifier of the related document: the fiscal folio (UUID)
	// of an electronic invoice or the operation number of a digital document.
	IDDocumento string `xml:"IdDocumento,attr"`
	// Serie is the series of the related document, for internal control.
	Serie string `xml:",attr,omitempty"`
	// Folio is the folio of the related document, for internal control.
	Folio string `xml:",attr,omitempty"`
	// MonedaDR is the key of the currency of the amounts of the related document (ISO
	// 4217).
	MonedaDR string `xml:",attr"`
	// EquivalenciaDR is the number of units of the currency of the related document
	// that are equivalent to one unit of the payment currency. Required when the
	// currencies differ.
	EquivalenciaDR string `xml:",attr,omitempty"`
	// NumParcialidad is the number of the instalment that the payment corresponds to.
	NumParcialidad string `xml:",attr"`
	// ImpSaldoAnt is the outstanding balance of the previous instalment, or the total
	// amount of the related document for the first instalment.
	ImpSaldoAnt string `xml:",attr"`
	// ImpPagado is the amount paid for the related document.
	ImpPagado string `xml:",attr"`
	// ImpSaldoInsoluto is the difference between the previous balance and the amount
	// paid.
	ImpSaldoInsoluto string `xml:",attr"`
	// ObjetoImpDR expresses whether the payment of the related document is subject to
	// tax or not (c_ObjetoImp).
	ObjetoImpDR string `xml:",attr"`

	// ImpuestosDR reports the taxes applicable to the amount of the payment received,
	// expressed in the currency of the related document.
	ImpuestosDR *ImpuestosDR `xml:"pago20:ImpuestosDR,omitempty"`
}

DoctoRelacionado stores the data of a document related to a payment.

type Document

type Document struct {
	XMLName        xml.Name `xml:"cfdi:Comprobante"`
	CFDINamespace  string   `xml:"xmlns:cfdi,attr"`
	XSINamespace   string   `xml:"xmlns:xsi,attr"`
	ECCNamespace   string   `xml:"xmlns:ecc12,attr,omitempty"`
	VDNamespace    string   `xml:"xmlns:valesdedespensa,attr,omitempty"`
	PagosNamespace string   `xml:"xmlns:pago20,attr,omitempty"`
	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          num.Amount  `xml:",attr"`
	Descuento         *num.Amount `xml:",attr,omitempty"`
	Total             num.Amount  `xml:",attr"`
	Moneda            string      `xml:",attr"`
	TipoCambio        *num.Amount `xml:",attr,omitempty"`
	Exportacion       string      `xml:",attr"`
	MetodoPago        string      `xml:",attr,omitempty"`
	FormaPago         string      `xml:",attr,omitempty"`
	CondicionesDePago string      `xml:",attr,omitempty"`
	Sello             string      `xml:",attr"`
	NoCertificado     string      `xml:",attr"`
	Certificado       string      `xml:",attr"`

	Global           *GlobalInformation `xml:"cfdi:InformacionGlobal,omitempty"`
	CFDIRelacionados *CFDIRelacionados  `xml:"cfdi:CfdiRelacionados,omitempty"`
	Emisor           *Emisor            `xml:"cfdi:Emisor"`
	Receptor         *Receptor          `xml:"cfdi:Receptor"`
	Conceptos        *Conceptos         `xml:"cfdi:Conceptos"` //nolint:misspell
	Impuestos        *Impuestos         `xml:"cfdi:Impuestos,omitempty"`

	// Supported complements
	ComplementoValesDeDespensa         *ValesDeDespensa           `xml:"cfdi:Complemento>valesdedespensa:ValesDeDespensa,omitempty"`
	ComplementoEstadoCuentaCombustible *EstadoDeCuentaCombustible `xml:"cfdi:Complemento>ecc12:EstadoDeCuentaCombustible,omitempty"`
	ComplementoPagos                   *Pagos                     `xml:"cfdi:Complemento>pago20:Pagos,omitempty"`
	ComplementoTimbreFiscalDigital     *TimbreFiscalDigital       `xml:"cfdi:Complemento>tfd:TimbreFiscalDigital,omitempty"`

	// Supported addendas
	AddendaMabe *addendas.MabeFactura `xml:"cfdi:Addenda>mabe:Factura,omitempty"`
}

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

func Convert

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

Convert 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 ECCConcepto

type ECCConcepto struct {
	Identificador     string `xml:",attr"`
	Fecha             string `xml:",attr"`
	Rfc               string `xml:",attr"`
	ClaveEstacion     string `xml:",attr"`
	Cantidad          string `xml:",attr"`
	TipoCombustible   string `xml:",attr"`
	Unidad            string `xml:",attr,omitempty"`
	NombreCombustible string `xml:",attr"`
	FolioOperacion    string `xml:",attr"`
	ValorUnitario     string `xml:",attr"`
	Importe           string `xml:",attr"`

	Traslados []*ECCTraslado `xml:"ecc12:Traslados>ecc12:Traslado"`
}

ECCConcepto stores the data of a fuel purchase

type ECCTraslado

type ECCTraslado struct {
	Impuesto   string `xml:",attr"`
	TasaOCuota string `xml:",attr"`
	Importe    string `xml:",attr"`
}

ECCTraslado stores the tax data of a fuel purchase

type Emisor

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

Emisor stores the invoice supplier data

type EstadoDeCuentaCombustible

type EstadoDeCuentaCombustible struct {
	XMLName       xml.Name `xml:"ecc12:EstadoDeCuentaCombustible"`
	Version       string   `xml:",attr"`
	TipoOperacion string   `xml:",attr"`

	NumeroDeCuenta string `xml:",attr"`
	SubTotal       string `xml:",attr"`
	Total          string `xml:",attr"`

	Conceptos []*ECCConcepto `xml:"ecc12:Conceptos>ecc12:ConceptoEstadoDeCuentaCombustible"` // nolint:misspell
}

EstadoDeCuentaCombustible stores the fuel account balance data

type GlobalInformation

type GlobalInformation struct {
	Period string `xml:"Periodicidad,attr"`
	Month  string `xml:"Meses,attr"`
	Year   string `xml:"Año,attr"`
}

GlobalInformation is used for invoices that contain a summary of B2C documents.

type Impuesto

type Impuesto struct {
	Base       *num.Amount `xml:",attr,omitempty"`
	Importe    *num.Amount `xml:",attr,omitempty"`
	Impuesto   string      `xml:",attr"`
	TasaOCuota *num.Amount `xml:",attr,omitempty"`
	TipoFactor string      `xml:",attr,omitempty"`
}

Impuesto stores the tax data of the invoice or a line

type Impuestos

type Impuestos struct {
	TotalImpuestosTrasladados *num.Amount  `xml:",attr,omitempty"`
	TotalImpuestosRetenidos   *num.Amount  `xml:",attr,omitempty"`
	Retenciones               *Retenciones `xml:"cfdi:Retenciones,omitempty"`
	Traslados                 *Traslados   `xml:"cfdi:Traslados,omitempty"`
}

Impuestos store the invoice tax totals

type ImpuestosDR added in v0.63.0

type ImpuestosDR struct {
	// RetencionesDR lists the taxes withheld from the amount of the payment received.
	RetencionesDR *RetencionesDR `xml:"pago20:RetencionesDR,omitempty"`
	// TrasladosDR lists the taxes transferred on the amount of the payment received.
	TrasladosDR *TrasladosDR `xml:"pago20:TrasladosDR,omitempty"`
}

ImpuestosDR stores the taxes applicable to the amount paid for a related document.

type ImpuestosP added in v0.63.0

type ImpuestosP struct {
	// RetencionesP lists the taxes withheld from the amount of the payment. Required
	// when a related document registers a withheld tax.
	RetencionesP *RetencionesP `xml:"pago20:RetencionesP,omitempty"`
	// TrasladosP lists the taxes transferred on the amount of the payment. Required
	// when a related document registers a transferred tax.
	TrasladosP *TrasladosP `xml:"pago20:TrasladosP,omitempty"`
}

ImpuestosP stores the summary of the taxes applicable to the amount of a payment, expressed in the payment currency.

type Pago added in v0.63.0

type Pago struct {
	// FechaPago is the date and time when the beneficiary receives the payment
	// (aaaa-mm-ddThh:mm:ss, ISO 8601; 12:00:00 when the time is unknown).
	FechaPago string `xml:",attr"`
	// FormaDePagoP is the key of the means by which the payment is made (c_FormaPago).
	FormaDePagoP string `xml:",attr"`
	// MonedaP is the key of the currency used to make the payment (ISO 4217).
	MonedaP string `xml:",attr"`
	// TipoCambioP is the exchange rate to MXN at the date of the payment. Required
	// when MonedaP is different from MXN.
	TipoCambioP string `xml:",attr,omitempty"`
	// Monto is the amount of the payment.
	Monto string `xml:",attr"`
	// NumOperacion is the cheque, authorisation, reference, SPEI tracking key or
	// analogous number that identifies the payment operation.
	NumOperacion string `xml:",attr,omitempty"`
	// RfcEmisorCtaOrd is the RFC of the entity issuing the ordering account.
	RfcEmisorCtaOrd string `xml:",attr,omitempty"`
	// NomBancoOrdExt is the name of the ordering bank, required when foreign.
	NomBancoOrdExt string `xml:",attr,omitempty"`
	// CtaOrdenante is the number of the account with which the payment was made.
	CtaOrdenante string `xml:",attr,omitempty"`
	// RfcEmisorCtaBen is the RFC of the entity operating the beneficiary account.
	RfcEmisorCtaBen string `xml:",attr,omitempty"`
	// CtaBeneficiario is the number of the account where the payment was received.
	CtaBeneficiario string `xml:",attr,omitempty"`
	// TipoCadPago is the key of the type of payment chain generated by the entity
	// receiving the payment (c_TipoCadenaPago).
	TipoCadPago string `xml:",attr,omitempty"`
	// CertPago is the certificate covering the payment, in base 64. Required when
	// TipoCadPago is set.
	CertPago string `xml:",attr,omitempty"`
	// CadPago is the original string of the payment receipt generated by the entity
	// issuing the beneficiary account. Required when TipoCadPago is set.
	CadPago string `xml:",attr,omitempty"`
	// SelloPago is the digital seal associated with the payment, in base 64. Required
	// when TipoCadPago is set.
	SelloPago string `xml:",attr,omitempty"`

	// DoctoRelacionado lists the documents related to the payment.
	DoctoRelacionado []*DoctoRelacionado `xml:"pago20:DoctoRelacionado"`
	// ImpuestosP summarises the taxes applicable to the amount of the payment
	// received, expressed in the payment currency.
	ImpuestosP *ImpuestosP `xml:"pago20:ImpuestosP,omitempty"`
}

Pago stores the data of a single payment received.

type Pagos added in v0.63.0

type Pagos struct {
	XMLName xml.Name `xml:"pago20:Pagos"`

	// Version is the version of the payment complement. Fixed to "2.0".
	Version string `xml:",attr"`

	// Totales reports the total amount of the payments and their taxes, expressed in
	// MXN.
	Totales *PagosTotales `xml:"pago20:Totales"`
	// Pago lists the payments received.
	Pago []*Pago `xml:"pago20:Pago"`
}

Pagos stores the data of the payment receipts complement ("Complemento para recepción de pagos" 2.0) added to CFDI documents of type "P".

type PagosTotales added in v0.63.0

type PagosTotales struct {
	// TotalRetencionesIVA is the total of the IVA taxes withheld in the payments.
	TotalRetencionesIVA string `xml:",attr,omitempty"`
	// TotalRetencionesISR is the total of the ISR taxes withheld in the payments.
	TotalRetencionesISR string `xml:",attr,omitempty"`
	// TotalRetencionesIEPS is the total of the IEPS taxes withheld in the payments.
	TotalRetencionesIEPS string `xml:",attr,omitempty"`
	// TotalTrasladosBaseIVA16 is the total base of the IVA transferred at the 16% rate.
	TotalTrasladosBaseIVA16 string `xml:",attr,omitempty"`
	// TotalTrasladosImpuestoIVA16 is the total of the IVA taxes transferred at the 16% rate.
	TotalTrasladosImpuestoIVA16 string `xml:",attr,omitempty"`
	// TotalTrasladosBaseIVA8 is the total base of the IVA transferred at the 8% rate.
	TotalTrasladosBaseIVA8 string `xml:",attr,omitempty"`
	// TotalTrasladosImpuestoIVA8 is the total of the IVA taxes transferred at the 8% rate.
	TotalTrasladosImpuestoIVA8 string `xml:",attr,omitempty"`
	// TotalTrasladosBaseIVA0 is the total base of the IVA transferred at the 0% rate.
	TotalTrasladosBaseIVA0 string `xml:",attr,omitempty"`
	// TotalTrasladosImpuestoIVA0 is the total of the IVA taxes transferred at the 0% rate.
	TotalTrasladosImpuestoIVA0 string `xml:",attr,omitempty"`
	// TotalTrasladosBaseIVAExento is the total base of the IVA transferred exempt.
	TotalTrasladosBaseIVAExento string `xml:",attr,omitempty"`
	// MontoTotalPagos is the total of the payments reported in the Pago nodes.
	MontoTotalPagos string `xml:",attr"`
}

PagosTotales stores the total amounts of the payments and the taxes that derive from them, expressed in MXN.

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"`
	NumRegIdTrib            string `xml:",attr,omitempty"` //nolint:staticcheck,revive
	ResidenciaFiscal        string `xml:",attr,omitempty"`
}

Receptor stores the invoice customer data

type RetencionDR added in v0.63.0

type RetencionDR struct {
	// BaseDR is the base for the calculation of the withheld tax.
	BaseDR string `xml:",attr"`
	// ImpuestoDR is the key of the type of tax withheld (c_Impuesto).
	ImpuestoDR string `xml:",attr"`
	// TipoFactorDR is the key of the factor type applied to the base (c_TipoFactor).
	TipoFactorDR string `xml:",attr"`
	// TasaOCuotaDR is the rate or quota of the tax withheld.
	TasaOCuotaDR string `xml:",attr"`
	// ImporteDR is the amount of the tax withheld.
	ImporteDR string `xml:",attr"`
}

RetencionDR stores the data of a tax withheld from the amount paid for a related document.

type RetencionP added in v0.63.0

type RetencionP struct {
	// ImpuestoP is the key of the type of tax withheld (c_Impuesto).
	ImpuestoP string `xml:",attr"`
	// ImporteP is the amount of the tax withheld.
	ImporteP string `xml:",attr"`
}

RetencionP stores the data of a tax withheld from the amount of a payment.

type Retenciones

type Retenciones struct {
	Retencion []*Impuesto `xml:"cfdi:Retencion"`
}

Retenciones lists the retained taxes of a line or the invoice

type RetencionesDR added in v0.63.0

type RetencionesDR struct {
	RetencionDR []*RetencionDR `xml:"pago20:RetencionDR"`
}

RetencionesDR lists the taxes withheld from the amount paid for a related document.

type RetencionesP added in v0.63.0

type RetencionesP struct {
	RetencionP []*RetencionP `xml:"pago20:RetencionP"`
}

RetencionesP lists the taxes withheld from the amount of a payment.

type ThirdParty

type ThirdParty struct {
	RFC          string   `xml:"RfcACuentaTerceros,attr"`
	Name         string   `xml:"NombreACuentaTerceros,attr"`
	FiscalRegime cbc.Code `xml:"RegimenFiscalACuentaTerceros,attr"`
	PostCode     cbc.Code `xml:"DomicilioFiscalACuentaTerceros,attr"`
}

ThirdParty or "ACuentaTerceros" defines the details of a third part for whom this transaction has been performed.

type TimbreFiscalDigital

type TimbreFiscalDigital struct {
	// Version is the version of the TimbreFiscalDigital standard (fixed at "1.1")
	Version string `xml:"Version,attr"`

	// UUID is the fiscal folio (36-character UUID) of the stamping transaction
	// conforming to RFC 4122 standard
	UUID string `xml:"UUID,attr"`

	// FechaTimbrado is the date and time when the stamp was generated by the SAT
	// certification. Format: YYYY-MM-DDThh:mm:ss in Mexico Central Time Zone
	FechaTimbrado string `xml:"FechaTimbrado,attr"`

	// RfcProvCertif is the RFC of the digital fiscal certificate provider
	// that generates the fiscal stamp
	RfcProvCertif string `xml:"RfcProvCertif,attr"`

	// Leyenda is an optional field to record information that the SAT
	// communicates to CFDI users (12-150 characters)
	Leyenda string `xml:"Leyenda,attr,omitempty"`

	// SelloCFD contains the digital seal of the CFDI that has been stamped,
	// expressed as a Base64 encoded string
	SelloCFD string `xml:"SelloCFD,attr"`

	// NoCertificadoSAT is the serial number of the SAT certificate used to
	// generate the digital seal of the fiscal stamp (20 digits)
	NoCertificadoSAT string `xml:"NoCertificadoSAT,attr"`

	// SelloSAT contains the digital seal of the fiscal stamp itself,
	// expressed as a Base64 encoded string
	SelloSAT string `xml:"SelloSAT,attr"`
}

TimbreFiscalDigital represents the digital fiscal stamp (Timbre Fiscal Digital) that validates a CFDI document.

type TrasladoDR added in v0.63.0

type TrasladoDR struct {
	// BaseDR is the base for the calculation of the transferred tax.
	BaseDR string `xml:",attr"`
	// ImpuestoDR is the key of the type of tax transferred (c_Impuesto).
	ImpuestoDR string `xml:",attr"`
	// TipoFactorDR is the key of the factor type applied to the base (c_TipoFactor).
	TipoFactorDR string `xml:",attr"`
	// TasaOCuotaDR is the rate or quota of the tax transferred. Required when
	// TipoFactorDR is Tasa or Cuota.
	TasaOCuotaDR string `xml:",attr,omitempty"`
	// ImporteDR is the amount of the tax transferred. Required when
	// TipoFactorDR is Tasa or Cuota.
	ImporteDR string `xml:",attr,omitempty"`
}

TrasladoDR stores the data of a tax transferred on the amount paid for a related document.

type TrasladoP added in v0.63.0

type TrasladoP struct {
	// BaseP is the sum of the BaseDR attributes of the related documents for the
	// transferred tax.
	BaseP string `xml:",attr"`
	// ImpuestoP is the key of the type of tax transferred (c_Impuesto).
	ImpuestoP string `xml:",attr"`
	// TipoFactorP is the key of the factor type applied to the base (c_TipoFactor).
	TipoFactorP string `xml:",attr"`
	// TasaOCuotaP is the rate or quota of the tax transferred in the related
	// documents.
	TasaOCuotaP string `xml:",attr,omitempty"`
	// ImporteP is the sum of the transferred tax, grouped by ImpuestoP,
	// TipoFactorP and TasaOCuotaP.
	ImporteP string `xml:",attr,omitempty"`
}

TrasladoP stores the data of a tax transferred on the amount of a payment.

type Traslados

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

Traslados lists the non-retained taxes of a line or the invoice

type TrasladosDR added in v0.63.0

type TrasladosDR struct {
	TrasladoDR []*TrasladoDR `xml:"pago20:TrasladoDR"`
}

TrasladosDR lists the taxes transferred on the amount paid for a related document.

type TrasladosP added in v0.63.0

type TrasladosP struct {
	TrasladoP []*TrasladoP `xml:"pago20:TrasladoP"`
}

TrasladosP lists the taxes transferred on the amount of a payment.

type VDConcepto

type VDConcepto struct {
	Identificador      string `xml:"identificador,attr"`
	Fecha              string `xml:"fecha,attr"`
	Rfc                string `xml:"rfc,attr"`
	Curp               string `xml:"curp,attr"`
	Nombre             string `xml:"nombre,attr"`
	NumSeguridadSocial string `xml:"numSeguridadSocial,attr,omitempty"`
	Importe            string `xml:"importe,attr"`
}

VDConcepto stores the data of a single food voucher

type ValesDeDespensa

type ValesDeDespensa struct {
	XMLName       xml.Name `xml:"valesdedespensa:ValesDeDespensa"`
	Version       string   `xml:"version,attr"`
	TipoOperacion string   `xml:"tipoOperacion,attr"`

	RegistroPatronal string `xml:"registroPatronal,attr,omitempty"`
	NumeroDeCuenta   string `xml:"numeroDeCuenta,attr"`
	Total            string `xml:"total,attr"`

	Conceptos []*VDConcepto `xml:"valesdedespensa:Conceptos>valesdedespensa:Concepto"` // nolint:misspell
}

ValesDeDespensa stores the food vouchers data

Directories

Path Synopsis
Package addendas adds additional functionality for "Addendas" to the CFDI documents.
Package addendas adds additional functionality for "Addendas" to the CFDI documents.
Package addon implements the CFDI (Comprobante Fiscal Digital por Internet) extensions and validation rules that need to be applied to GOBL documents in order to comply with the Mexican tax authority (SAT).
Package addon implements the CFDI (Comprobante Fiscal Digital por Internet) extensions and validation rules that need to be applied to GOBL documents in order to comply with the Mexican tax authority (SAT).
cmd
gobl.mx.cfdi command
Package main provides a CLI interface for the library
Package main provides a CLI interface for the library
Package internal contains additional functionality required internally.
Package internal contains additional functionality required internally.
format
Package format contains helps to help format output.
Package format contains helps to help format output.
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
⌂ 换网址