line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Vparam::RU; |
2
|
73
|
|
|
73
|
|
5649521
|
use Mojo::Base -strict; |
|
73
|
|
|
|
|
110013
|
|
|
73
|
|
|
|
|
428
|
|
3
|
73
|
|
|
73
|
|
7633
|
use Mojolicious::Plugin::Vparam::Common; |
|
73
|
|
|
|
|
128
|
|
|
73
|
|
|
|
|
33750
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub check_inn($) { |
6
|
7
|
50
|
|
7
|
0
|
12
|
return 'Value not defined' unless defined $_[0]; |
7
|
7
|
100
|
|
|
|
18
|
return 'Value not set' unless length $_[0]; |
8
|
6
|
100
|
|
|
|
67
|
return 'Wrong format' unless $_[0] =~ m{^(?:\d{10}|\d{12})$}; |
9
|
|
|
|
|
|
|
|
10
|
4
|
|
|
|
|
19
|
my @str = split '', $_[0]; |
11
|
4
|
100
|
|
|
|
12
|
if( @str == 10 ) { |
|
|
50
|
|
|
|
|
|
12
|
2
|
100
|
|
|
|
13
|
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
|
|
|
|
|
4
|
return 0; |
20
|
|
|
|
|
|
|
} elsif( @str == 12 ) { |
21
|
2
|
100
|
66
|
|
|
24
|
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
|
|
|
|
|
4
|
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
|
|
|
|
14
|
return 'Value not set' unless length $_[0]; |
42
|
3
|
100
|
|
|
|
54
|
return 'Wrong format' unless $_[0] =~ m{^\d{9}$}; |
43
|
1
|
|
|
|
|
4
|
return 0; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub register { |
47
|
75
|
|
|
75
|
0
|
220
|
my ($class, $self, $app, $conf) = @_; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
$app->vtype( |
50
|
|
|
|
|
|
|
inn => |
51
|
7
|
|
|
7
|
|
17
|
pre => sub { trim $_[1] }, |
52
|
7
|
|
|
7
|
|
13
|
valid => sub { check_inn $_[1] }, |
53
|
75
|
|
|
|
|
657
|
); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
$app->vtype( |
56
|
|
|
|
|
|
|
kpp => |
57
|
4
|
|
|
4
|
|
11
|
pre => sub { trim $_[1] }, |
58
|
4
|
|
|
4
|
|
7
|
valid => sub { check_kpp $_[1] }, |
59
|
75
|
|
|
|
|
667
|
); |
60
|
|
|
|
|
|
|
|
61
|
75
|
|
|
|
|
277
|
return; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |