Home

Awesome

pyafipws

PyAfipWs contains Python modules to operate with web services regarding AFIP (Argentina's "IRS") and other government agencies, mainly related to electronic invoicing, several taxes and traceability.

Copyright 2008 - 2022 (C) Mariano Reingart reingart@gmail.com (creator and maintainter). All rights reserved.

License: LGPLv3+, with "commercial" exception available to include it and distribute with propietary programs

General Information:

Project Structure:

Features implemented:

Web services supported so far:

AFIP:

ARBA:

ANMAT/SEDRONAR/SENASA (SNT):

Installation Instructions:

Notes:

You could see the .github directory for detailed workflows and automated commands to build the project.

Quick-Start

These instructions are for Ubuntu/Debian. In Windows you can use PowerShell.

You can download the compressed file: https://github.com/reingart/pyafipws/archive/main.zip and unzip it.

Then install dependencies and the project itself:

pip download https://github.com/reingart/pyafipws/archive/main.zip
python -m zipfile -e main.zip  .
cd pyafipws-main
pip install -r requirements.txt --user
python setup.py install

You'll need a digital certificate (.crt) and private key (.key) to authenticate (see certificate generation for more information and instructions). Provisionally, you can use author's testing certificate/key:

wget https://www.sistemasagiles.com.ar/soft/pyafipws/reingart.zip -O reingart.zip
python -m zipfile -e reingart.zip .

You should copy and configure rece.ini to set up paths and URLs:

cp conf/*.ini .

Then, you could execute WSAA script to authenticate (getting Token and Sign) and WSFEv1 to process an electronic invoice:

python -m pyafipws.wsaa
python -m pyafipws.wsfev1 --prueba

With the last command, you should get the Electronic Autorization Code (CAE) for testing purposes (sample invoice data, do not use in production!).

Virtual environment (testing):

The following commands clone the repository, creates a virtualenv and install the packages there (including the latest versions of the dependencies) to avoid conflicts with other libraries:

git clone https://github.com/reingart/pyafipws.git
cd pyafipws
python -m venv .venv
. .venv/bin/activate
pip install -r requirements.txt
pip install -r requirements-dev.txt

Run python setup_win.py py2exe to build in windows and "compile" executables. See the GitHub Actions for specific steps and more details.

Just execute pytest to run automated Python tests. For Windows, see tests/powershell directory for Pester tests.

Dependency installation (development):

For SOAP webservices PySimpleSOAP is needed (spin-off of this library, inspired by the PHP SOAP extension):

git clone https://github.com/pysimplesoap/pysimplesoap.git -b stable_py3k
cd pysimplesoap
python setup.py install

Use "stable_py3k" branch reingart (see requirements.txt for more information)

For PDF generation, you will need the PyFPDF (PHP's FPDF library, python port):

git clone https://github.com/reingart/pyfpdf.git
cd pyfpdf
python setup.py install

On Windows, you can see available installers released for evaluation purposes on Download Releases

For more information see the source code installation steps in the wiki