Metadata-Version: 2.1
Name: satcfdi
Version: 4.4.12
Summary: The best open-source python library to generate and process SAT's CFDI
Home-page: https://github.com/SAT-CFDI/python-satcfdi
Author: satcfdi@outlook.com
Author-email: satcfdi@outlook.com
License: MIT License
Project-URL: Documentation, https://satcfdi.readthedocs.io
Project-URL: Source, https://github.com/SAT-CFDI/python-satcfdi
Keywords: cfdi,sat,facturación,comprobante,retenciones,nómina,pagos,carta porte,contabilidad,e-invoicing,DIOT
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: Spanish
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.10
Description-Content-Type: text/x-rst
Requires-Dist: jinja2>=3.0.0
Requires-Dist: lxml>=4.9.0
Requires-Dist: weasyprint>=57.0
Requires-Dist: requests>=2.0.0
Requires-Dist: cryptography<43,>=39.0.0
Requires-Dist: pytz>=2022.5
Requires-Dist: xlsxwriter>=3.0.0
Requires-Dist: pyOpenSSL>=22.0.0
Requires-Dist: qrcode>=7.3.0
Requires-Dist: tabulate>=0.9.0
Requires-Dist: packaging>=21.0
Requires-Dist: beautifulsoup4>4.11.0
Provides-Extra: test
Requires-Dist: coverage; extra == "test"
Requires-Dist: pytest; extra == "test"
Requires-Dist: PyYAML; extra == "test"
Provides-Extra: docs
Requires-Dist: Sphinx>=5.3.0; extra == "docs"
Requires-Dist: sphinx-rtd-theme>=1.1.1; extra == "docs"

.. image:: https://img.shields.io/github/commit-activity/m/SAT-CFDI/python-satcfdi
    :target: https://github.com/badges/SAT-CFDI/python-satcfdi
    :alt: Activity

.. image:: https://readthedocs.org/projects/satcfdi/badge?version=latest
    :target: https://satcfdi.readthedocs.io?badge=latest
    :alt: Documentation Status

.. image:: https://github.com/SAT-CFDI/python-satcfdi/actions/workflows/tests.yml/badge.svg
    :target: https://github.com/SAT-CFDI/python-satcfdi/actions/workflows/tests.yml
    :alt: Tests

.. image:: https://github.com/SAT-CFDI/python-satcfdi/actions/workflows/codeql.yml/badge.svg
    :target: https://github.com/SAT-CFDI/python-satcfdi/actions/workflows/codeql.yml
    :alt: CodeQL

.. image:: https://github.com/SAT-CFDI/python-satcfdi/actions/workflows/publish.yml/badge.svg
    :target: https://github.com/SAT-CFDI/python-satcfdi/actions/workflows/publish.yml
    :alt: Publish

.. image:: https://img.shields.io/github/v/release/SAT-CFDI/python-satcfdi.svg?logo=git&style=flat
    :target: https://github.com/SAT-CFDI/python-satcfdi/releases
    :alt: Releases

.. image:: https://pepy.tech/badge/satcfdi/month
    :target: https://pepy.tech/project/satcfdi
    :alt: Downloads

.. image:: https://img.shields.io/pypi/pyversions/satcfdi.svg
    :target: https://pypi.org/project/satcfdi
    :alt: Supported Versions

.. image:: https://img.shields.io/github/contributors/SAT-CFDI/python-satcfdi.svg
    :target: https://github.com/SAT-CFDI/python-satcfdi/graphs/contributors
    :alt: Contributors

.. image:: https://scrutinizer-ci.com/g/SAT-CFDI/python-satcfdi/badges/quality-score.png?b=main
    :target: https://scrutinizer-ci.com/g/SAT-CFDI/python-satcfdi/?branch=main
    :alt: Scrutinizer Code Quality

.. image:: https://scrutinizer-ci.com/g/SAT-CFDI/python-satcfdi/badges/coverage.png?b=main
    :target: https://scrutinizer-ci.com/g/SAT-CFDI/python-satcfdi/code-structure/main/code-coverage/satcfdi/
    :alt: Code Coverage

.. image:: https://img.shields.io/discord/1045508868807073792?logo=discord&style=flat
    :target: https://discord.gg/6WA9QvZcRn
    :alt: Discord

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 <https://satcfdi.readthedocs.io>`_

