Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 2d34ea2a

Von Steven Schubiger vor mehr als 1 Jahr hinzugefügt

  • ID 2d34ea2a0adc1fcb89d0c36501aecd0d96d47848
  • Vorgänger 913447a0
  • Nachfolger b71e18fb

Schweizer QR-Rechnung: qrbill_parser.t: Verwende lexikalische Bereiche

Unterschiede anzeigen:

t/helper/qrbill_parser.t
9 9

  
10 10
Support::TestSetup::login();
11 11

  
12
my $code1 = "SPC\n0200\n1\nCH5204835012345671000\nS\nSample Foundation\nPO Box\n\n3001\nBern\nCH\n\n\n\n\n\n\n\n\nCHF\n\n\n\n\n\n\n\nNON\n\n\nEPD\n";
13
my $obj1 = SL::Helper::QrBillParser->new($code1);
14

  
15
is($obj1->is_valid, 1, 'code1valid');
16
is($obj1->{creditor_information}->{iban}, "CH5204835012345671000", 'code1iban');
17
is($obj1->{creditor}->{name}, "Sample Foundation", 'code1name');
18
is($obj1->{payment_amount_information}->{amount}, "", 'code1amount');
19

  
20
my $code2 = "SPC\r\n0200\r\n1\r\nCH4431999123000889012\r\nS\r\nMax Muster & Söhne\r\nMusterstrasse\r\n123\r\n8000\r\nSeldwyla\r\nCH\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n1949.75\r\nCHF\r\nS\r\nSimon Muster\r\nMusterstrasse\r\n1\r\n8000\r\nSeldwyla\r\nCH\r\nQRR\r\n210000000003139471430009017\r\nOrder from 15.10.2020\r\nEPD\r\n//S1/10/1234/11/201021/30/102673386/32/7.7/40/0:30\r\nName AV1: UV;UltraPay005;12345\r\nName AV2: XY;XYService;54321";
21
my $obj2 = SL::Helper::QrBillParser->new($code2);
22

  
23
is($obj2->is_valid, 1, 'code2valid');
24
is($obj2->{creditor_information}->{iban}, "CH4431999123000889012", 'code2iban');
25
is($obj2->{creditor}->{name}, "Max Muster & Söhne", 'code2name');
26
is($obj2->{payment_amount_information}->{amount}, "1949.75", 'code2amount');
27
is($obj2->{payment_reference}->{reference}, "210000000003139471430009017", 'code2reference');
28
is($obj2->{additional_information}->{unstructured_message}, "Order from 15.10.2020", 'code2unstructured_message');
29

  
30
is($obj2->get_creditor_street_name(), 'Musterstrasse', 'code2street_name');
31
is($obj2->get_creditor_building_number(), '123', 'code2building_number');
32
is($obj2->get_creditor_post_code(), '8000', 'code2post_code');
33
is($obj2->get_creditor_town_name(), 'Seldwyla', 'code2town_name');
34

  
35
my $code3 = "SPC\n0200\n1\nCH5800791123000889012\nS\nMuster Krankenkasse\nMusterstrasse\n12\n8000\nSeldwyla\nCH\n\n\n\n\n\n\n\n211.00\nCHF\nS\nSarah Beispiel\nMusterstrasse\n1\n8000\nSeldwyla\nCH\nSCOR\nRF240191230100405JSH0438\n\nEPD\n";
36
my $obj3 = SL::Helper::QrBillParser->new($code3);
37

  
38
is($obj3->is_valid, 1, 'code3valid');
39
is($obj3->{creditor_information}->{iban}, "CH5800791123000889012", 'code3iban');
40
is($obj3->{creditor}->{name}, "Muster Krankenkasse", 'code3name');
41
is($obj3->{payment_amount_information}->{amount}, "211.00", 'code3amount');
42
is($obj3->{payment_reference}->{reference}, "RF240191230100405JSH0438", 'code3reference');
43

  
44
my $code4 = "SPC\n0200\n1\nCH5800791123000889012\nS\nMax Muster & Söhne\nMusterstrasse\n123\n8000\nSeldwyla\nCH\n\n\n\n\n\n\n\n199.95\nCHF\nS\nSarah Beispiel\nMusterstrasse\n1\n78462\nKonstanz\nDE\nSCOR\nRF18539007547034\n\nEPD\n";
45
my $obj4 = SL::Helper::QrBillParser->new($code4);
46

  
47
is($obj4->is_valid, 1, 'code4valid');
48
is($obj4->{creditor_information}->{iban}, "CH5800791123000889012", 'code4iban');
49
is($obj4->{creditor}->{name}, "Max Muster & Söhne", 'code4name');
50
is($obj4->{payment_amount_information}->{amount}, "199.95", 'code4amount');
51
is($obj4->{payment_reference}->{reference}, "RF18539007547034", 'code4reference');
52

  
53
my $code5 = "SP\n0200\n1\nCH5800791123000889012\nS\nMax Muster & Söhne\nMusterstrasse\n123\n8000\nSeldwyla\nCH\n\n\n\n\n\n199.95\nCHF\nS\nSarah Beispiel\nMusterstrasse\n1\n78462\nKonstanz\nDE\nSCOR\nRF18539007547034\n\nEPD\n";
54
my $obj5 = SL::Helper::QrBillParser->new($code5);
55

  
56
is($obj5->is_valid, 0, 'code5invalid');
57
is($obj5->error, "Test failed: Section: 'header' Field: 'qrtype' Value: 'SP'", 'code5error');
58

  
59
my $code6 = "SPC\n0200\n1\nCH5800791123889012\nS\nMax Muster & Söhne\nMusterstrasse\n123\n8000\nSeldwyla\nCH\n\n\n\n\n\n\n\n199.95\nCHF\nS\nSarah Beispiel\nMusterstrasse\n1\n78462\nKonstanz\nDE\nSCOR\nRF18539007547034\n\nEPD\n";
60
my $obj6 = SL::Helper::QrBillParser->new($code6);
61

  
62
is($obj6->is_valid, 0, 'code6invalid');
63
is($obj6->error, "Test failed: Section: 'creditor_information' Field: 'iban' Value: 'CH5800791123889012'", 'code6error');
64

  
65
my $code7 = "SPC\n0200\n1\nCH5204835012345671000\nK\nSample Foundation\nMusterstrasse 55\n3005 Bern\n\n\nCH\n\n\n\n\n\n\n\n\nCHF\n\n\n\n\n\n\n\nNON\n\n\nEPD\n";
66
my $obj7 = SL::Helper::QrBillParser->new($code7);
67

  
68
is($obj7->is_valid, 1, 'code7valid');
69
is($obj7->get_creditor_street_name(), 'Musterstrasse', 'code7street_name');
70
is($obj7->get_creditor_building_number(), '55', 'code7building_number');
71
is($obj7->get_creditor_post_code(), '3005', 'code7post_code');
72
is($obj7->get_creditor_town_name(), 'Bern', 'code7town_name');
73

  
74
my $code8 = "SPC\n0200\n1\nCH5204835012345671000\nK\nSample Foundation\nMusterstrasse 25b\n3005 Bern\n\n\nCH\n\n\n\n\n\n\n\n\nCHF\n\n\n\n\n\n\n\nNON\n\n\nEPD\n";
75
my $obj8 = SL::Helper::QrBillParser->new($code8);
76

  
77
is($obj8->is_valid, 1, 'code8valid');
78
is($obj8->get_creditor_street_name(), 'Musterstrasse', 'code8street_name');
79
is($obj8->get_creditor_building_number(), '25b', 'code8building_number');
80

  
81
my $code9 = "SPC\n0200\n1\nCH5204835012345671000\nK\nSample Foundation\nMusterstrasse 25 c\n3005 Bern\n\n\nCH\n\n\n\n\n\n\n\n\nCHF\n\n\n\n\n\n\n\nNON\n\n\nEPD\n";
82
my $obj9 = SL::Helper::QrBillParser->new($code9);
83

  
84
is($obj9->is_valid, 1, 'code9valid');
85
is($obj9->get_creditor_street_name(), 'Musterstrasse', 'code9street_name');
86
is($obj9->get_creditor_building_number(), '25 c', 'code9building_number');
12
{
13
  my $code = "SPC\n0200\n1\nCH5204835012345671000\nS\nSample Foundation\nPO Box\n\n3001\nBern\nCH\n\n\n\n\n\n\n\n\nCHF\n\n\n\n\n\n\n\nNON\n\n\nEPD\n";
14
  my $obj = SL::Helper::QrBillParser->new($code);
15

  
16
  is($obj->is_valid, 1, 'code1valid');
17
  is($obj->{creditor_information}->{iban}, "CH5204835012345671000", 'code1iban');
18
  is($obj->{creditor}->{name}, "Sample Foundation", 'code1name');
19
  is($obj->{payment_amount_information}->{amount}, "", 'code1amount');
20
}
21

  
22
{
23
  my $code = "SPC\r\n0200\r\n1\r\nCH4431999123000889012\r\nS\r\nMax Muster & Söhne\r\nMusterstrasse\r\n123\r\n8000\r\nSeldwyla\r\nCH\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n1949.75\r\nCHF\r\nS\r\nSimon Muster\r\nMusterstrasse\r\n1\r\n8000\r\nSeldwyla\r\nCH\r\nQRR\r\n210000000003139471430009017\r\nOrder from 15.10.2020\r\nEPD\r\n//S1/10/1234/11/201021/30/102673386/32/7.7/40/0:30\r\nName AV1: UV;UltraPay005;12345\r\nName AV2: XY;XYService;54321";
24
  my $obj = SL::Helper::QrBillParser->new($code);
25

  
26
  is($obj->is_valid, 1, 'code2valid');
27
  is($obj->{creditor_information}->{iban}, "CH4431999123000889012", 'code2iban');
28
  is($obj->{creditor}->{name}, "Max Muster & Söhne", 'code2name');
29
  is($obj->{payment_amount_information}->{amount}, "1949.75", 'code2amount');
30
  is($obj->{payment_reference}->{reference}, "210000000003139471430009017", 'code2reference');
31
  is($obj->{additional_information}->{unstructured_message}, "Order from 15.10.2020", 'code2unstructured_message');
32

  
33
  is($obj->get_creditor_street_name(), 'Musterstrasse', 'code2street_name');
34
  is($obj->get_creditor_building_number(), '123', 'code2building_number');
35
  is($obj->get_creditor_post_code(), '8000', 'code2post_code');
36
  is($obj->get_creditor_town_name(), 'Seldwyla', 'code2town_name');
37
}
38

  
39
{
40
  my $code = "SPC\n0200\n1\nCH5800791123000889012\nS\nMuster Krankenkasse\nMusterstrasse\n12\n8000\nSeldwyla\nCH\n\n\n\n\n\n\n\n211.00\nCHF\nS\nSarah Beispiel\nMusterstrasse\n1\n8000\nSeldwyla\nCH\nSCOR\nRF240191230100405JSH0438\n\nEPD\n";
41
  my $obj = SL::Helper::QrBillParser->new($code);
42

  
43
  is($obj->is_valid, 1, 'code3valid');
44
  is($obj->{creditor_information}->{iban}, "CH5800791123000889012", 'code3iban');
45
  is($obj->{creditor}->{name}, "Muster Krankenkasse", 'code3name');
46
  is($obj->{payment_amount_information}->{amount}, "211.00", 'code3amount');
47
  is($obj->{payment_reference}->{reference}, "RF240191230100405JSH0438", 'code3reference');
48
}
49

  
50
{
51
  my $code = "SPC\n0200\n1\nCH5800791123000889012\nS\nMax Muster & Söhne\nMusterstrasse\n123\n8000\nSeldwyla\nCH\n\n\n\n\n\n\n\n199.95\nCHF\nS\nSarah Beispiel\nMusterstrasse\n1\n78462\nKonstanz\nDE\nSCOR\nRF18539007547034\n\nEPD\n";
52
  my $obj = SL::Helper::QrBillParser->new($code);
53

  
54
  is($obj->is_valid, 1, 'code4valid');
55
  is($obj->{creditor_information}->{iban}, "CH5800791123000889012", 'code4iban');
56
  is($obj->{creditor}->{name}, "Max Muster & Söhne", 'code4name');
57
  is($obj->{payment_amount_information}->{amount}, "199.95", 'code4amount');
58
  is($obj->{payment_reference}->{reference}, "RF18539007547034", 'code4reference');
59
}
60

  
61
{
62
  my $code = "SP\n0200\n1\nCH5800791123000889012\nS\nMax Muster & Söhne\nMusterstrasse\n123\n8000\nSeldwyla\nCH\n\n\n\n\n\n199.95\nCHF\nS\nSarah Beispiel\nMusterstrasse\n1\n78462\nKonstanz\nDE\nSCOR\nRF18539007547034\n\nEPD\n";
63
  my $obj = SL::Helper::QrBillParser->new($code);
64

  
65
  is($obj->is_valid, 0, 'code5invalid');
66
  is($obj->error, "Test failed: Section: 'header' Field: 'qrtype' Value: 'SP'", 'code5error');
67
}
68

  
69
{
70
  my $code = "SPC\n0200\n1\nCH5800791123889012\nS\nMax Muster & Söhne\nMusterstrasse\n123\n8000\nSeldwyla\nCH\n\n\n\n\n\n\n\n199.95\nCHF\nS\nSarah Beispiel\nMusterstrasse\n1\n78462\nKonstanz\nDE\nSCOR\nRF18539007547034\n\nEPD\n";
71
  my $obj = SL::Helper::QrBillParser->new($code);
72

  
73
  is($obj->is_valid, 0, 'code6invalid');
74
  is($obj->error, "Test failed: Section: 'creditor_information' Field: 'iban' Value: 'CH5800791123889012'", 'code6error');
75
}
76

  
77
{
78
  my $code = "SPC\n0200\n1\nCH5204835012345671000\nK\nSample Foundation\nMusterstrasse 55\n3005 Bern\n\n\nCH\n\n\n\n\n\n\n\n\nCHF\n\n\n\n\n\n\n\nNON\n\n\nEPD\n";
79
  my $obj = SL::Helper::QrBillParser->new($code);
80

  
81
  is($obj->is_valid, 1, 'code7valid');
82
  is($obj->get_creditor_street_name(), 'Musterstrasse', 'code7street_name');
83
  is($obj->get_creditor_building_number(), '55', 'code7building_number');
84
  is($obj->get_creditor_post_code(), '3005', 'code7post_code');
85
  is($obj->get_creditor_town_name(), 'Bern', 'code7town_name');
86
}
87

  
88
{
89
  my $code = "SPC\n0200\n1\nCH5204835012345671000\nK\nSample Foundation\nMusterstrasse 25b\n3005 Bern\n\n\nCH\n\n\n\n\n\n\n\n\nCHF\n\n\n\n\n\n\n\nNON\n\n\nEPD\n";
90
  my $obj = SL::Helper::QrBillParser->new($code);
91

  
92
  is($obj->is_valid, 1, 'code8valid');
93
  is($obj->get_creditor_street_name(), 'Musterstrasse', 'code8street_name');
94
  is($obj->get_creditor_building_number(), '25b', 'code8building_number');
95
}
96

  
97
{
98
  my $code = "SPC\n0200\n1\nCH5204835012345671000\nK\nSample Foundation\nMusterstrasse 25 c\n3005 Bern\n\n\nCH\n\n\n\n\n\n\n\n\nCHF\n\n\n\n\n\n\n\nNON\n\n\nEPD\n";
99
  my $obj = SL::Helper::QrBillParser->new($code);
100

  
101
  is($obj->is_valid, 1, 'code9valid');
102
  is($obj->get_creditor_street_name(), 'Musterstrasse', 'code9street_name');
103
  is($obj->get_creditor_building_number(), '25 c', 'code9building_number');
104
}

Auch abrufbar als: Unified diff