Validating the Australian Tax File Number
Validating Australian Tax File Numbers
Tax file numbers are identifiers issued by the Australian Tax Office to individuals or organisations for tax purposes. Modern TFNs (those issued under the Extend TFN System that took effect from 1 Jan 1989) have 9 digits, consisting of an 8-digit identifer followed by a 1-digit check digit.
The validation algorithm is uses a weighted sum of digits, with weights as follows:
Position | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
Weight | 1 | 4 | 3 | 7 | 5 | 8 | 6 | 9 | 10 |
A TFN passes verification if the weighted sum of all 9 digits is a product of 11.
Example
TFN Digits | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
---|---|---|---|---|---|---|---|---|---|
Weight | x 1 | x 4 | x 3 | x 7 | x 5 | x 8 | x 6 | x 9 | x 10 |
Sum | 8 | 28 | 18 | 35 | 20 | 24 | 12 | 9 | 0 |
Validation | 8 + 28 + 18 + 35 + 20 + 24 + 12 + 9 + 0 = 154 = 14 x 11 |
PHP Sample Code
// ValidateTFN
// Checks TFN for validity using the checksum algorithm.
//
// Returns: true if the TFN is valid, false otherwise.
// Source: http://www.clearwater.com.au/code
// Author: Guy Carpenter
// License: The author claims no rights to this code.
// Use it as you wish.
function ValidateTFN($tfn)
{
$weights = array(1, 4, 3, 7, 5, 8, 6, 9, 10);
// strip anything other than digits
$tfn = preg_replace("/[^\d]/","",$tfn);
// check length is 9 digits
if (strlen($tfn)==9) {
$sum = 0;
foreach ($weights as $position=>$weight) {
$digit = $tfn[$position];
$sum += $weight * $digit;
}
return ($sum % 11)==0;
}
return false;
}
References
Reference The checksum algorithm is not publically disseminated by the ATO, but is widely known by software developers.