If you’re getting an error saying your account number or access code aren’t valid, it might just be that you’re entering them onto the wrong webpage.
New XML Files
On Get Ready to File page, under step 3, it mentions the XML file has been changed.
If you try to upload the old XML file format, this somewhat helpful error message comes up
Error: We are unable to process your submission because the transmitter CRA account number given in the attached T619 electronic transmittal record does not match the account number you used to sign in.
What they really should be saying is that it couldn’t find the *new* XML field where it expects the CRA account number to be located.
The T619 Electronic Transmittal page actually fairly helpfully describes what’s changed: a bunch of fields were removed, some were added.
But really, we should be using the new XML descriptor files (they used to have like 8, if I recall correctly, but now their engineers have had a field day and made like 50). This note from Get Ready to File, Step 3, Download the CRA Schema is important:
Please note that the “layout-topologies.xsd” file has been replaced by “T619_<FormType>.xsd” files
The old “main” XML descriptior file (XSD) used to be “layout-topologies.xsd”, but now, when making the report on T2202s, it’s T619_T2202.xsd”. So when using software that needs to know which is the main XML descriptor file, there you have it.
Having Trouble
Once I updated my Python code to use the new Python classes generated from the slightly tweaked XML schema provided by the CRA, I tried uploading the file and got a super vague error.
Error I got after uploading the XML file.
The error basically said “something is wrong. We’re not saying what.”
So I ran some validation on it… It turned out I previously had added some code that did this but only when requested and had turned it off. It looked like this:
if settings.VALIDATE_XML:
# Validate it before we download it
from xmlschema import XMLSchema
schema = XMLSchema('libs/cra-xsds/T619_T2202.xsd')
schema.validate(generated_xml)
There’s a ton of other tools out there to validate XML (the CRA non-helpfully says “You can find them on the internet!”) You can even do XML validation using ChatGPT. The only gotcha is that you need to provide it with the local XML schema file, not one publicly available over the internet (eg some of them expect the schema files to be located at https://somesite.com/my-xml-schema-file.xsd or something like that.)
ChatGPT almost worked for me, but it used up all my free daily ChatGPT 4 credits just parsing the XML files I provided it with.
XML Namespacing Issues
Once I XML validation on, most of the XML validation error I got were from XML tag namespaces. I’ve never bothered to really understand it, but some of the XML tags in the generated XML file were getting a namespace prefix added onto them, which the validator didn’t like.
Eg instead of having the tag <TaxationYear>, my XML file had <sdt:TaxationYear>, as mention in the below error output while running my command to generate the XML file:
(env) [earlychildhood@pac-prod-earlychildhood-web01 stgsite]$ python manage.py cra_report
System check identified some issues:
WARNINGS:
?: (debug_toolbar.W001) debug_toolbar.middleware.DebugToolbarMiddleware is missing from MIDDLEWARE.
HINT: Add debug_toolbar.middleware.DebugToolbarMiddleware to MIDDLEWARE.
?: (debug_toolbar.W006) At least one DjangoTemplates TEMPLATES configuration needs to have APP_DIRS set to True.
HINT: Use APP_DIRS=True for at least one django.template.backends.django.DjangoTemplates backend configuration.
Traceback (most recent call last):
File "manage.py", line 25, in <module>
main()
File "manage.py", line 21, in main
execute_from_command_line(sys.argv)
File "/var/data/websites/stg.earlychildhoodeducator.com/env/lib64/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/var/data/websites/stg.earlychildhoodeducator.com/env/lib64/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/var/data/websites/stg.earlychildhoodeducator.com/env/lib64/python3.6/site-packages/django/core/management/base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "/var/data/websites/stg.earlychildhoodeducator.com/env/lib64/python3.6/site-packages/django/core/management/base.py", line 364, in execute
output = self.handle(*args, **options)
File "/var/data/websites/stg.earlychildhoodeducator.com/director/management/commands/cra_report.py", line 33, in handle
xml = generate_cra_t2202_report_xml(last_year, type, notes)
File "/var/data/websites/stg.earlychildhoodeducator.com/director/models.py", line 55, in generate_cra_t2202_report_xml
return report.get_xml()
File "/var/data/websites/stg.earlychildhoodeducator.com/director/models.py", line 334, in get_xml
schema.validate(generated_xml)
File "/var/data/websites/stg.earlychildhoodeducator.com/env/lib64/python3.6/site-packages/xmlschema/validators/schema.py", line 1269, in validate
raise error
xmlschema.validators.exceptions.XMLSchemaChildrenValidationError: failed validating <Element 'T2202Summary' at 0x7fc43beebae8> with XsdGroup(model='all', occurs=[1, 1]):
Reason: Unexpected child with tag 'sdt:TaxationYear' at position 3. Tag (TaxationYear | TotalSlipCount | PostSecondaryEducationalInstitutionName | PostSecondaryEducationalInstitutionMailingAddress | TotalEligibleTuitionFeeAmount) expected.
In my Python code, I fixed it by specifying that there should be no namespace prefix on that tag. Like so
And then I got a similar error for another twelve-or-so tags, each of which I used the same fix for. There might be a better solution, my brain was just kinda shut off and trying to just find the quickest solution.
The last error I had was that the CRA’s XML schema only allowed 20 characters for a last-name, and one of our students had a combined last name (it was like “Saint-Augustine Bemont” or something), which caused the CRA to again give that wonderfully vague error I shared a screenshot of above. I fixed it by just only using the first 20 characters of the students’ last name, everything else got chopped off.
Success
After that, and saying a prayer, the CRA finally accepted the file. Well, they didn’t give an error. They did say they’d process it later, so hopefully they don’t say it’s incorrect after the due date and then say we need to pay a fine (that seems like a government-type thing to do ).
So hopefully that’s all there is to say about that this year!