1Algorithm::CheckDigits:U:sMe1r1_C0o1n1t(r3i)buted Perl DAolcguomreintthamt:i:oCnheckDigits::M11_011(3)
2
3
4
6 CheckDigits::M11_011 - compute check digits for VAT Registration Number
7 (NL)
8
10 use Algorithm::CheckDigits;
11
12 $ustid = CheckDigits('ustid_nl');
13
14 if ($ustid->is_valid('123456782')) {
15 # do something
16 }
17 if ($ustid->is_valid('123456782B04')) {
18 # do something
19 }
20
21 $cn = $ustid->complete('12345678');
22 # $cn = '123456782'
23 $cn = $ustid->complete('12345678.B04');
24 # $cn = '123456782B04'
25
26 $cd = $ustid->checkdigit('123456782');
27 # $cd = '2'
28 $cd = $ustid->checkdigit('123456782B04');
29 # $cd = '2'
30
31 $bn = $ustid->basenumber('123456782');
32 # $bn = '12345678';
33 $bn = $ustid->basenumber('123456782B04');
34 # $bn = '12345678.B04';
35
37 This VATRN has 12 "digits", the third last must be a B, the fourth last
38 is the checkdigit. I don't know anything about the meaning of the last
39 two digits.
40
41 You may use the whole VATRN or only the first eight digits to compute
42 the checkdigit with this module.
43
44 ALGORITHM
45 1. Beginning right with the digit before the checkdigit all digits are
46 weighted with their position. I.e. the digit before the checkdigit
47 is multiplied with 2, the next with 3 and so on.
48
49 2. The weighted digits are added.
50
51 3. The sum from step 2 is taken modulo 11.
52
53 4. If the sum from step 3 is 10, the number is discarded.
54
55 METHODS
56 is_valid($number)
57 Returns true only if the first eight positions of $number consist
58 solely of digits (maybe followed by 'B' and to further digits) and
59 the eighth digit is a valid check digit according to the algorithm
60 given above.
61
62 Returns false otherwise,
63
64 complete($number)
65 The check digit for $number is computed and inserted at position
66 eight of $number.
67
68 Returns the complete number with check digit or '' if $number does
69 not consist solely of digits a dot and maybe 'B' at the ninth
70 position.
71
72 basenumber($number)
73 Returns the basenumber of $number if $number has a valid check
74 digit.
75
76 Return '' otherwise.
77
78 checkdigit($number)
79 Returns the check digits of $number if $number has valid check
80 digits.
81
82 Return '' otherwise.
83
84 EXPORT
85 None by default.
86
88 perl, CheckDigits, www.pruefziffernberechnung.de,
89
91 Mathias Weidner, "<mamawe@cpan.org>"
92
94 Copyright 2004-2020 by Mathias Weidner
95
96 This library is free software; you can redistribute it and/or modify it
97 under the same terms as Perl itself.
98
99
100
101perl v5.34.0 2022-01-20Algorithm::CheckDigits::M11_011(3)