Supported Features
____________________

* CFDI 3.2, 3.3, 4.0 - Ingreso, Nomina, Pagos, Traslados y Complementos
* Retenciones 1.0, 2.0
* Contabilidad Electronica 1.3
* Representación Impresa PDF, HTML, JSON
* Facturación con PAC's

  * Comercio Digital
  * Diverza
  * Prodigia
  * SW Sapien
* Descarga Masiva
* Validación de Comprobantes
* Listado 69B
* Exportar Comprobantes a Excel
* Descarga de Constancia de Situación Fiscal
* Portal SAT - Factura Electrónica

  * Validación de RFC, Razón Social
  * LCO - Lista de Contribuyentes Obligados
* DIOT - Declaración Informativa de Operaciones con Terceros
* Certifica - Solicitud de Certificados, Renovación de Fiel
* PLD - Prevención de Lavado de Dinero


Installation
____________________

Install SAT-CFDI from PyPI with:

.. code-block:: sh

    python -m pip install satcfdi

or install from source with:

.. code-block:: sh

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


Load
____________________

.. code-block:: python

    from satcfdi.cfdi import CFDI
    
    # from file
    invoice = CFDI.from_file('comprobante.xml')
    
    # from string/bytes
    invoice = CFDI.from_string(open('comprobante.xml', 'rb').read())
    
    

Create
____________________

.. code-block:: python

    from decimal import Decimal
    from satcfdi.models import Signer
    from satcfdi.create.cfd import cfdi40
    from satcfdi.create.cfd.catalogos import RegimenFiscal, UsoCFDI, MetodoPago, Impuesto, TipoFactor
    
    # 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 Comprobante
    invoice = cfdi40.Comprobante(
        emisor=cfdi40.Emisor(
            rfc=signer.rfc,
            nombre=signer.legal_name,
            regimen_fiscal=RegimenFiscal.GENERAL_DE_LEY_PERSONAS_MORALES
        ),
        lugar_expedicion="56820",
        receptor=cfdi40.Receptor(
            rfc='KIJ0906199R1',
            nombre='KIJ, S.A DE C.V.',
            uso_cfdi=UsoCFDI.GASTOS_EN_GENERAL,
            domicilio_fiscal_receptor="59820",
            regimen_fiscal_receptor=RegimenFiscal.GENERAL_DE_LEY_PERSONAS_MORALES
        ),
        metodo_pago=MetodoPago.PAGO_EN_PARCIALIDADES_O_DIFERIDO,
        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'),
                impuestos=cfdi40.Impuestos(
                    traslados=cfdi40.Traslado(
                            impuesto=Impuesto.IVA,
                            tipo_factor=TipoFactor.TASA,
                            tasa_o_cuota=Decimal('0.160000'),
                        ),
                    retenciones=[
                        cfdi40.Retencion(
                            impuesto=Impuesto.ISR,
                            tipo_factor=TipoFactor.TASA,
                            tasa_o_cuota=Decimal('0.100000'),
                        ),
                        cfdi40.Retencion(
                            impuesto=Impuesto.IVA,
                            tipo_factor=TipoFactor.TASA,
                            tasa_o_cuota=Decimal('0.106667'),
                        )
                    ],
                ),
                _traslados_incluidos=False  # indica si el valor unitario incluye los traslados
            )
        ]
    )
    invoice.sign(signer)
    invoice = invoice.process()
    

Output
____________________

.. code-block:: python

    from satcfdi import render
    from satcfdi.render import BODY_TEMPLATE
    
    # XML
    invoice.xml_write("my_invoice.xml")
    
    # JSON
    render.json_write(invoice, "my_invoice.json", pretty_print=True)
    
    # HTML
    render.html_write(invoice, "my_invoice.html")
    
    # PDF
    render.pdf_write(invoice, "my_invoice.pdf")
    
    # Multiple HTML
    render.html_write([invoice1, invoice2], "my_invoice.html")
    
    # Multiple PDF
    render.pdf_write([invoice1, invoice2], "my_invoice.pdf")
    
    # HTML Body only
    html_body = render.html_str(invoice, template=BODY_TEMPLATE)


Contributing
____________________

We value feedback and contributions from our community.

