Revision a30d7803
Von Cem Aydin vor etwa 2 Jahren hinzugefügt
SL/Helper/QrBillFunctions.pm | ||
---|---|---|
35 | 35 |
|
36 | 36 |
# check values (analog to checks in makro) |
37 | 37 |
# - bank_id |
38 |
# input: 6 digits, only numbers |
|
39 |
# output: 6 digits, only numbers |
|
38 |
# in-/output: a string containing a 6 digit number |
|
40 | 39 |
if (!($bank_id =~ /^\d*$/) || length($bank_id) != 6) { |
41 | 40 |
return undef, $::locale->text('Bank account id number invalid. Must be 6 digits.'); |
42 | 41 |
} |
43 | 42 |
|
44 | 43 |
# - customer_number |
45 |
# input: prefix (letters) + up to 6 digits (numbers)
|
|
46 |
# output: prefix removed, 6 digits, filled with leading zeros
|
|
47 |
$customer_number = remove_letters_prefix($customer_number);
|
|
44 |
# input: a string containing up to 6 digits [0-9]
|
|
45 |
# output: non-digits removed, 6 digits, filled with leading zeros
|
|
46 |
$customer_number = remove_non_digits($customer_number);
|
|
48 | 47 |
if (!check_digits_and_max_length($customer_number, 6)) { |
49 | 48 |
return undef, $::locale->text('Customer number invalid. Must be less then or equal to 6 digits after non-digits removed.'); |
50 | 49 |
} |
... | ... | |
52 | 51 |
$customer_number = sprintf "%06d", $customer_number; |
53 | 52 |
|
54 | 53 |
# - invoice_number |
55 |
# input: prefix (letters) + up to 14 digits, may be zero
|
|
56 |
# output: prefix removed, 14 digits, filled with leading zeros
|
|
57 |
$invoice_number = remove_letters_prefix($invoice_number);
|
|
54 |
# input: a string containing up to 14 digits, may be zero
|
|
55 |
# output: non-digits removed, 14 digits, filled with leading zeros
|
|
56 |
$invoice_number = remove_non_digits($invoice_number);
|
|
58 | 57 |
if (!check_digits_and_max_length($invoice_number, 14)) { |
59 |
return undef, $::locale->text('Invoice number invalid. Must be less then or equal to 14 digits after prefix.');
|
|
58 |
return undef, $::locale->text('Invoice number invalid. Must be less then or equal to 14 digits after non-digits removed.');
|
|
60 | 59 |
} |
61 | 60 |
# fill with zeros |
62 | 61 |
$invoice_number = sprintf "%014d", $invoice_number; |
... | ... | |
125 | 124 |
|
126 | 125 |
### internal functions |
127 | 126 |
|
128 |
sub remove_letters_prefix {
|
|
127 |
sub remove_non_digits {
|
|
129 | 128 |
my $s = $_[0]; |
130 |
$s =~ s/^[a-zA-Z]+//;
|
|
129 |
$s =~ s/[^0-9]//g;
|
|
131 | 130 |
return $s; |
132 | 131 |
} |
133 | 132 |
|
... | ... | |
207 | 206 |
from the parameters plus one check digit. And a string containing an error |
208 | 207 |
message as second return value or undef if no error occurred. |
209 | 208 |
|
210 |
Prefixes will be removed and numbers filled up with leading zeros.
|
|
209 |
Non-digits will be removed and remaining numbers filled up with leading zeros.
|
|
211 | 210 |
|
212 | 211 |
Parameters: |
213 | 212 |
|
... | ... | |
215 | 214 |
|
216 | 215 |
=item C<bank_id> |
217 | 216 |
|
218 |
"Bankkonto Identifikationsnummer". 6 digit number. |
|
217 |
"Bankkonto Identifikationsnummer". A string containing a 6 digit number.
|
|
219 | 218 |
|
220 | 219 |
=item C<customer_number> |
221 | 220 |
|
222 |
Kivitendo customer number. Prefix (letters) and up to 6 digits.
|
|
221 |
Kivitendo customer number. A string containing up to 6 digits.
|
|
223 | 222 |
|
224 | 223 |
=item C<invoice_number> |
225 | 224 |
|
226 |
Kivitendo invoice number. Prefix (letters) and up to 14 digits, may be zero.
|
|
225 |
Kivitendo invoice number. A string containing up to 14 digits, may be zero.
|
|
227 | 226 |
|
228 | 227 |
=back |
229 | 228 |
|
Auch abrufbar als: Unified diff
Swiss QR-Bill: Bei der Erzeugung der Referenznummer nicht numerische Zeichen entfernen, anstatt nur Prefix