Opened 15 years ago

Closed 11 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)

django-contrib-localflavor-au-taxfilenumber.patch (776 bytes ) - added by Paul Wayper 15 years ago.
Patch in svn diff format

Download all attachments as: .zip

Change History (12)

by Paul Wayper, 15 years ago

Patch in svn diff format

comment:1 by Malcolm Tredinnick, 15 years ago

Needs documentation: set
Needs tests: set
Patch needs improvement: set
Triage Stage: UnreviewedAccepted

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:

  1. 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.
  2. Patch needs both tests and documentation. Tests for localflavors are in regressiontests/forms/localflavor/.
  3. 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 Malcolm Tredinnick, 15 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 Paul Wayper, 15 years ago

Hi mtredinnick,

  1. 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.
  1. Thanks for that - I was wondering where the tests were.
  1. Good point.

Will submit a patch for these soon.

comment:4 by Paul Wayper, 15 years ago

I can't find anything definitive on Tax File Number formatting yet. Stay tuned.

comment:5 by Malcolm Tredinnick, 15 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 Paul Wayper, 15 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 Malcolm Tredinnick, 15 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 Luke Plant, 13 years ago

Severity: Normal
Type: New feature

comment:9 by Aymeric Augustin, 12 years ago

UI/UX: unset

Change UI/UX from NULL to False.

comment:10 by Aymeric Augustin, 12 years ago

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:11 by Aymeric Augustin, 11 years ago

Keywords: localflavorsplit added
Resolution: invalid
Status: newclosed

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!

Note: See TracTickets for help on using tickets.
Back to Top