Skip to main content

Spanish Tax Agency Electronic Office (AEAT) Integration

Project description

=================
AEAT-WEB-SERVICES
=================

.. list-table::

* - Master
- .. image:: https://travis-ci.org/initios/aeat-web-services.svg?branch=master
:target: https://travis-ci.org/initios/aeat-web-services
- .. image:: https://coveralls.io/repos/github/initios/aeat-web-services/badge.svg?branch=master
:target: https://coveralls.io/github/initios/aeat-web-services?branch=master


Spanish Tax Agency Electronic Office (AEAT) Integration.

Make requests `AEAT Web Services <https://www2.agenciatributaria.gob.es/ADUA/internet/ws.html>`_
and sign your connection and xml using your certificate.

-----

*Integración con la Agencia Estatal de Administración Tributaria Española*

*Realiza peticiones a los* `Servicios Web de AEAT <https://www2.agenciatributaria.gob.es/ADUA/internet/ws.html>`_
*y firma tu conexión y mensajes XML utilizando tu certificado.*

Usage (English)
===============

**Example for requesting a list of ENS's.**

Initialize a Config object with the desired preconfigured service and if you want to request AEAT test or production endpoints (test_mode).
Finally initialize controller with the config and the desired certificate and make the request with your payload.

If you need more control just build the controller by hand, see build_from_config method for inspiration.

* `Preconfigured aduanet services <src/aeat/wsdl.py>`_.
* `Official AEAT Web Services <https://www2.agenciatributaria.gob.es/ADUA/internet/ws.html>`_

.. code:: python

import aeat

config = aeat.Config('ens_query', test_mode=True)
ctrl = aeat.Controller.build_from_config(config, 'cert.pem', 'key.pem')
payload = {'TraModAtBorHEA76': '1', 'ExpDatOfArr': '20110809', 'ConRefNum': '9294408'}
result = ctrl.request(payload)

assert result.valid, f'Error requesting aeat: {result.error}'
assert result.data is not None


Usage (Spanish)
===============

**Ejemplo de consulta de ENSs.**

*Inicializa el objecto Config con el servicio preconfigurado y si quieres usar los endpoints de AEAT de test o de producción (test_mode).*
*Por último inicializa el controlador con la config y el certificado que gustes y realiza la petición pasándole los datos que necesites.*

*Si necesitas un mayor control simplemente construye el controlador a mano, puedes inspirarte en el método build_from_config.*

* `Lista de Servicios Preconfigurados <src/aeat/wsdl.py>`_.
* `Servicios Web oficial de AEAT <https://www2.agenciatributaria.gob.es/ADUA/internet/ws.html>`_

.. code:: python

import aeat

config = aeat.Config('ens_query', test_mode=True)
ctrl = aeat.Controller.build_from_config(config, 'cert.pem', 'key.pem')
payload = {'TraModAtBorHEA76': '1', 'ExpDatOfArr': '20110809', 'ConRefNum': '9294408'}
result = ctrl.request(payload)

assert result.valid, f'Error requesting aeat: {result.error}'
assert result.data is not None


Django Rest Framework
=====================

```
from aeat.rest_framework import serializers as aeat_serializers

serializrer = aeat_serializers.ENSPresentationSerializer(data=payload)
serializer.is_valid(raise_exception=True)
result = serializer.save()

# aeat.Result object is returned
assert result.valid
assert result.data is not None
asssert result.error is None
assert result.raw_request is not None
assert result.raw_response is not None
```


Prerequisites
=============

Install xmlsec prerequisites.
Check https://github.com/mehcode/python-xmlsec


Install
=======

.. code:: console

$ pip install aeat-web-services


Develop
=======

.. code:: console

$ python setup.py develop
$ pip install -r requirements_test.txt


Test
=======

.. code:: console

$ pip install tox
$ tox


Releases
=========

https://github.com/initios/aeat-web-services/releases


Usefull Links
=============

- `AEAT Web Services <https://www2.agenciatributaria.gob.es/ADUA/internet/ws.html>`_
- `Available preconfigured services <src/aeat/wsdl.py>`_
- `Structure, rules and conditions <http://www.agenciatributaria.es/static_files/AEAT/Aduanas/Contenidos_Privados/Procedimientos_aduaneros/Proyecto_ICS/Descripcion_tecnica_del_proyecto/Estructurav950.pdf>`_


Project details


Download files

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

Files for aeat-web-services, version 1.0.0rc5
Filename, size File type Python version Upload date Hashes
Filename, size aeat_web_services-1.0.0rc5-py2.py3-none-any.whl (13.3 kB) File type Wheel Python version py2.py3 Upload date Hashes View hashes
Filename, size aeat-web-services-1.0.0rc5.tar.gz (54.3 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page