The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Algorithm::NIN - Functions to validate National Insurance number (UK) and calculate NI contributions.

VERSION

Version 0.09

SYNOPSIS

    use Algorithm::NIN;

    my $ni = 'AA123456C';
    my $status = Algorithm::NIN::validate($ni);
    
    or
    
    my $ni = 'AA 12 34 56 C';
    my $status = Algorithm::NIN::validate($ni);

METHODS

validate

This method accepts National Insurance number and validate it against the UK format. For more information please visit http://en.wikipedia.org/wiki/National_Insurance_UK

format

This method accepts National Insurance number and returns back in the pair format. e.g. AA1234546C would become AA 12 34 56 C as it appears on NI card.

calculateNI

Returns NI contributions (approx) according to HMRC website http://www.hmrc.gov.uk/rates/nic.htm It only covers fiscal year 2009-10, 2010-11 and 2011-2012. I don't claim the number you get back is exactly what you see in your pay slip. This is simply my attempt to understand the mathematics behind the NI contributions. Any suggestion to improve the functionality is hight appreciated. This method accepts the following parameter as reference to a hash.

  • fiscal_year

    e.g. 2010-11

  • gross_salary

    e.g. 60000

  • annual_profit

    e.g. 50000

  • self_employed

    e.g. 1 or 0

  • married

    e.g. 1 or 0

  • sex

    e.g. m or f

  • class

    e.g. 2 or 4 (only applicable to self-employed); 3 (voluntary contributions).

TODO

Following NI contributions scenarios are NOT yet covered.

  • Employer's contracted-out rebate, money-purchase schemes

  • Employer's contracted-out rebate, salary-related schemes

  • Employee's contracted-out rebate

  • Special Class 2 rate for share fishermen

  • Additional primary Class 1 percentage rate on deferred employments

  • Additional Class 4 percentage rate where deferment has been granted

AUTHOR

Mohammad S Anwar, <mohammad.anwar at yahoo.com>

BUGS

Please report any bugs or feature requests to bug-algorithm-nin at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Algorithm-NIN. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Algorithm::NIN

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

Copyright 2011 Mohammad S Anwar.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.

DISCLAIMER

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.