satcfdi


Namesatcfdi JSON
Version 4.4.15 PyPI version JSON
download
home_pagehttps://github.com/SAT-CFDI/python-satcfdi
SummaryThe best open-source python library to generate and process SAT's CFDI
upload_time2024-04-25 08:54:23
maintainerNone
docs_urlNone
authorsatcfdi@outlook.com
requires_python>=3.10
licenseMIT License
keywords cfdi sat facturación comprobante retenciones nómina pagos carta porte contabilidad e-invoicing diot
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            .. 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.


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/SAT-CFDI/python-satcfdi",
    "name": "satcfdi",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "cfdi, sat, facturaci\u00f3n, comprobante, retenciones, n\u00f3mina, pagos, carta porte, contabilidad, e-invoicing, DIOT",
    "author": "satcfdi@outlook.com",
    "author_email": "satcfdi@outlook.com",
    "download_url": "https://files.pythonhosted.org/packages/4c/69/64856b95ad83f8d0ced4cc40f3edf444218cc431b875884d5fc9da9a7398/satcfdi-4.4.15.tar.gz",
    "platform": null,
    "description": ".. image:: https://img.shields.io/github/commit-activity/m/SAT-CFDI/python-satcfdi\n    :target: https://github.com/badges/SAT-CFDI/python-satcfdi\n    :alt: Activity\n\n.. image:: https://readthedocs.org/projects/satcfdi/badge?version=latest\n    :target: https://satcfdi.readthedocs.io?badge=latest\n    :alt: Documentation Status\n\n.. image:: https://github.com/SAT-CFDI/python-satcfdi/actions/workflows/tests.yml/badge.svg\n    :target: https://github.com/SAT-CFDI/python-satcfdi/actions/workflows/tests.yml\n    :alt: Tests\n\n.. image:: https://github.com/SAT-CFDI/python-satcfdi/actions/workflows/codeql.yml/badge.svg\n    :target: https://github.com/SAT-CFDI/python-satcfdi/actions/workflows/codeql.yml\n    :alt: CodeQL\n\n.. image:: https://github.com/SAT-CFDI/python-satcfdi/actions/workflows/publish.yml/badge.svg\n    :target: https://github.com/SAT-CFDI/python-satcfdi/actions/workflows/publish.yml\n    :alt: Publish\n\n.. image:: https://img.shields.io/github/v/release/SAT-CFDI/python-satcfdi.svg?logo=git&style=flat\n    :target: https://github.com/SAT-CFDI/python-satcfdi/releases\n    :alt: Releases\n\n.. image:: https://pepy.tech/badge/satcfdi/month\n    :target: https://pepy.tech/project/satcfdi\n    :alt: Downloads\n\n.. image:: https://img.shields.io/pypi/pyversions/satcfdi.svg\n    :target: https://pypi.org/project/satcfdi\n    :alt: Supported Versions\n\n.. image:: https://img.shields.io/github/contributors/SAT-CFDI/python-satcfdi.svg\n    :target: https://github.com/SAT-CFDI/python-satcfdi/graphs/contributors\n    :alt: Contributors\n\n.. image:: https://scrutinizer-ci.com/g/SAT-CFDI/python-satcfdi/badges/quality-score.png?b=main\n    :target: https://scrutinizer-ci.com/g/SAT-CFDI/python-satcfdi/?branch=main\n    :alt: Scrutinizer Code Quality\n\n.. image:: https://scrutinizer-ci.com/g/SAT-CFDI/python-satcfdi/badges/coverage.png?b=main\n    :target: https://scrutinizer-ci.com/g/SAT-CFDI/python-satcfdi/code-structure/main/code-coverage/satcfdi/\n    :alt: Code Coverage\n\n.. image:: https://img.shields.io/discord/1045508868807073792?logo=discord&style=flat\n    :target: https://discord.gg/6WA9QvZcRn\n    :alt: Discord\n\nSAT-CFDI\n==========================\n\nThe best open-source python library to generate and process SAT's CFDI\n\nDocumentation and User Guide available\n____________________________________________________________________________________\n\n`SAT-CFDI Read the Docs <https://satcfdi.readthedocs.io>`_\n\nSupported Features\n____________________\n\n* CFDI 3.2, 3.3, 4.0 - Ingreso, Nomina, Pagos, Traslados y Complementos\n* Retenciones 1.0, 2.0\n* Contabilidad Electronica 1.3\n* Representaci\u00f3n Impresa PDF, HTML, JSON\n* Facturaci\u00f3n con PAC's\n\n  * Comercio Digital\n  * Diverza\n  * Prodigia\n  * SW Sapien\n* Descarga Masiva\n* Validaci\u00f3n de Comprobantes\n* Listado 69B\n* Exportar Comprobantes a Excel\n* Descarga de Constancia de Situaci\u00f3n Fiscal\n* Portal SAT - Factura Electr\u00f3nica\n\n  * Validaci\u00f3n de RFC, Raz\u00f3n Social\n  * LCO - Lista de Contribuyentes Obligados\n* DIOT - Declaraci\u00f3n Informativa de Operaciones con Terceros\n* Certifica - Solicitud de Certificados, Renovaci\u00f3n de Fiel\n* PLD - Prevenci\u00f3n de Lavado de Dinero\n\n\nInstallation\n____________________\n\nInstall SAT-CFDI from PyPI with:\n\n.. code-block:: sh\n\n    python -m pip install satcfdi\n\nor install from source with:\n\n.. code-block:: sh\n\n    git clone https://github.com/SAT-CFDI/python-satcfdi\n    cd python-satcfdi\n    python -m pip install .\n\n\nLoad\n____________________\n\n.. code-block:: python\n\n    from satcfdi.cfdi import CFDI\n    \n    # from file\n    invoice = CFDI.from_file('comprobante.xml')\n    \n    # from string/bytes\n    invoice = CFDI.from_string(open('comprobante.xml', 'rb').read())\n    \n    \n\nCreate\n____________________\n\n.. code-block:: python\n\n    from decimal import Decimal\n    from satcfdi.models import Signer\n    from satcfdi.create.cfd import cfdi40\n    from satcfdi.create.cfd.catalogos import RegimenFiscal, UsoCFDI, MetodoPago, Impuesto, TipoFactor\n    \n    # Load signing certificate\n    signer = Signer.load(\n        certificate=open('csd/xiqb891116qe4_csd.cer', 'rb').read(),\n        key=open('csd/xiqb891116qe4_csd.key', 'rb').read(),\n        password=open('csd/xiqb891116qe4_csd.txt', 'r').read()\n    )\n    \n    # create Comprobante\n    invoice = cfdi40.Comprobante(\n        emisor=cfdi40.Emisor(\n            rfc=signer.rfc,\n            nombre=signer.legal_name,\n            regimen_fiscal=RegimenFiscal.GENERAL_DE_LEY_PERSONAS_MORALES\n        ),\n        lugar_expedicion=\"56820\",\n        receptor=cfdi40.Receptor(\n            rfc='KIJ0906199R1',\n            nombre='KIJ, S.A DE C.V.',\n            uso_cfdi=UsoCFDI.GASTOS_EN_GENERAL,\n            domicilio_fiscal_receptor=\"59820\",\n            regimen_fiscal_receptor=RegimenFiscal.GENERAL_DE_LEY_PERSONAS_MORALES\n        ),\n        metodo_pago=MetodoPago.PAGO_EN_PARCIALIDADES_O_DIFERIDO,\n        serie=\"A\",\n        folio=\"123456\",\n        conceptos=[\n            cfdi40.Concepto(\n                clave_prod_serv='84111506',\n                cantidad=Decimal('1.00'),\n                clave_unidad='E48',\n                descripcion='SERVICIOS DE FACTURACION',\n                valor_unitario=Decimal('1250.30'),\n                impuestos=cfdi40.Impuestos(\n                    traslados=cfdi40.Traslado(\n                            impuesto=Impuesto.IVA,\n                            tipo_factor=TipoFactor.TASA,\n                            tasa_o_cuota=Decimal('0.160000'),\n                        ),\n                    retenciones=[\n                        cfdi40.Retencion(\n                            impuesto=Impuesto.ISR,\n                            tipo_factor=TipoFactor.TASA,\n                            tasa_o_cuota=Decimal('0.100000'),\n                        ),\n                        cfdi40.Retencion(\n                            impuesto=Impuesto.IVA,\n                            tipo_factor=TipoFactor.TASA,\n                            tasa_o_cuota=Decimal('0.106667'),\n                        )\n                    ],\n                ),\n                _traslados_incluidos=False  # indica si el valor unitario incluye los traslados\n            )\n        ]\n    )\n    invoice.sign(signer)\n    invoice = invoice.process()\n    \n\nOutput\n____________________\n\n.. code-block:: python\n\n    from satcfdi import render\n    from satcfdi.render import BODY_TEMPLATE\n    \n    # XML\n    invoice.xml_write(\"my_invoice.xml\")\n    \n    # JSON\n    render.json_write(invoice, \"my_invoice.json\", pretty_print=True)\n    \n    # HTML\n    render.html_write(invoice, \"my_invoice.html\")\n    \n    # PDF\n    render.pdf_write(invoice, \"my_invoice.pdf\")\n    \n    # Multiple HTML\n    render.html_write([invoice1, invoice2], \"my_invoice.html\")\n    \n    # Multiple PDF\n    render.pdf_write([invoice1, invoice2], \"my_invoice.pdf\")\n    \n    # HTML Body only\n    html_body = render.html_str(invoice, template=BODY_TEMPLATE)\n\n\nContributing\n____________________\n\nWe value feedback and contributions from our community.\n\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "The best open-source python library to generate and process SAT's CFDI",
    "version": "4.4.15",
    "project_urls": {
        "Documentation": "https://satcfdi.readthedocs.io",
        "Homepage": "https://github.com/SAT-CFDI/python-satcfdi",
        "Source": "https://github.com/SAT-CFDI/python-satcfdi"
    },
    "split_keywords": [
        "cfdi",
        " sat",
        " facturaci\u00f3n",
        " comprobante",
        " retenciones",
        " n\u00f3mina",
        " pagos",
        " carta porte",
        " contabilidad",
        " e-invoicing",
        " diot"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1b78bb0ae4102a49a232054dc6f5b685e2193a325c4b6c6340e8d0cb8187e66e",
                "md5": "9f942393529e73134d6cb63c844886a8",
                "sha256": "206ea3637e016970597c45986fdd7aab50eb3c0720a39dbe18bd6770e1def675"
            },
            "downloads": -1,
            "filename": "satcfdi-4.4.15-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9f942393529e73134d6cb63c844886a8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 11557871,
            "upload_time": "2024-04-25T08:54:19",
            "upload_time_iso_8601": "2024-04-25T08:54:19.593102Z",
            "url": "https://files.pythonhosted.org/packages/1b/78/bb0ae4102a49a232054dc6f5b685e2193a325c4b6c6340e8d0cb8187e66e/satcfdi-4.4.15-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4c6964856b95ad83f8d0ced4cc40f3edf444218cc431b875884d5fc9da9a7398",
                "md5": "51d5ba38a7a2a39a0b3ee8ea3dea2be9",
                "sha256": "8753f67fa1120c2d381178b028ef7bf8db1952434ce7b1e0db1671dabf972fe4"
            },
            "downloads": -1,
            "filename": "satcfdi-4.4.15.tar.gz",
            "has_sig": false,
            "md5_digest": "51d5ba38a7a2a39a0b3ee8ea3dea2be9",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 10634145,
            "upload_time": "2024-04-25T08:54:23",
            "upload_time_iso_8601": "2024-04-25T08:54:23.437835Z",
            "url": "https://files.pythonhosted.org/packages/4c/69/64856b95ad83f8d0ced4cc40f3edf444218cc431b875884d5fc9da9a7398/satcfdi-4.4.15.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-25 08:54:23",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "SAT-CFDI",
    "github_project": "python-satcfdi",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "lcname": "satcfdi"
}
        
Elapsed time: 0.25248s