line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Vparam::RU; |
2
|
72
|
|
|
72
|
|
5029194
|
use Mojo::Base -strict; |
|
72
|
|
|
|
|
8796
|
|
|
72
|
|
|
|
|
739
|
|
3
|
72
|
|
|
72
|
|
6858
|
use Mojolicious::Plugin::Vparam::Common; |
|
72
|
|
|
|
|
140
|
|
|
72
|
|
|
|
|
31726
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub check_inn($) { |
6
|
7
|
50
|
|
7
|
0
|
15
|
return 'Value not defined' unless defined $_[0]; |
7
|
7
|
100
|
|
|
|
24
|
return 'Value not set' unless length $_[0]; |
8
|
6
|
100
|
|
|
|
24
|
return 'Wrong format' unless $_[0] =~ m{^(?:\d{10}|\d{12})$}; |
9
|
|
|
|
|
|
|
|
10
|
4
|
|
|
|
|
19
|
my @str = split '', $_[0]; |
11
|
4
|
100
|
|
|
|
13
|
if( @str == 10 ) { |
|
|
50
|
|
|
|
|
|
12
|
2
|
100
|
|
|
|
15
|
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
|
|
|
|
|
5
|
return 0; |
20
|
|
|
|
|
|
|
} elsif( @str == 12 ) { |
21
|
2
|
100
|
66
|
|
|
26
|
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
|
10
|
return 'Value not defined' unless defined $_[0]; |
41
|
4
|
100
|
|
|
|
15
|
return 'Value not set' unless length $_[0]; |
42
|
3
|
100
|
|
|
|
15
|
return 'Wrong format' unless $_[0] =~ m{^\d{9}$}; |
43
|
1
|
|
|
|
|
6
|
return 0; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub register { |
47
|
74
|
|
|
74
|
0
|
213
|
my ($class, $self, $app, $conf) = @_; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
$app->vtype( |
50
|
|
|
|
|
|
|
inn => |
51
|
7
|
|
|
7
|
|
18
|
pre => sub { trim $_[1] }, |
52
|
7
|
|
|
7
|
|
16
|
valid => sub { check_inn $_[1] }, |
53
|
74
|
|
|
|
|
616
|
); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
$app->vtype( |
56
|
|
|
|
|
|
|
kpp => |
57
|
4
|
|
|
4
|
|
12
|
pre => sub { trim $_[1] }, |
58
|
4
|
|
|
4
|
|
8
|
valid => sub { check_kpp $_[1] }, |
59
|
74
|
|
|
|
|
696
|
); |
60
|
|
|
|
|
|
|
|
61
|
74
|
|
|
|
|
279
|
return; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |