From 87c6092d5950a60c6966703274c7e722e01b487c Mon Sep 17 00:00:00 2001 From: David Koblas Date: Mon, 16 Nov 2026 05:23:42 -0500 Subject: [PATCH] fix(nz/ird): raise the upper limit to 200,000,000 Inland Revenue raised the maximum valid IRD number from 150,000,000 to 200,000,000 in February 2026. python-stdnum still caps at 150,000,000, so this is a deliberate difference. Fixes #265 --- src/nz/ird.spec.ts | 20 ++++++++++++++++++++ src/nz/ird.ts | 14 ++++++++++---- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/nz/ird.spec.ts b/src/nz/ird.spec.ts index d69e11b0..5bb073c1 100644 --- a/src/nz/ird.spec.ts +++ b/src/nz/ird.spec.ts @@ -31,6 +31,26 @@ describe('nz/ird', () => { expect(result.error).toBeInstanceOf(InvalidComponent); }); + // Valid since Inland Revenue raised the upper limit to 200,000,000 (2026) + it('validate:150000009', () => { + const result = validate('150000009'); + + expect(result.isValid && result.compact).toEqual('150000009'); + }); + + it('validate:199-999-990', () => { + const result = validate('199-999-990'); + + expect(result.isValid && result.compact).toEqual('199999990'); + }); + + // Valid check digit, but above the upper limit + it('validate:200000005', () => { + const result = validate('200000005'); + + expect(result.error).toBeInstanceOf(InvalidComponent); + }); + it('validate:123478', () => { const result = validate('123478'); diff --git a/src/nz/ird.ts b/src/nz/ird.ts index 66f8024d..3fd83de7 100644 --- a/src/nz/ird.ts +++ b/src/nz/ird.ts @@ -4,11 +4,16 @@ * The IRD number is used by the New Zealand Inland Revenue Department (Te Tari Taake) * to identify businesses and individuals for tax purposes. The number consists of 8 or 9 digits * where the last digit is a check digit. Valid numbers lie between 10-000-000 - * and 150-000-000. + * and 200-000-000. + * + * In February 2026 Inland Revenue raised the maximum valid IRD number from + * 150,000,000 to 200,000,000. python-stdnum still uses 150,000,000 as the + * upper limit, so this module deliberately differs from it there. * * Source + * https://www.ird.govt.nz/updates/news-folder/2026/increase-to-ird-number-validation-upper-limit * https://www.ird.govt.nz/ - * https://github.com/arthurdejong/python-stdnum/blob/master/stdnum/nz/ird.py (range) + * https://github.com/arthurdejong/python-stdnum/blob/master/stdnum/nz/ird.py * https://www.oecd.org/tax/automatic-exchange/crs-implementation-and-assistance/tax-identification-numbers/New%20Zealand-TIN.pdf * * PERSON/ENTITY @@ -68,9 +73,10 @@ const impl: Validator = { if (!strings.isdigits(value)) { return { isValid: false, error: new exceptions.InvalidFormat() }; } - // Numbers outside this range have not been (or will not soon be) issued + // Numbers outside this range are not valid IRD numbers (upper limit raised + // from 150,000,000 to 200,000,000 by Inland Revenue in February 2026) const num = parseInt(value, 10); - if (num <= 10000000 || num >= 150000000) { + if (num <= 10000000 || num >= 200000000) { return { isValid: false, error: new exceptions.InvalidComponent() }; }