Revision 07edce60
Von Steven Schubiger vor mehr als 2 Jahren hinzugefügt
SL/Helper/QrBill.pm | ||
---|---|---|
26 | 26 |
my $self = shift; |
27 | 27 |
my ($biller_information, $biller_data, $payment_information, $invoice_recipient_data, $ref_nr_data) = @_; |
28 | 28 |
|
29 |
my $address = sub { |
|
30 |
my ($href) = @_; |
|
31 |
my $address_type = $href->{address_type}; |
|
32 |
return ((map $href->{$_}, qw(address_row1 address_row2)), '', '') |
|
33 |
if $address_type eq 'K'; |
|
34 |
return (map $href->{$_}, qw(street street_no postalcode city)) |
|
35 |
if $address_type eq 'S'; |
|
36 |
}; |
|
37 |
|
|
29 | 38 |
$self->{data}{header} = [ |
30 | 39 |
'SPC', # QRType |
31 | 40 |
'0200', # Version |
... | ... | |
37 | 46 |
$self->{data}{biller_data} = [ |
38 | 47 |
$biller_data->{address_type}, |
39 | 48 |
$biller_data->{company}, |
40 |
$biller_data->{address_row1}, |
|
41 |
$biller_data->{address_row2}, |
|
42 |
'', |
|
43 |
'', |
|
49 |
$address->($biller_data), |
|
44 | 50 |
$biller_data->{countrycode}, |
45 | 51 |
]; |
46 | 52 |
$self->{data}{payment_information} = [ |
... | ... | |
50 | 56 |
$self->{data}{invoice_recipient_data} = [ |
51 | 57 |
$invoice_recipient_data->{address_type}, |
52 | 58 |
$invoice_recipient_data->{name}, |
53 |
$invoice_recipient_data->{address_row1}, |
|
54 |
$invoice_recipient_data->{address_row2}, |
|
55 |
'', |
|
56 |
'', |
|
59 |
$address->($invoice_recipient_data), |
|
57 | 60 |
$invoice_recipient_data->{countrycode}, |
58 | 61 |
]; |
59 | 62 |
$self->{data}{ref_nr_data} = [ |
... | ... | |
82 | 85 |
$group = 'biller data'; |
83 | 86 |
$check_re->($group, $biller_data, 'address_type', qr{^[KS]$}); |
84 | 87 |
$check_re->($group, $biller_data, 'company', qr{^.{1,70}$}); |
85 |
$check_re->($group, $biller_data, 'address_row1', qr{^.{0,70}$}); |
|
86 |
$check_re->($group, $biller_data, 'address_row2', qr{^.{0,70}$}); |
|
88 |
if ($biller_data->{address_type} eq 'K') { |
|
89 |
$check_re->($group, $biller_data, 'address_row1', qr{^.{0,70}$}); |
|
90 |
$check_re->($group, $biller_data, 'address_row2', qr{^.{0,70}$}); |
|
91 |
} elsif ($biller_data->{address_type} eq 'S') { |
|
92 |
$check_re->($group, $biller_data, 'street', qr{^.{0,70}$}); |
|
93 |
$check_re->($group, $biller_data, 'street_no', qr{^.{0,16}$}); |
|
94 |
$check_re->($group, $biller_data, 'postalcode', qr{^.{0,16}$}); |
|
95 |
$check_re->($group, $biller_data, 'city', qr{^.{0,35}$}); |
|
96 |
} |
|
87 | 97 |
$check_re->($group, $biller_data, 'countrycode', qr{^[A-Z]{2}$}); |
88 | 98 |
|
89 | 99 |
$group = 'payment information'; |
... | ... | |
93 | 103 |
$group = 'invoice recipient data'; |
94 | 104 |
$check_re->($group, $invoice_recipient_data, 'address_type', qr{^[KS]$}); |
95 | 105 |
$check_re->($group, $invoice_recipient_data, 'name', qr{^.{1,70}$}); |
96 |
$check_re->($group, $invoice_recipient_data, 'address_row1', qr{^.{0,70}$}); |
|
97 |
$check_re->($group, $invoice_recipient_data, 'address_row2', qr{^.{0,70}$}); |
|
106 |
if ($invoice_recipient_data->{address_type} eq 'K') { |
|
107 |
$check_re->($group, $invoice_recipient_data, 'address_row1', qr{^.{0,70}$}); |
|
108 |
$check_re->($group, $invoice_recipient_data, 'address_row2', qr{^.{0,70}$}); |
|
109 |
} elsif ($invoice_recipient_data->{address_type} eq 'S') { |
|
110 |
$check_re->($group, $invoice_recipient_data, 'street', qr{^.{0,70}$}); |
|
111 |
$check_re->($group, $invoice_recipient_data, 'street_no', qr{^.{0,16}$}); |
|
112 |
$check_re->($group, $invoice_recipient_data, 'postalcode', qr{^.{0,16}$}); |
|
113 |
$check_re->($group, $invoice_recipient_data, 'city', qr{^.{0,35}$}); |
|
114 |
} |
|
98 | 115 |
$check_re->($group, $invoice_recipient_data, 'countrycode', qr{^[A-Z]{2}$}); |
99 | 116 |
|
100 | 117 |
$group = 'reference number data'; |
... | ... | |
237 | 254 |
|
238 | 255 |
=item C<%biller_data> |
239 | 256 |
|
240 |
Fields: address_type, company, address_row1, address_row2 and countrycode. |
|
257 |
Fields (mandatory): address_type, company and countrycode. |
|
258 |
Fields (combined): address_row1 and address_row2. |
|
259 |
Fields (structured): street, street_no, postalcode and city. |
|
241 | 260 |
|
242 | 261 |
=over 4 |
243 | 262 |
|
244 | 263 |
=item C<address_type> |
245 | 264 |
|
246 |
Fixed length; 1-digit, alphanumerical. 'K' implemented only.
|
|
265 |
Fixed length; 1-digit, alphanumerical. |
|
247 | 266 |
|
248 | 267 |
=item C<company> |
249 | 268 |
|
... | ... | |
251 | 270 |
|
252 | 271 |
=item C<address_row1> |
253 | 272 |
|
254 |
Maximum of 70 characters, street/nr.
|
|
273 |
Maximum of 70 characters, street/no.
|
|
255 | 274 |
|
256 | 275 |
=item C<address_row2> |
257 | 276 |
|
258 |
Maximum of 70 characters, postal code/place. |
|
277 |
Maximum of 70 characters, postal code/city. |
|
278 |
|
|
279 |
=item C<street> |
|
280 |
|
|
281 |
Maximum of 70 characters, street. |
|
282 |
|
|
283 |
=item C<street_no> |
|
284 |
|
|
285 |
Maximum of 16 characters, street no. |
|
286 |
|
|
287 |
=item C<postalcode> |
|
288 |
|
|
289 |
Maximum of 16 characters, postal code. |
|
290 |
|
|
291 |
=item C<city> |
|
292 |
|
|
293 |
Maximum of 35 characters, city. |
|
259 | 294 |
|
260 | 295 |
=item C<countrycode> |
261 | 296 |
|
... | ... | |
282 | 317 |
|
283 | 318 |
=item C<%invoice_recipient_data> |
284 | 319 |
|
285 |
Fields: address_type, name, address_row1, address_row2 and countrycode. |
|
320 |
Fields (mandatory): address_type, name and countrycode. |
|
321 |
Fields (combined): address_row1 and address_row2. |
|
322 |
Fields (structured): street, street_no, postalcode and city. |
|
286 | 323 |
|
287 | 324 |
=over 4 |
288 | 325 |
|
289 | 326 |
=item C<address_type> |
290 | 327 |
|
291 |
Fixed length; 1-digit, alphanumerical. 'K' implemented only.
|
|
328 |
Fixed length; 1-digit, alphanumerical. |
|
292 | 329 |
|
293 | 330 |
=item C<name> |
294 | 331 |
|
... | ... | |
296 | 333 |
|
297 | 334 |
=item C<address_row1> |
298 | 335 |
|
299 |
Maximum of 70 characters, street/nr.
|
|
336 |
Maximum of 70 characters, street/no.
|
|
300 | 337 |
|
301 | 338 |
=item C<address_row2> |
302 | 339 |
|
303 |
Maximum of 70 characters, postal code/place. |
|
340 |
Maximum of 70 characters, postal code/city. |
|
341 |
|
|
342 |
=item C<street> |
|
343 |
|
|
344 |
Maximum of 70 characters, street. |
|
345 |
|
|
346 |
=item C<street_no> |
|
347 |
|
|
348 |
Maximum of 16 characters, street no. |
|
349 |
|
|
350 |
=item C<postalcode> |
|
351 |
|
|
352 |
Maximum of 16 characters, postal code. |
|
353 |
|
|
354 |
=item C<city> |
|
355 |
|
|
356 |
Maximum of 35 characters, city. |
|
304 | 357 |
|
305 | 358 |
=item C<countrycode> |
306 | 359 |
|
Auch abrufbar als: Unified diff
Swiss QR-Bill: QrBill.pm: Verarbeite/validiere strukturierte Adressen