13 |
13 |
|
14 |
14 |
use SL::DB::BankAccount;
|
15 |
15 |
use SL::Helper::QrBill;
|
16 |
|
use SL::Helper::QrBillFunctions qw(get_qrbill_account get_ref_number_formatted
|
17 |
|
get_iban_formatted get_amount_formatted);
|
|
16 |
use SL::Helper::QrBillFunctions qw(get_ref_number_formatted get_iban_formatted get_amount_formatted);
|
18 |
17 |
use SL::Helper::ISO3166;
|
19 |
18 |
|
20 |
19 |
use Cwd;
|
... | ... | |
481 |
480 |
|
482 |
481 |
# assemble data for QR-Code
|
483 |
482 |
|
484 |
|
# get qr-account data
|
485 |
|
my ($qr_account, $error) = get_qrbill_account();
|
486 |
|
if (!$qr_account) {
|
487 |
|
$::form->error($error);
|
|
483 |
if (!$form->{qrbill_iban}) {
|
|
484 |
$::form->error($::locale->text('No bank account flagged for QRBill usage was found.'));
|
488 |
485 |
}
|
489 |
486 |
|
490 |
487 |
my %biller_information = (
|
491 |
|
'iban' => $qr_account->{'iban'}
|
|
488 |
'iban' => $form->{qrbill_iban}
|
492 |
489 |
);
|
493 |
490 |
|
494 |
|
my $biller_country = $::instance_conf->get_address_country() || 'CH';
|
495 |
|
my $biller_countrycode = SL::Helper::ISO3166::map_name_to_alpha_2_code($biller_country);
|
496 |
|
if (!$biller_countrycode) {
|
|
491 |
if (!$form->{qrbill_biller_countrycode}) {
|
497 |
492 |
$::form->error($::locale->text('Error mapping biller countrycode.'));
|
498 |
493 |
}
|
499 |
494 |
my %biller_data = (
|
... | ... | |
501 |
496 |
'company' => $::instance_conf->get_company(),
|
502 |
497 |
'address_row1' => $::instance_conf->get_address_street1(),
|
503 |
498 |
'address_row2' => $::instance_conf->get_address_zipcode() . ' ' . $::instance_conf->get_address_city(),
|
504 |
|
'countrycode' => $biller_countrycode,
|
|
499 |
'countrycode' => $form->{qrbill_biller_countrycode},
|
505 |
500 |
);
|
506 |
501 |
|
507 |
502 |
my ($amount, $amount_formatted);
|
... | ... | |
509 |
504 |
$amount = '';
|
510 |
505 |
$amount_formatted = '';
|
511 |
506 |
} else {
|
512 |
|
$amount = sprintf("%.2f", $form->parse_amount(\%::myconfig, $form->{'total'}));
|
|
507 |
$amount = $form->{qrbill_amount};
|
513 |
508 |
|
514 |
509 |
# format amount for template
|
515 |
510 |
$amount_formatted = get_amount_formatted($amount);
|
... | ... | |
523 |
518 |
'currency' => $form->{'currency'},
|
524 |
519 |
);
|
525 |
520 |
|
526 |
|
my $customer_country = $form->{'country'} || 'CH';
|
527 |
|
my $customer_countrycode = SL::Helper::ISO3166::map_name_to_alpha_2_code($customer_country);
|
528 |
|
if (!$customer_countrycode) {
|
|
521 |
if (!$form->{qrbill_customer_countrycode}) {
|
529 |
522 |
$::form->error($::locale->text('Error mapping customer countrycode.'));
|
530 |
523 |
}
|
531 |
524 |
my %invoice_recipient_data = (
|
... | ... | |
533 |
526 |
'name' => $form->{'name'},
|
534 |
527 |
'address_row1' => $form->{'street'},
|
535 |
528 |
'address_row2' => $form->{'zipcode'} . ' ' . $form->{'city'},
|
536 |
|
'countrycode' => $customer_countrycode,
|
|
529 |
'countrycode' => $form->{qrbill_customer_countrycode},
|
537 |
530 |
);
|
538 |
531 |
|
539 |
532 |
my %ref_nr_data;
|
... | ... | |
562 |
555 |
# set into form for template processing
|
563 |
556 |
$form->{'biller_information'} = \%biller_information;
|
564 |
557 |
$form->{'biller_data'} = \%biller_data;
|
565 |
|
$form->{'iban_formatted'} = get_iban_formatted($qr_account->{'iban'});
|
|
558 |
$form->{'iban_formatted'} = get_iban_formatted($form->{qrbill_iban});
|
566 |
559 |
$form->{'amount_formatted'} = $amount_formatted;
|
567 |
560 |
$form->{'unstructured_message'} = $form->{'qr_unstructured_message'};
|
568 |
561 |
|
Swiss QR-Bill: Einige Variablen bereits in der invoice setzen, so dass
diese auch in den latex Vorlagen verfügbar sind.
Variablen:
qrbill_iban, qrbill_biller_countrycode, qrbill_customer_countrycode,
qrbill_amount