1Algorithm::CheckDigits:U:sMe2r3_C0o0n2t(r3i)buted Perl DAolcguomreintthamt:i:oCnheckDigits::M23_002(3)
2
3
4
6 CheckDigits::M23_002 - compute check digits for Tax Identification
7 Number (IE)
8
10 use Algorithm::CheckDigits;
11
12 $dni = CheckDigits('tin_ie');
13
14 if ($dni->is_valid('8473625E')) {
15 # do something
16 }
17
18 $cn = $dni->complete('1234567.W');
19 # $cn = '1234567TW'
20
21 $cd = $dni->checkdigit('1234577IA');
22 # $cd = 'I'
23
24 $bn = $dni->basenumber('1234577WW');
25 # $bn = '1234577.W'
26
28 ALGORITHM
29 The irish TIN (Tax Identification Number) or VAT Regstration Number
30 consists of 7 digits, a letter in the range from 'A' - 'W' as checksum,
31 and an optionally letter in the range from 'A' - 'I' or the letter 'W'.
32
33 1. In reverse order, each digit is multiplied by a weight started at
34 2. (i.e. the number left from the check digit is multiplied with
35 2, the next with 3 and so on).
36
37 2. If there is an optional letter following the checksum letter
38 (position 9), this letter is mapped to a numeric value based on the
39 following mapping: "A" = 1, "B" = 2, ... "H" = 8, "I" = 9. "W" or
40 absence of this letter means a value of 0. This numeric value is
41 multiplied with 9.
42
43 3. All products from step 1 and 2 are added.
44
45 4. The check digit is the sum from step 3 modulo 23. This number is
46 expressed as the corresponding letter from the alphabet where A-V
47 correspond to 1-22 and W stands for check digit 0.
48
49 METHODS
50 is_valid($number)
51 Returns true only if $number complies with the rules given above
52 and there is a valid check digit at position eight.
53
54 Returns false otherwise,
55
56 complete($number)
57 The check digit for $number is computed and inserted at position
58 eight of $number.
59
60 Returns the complete number with check digit or '' if $number does
61 not consist solely of digits and an optional letter at position
62 nine.
63
64 basenumber($number)
65 Returns the basenumber of $number if $number has a valid check
66 digit. As a placeholder for the checksum a point ('.') is inserted
67 at position eight when the checksum contains the optional letter at
68 position nine.
69
70 Return '' otherwise.
71
72 checkdigit($number)
73 Returns the checkdigit of $number if $number has a valid check
74 digit.
75
76 Return '' otherwise.
77
78 EXPORT
79 None by default.
80
82 Mathias Weidner, "<mamawe@cpan.org>"
83
85 perl, CheckDigits, https://ec.europa.eu/taxation_customs/tin/
86
87
88
89perl v5.36.0 2022-07-22Algorithm::CheckDigits::M23_002(3)