Today I am going to discuss a support case where we found an issue with the XML file created when exporting the Business Activity Statement (BAS) tax return report for Australian Goods and Services Tax (GST).
So, if you don't have to work with Australian companies and the rest of this article does not make sense, please don't worry.
Before I start, I should explain that the issue discussed below has been fixed for GP 2010 (v11.0) Service Pack 3 and later as Problem Report 63031. If you are still on version 10.0 read on, if you are on GP 2010, install SP3 or later (or read on).
Get ready for lots of TLAs (Three Letter Acronyms).
Tax returns for Australian Goods & Service Tax (GST) are called Business Activity Statements (BAS) and there are a number of different forms based on what components of the tax legislation the business needs to report on. The Australian Taxation Office (ATO) provides software called the Electronic Commerce Interface (ECI) which allows the BAS data to be sent electronically to the ATO. The ECI also allows you to export and import the data using XML files.
Microsoft Dynamics GP has an additional BAS Report module for Australian installations. This BAS Report module will gather the data for the required date period in the form needed by the ATO from the source transactions in Microsoft Dynamics GP. Once the information has been collected, it can be either:
- Manually transferred on the hand written paper form. While the BAS Report module can print a form that looks very like the real paper form, only the real paper form from the ATO can be lodged.
- Manually transferred (cut and paste) directly into ECI software and lodged electronically.
- Automatically transferred via XML files to the ECI software and lodged electronically.
It is this last method that we are interested in.
The way that the XML file method works is as follows:
- In Microsoft Dynamics GP, process the BAS data for the desired date period.
- Once complete, Edit the Business Activity Statement to see and adjust the data as needed.
- From the ECI software, locate the form provided by the ATO which needs completion and export it to an XML file.
- Back in GP, import the XML file to populate the BAS header information.
- Then export from the BAS a new XML file which now contains the additional transaction data.
- From the ECI software, import the updated XML file.
- From the ECI software, send the document to the ATO via the internet.
- Back in GP, mark the BAS as lodged and close the appropriate Tax Periods.
Note: There is a method of automating the export/import processes to combine steps 3 & 4 into a single step and steps 5 & 6 into a single step.
The issue we are seeing occurs at step 6 above. When you attempt to import the XML file into the ECI software it generates an error similar to the one below:
Error - BT - E104
An unexpected error occurred while opening a form.
Further details: unable to access form resource archive for NAT4235-0.2001.V2
Notice that it has a Document Type Description (DTD) of NAT4235-0.2001.V2. All of the different BAS forms have a number similar to this. This number is for a BAS-G type form. However, if we compare the XML exported from the ECI software (step 3) and compare it to the XML exported form the BAS software (step 5) we can see a difference in the headers:
Original ECI Software exported XML
<?xml version="1.0" ?> <!DOCTYPE NAT4235-9.2001.V5>
Updated BAS Software exported XML
<?xml version="1.0" ?>
There is a difference in the DTD with the version number. The "V5" in the original XML file has been changed to "V2" in the updated XML file. "V2" is incorrect and so when you attempt to import the XML back into the ECI Software, it generates the error.
OK, so the version has been updated and the BAS code was written using the old version. However, this was something that we expected and the BAS code had special handling exactly for this situation. There is a BAS_Report_Forms_SETP (BAS40200) table whose only job is to store the latest updated DTD version numbers for the different BAS forms. If you import a form with a higher number than the one the BAS code was expecting, it will write it into the table and then use that DTD when exporting.
So what went wrong, why did the "future proofing" code not work?
Well, I have worked it out, it took a while, but the cause is very subtle. Firstly, you have to understand that the BAS code that is reading the XML file is not actually an XML processor. To use the XML libraries requires Dexterity to use COM (Component Object Model) calls, but the BAS code was written before Dexterity supported COM. So the XML file is just read as a Text file and the BAS code interprets the XML tags accordingly.
This is import because the code that handled the "future proofing" of the Document Type Descriptions (DTDs) is looking for the "<!DOCTYPE" tag to read the DTD, but it is looking for it at the beginning of a line! Look closely at the XML excerpts above and you will notice that the "<!DOCTYPE" tag is not at the beginning of the line.
This is why the DTD version check was being skipped and why the updated version was not getting written to the BAS_Report_Forms_SETP (BAS40200) table.
In GP 2010 Service Pack 3 or later, the code has been fixed in two ways. The default Document Type Descriptions (DTDs) have been updated to the latest versions AND the "future proofing" code that updates the BAS_Report_Forms_SETP (BAS40200) table has been adjusted.
However, if you can't install GP 2010 SP 3 or later, you can manually fix the issue by populating the BAS_Report_Forms_SETP (BAS40200) table with the updated DTDs.
The SQL script below can be executed against each Australian Company database to update the contents of the table.
I hope you find this interesting and not too confusing and more importantly... useful.