Revision d73f2c37
Added by Cem Aydin over 1 year ago
SL/Helper/QrBillFunctions.pm | ||
---|---|---|
2 | 2 |
|
3 | 3 |
use List::Util qw(first); |
4 | 4 |
|
5 |
use SL::Util qw(trim); |
|
6 |
|
|
5 | 7 |
use strict; |
6 | 8 |
use warnings; |
7 | 9 |
|
8 | 10 |
use Exporter qw(import); |
9 |
our @EXPORT_OK = qw(get_qrbill_account assemble_ref_number get_ref_number_formatted |
|
10 |
get_iban_formatted get_amount_formatted); |
|
11 |
our @EXPORT_OK = qw( |
|
12 |
get_street_name_from_address_line |
|
13 |
get_building_number_from_address_line |
|
14 |
get_postal_code_from_address_line |
|
15 |
get_town_name_from_address_line |
|
16 |
get_qrbill_account |
|
17 |
assemble_ref_number |
|
18 |
get_ref_number_formatted |
|
19 |
get_iban_formatted |
|
20 |
get_amount_formatted |
|
21 |
); |
|
22 |
|
|
23 |
use constant { |
|
24 |
REGEX_STREET_NAME_FROM_ADDRESS_LINE => qr{^([^\d]+)\s*}, |
|
25 |
REGEX_BUILDING_NUMBER_FROM_ADDRESS_LINE => qr{(\d+.*)}, |
|
26 |
REGEX_POSTAL_CODE_FROM_ADDRESS_LINE => qr{^(\d+).*$}, |
|
27 |
REGEX_TOWN_FROM_ADDRESS_LINE => qr{^\d+\s(.*)$}, |
|
28 |
}; |
|
29 |
|
|
30 |
sub get_street_name_from_address_line { |
|
31 |
my $address_line = $_[0]; |
|
32 |
|
|
33 |
my ($street_name) = $address_line =~ REGEX_STREET_NAME_FROM_ADDRESS_LINE; |
|
34 |
|
|
35 |
return trim($street_name) // ''; |
|
36 |
} |
|
37 |
|
|
38 |
sub get_building_number_from_address_line { |
|
39 |
my $address_line = $_[0]; |
|
40 |
|
|
41 |
my ($building_number) = $address_line =~ REGEX_BUILDING_NUMBER_FROM_ADDRESS_LINE; |
|
42 |
|
|
43 |
return trim($building_number) // ''; |
|
44 |
} |
|
45 |
|
|
46 |
sub get_postal_code_from_address_line { |
|
47 |
my $address_line = $_[0]; |
|
48 |
|
|
49 |
my ($postal_code) = $address_line =~ REGEX_POSTAL_CODE_FROM_ADDRESS_LINE; |
|
50 |
|
|
51 |
return trim($postal_code) // ''; |
|
52 |
} |
|
53 |
|
|
54 |
sub get_town_name_from_address_line { |
|
55 |
my $address_line = $_[0]; |
|
56 |
|
|
57 |
my ($town_name) = $address_line =~ REGEX_TOWN_FROM_ADDRESS_LINE; |
|
58 |
|
|
59 |
return trim($town_name) // ''; |
|
60 |
} |
|
11 | 61 |
|
12 | 62 |
sub get_qrbill_account { |
13 | 63 |
$main::lxdebug->enter_sub(); |
... | ... | |
202 | 252 |
|
203 | 253 |
=over 4 |
204 | 254 |
|
255 |
=item C<get_street_name_from_address_line> |
|
256 |
|
|
257 |
Returns the street name from a combined street name and number. |
|
258 |
|
|
259 |
=item C<get_street_number_from_address_line> |
|
260 |
|
|
261 |
Returns the street number from a combined street name and number. |
|
262 |
|
|
263 |
=item C<get_postal_code_from_address_line> |
|
264 |
|
|
265 |
Returns the postal code from an combined postal code and town. |
|
266 |
|
|
267 |
=item C<get_town_name_from_address_line> |
|
268 |
|
|
269 |
Returns the town name from an combined postal code and town. |
|
270 |
|
|
205 | 271 |
=item C<get_qrbill_account> |
206 | 272 |
|
207 | 273 |
Return the bank account flagged for the QR bill. And a string containing an |
Also available in: Unified diff
Schweizer QR-Rechnung: Aufsplitten von kombinierten Adressfelder in Helferfunktionen ausgelagert