Since 1st of July of 2017 the Spanish Tax Authorities requires companies with more than 6M of annual revenue to send all the invoices they issue and receive to a web-service in a period of 4 days. All the related normative is available on it’s website. There is also a document with all the detailed requirements and several examples of how to send the information.
The invoices should be sent by using a WSDL web-service. There is one for issued invoices and other for received invoices. All the requests to this web-services should be made with a certificate authentication.
Add a new module named account_es_sii. This module will automatically send the invoices to the web-services when an invoices is posted. In order to keep it transactional a separate record wil be created to store the comunincation details. A cron job will read this records and send them to the tax authorities.
The account.invoice.sii modul will be used to store the comunication details and will have the following fields:
- Invoice: The invoice to be sent.
- State: A selection field indicating the reply of the web-service. Can be one of the following:
- Accepted with errors
- CSV: A character to identify the communication
- Error: In case of error the returned message from the web-service.
As the invoice may be rejected, it should be possible to resend it (once the error is corrected) by duplicating the record.
The web-service also requires to identify the type of taxes with a special codes. New fields will be added on tax (and tax template) to let the user set the codes. The values will be set for the taxes defined on the account_es module.
On the account configuration model we will add the following fields
- SII URL: The URL from where to read the webservice URL.
- SII Environment: None, Staging and Production
The Public and private keys used for authentification will be stored on the filesystem and they should be specified by adding its url to the tryton configuration system.