Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision aab96bbe

Von Cem Aydin vor etwa 2 Jahren hinzugefügt

  • ID aab96bbee6c774396e357c0723a1185c2f656653
  • Vorgänger 358db41e
  • Nachfolger 004a4e06

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

Unterschiede anzeigen:

SL/IS.pm
62 62
use SL::DB;
63 63
use SL::Presenter::Part qw(type_abbreviation classification_abbreviation);
64 64
use SL::Helper::QrBillFunctions qw(get_qrbill_account assemble_ref_number);
65
use SL::Helper::ISO3166;
65 66
use Data::Dumper;
66 67

  
67 68
use strict;
......
622 623
  $form->{iap_final_amount_nofmt} = $form->{invtotal_nofmt} - $form->{iap_amount_nofmt};
623 624
  $form->{iap_final_amount}       = $form->format_amount($myconfig, $form->{iap_final_amount_nofmt}, 2);
624 625

  
626
  # set variables for swiss QR bill, if feature enabled
627
  # handling errors gracefully (don't die if undef)
628
  if ($::instance_conf->get_create_qrbill_invoices && $form->{formname} eq 'invoice') {
629
    my ($qr_account, $error) = get_qrbill_account();
630
    $form->{qrbill_iban} = $qr_account->{iban};
631

  
632
    my $biller_country = $::instance_conf->get_address_country() || 'CH';
633
    my $biller_countrycode = SL::Helper::ISO3166::map_name_to_alpha_2_code($biller_country);
634
    $form->{qrbill_biller_countrycode} = $biller_countrycode;
635

  
636
    my $customer_country = $form->{'country'} || 'CH';
637
    my $customer_countrycode = SL::Helper::ISO3166::map_name_to_alpha_2_code($customer_country);
638
    $form->{qrbill_customer_countrycode} = $customer_countrycode;
639

  
640
    $form->{qrbill_amount} = sprintf("%.2f", $form->parse_amount($myconfig, $form->{'total'}));
641
  }
625 642
  $main::lxdebug->leave_sub();
626 643
}
627 644

  
SL/Template/OpenDocument.pm
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
  

Auch abrufbar als: Unified diff