FAILURE MAP
← Case archive

FA-72701 / Check-digit algorithms / Open access

UK VAT reads only the last check digit · case 01

Most valid VAT numbers are rejected.

Verified by executionVariant 1 · 8 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

c is taken from the final digit only instead of the two-digit number formed by digits 8 and 9.

THE FAILURE

c is taken from the final digit only instead of the two-digit number formed by digits 8 and 9.

Unsuccessful approach: Adding the two digits is still not the two-digit number.

Case contract

UK VAT registration number check. Spaces are removed, the text is upper-cased and an optional GB prefix removed; the rest must be 9 ASCII digits (else "malformed"). Weights 8..2 apply to the first seven digits; the last two digits form a number c. Return "mod97" if (sum + c) is divisible by 97, "mod9755" if (sum + c + 55) is, else "invalid".

Why this case matters

Invoice processing screens supplier VAT numbers before reclaiming input tax.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(s):
    t = s.replace(' ', '').upper()
    if t.startswith('GB'):
        t = t[2:]
    if len(t) != 9 or not t.isascii() or not t.isdigit():
        return 'malformed'
    total = sum(int(ch) * w for ch, w in zip(t[:7], range(8, 1, -1)))
    c = int(t[8])
    if (total + c) % 97 == 0:
        return 'mod97'
    if (total + c + 55) % 97 == 0:
        return 'mod9755'
    return 'invalid'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["GB041839277"]', ['GB041839277'], 'mod97'], ['regression ["729236520"]', ['729236520'], 'mod97'], ['control ["041839278"]', ['041839278'], 'invalid'], ['control ["GB 261 7623 04"]', ['GB 261 7623 04'], 'mod9755'], ['control ["261762305"]', ['261762305'], 'invalid'], ['control ["729236521"]', ['729236521'], 'invalid'], ['control ["260407727"]', ['260407727'], 'invalid'], ['control ["029331391"]', ['029331391'], 'invalid']], [['regression ["GB 029 3313 90"]', ['GB 029 3313 90'], 'mod97'], ['regression ["581077575"]', ['581077575'], 'mod9755'], ['control ["029331391"]', ['029331391'], 'invalid'], ['control ["581077576"]', ['581077576'], 'invalid'], ['control ["GB658372602"]', ['GB658372602'], 'mod97'], ['control ["GB98078068"]', ['GB98078068'], 'malformed'], ['control ["GB98078068X"]', ['GB98078068X'], 'malformed'], ['control ["123456789"]', ['123456789'], 'invalid']], [['regression ["331553089"]', ['331553089'], 'mod97'], ['regression ["GB784073455"]', ['GB784073455'], 'mod9755'], ['control ["123456789"]', ['123456789'], 'invalid'], ['control ["041839278"]', ['041839278'], 'invalid'], ['control ["GB 261 7623 04"]', ['GB 261 7623 04'], 'mod9755'], ['control ["261762305"]', ['261762305'], 'invalid'], ['control ["729236521"]', ['729236521'], 'invalid'], ['control ["260407727"]', ['260407727'], 'invalid']], [['regression ["155142529"]', ['155142529'], 'mod9755'], ['regression ["GB801525174"]', ['GB801525174'], 'mod97'], ['control ["260407727"]', ['260407727'], 'invalid'], ['control ["029331391"]', ['029331391'], 'invalid'], ['control ["581077576"]', ['581077576'], 'invalid'], ['control ["GB658372602"]', ['GB658372602'], 'mod97'], ['control ["GB98078068"]', ['GB98078068'], 'malformed'], ['control ["GB98078068X"]', ['GB98078068X'], 'malformed']], [['regression ["GB980780684"]', ['GB980780684'], 'mod97'], ['regression ["980 7806 84"]', ['980 7806 84'], 'mod97'], ['control ["GB98078068X"]', ['GB98078068X'], 'malformed'], ['control ["123456789"]', ['123456789'], 'invalid'], ['control ["041839278"]', ['041839278'], 'invalid'], ['control ["GB 261 7623 04"]', ['GB 261 7623 04'], 'mod9755'], ['control ["261762305"]', ['261762305'], 'invalid'], ['control ["729236521"]', ['729236521'], 'invalid']]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression ["GB041839277"]invalidmod97Failed
regression ["729236520"]invalidmod97Failed
control ["041839278"]invalidinvalidPassed
control ["GB 261 7623 04"]mod9755mod9755Passed
control ["261762305"]invalidinvalidPassed
control ["729236521"]invalidinvalidPassed
control ["260407727"]invalidinvalidPassed
control ["029331391"]invalidinvalidPassed

