line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Vparam::RU; |
2
|
72
|
|
|
72
|
|
5647985
|
use Mojo::Base -strict; |
|
72
|
|
|
|
|
11721
|
|
|
72
|
|
|
|
|
538
|
|
3
|
72
|
|
|
72
|
|
7961
|
use Mojolicious::Plugin::Vparam::Common; |
|
72
|
|
|
|
|
159
|
|
|
72
|
|
|
|
|
35580
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub check_inn($) { |
6
|
7
|
50
|
|
7
|
0
|
28
|
return 'Value not defined' unless defined $_[0]; |
7
|
7
|
100
|
|
|
|
30
|
return 'Value not set' unless length $_[0]; |
8
|
6
|
100
|
|
|
|
35
|
return 'Wrong format' unless $_[0] =~ m{^(?:\d{10}|\d{12})$}; |
9
|
|
|
|
|
|
|
|
10
|
4
|
|
|
|
|
26
|
my @str = split '', $_[0]; |
11
|
4
|
100
|
|
|
|
18
|
if( @str == 10 ) { |
|
|
50
|
|
|
|
|
|
12
|
2
|
100
|
|
|
|
28
|
return 'Checksum error' |
13
|
|
|
|
|
|
|
unless $str[9] eq |
14
|
|
|
|
|
|
|
((( |
15
|
|
|
|
|
|
|
2 * $str[0] + 4 * $str[1] + 10 * $str[2] + 3 * $str[3] + |
16
|
|
|
|
|
|
|
5 * $str[4] + 9 * $str[5] + 4 * $str[6] + 6 * $str[7] + |
17
|
|
|
|
|
|
|
8 * $str[8] |
18
|
|
|
|
|
|
|
) % 11 ) % 10); |
19
|
1
|
|
|
|
|
7
|
return 0; |
20
|
|
|
|
|
|
|
} elsif( @str == 12 ) { |
21
|
2
|
100
|
66
|
|
|
32
|
return 'Checksum error' |
22
|
|
|
|
|
|
|
unless $str[10] eq |
23
|
|
|
|
|
|
|
((( |
24
|
|
|
|
|
|
|
7 * $str[0] + 2 * $str[1] + 4 * $str[2] + 10 * $str[3] + |
25
|
|
|
|
|
|
|
3 * $str[4] + 5 * $str[5] + 9 * $str[6] + 4 * $str[7] + |
26
|
|
|
|
|
|
|
6 * $str[8] + 8 * $str[9] |
27
|
|
|
|
|
|
|
) % 11 ) % 10) |
28
|
|
|
|
|
|
|
&& $str[11] eq |
29
|
|
|
|
|
|
|
((( |
30
|
|
|
|
|
|
|
3 * $str[0] + 7 * $str[1] + 2 * $str[2] + 4 * $str[3] + |
31
|
|
|
|
|
|
|
10 * $str[4] + 3 * $str[5] + 5 * $str[6] + 9 * $str[7] + |
32
|
|
|
|
|
|
|
4 * $str[8] + 6 * $str[9] + 8 * $str[10] |
33
|
|
|
|
|
|
|
) % 11 ) % 10); |
34
|
1
|
|
|
|
|
5
|
return 0; |
35
|
|
|
|
|
|
|
} |
36
|
0
|
|
|
|
|
0
|
return 'Must be 10 or 12 digits'; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub check_kpp($) { |
40
|
4
|
50
|
|
4
|
0
|
9
|
return 'Value not defined' unless defined $_[0]; |
41
|
4
|
100
|
|
|
|
18
|
return 'Value not set' unless length $_[0]; |
42
|
3
|
100
|
|
|
|
16
|
return 'Wrong format' unless $_[0] =~ m{^\d{9}$}; |
43
|
1
|
|
|
|
|
4
|
return 0; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub register { |
47
|
74
|
|
|
74
|
0
|
248
|
my ($class, $self, $app, $conf) = @_; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
$app->vtype( |
50
|
|
|
|
|
|
|
inn => |
51
|
7
|
|
|
7
|
|
29
|
pre => sub { trim $_[1] }, |
52
|
7
|
|
|
7
|
|
23
|
valid => sub { check_inn $_[1] }, |
53
|
74
|
|
|
|
|
719
|
); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
$app->vtype( |
56
|
|
|
|
|
|
|
kpp => |
57
|
4
|
|
|
4
|
|
13
|
pre => sub { trim $_[1] }, |
58
|
4
|
|
|
4
|
|
12
|
valid => sub { check_kpp $_[1] }, |
59
|
74
|
|
|
|
|
813
|
); |
60
|
|
|
|
|
|
|
|
61
|
74
|
|
|
|
|
331
|
return; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |