Code

Opened 5 years ago

Closed 18 months ago

#9697 closed New feature (invalid)

Adding the Australian Tax File Number field validator

Reported by: PaulWay 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 PaulWay 5 years ago.
Patch in svn diff format

Download all attachments as: .zip

Change History (12)

Changed 5 years ago by PaulWay

Patch in svn diff format

comment:1 Changed 5 years ago by mtredinnick

  • Needs documentation set
  • Needs tests set
  • Patch needs improvement set
  • Triage Stage changed from Unreviewed to 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:

  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 Changed 5 years ago by mtredinnick

(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 Changed 5 years ago by PaulWay

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 Changed 5 years ago by PaulWay

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

comment:5 Changed 5 years ago by mtredinnick

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 Changed 5 years ago by PaulWay

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 Changed 5 years ago by mtredinnick

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 Changed 3 years ago by lukeplant

  • Severity set to Normal
  • Type set to New feature

comment:9 Changed 2 years ago by aaugustin

  • UI/UX unset

Change UI/UX from NULL to False.

comment:10 Changed 2 years ago by aaugustin

  • Easy pickings unset

Change Easy pickings from NULL to False.

comment:11 Changed 18 months ago by aaugustin

  • Keywords australian, tax, file, number, localflavorsplit added; australian tax file number removed
  • Resolution set to invalid
  • Status changed from new to 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!

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.