SHA-256 / e5e494297834139046b9f5c8613f2cee2f4e02a5de1361964991428f3e00490f

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(s):
    t = s.replace(' ', '').upper()
    if t.startswith('GB'):
        t = t[2:]
    if len(t) != 9 or not t.isascii() or not t.isdigit():
        return 'malformed'
    total = sum(int(ch) * w for ch, w in zip(t[:7], range(8, 1, -1)))
    c = int(t[7]) + int(t[8])
    if (total + c) % 97 == 0:
        return 'mod97'
    if (total + c + 55) % 97 == 0:
        return 'mod9755'
    return 'invalid'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["GB041839277"]', ['GB041839277'], 'mod97'], ['regression ["729236520"]', ['729236520'], 'mod97'], ['control ["041839278"]', ['041839278'], 'invalid'], ['control ["GB 261 7623 04"]', ['GB 261 7623 04'], 'mod9755'], ['control ["261762305"]', ['261762305'], 'invalid'], ['control ["729236521"]', ['729236521'], 'invalid'], ['control ["260407727"]', ['260407727'], 'invalid'], ['control ["029331391"]', ['029331391'], 'invalid']], [['regression ["GB 029 3313 90"]', ['GB 029 3313 90'], 'mod97'], ['regression ["581077575"]', ['581077575'], 'mod9755'], ['control ["029331391"]', ['029331391'], 'invalid'], ['control ["581077576"]', ['581077576'], 'invalid'], ['control ["GB658372602"]', ['GB658372602'], 'mod97'], ['control ["GB98078068"]', ['GB98078068'], 'malformed'], ['control ["GB98078068X"]', ['GB98078068X'], 'malformed'], ['control ["123456789"]', ['123456789'], 'invalid']], [['regression ["331553089"]', ['331553089'], 'mod97'], ['regression ["GB784073455"]', ['GB784073455'], 'mod9755'], ['control ["123456789"]', ['123456789'], 'invalid'], ['control ["041839278"]', ['041839278'], 'invalid'], ['control ["GB 261 7623 04"]', ['GB 261 7623 04'], 'mod9755'], ['control ["261762305"]', ['261762305'], 'invalid'], ['control ["729236521"]', ['729236521'], 'invalid'], ['control ["260407727"]', ['260407727'], 'invalid']], [['regression ["155142529"]', ['155142529'], 'mod9755'], ['regression ["GB801525174"]', ['GB801525174'], 'mod97'], ['control ["260407727"]', ['260407727'], 'invalid'], ['control ["029331391"]', ['029331391'], 'invalid'], ['control ["581077576"]', ['581077576'], 'invalid'], ['control ["GB658372602"]', ['GB658372602'], 'mod97'], ['control ["GB98078068"]', ['GB98078068'], 'malformed'], ['control ["GB98078068X"]', ['GB98078068X'], 'malformed']], [['regression ["GB980780684"]', ['GB980780684'], 'mod97'], ['regression ["980 7806 84"]', ['980 7806 84'], 'mod97'], ['control ["GB98078068X"]', ['GB98078068X'], 'malformed'], ['control ["123456789"]', ['123456789'], 'invalid'], ['control ["041839278"]', ['041839278'], 'invalid'], ['control ["GB 261 7623 04"]', ['GB 261 7623 04'], 'mod9755'], ['control ["261762305"]', ['261762305'], 'invalid'], ['control ["729236521"]', ['729236521'], 'invalid']]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression ["GB041839277"]invalidmod97Failed
regression ["729236520"]invalidmod97Failed
control ["041839278"]invalidinvalidPassed
control ["GB 261 7623 04"]mod9755mod9755Passed
control ["261762305"]invalidinvalidPassed
control ["729236521"]invalidinvalidPassed
control ["260407727"]invalidinvalidPassed
control ["029331391"]invalidinvalidPassed

SHA-256 / cc9db48f3131c29f81c6173dbf118032e4018641a0856db74a783c1601dccc27

HELD IN THE MEMBER ARCHIVE

The verified repair and its recorded checks are member-only.

This mechanism has 8 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.

Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.

Member access is invitation-based. Sign in with your invited account to inspect the repair.

Sign in to the archive ↗

Verification & scope

A deterministic, bounded teaching model of the named scheme under the stated contract; not a certified validator. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:48:40.885085+00:00.

Case digest / fb18e0fac97d242659296f70d37c4026f9d726b63b0e721f737038c46eadcc06