Skip to main content

The best open-source python library to generate and process SAT's CFDI

Project description

Source Documentation Status Python v10 Python v11 CodeQL CodeQL

SAT-CFDI

The best open-source python library to generate and process SAT’s CFDI

Documentation and User Guide available

SAT-CFDI Read the Docs

Supported Features

  • Crear CFDI - Ingreso, Nomina, Pagos, Traslados, Retenciones

  • Representación Impresa PDF y HTML

  • Facturación con PAC’s

  • Descarga Masiva

  • Validación de CFDI’s

  • Listado 59b

  • Exportar CFDI’s a Excel

  • Descarga de Constancia de Situación Fiscal

  • DIOT - Declaración Informativa de Operaciones con Terceros

  • Certifica - Generación de certificados

  • PLD (Prevención de Lavado de Dinero)

Installation

Install SAT-CFDI from PyPI with:

python -m pip install satcfdi

or install from source with:

git clone https://github.com/SAT-CFDI/python-satcfdi
cd python-satcfdi
python -m pip install .

Quick Example

from decimal import Decimal
from satcfdi import Signer
from satcfdi.create.cfd import cfdi40
from satcfdi.create import Issuer

# Load signing certificate
signer = Signer.load(
    certificate=open('csd/xiqb891116qe4_csd.cer', 'rb').read(),
    key=open('csd/xiqb891116qe4_csd.key', 'rb').read(),
    password=open('csd/xiqb891116qe4_csd.txt', 'r').read()
)

# create an Emisor
emisor = Issuer(signer=signer, tax_system="606")

# create Comprobante
invoice = cfdi40.Comprobante(
    emisor=emisor,
    lugar_expedicion="56820",
    receptor=cfdi40.Receptor(
        rfc='KIJ0906199R1',
        nombre='KIJ, S.A DE C.V.',
        uso_cfdi='G03',
        domicilio_fiscal_receptor="59820",
        regimen_fiscal_receptor="601"
    ),
    metodo_pago='PPD',
    serie="A",
    folio="123456",
    conceptos=[
        cfdi40.Concepto(
            clave_prod_serv='84111506',
            cantidad=Decimal('1.00'),
            clave_unidad='E48',
            descripcion='SERVICIOS DE FACTURACION',
            valor_unitario=Decimal('1250.30'),
            traslados='IVA|Tasa|0.160000',
            retenciones=['ISR|Tasa|0.100000', 'IVA|Tasa|0.106667'],
            _traslados_incluidos=False
        )
    ]
).process()

# XML
invoice.xml_write("my_invoice.xml")

# HTML
invoice.html_write("my_invoice.html")

# PDF
invoice.pdf_write("my_invoice.pdf")

Contributing

We value feedback and contributions from our community.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

satcfdi-1.0.3.tar.gz (4.2 MB view hashes)

Uploaded Source

Built Distribution

satcfdi-1.0.3-py3-none-any.whl (4.6 MB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page