| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Business::BBAN; |
|
2
|
2
|
|
|
2
|
|
4825
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
75
|
|
|
3
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
55
|
|
|
4
|
2
|
|
|
2
|
|
43
|
use 5.010; |
|
|
2
|
|
|
|
|
14
|
|
|
|
2
|
|
|
|
|
756
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.0'; |
|
6
|
|
|
|
|
|
|
# ABSTRACT: helpers to compute BBAN key and generate an BBAN. |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 AUTHORS |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=over 4 |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=item * |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Vincent Lucas (code and documentation) |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=item * |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Marc Chantreux (podification and cpan distrib) |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=back |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Package helper to compute BBAN key and generate an BBAN from a bank |
|
26
|
|
|
|
|
|
|
identifier, a bank location identifier and an account identifier. |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Converts alpha characters into digit following the described table (beware, |
|
29
|
|
|
|
|
|
|
there is a gap between R and S): |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Char | Digit |
|
32
|
|
|
|
|
|
|
-------------------- |
|
33
|
|
|
|
|
|
|
A, J | 1 |
|
34
|
|
|
|
|
|
|
B, K, S | 2 |
|
35
|
|
|
|
|
|
|
C, L, T | 3 |
|
36
|
|
|
|
|
|
|
D, M, U | 4 |
|
37
|
|
|
|
|
|
|
E, N, V | 5 |
|
38
|
|
|
|
|
|
|
F, O, W | 6 |
|
39
|
|
|
|
|
|
|
G, P, X | 7 |
|
40
|
|
|
|
|
|
|
H, q, Y | 8 |
|
41
|
|
|
|
|
|
|
I, R, Z | 9 |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 to_digit ( $bban ) |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
when C<$bban> is string representation of the Basic Bank Account Number (BBAN), |
|
46
|
|
|
|
|
|
|
which can contains some alpha caracters. |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
returns string representation of the Basic Bank Account Number (BBAN), which |
|
49
|
|
|
|
|
|
|
contains only digits. |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=cut |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub to_digit (_) { |
|
54
|
3
|
|
|
3
|
1
|
16
|
my $bban = shift; |
|
55
|
3
|
|
|
|
|
6
|
$bban = uc $bban; |
|
56
|
|
|
|
|
|
|
|
|
57
|
3
|
|
|
|
|
8
|
$bban =~ s/([A-R])/(((ord $1) - 56) % 9) + 1/eg; |
|
|
0
|
|
|
|
|
0
|
|
|
58
|
3
|
|
|
|
|
16
|
$bban =~ s/([S-Z])/(((ord $1) - 56) % 9) + 2/eg; |
|
|
3
|
|
|
|
|
17
|
|
|
59
|
|
|
|
|
|
|
|
|
60
|
3
|
|
|
|
|
16
|
$bban; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head2 compute_key ( $bban ) |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Computes the key corresponding to a given Basic Bank Account Number (BBAN) |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
when C<$bban> is a string representation of the Basic Bank Account Number (BBAN), |
|
68
|
|
|
|
|
|
|
which contains only digits, but does not contains the key part. |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
returns the computed key of the BBAN given in parameter. |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=cut |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub compute_key (_) { |
|
75
|
2
|
|
|
2
|
1
|
6
|
my $bban = shift.'00'; |
|
76
|
2
|
|
|
|
|
5
|
my $rest = 0; |
|
77
|
2
|
|
|
|
|
15
|
map { $rest = ($rest * 10 + $_ ) % 97 } split //, $bban; |
|
|
46
|
|
|
|
|
76
|
|
|
78
|
2
|
|
|
|
|
8
|
my $key = 97 - $rest; |
|
79
|
2
|
50
|
|
|
|
8
|
if($key < 10) |
|
80
|
|
|
|
|
|
|
{ |
|
81
|
0
|
|
|
|
|
0
|
$key = '0'.$key; |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
2
|
|
|
|
|
7
|
$key; |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 get_BBAN ( $bank_id, $bank_location_id, $account_id ) |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Computes and returns the Basic Bank Account Number (BBAN) corresponding to the |
|
90
|
|
|
|
|
|
|
given bank identifier, bank location identifier and the account identifier. When |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
$bank_id is the bank identifier. |
|
93
|
|
|
|
|
|
|
$bank_locaiton_id is the bank location identifier. |
|
94
|
|
|
|
|
|
|
$account_id is the account identifier. |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
return the string representation of the Basic Bank Account Number (BBAN) with |
|
97
|
|
|
|
|
|
|
the key part. The returned BBAN can contains alpha and digit characters. |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=cut |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub get_BBAN { |
|
102
|
1
|
|
|
1
|
1
|
3
|
my $bank_id = shift; |
|
103
|
1
|
|
|
|
|
3
|
my $bank_location_id = shift; |
|
104
|
1
|
|
|
|
|
2
|
my $account_id = shift; |
|
105
|
|
|
|
|
|
|
|
|
106
|
1
|
|
|
|
|
5
|
my $bban = $bank_id.$bank_location_id.$account_id; |
|
107
|
1
|
|
|
|
|
3
|
my $bban_digit = to_digit($bban); |
|
108
|
1
|
|
|
|
|
4
|
my $bban_key = compute_key($bban_digit); |
|
109
|
|
|
|
|
|
|
|
|
110
|
1
|
|
|
|
|
8
|
$bban.$bban_key; |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
1; |