SAF-T Implementation in Tryton

Hello guys,

I have been thinking of implementing a feature in Tryton that could allow me to export an xml file according to SAF-T standard.

Wikipedia Definition

SAF-T (Standard Audit File for Tax) is an international standard for electronic exchange of reliable accounting data from organizations to a national tax authority or external auditors. The standard is defined by the Organisation for Economic Co-operation and Development (OECD). The file requirements are expressed using XML, but the OECD does not impose any particular file format.

Right now, Angola is implementing VAT on their economic system. Consequently, all software must be certified by the tax authority. For it, they demand the software to be able to generate SAF-T / XML file.

I’ve got the XSD file and an example of an xml file that the program should export from the tax authority.

So, I have been thinking of a wizard capable of accepting a range of dates and then Tryton exports an xml file according to the company information, such as client information, suppliers, invoice moves, etc.

Any ideas?

I see that the French FEC is an adaptation of the SAF-T. So you should probably take a look at it in the account_fr module. We implemented the CSV format because it was simpler and faster to generate than XML file but the same design an logic should be applicable.
It will be great if you could provide submit a generic module that generate such file and which can support different version of the schema (the account_payment_sepa module could also help you to see how to manage different XML schema).

Hello Ced,

After a little investigation, I’m starting to have a sense of how account_fr works. So I can work on something similar.
I thought of creating a module called account_saft. With this module tryton would have a wizard inside Financial/Reporting called Generate SAFT, which would ask for a range of dates to generate the SAFT / XML file.

With the account_saft module installed, tryton would have a field at Financial/Configuration/Account Configuration tab where we can choose different schema of the SAFT file to use.

It this seems right?

Why not just ask for the format on the wizard?

Because I think that the schema to use for generating the SAFT file will be chosen just once. For example, in Angola I will use the schema, saft_ao, distributed by the Tax Authority to generate the SAFT file. While in Portugal they will use their schema, saft_pt.

I think it will be simpler to choose the version in a dropdown and have each version implemented in a module so usually a setup will have only one option in the dropdown.

On a second though, I think all the format should be implemented in the same module and we should still ask for the version on the wizard but we should store the last format used on the company and set it as default value for the next time. Like that we reduce the number of configuration settings, we make the system learn from past usage and we request the data only when needed.

So in this case, it’d be better to have two separate modules: account_ao and account_ao_saft? So with account_ao module tryton will have all the angolan accounts plus some specific implementations for Angola. And, with account_ao_saft, tryton will have the wizard to generate the SAFT file according to its schema

Sounds good?