Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 62b01d9c

Von Steven Schubiger vor fast 3 Jahren hinzugefügt

  • ID 62b01d9c81ce8be8b9fcad4de622a775a1c4d2e1
  • Vorgänger 94976940
  • Nachfolger 4c4c236f

Swiss QR-Bill: QrBill.pm: Inkludiere Datengruppe-Beschreibung in Fehlerausgabe

Unterschiede anzeigen:

SL/Helper/QrBill.pm
71 71
  my ($biller_information, $biller_data, $payment_information, $invoice_recipient_data, $ref_nr_data) = @_;
72 72

  
73 73
  my $check_re = sub {
74
    my ($href, $elem, $regex) = @_;
74
    my ($group, $href, $elem, $regex) = @_;
75 75
    defined $href->{$elem} && $href->{$elem} =~ $regex
76
      or die "parameter '$elem' not valid", "\n";
76
      or die "field '$elem' in group '$group' not valid", "\n";
77 77
  };
78 78

  
79
  $check_re->($biller_information, 'iban', qr{^(?:CH|LI)[0-9a-zA-Z]{19}$});
79
  my $group = 'biller information';
80
  $check_re->($group, $biller_information, 'iban', qr{^(?:CH|LI)[0-9a-zA-Z]{19}$});
80 81

  
81
  $check_re->($biller_data, 'address_type', qr{^[KS]$});
82
  $check_re->($biller_data, 'company', qr{^.{1,70}$});
83
  $check_re->($biller_data, 'address_row1', qr{^.{0,70}$});
84
  $check_re->($biller_data, 'address_row2', qr{^.{0,70}$});
85
  $check_re->($biller_data, 'countrycode', qr{^[A-Z]{2}$});
82
  $group = 'biller data';
83
  $check_re->($group, $biller_data, 'address_type', qr{^[KS]$});
84
  $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}$});
87
  $check_re->($group, $biller_data, 'countrycode', qr{^[A-Z]{2}$});
86 88

  
87
  $check_re->($payment_information, 'amount', qr{^(?:(?:0|[1-9][0-9]{0,8})\.[0-9]{2})?$});
88
  $check_re->($payment_information, 'currency', qr{^(?:CHF|EUR)$});
89
  $group = 'payment information';
90
  $check_re->($group, $payment_information, 'amount', qr{^(?:(?:0|[1-9][0-9]{0,8})\.[0-9]{2})?$});
91
  $check_re->($group, $payment_information, 'currency', qr{^(?:CHF|EUR)$});
89 92

  
90
  $check_re->($invoice_recipient_data, 'address_type', qr{^[KS]$});
91
  $check_re->($invoice_recipient_data, 'name', qr{^.{1,70}$});
92
  $check_re->($invoice_recipient_data, 'address_row1', qr{^.{0,70}$});
93
  $check_re->($invoice_recipient_data, 'address_row2', qr{^.{0,70}$});
94
  $check_re->($invoice_recipient_data, 'countrycode', qr{^[A-Z]{2}$});
93
  $group = 'invoice recipient data';
94
  $check_re->($group, $invoice_recipient_data, 'address_type', qr{^[KS]$});
95
  $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}$});
98
  $check_re->($group, $invoice_recipient_data, 'countrycode', qr{^[A-Z]{2}$});
95 99

  
100
  $group = 'reference number data';
96 101
  my %ref_nr_regexes = (
97 102
    QRR => qr{^\d{27}$},
98 103
    NON => qr{^$},
99 104
  );
100
  $check_re->($ref_nr_data, 'type', qr{^(?:QRR|SCOR|NON)$});
101
  $check_re->($ref_nr_data, 'ref_number', $ref_nr_regexes{$ref_nr_data->{type}});
105
  $check_re->($group, $ref_nr_data, 'type', qr{^(?:QRR|SCOR|NON)$});
106
  $check_re->($group, $ref_nr_data, 'ref_number', $ref_nr_regexes{$ref_nr_data->{type}});
102 107
}
103 108

  
104 109
sub generate {

Auch abrufbar als: Unified diff