SAF-T (Standard Audit File for Tax) is an international standard for electronic exchange of accounting data. In this post I propose some improvements for SAF-T version 2.00.
SAF-T was defined by the Organisation for Economic Co-operation and Development (OECD). The standard was adopted in 2008 by Portugal and has since spread to other European countries, e.g. Luxembourg, Austria and Norway. Version 1.0 of SAF-T was introduced in 2005, you can download the package with xsd-schema here. Version 2.00 was introduced in 2010, however a package was never published. An annotated schema in pdf format is available here. If you prefer an xsd-schema file then you need to contact the OECD, or download the package below.
In this post I present some findings in working with SAF-T and propose some improvements.
Incomplete selector in KeyTaxCode key element
The original KeyTaxCode element looks like this:
However, level TaxCodeDetails is missing. The XPath expression should be:
This was modified in the improved schema.
XPath expressions with namespace
When you validate a SAF-T file in Visual Studio against the SAF-T schema Visual Studio ignores errors caused by key or keyref declarations. The reason for this is that XPath expressions are defined without namespace. E.g.:
This is fine for XMLSpy and other tools but not for MSXML based tools like Visual Studio, where XPath expressions must be qualified using a namespace, like this:
To change this we first need to define an extra namespace, with the value of the target namespace. This was done in the improved schema. Also, all XPath expressions in the key and keyref elements were modified.
This issue occurs in many other auditfiles created by XMLSpy, for example in the Dutch auditfile family.
StockCharacteristics has unusual structure
StockCharacteristics is a complex type with a sequence that is unbounded:
A valid example is:
This is unusual, and makes the transformation of the Xml to a relational model more difficult. In Power Query for example, we need three queries: one to handle the key element, one for the value element, and a query to merge the two tables.
It would be easier to introduce an extra level below StockCharacteristics, and define this element as unbounded.
MovementReference can not repeat
A Line in a InvoiceStructure has a part Delivery that looks like this:
As you can see the element MovementReference is unbounded. However, if we try to add another MovementReference like this:
Then Visual Studio throws an error, see image. The reason for this error is that element MovementReference references KeyMovementReference.
Declaration of keys
I would expect that all tables in MasterFiles have a key. However, TaxonomyReference in Taxonomy is not declared as key, and the same for TaxonomyCode in TaxonomyElement.
Also, in GeneralLedgerEntries the only declared key is TransactionID, which is second level below Journal. So I would expect that top level JournalID is a key, and TransactionID may occur multiple times, since TransactionID must be unique within a journal.
Perhaps this is by design, as a workaround for the multi-level key issue in XML.
Schema extension for documentation
In the SAF-T schema this namespace is defined:
Visual Studio will throw messages saying it can’t find schema information, because the extension is not available. To prevent this you could comment out the first annotation element in the schema file. This was done in the improved schema file.
The improved schema file has the following target namespace:
So if you want to use it don’t forget to modify the namespace in your xml auditfile.
Enter your name and e-mail below and you will receive an email with a download link to a zip-file with the improved Xsd file. It’s free!