Opened 16 years ago
Closed 12 years ago
#9697 closed New feature (invalid)
Adding the Australian Tax File Number field validator
Reported by: | Paul Wayper | Owned by: | nobody |
---|---|---|---|
Component: | contrib.localflavor | Version: | 1.0 |
Severity: | Normal | Keywords: | australian, tax, file, number, localflavorsplit |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | yes |
Needs tests: | yes | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
This patch adds the Australian Tax File Number field validator to the Australian local flavour.
Attachments (1)
Change History (12)
by , 16 years ago
Attachment: | django-contrib-localflavor-au-taxfilenumber.patch added |
---|
comment:1 by , 16 years ago
Needs documentation: | set |
---|---|
Needs tests: | set |
Patch needs improvement: | set |
Triage Stage: | Unreviewed → Accepted |
Looks reasonable (although at some point we're going to have to decide when something like this is sufficiently simple that people can just subclass RegexField themselves). A few improvements that are needed, however:
- Tax file numbers shouldn't have to be in the form 123-456-789 for input. That's certainly a good normalised (cleaned) result, but it's not uncommon for people to enter the same value as 123456789 or "123 456 789". Both versions unambiguously contain the right information. So it would be better to just strip all spaces and hyphens (even 1-234-56-7-89, although unlikely, is clear in its intent, so we never try to get cute and treat such things as invalid) and then validate that the result is 9 digits. Then the normalising step can change it to 123-456-789.
- Patch needs both tests and documentation. Tests for localflavors are in regressiontests/forms/localflavor/.
- Is there an online reference that's likely to be stable describing the format. I know what Australian TFN's look like, but somebody maintaining this in the future might not.
If you create an updated patch, feel free to include a change to AUTHORS to add yourself to that file.
comment:2 by , 16 years ago
(Note to self: proof-read, *then* submit.)
My third point above was meant to note that the URL for such a reference can be included in the docstring for the class, so that it's readily available.
comment:3 by , 16 years ago
Hi mtredinnick,
- Good point. In the eTax application issued by the ATO and in many other forms requiring your TFN, it's required as three groups of three digits, separated either by spaces or dashes. I don't think I've ever seen a TFN as a spaceless nine digit number, and almost without doubt you wouldn't be able to submit it as such. Whether this is the format that the data stores TFNs in is another question.
- Thanks for that - I was wondering where the tests were.
- Good point.
Will submit a patch for these soon.
comment:4 by , 16 years ago
I can't find anything definitive on Tax File Number formatting yet. Stay tuned.
comment:5 by , 16 years ago
The reason for allowing alternate input formats (point 1) has nothing to do with what the Tax Office accepts. This is an input widget.We are accepting human-generated input and any reasonable, unambiguous form that we can subsequently convert to a normalised form should be accepted. It's similar to the normal handling for various postal codes around the world, phone numbers, dates, etc. Part of "be liberal in what you accept". A person typing in their tax file number could quite easily enter it as simply nine digits with no punctuation. It's a natural way to represent the number and easy to type in. Keep 'input format' and 'normalised format' separate when thinking about this. I am only asking that we're liberal on the input side. The cleaned/normalised version should definitely be something standard.
comment:6 by , 16 years ago
OK, I've updated my code to accept 555-000-555, 555 000 555 and 555000555. I've also implemented some tests.
How do I run the localflavor regression tests? If you want to drop me a line on paulway@… I'd appreciate it.
comment:7 by , 16 years ago
I don't know if you can just run the localflavor tests on their own, but running all the form regression tests (of which these are part) is simple enough:
./runtests.py --settings=settings forms
where "settings" is the import path of your test settings file, as documented in docs/internal/contributing.txt. On my really slow laptop, it takes about 20 seconds to run those tests.
comment:8 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → New feature |
comment:11 by , 12 years ago
Keywords: | localflavorsplit added |
---|---|
Resolution: | → invalid |
Status: | new → closed |
django.contrib.localflavor
is now deprecated — see https://docs.djangoproject.com/en/dev/ref/contrib/localflavor/
A repository was created for each localflavor at https://github.com/django/django-localflavor-? (Replace with the country code.)
If you're still interested in this ticket, could you create a pull request on that repository?
Sorry for not resolving this issue earlier, and thanks for your input!
Patch in svn diff format