payment_dta 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +20 -0
- data/README.rdoc +45 -0
- data/VERSION +1 -0
- data/generators/payment/USAGE +5 -0
- data/generators/payment/payment_generator.rb +76 -0
- data/generators/payment/templates/model.rb.erb +39 -0
- data/generators/payment/templates/spec.rb.erb +48 -0
- data/lib/payment_dta.rb +4 -0
- data/lib/payment_dta/character_conversion.rb +251 -0
- data/lib/payment_dta/dta_file.rb +55 -0
- data/lib/payment_dta/payment_sorting.rb +19 -0
- data/lib/payment_dta/payments/bank_cheque_payment.rb +60 -0
- data/lib/payment_dta/payments/base.rb +288 -0
- data/lib/payment_dta/payments/domestic_chf_payment.rb +67 -0
- data/lib/payment_dta/payments/esr_payment.rb +48 -0
- data/lib/payment_dta/payments/financial_institution_payment.rb +56 -0
- data/lib/payment_dta/payments/iban_payment.rb +76 -0
- data/lib/payment_dta/payments/special_financial_institution_payment.rb +64 -0
- data/lib/payment_dta/payments/total_record.rb +31 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/spec/factory.rb +82 -0
- data/spec/lib/bank_cheque_payment_spec.rb +178 -0
- data/spec/lib/character_conversion_spec.rb +280 -0
- data/spec/lib/domestic_chf_payment_spec.rb +189 -0
- data/spec/lib/dta_file_spec.rb +81 -0
- data/spec/lib/esr_payment_spec.rb +157 -0
- data/spec/lib/financial_institution_payment_spec.rb +229 -0
- data/spec/lib/iban_payment_spec.rb +201 -0
- data/spec/lib/payment_header_spec.rb +221 -0
- data/spec/lib/payment_spec.rb +15 -0
- data/spec/lib/special_financial_institution_payment_spec.rb +238 -0
- data/spec/lib/total_record_spec.rb +20 -0
- data/spec/spec_helper.rb +9 -0
- metadata +107 -0
@@ -0,0 +1,81 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
require 'dta_file'
|
3
|
+
require 'payments/esr_payment'
|
4
|
+
|
5
|
+
describe DTAFile do
|
6
|
+
before(:all) do
|
7
|
+
@path = File.expand_path(File.dirname(__FILE__) + '/../../tmp/payments.dta')
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should create a file" do
|
11
|
+
DTAFile.create(@path) do |file|
|
12
|
+
file << Factory.create_esr_payment
|
13
|
+
end
|
14
|
+
File.exist?(@path).should be_true
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should set the transaction_number for any record added" do
|
18
|
+
file = DTAFile.new(@path, "00123478901")
|
19
|
+
file << Factory.create_esr_payment
|
20
|
+
file.records.first.transaction_number.should == "00123478901"
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should set the transaction number for any record added" do
|
24
|
+
file = DTAFile.new(@path)
|
25
|
+
file << Factory.create_esr_payment
|
26
|
+
file << Factory.create_esr_payment
|
27
|
+
|
28
|
+
file.records.to_a.first.output_sequence_number.should == "00001"
|
29
|
+
file.records.to_a[1].output_sequence_number.should == "00002"
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should calculate the total amount" do
|
33
|
+
file = DTAFile.new(@path)
|
34
|
+
file << Factory.create_esr_payment(:payment_amount => 420.50)
|
35
|
+
file << Factory.create_esr_payment(:payment_amount => 320.20)
|
36
|
+
file.total.should == (420.50 + 320.20)
|
37
|
+
end
|
38
|
+
|
39
|
+
describe DTAFile, "file records" do
|
40
|
+
before(:each) do
|
41
|
+
@record1 = Factory.create_esr_payment(:payment_amount => 2222.22)
|
42
|
+
@record2 = Factory.create_esr_payment(:payment_amount => 4444.44)
|
43
|
+
@dta_file = DTAFile.create(@path) do |file|
|
44
|
+
file << @record1
|
45
|
+
file << @record2
|
46
|
+
end
|
47
|
+
@file_records = File.open(@path).readlines
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should add the records to the file in dta format" do
|
51
|
+
@file_records.should include(@record2.to_dta + "\n")
|
52
|
+
@file_records.should include(@record2.to_dta + "\n")
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should add a total record" do
|
56
|
+
@file_records.last.should include(Factory.create_total_record(:total_amount => 6666.66).to_dta)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe DTAFile, "record sorting" do
|
61
|
+
before(:each) do
|
62
|
+
@record1 = Factory.create_esr_payment(:requested_processing_date => "091027", :issuer_identification => "AAAAA")
|
63
|
+
@record2 = Factory.create_esr_payment(:requested_processing_date => "091026",:issuer_identification => "BBBBB")
|
64
|
+
@record3 = Factory.create_esr_payment(:requested_processing_date => "091026",:issuer_identification => "CCCCC")
|
65
|
+
@record4 = Factory.create_esr_payment(:requested_processing_date => "091028",:issuer_identification => "AAAAA")
|
66
|
+
@dta_file = DTAFile.new(@path)
|
67
|
+
@dta_file << @record1
|
68
|
+
@dta_file << @record2
|
69
|
+
@dta_file << @record3
|
70
|
+
@dta_file << @record4
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should add all records to it" do
|
74
|
+
@dta_file.records.size.should equal(4)
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should sort the records" do
|
78
|
+
@dta_file.records.to_a.should == [@record1, @record2,@record3, @record4].sort
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,157 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
require 'payments/esr_payment'
|
3
|
+
|
4
|
+
describe 'ESRPayment' do
|
5
|
+
it "should have a total length of 384 characters" do
|
6
|
+
Factory.create_esr_payment.record.size.should == 384
|
7
|
+
end
|
8
|
+
|
9
|
+
describe ESRPayment, 'segment 1' do
|
10
|
+
it 'should set the segment field to 01' do
|
11
|
+
Factory.create_esr_payment.segment1[0,2].should == '01'
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should have a reference number' do
|
15
|
+
Factory.create_esr_payment(:issuer_identification => 'ABC01', :transaction_number => '00123478901').segment1[53,16].should == 'ABC0100123478901'
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should have an account to be debited without IBAN justified left filled with blanks' do
|
19
|
+
Factory.create_esr_payment(:account_to_be_debited => '10235678').segment1[69,24].should == '10235678 '
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should have an account to be debited with IBAN' do
|
23
|
+
Factory.create_esr_payment(:account_to_be_debited => 'CH9300762011623852957').segment1[69,24].should == 'CH9300762011623852957 '
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should have a blank payment amount valuta (6 blanks)' do
|
27
|
+
Factory.create_esr_payment.segment1[93,6].should == ' '
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should have a payment amount currency code' do
|
31
|
+
Factory.create_esr_payment(:payment_amount_currency => 'CHF').segment1[99,3].should == 'CHF'
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should have a payment amount justified left filled with blanks' do
|
35
|
+
Factory.create_esr_payment(:payment_amount => '3949.75').segment1[102,12].should == '3949.75 '
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should have a reserve field' do
|
39
|
+
Factory.create_esr_payment.segment1[114,14].should == ' '.ljust(14)
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should have a total length of 128 characters' do
|
43
|
+
Factory.create_esr_payment.segment1.size.should == 128
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe ESRPayment, 'segment 2' do
|
48
|
+
it 'should set the segment field to 02' do
|
49
|
+
Factory.create_esr_payment.segment2[0,2].should == '02'
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should have an ordering partys address line 1' do
|
53
|
+
Factory.create_esr_payment(:ordering_partys_address_line1 => 'John Doe').segment2[2,20].should == 'John Doe'.ljust(20)
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should have an ordering partys address line 2' do
|
57
|
+
Factory.create_esr_payment(:ordering_partys_address_line2 => 'Bahnhofstrasse 1').segment2[22,20].should == 'Bahnhofstrasse 1'.ljust(20)
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should have an ordering partys address line 3' do
|
61
|
+
Factory.create_esr_payment(:ordering_partys_address_line3 => '8000 Zurich').segment2[42,20].should == '8000 Zurich'.ljust(20)
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'should have an ordering partys address line 4' do
|
65
|
+
Factory.create_esr_payment(:ordering_partys_address_line4 => 'Schweiz').segment2[62,20].should == 'Schweiz'.ljust(20)
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'should have a reserve field' do
|
69
|
+
Factory.create_esr_payment.segment2[82,46].should == ''.ljust(46)
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'should have a length of 128 characters' do
|
73
|
+
Factory.create_esr_payment.segment2.size.should == 128
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe ESRPayment, 'segment 3' do
|
78
|
+
it 'should set the segment field to 03' do
|
79
|
+
Factory.create_esr_payment.segment3[0,2].should == '03'
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'should have the beneficiarys ESR party number' do
|
83
|
+
Factory.create_esr_payment(:beneficiarys_esr_party_number => '012127029').segment3[2,12].should == '/C/012127029'
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'should have a beneficiary address line 1' do
|
87
|
+
Factory.create_esr_payment(:beneficiary_address_line1 => 'Michael Recipient').segment3[14,20].should == 'Michael Recipient'.ljust(20)
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'should have a beneficiary address line 2' do
|
91
|
+
Factory.create_esr_payment(:beneficiary_address_line2 => 'Empfaengerstrasse 1').segment3[34,20].should == 'Empfaengerstrasse 1'.ljust(20)
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'should have a beneficiary address line 3' do
|
95
|
+
Factory.create_esr_payment(:beneficiary_address_line3 => '8640 Rapperswil').segment3[54,20].should == '8640 Rapperswil'.ljust(20)
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'should have a beneficiary address line 4' do
|
99
|
+
Factory.create_esr_payment(:beneficiary_address_line4 => 'Schweiz').segment3[74,20].should == 'Schweiz'.ljust(20)
|
100
|
+
end
|
101
|
+
|
102
|
+
describe 'ESR reference number with 9 figure beneficiary esr number' do
|
103
|
+
it 'should have an ESR reference number' do
|
104
|
+
Factory.create_esr_payment(:beneficiarys_esr_party_number => '012127029',:reason_for_payment_esr_reference_number => '123456789012345678901234567').segment3[94,27].should == '123456789012345678901234567'
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'should justify right the ESR reference number' do
|
108
|
+
Factory.create_esr_payment(:beneficiarys_esr_party_number => '12127029',:reason_for_payment_esr_reference_number => '9876543210123456').segment3[94,27].should == '000000000009876543210123456'
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'should have an esr reference number check' do
|
112
|
+
Factory.create_esr_payment(:beneficiarys_esr_party_number => '12127029').segment3[121,2].should == ' '
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
describe 'ESR reference number with 5 figure beneficiary esr number' do
|
117
|
+
it 'should have an ESR reference number justified left with blanks' do
|
118
|
+
Factory.create_esr_payment(:beneficiarys_esr_party_number => '10304', :reason_for_payment_esr_reference_number => '012345678901234').segment3[94,27].should == '012345678901234'.ljust(27)
|
119
|
+
end
|
120
|
+
|
121
|
+
it 'should have an esr reference number check' do
|
122
|
+
Factory.create_esr_payment(:beneficiarys_esr_party_number => '10304', :beneficiarys_esr_party_number_check => '45').segment3[121,2].should == '45'
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
it 'should have a reserve field' do
|
127
|
+
Factory.create_esr_payment.segment3[123,5].should == ''.ljust(5)
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'should have a length of 128 characters' do
|
131
|
+
Factory.create_esr_payment.segment3.size.should == 128
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
describe ESRPayment, "comparison" do
|
136
|
+
it "should sort by execution date ascending" do
|
137
|
+
@record1 = Factory.create_esr_payment(:requested_processing_date => "091026")
|
138
|
+
@record2 = Factory.create_esr_payment(:requested_processing_date => "091027")
|
139
|
+
|
140
|
+
(@record1 < @record2).should be_true
|
141
|
+
end
|
142
|
+
|
143
|
+
it "should sort by issuer identification when the execution date is equal" do
|
144
|
+
@record1 = Factory.create_esr_payment(:requested_processing_date => "091026", :issuer_identification => "AAAAA")
|
145
|
+
@record2 = Factory.create_esr_payment(:requested_processing_date => "091026",:issuer_identification => "BBBBB")
|
146
|
+
|
147
|
+
(@record1 < @record2).should be_true
|
148
|
+
end
|
149
|
+
|
150
|
+
it "should sort by issuers clearing number when execution date and issuer identification are equal" do
|
151
|
+
@record1 = Factory.create_esr_payment(:requested_processing_date => "091026", :issuer_identification => "AAAAA", :ordering_party_bank_clearing_number => '253')
|
152
|
+
@record2 = Factory.create_esr_payment(:requested_processing_date => "091026",:issuer_identification => "AAAAA", :ordering_party_bank_clearing_number => '254')
|
153
|
+
|
154
|
+
(@record1 < @record2).should be_true
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
@@ -0,0 +1,229 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
require 'payments/financial_institution_payment'
|
3
|
+
|
4
|
+
describe FinancialInstitutionPayment do
|
5
|
+
|
6
|
+
it "should have a total length of 768 characters" do
|
7
|
+
Factory.create_financial_institution_payment.record.size.should == 768
|
8
|
+
end
|
9
|
+
|
10
|
+
describe 'segment 1' do
|
11
|
+
it 'should set the segment field to 01' do
|
12
|
+
Factory.create_financial_institution_payment.segment1[0,2].should == '01'
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should have a reference number' do
|
16
|
+
Factory.create_financial_institution_payment(:issuer_identification => 'ABC01', :transaction_number => '00123478901').segment1[53,16].should == "ABC0100123478901"
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should have an account to be debited without IBAN justified left filled with blanks' do
|
20
|
+
Factory.create_financial_institution_payment(:account_to_be_debited => '10235678').segment1[69,24].should == '10235678 '
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should have an account to be debited with IBAN' do
|
24
|
+
Factory.create_financial_institution_payment(:account_to_be_debited => 'CH9300762011623852957').segment1[69,24].should == 'CH9300762011623852957 '
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should have a payment amount value date yymmdd' do
|
28
|
+
Factory.create_financial_institution_payment(:payment_amount_value_date => '051031').segment1[93,6].should == '051031'
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should have a payment amount currency code' do
|
32
|
+
Factory.create_financial_institution_payment(:payment_amount_currency => 'CHF').segment1[99,3].should == 'CHF'
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should have a payment amount justified left filled with blanks' do
|
36
|
+
Factory.create_financial_institution_payment(:payment_amount => '3949.75').segment1[102,15].should == '3949.75'.ljust(15)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should have a reserve field' do
|
40
|
+
Factory.create_financial_institution_payment.segment1[114,11].should == ' '.ljust(11)
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'should have a total length of 128 characters' do
|
44
|
+
Factory.create_financial_institution_payment.segment1.size.should == 128
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe 'segment 2' do
|
49
|
+
it 'should set the segment field to 02' do
|
50
|
+
Factory.create_financial_institution_payment.segment2[0,2].should == '02'
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'should set the conversion rate if given' do
|
54
|
+
Factory.create_financial_institution_payment(:convertion_rate => '0.9543').segment2[2,12].should == '0.9543'.ljust(12)
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'should have an ordering partys address line 1' do
|
58
|
+
Factory.create_financial_institution_payment(:ordering_partys_address_line1 => 'John Doe').segment2[14,24].should == 'John Doe'.ljust(24)
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should have an ordering partys address line 2' do
|
62
|
+
Factory.create_financial_institution_payment(:ordering_partys_address_line2 => 'Bahnhofstrasse 1').segment2[38,24].should == 'Bahnhofstrasse 1'.ljust(24)
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'should have an ordering partys address line 3' do
|
66
|
+
Factory.create_financial_institution_payment(:ordering_partys_address_line3 => '8000 Zurich').segment2[62,24].should == '8000 Zurich'.ljust(24)
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should have an ordering partys address line 4' do
|
70
|
+
Factory.create_financial_institution_payment(:ordering_partys_address_line4 => 'Schweiz').segment2[86,24].should == 'Schweiz'.ljust(24)
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'should have a reserve field' do
|
74
|
+
Factory.create_financial_institution_payment.segment2[82,18].should == ''.ljust(18)
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'should have a length of 128 characters' do
|
78
|
+
Factory.create_financial_institution_payment.segment2.size.should == 128
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe 'segment 3' do
|
83
|
+
it 'should set the segment field to 03' do
|
84
|
+
Factory.create_financial_institution_payment.segment3[0,2].should == '03'
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'have an identification bank address' do
|
88
|
+
Factory.create_financial_institution_payment(:identification_bank_address => 'D').segment3[2,1].should == 'D'
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'should have the beneficiarys bank account number' do
|
92
|
+
Factory.create_financial_institution_payment(:beneficiary_institution_bank_account_number =>'111222333').segment3[3,24].should == '/C/111222333'.ljust(24)
|
93
|
+
end
|
94
|
+
|
95
|
+
describe 'option A' do
|
96
|
+
it 'should must contain the 8- or 11-character BIC address (= SWIFT address) of the beneficiarys institution' do
|
97
|
+
Factory.create_financial_institution_payment(:identification_bank_address => 'A', :beneficiarys_institution_swift_address_ => 'BBBBLLRRNL2').segment3[27,24].should == 'BBBBLLRRNL2'.ljust(24)
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'should leave lines 3 to 5 blank' do
|
101
|
+
Factory.create_financial_institution_payment(:identification_bank_address => 'A', :beneficiarys_institution_swift_address_ => 'BBBBLLRRNL2').segment3[51,72].should == ''.ljust(72)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
describe 'option D' do
|
106
|
+
it 'should have a address line 1' do
|
107
|
+
Factory.create_financial_institution_payment(:identification_bank_address => 'D',:beneficiary_institution_address_line1 => 'Michael Recipient').segment3[27,24].should == 'Michael Recipient'.ljust(24)
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'should have a beneficiary institution address line 2' do
|
111
|
+
Factory.create_financial_institution_payment(:identification_bank_address => 'D',:beneficiary_institution_address_line2 => 'Empfaengerstrasse 1').segment3[51,24].should == 'Empfaengerstrasse 1'.ljust(24)
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'should have a beneficiary institution address line 3' do
|
115
|
+
Factory.create_financial_institution_payment(:identification_bank_address => 'D',:beneficiary_institution_address_line3 => '8640 Rapperswil').segment3[75,24].should == '8640 Rapperswil'.ljust(24)
|
116
|
+
end
|
117
|
+
|
118
|
+
it 'should have a beneficiary institution address line 4' do
|
119
|
+
Factory.create_financial_institution_payment(:identification_bank_address => 'D',:beneficiary_institution_address_line4 => 'Schweiz').segment3[99,24].should == 'Schweiz'.ljust(24)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
it 'should have a reserve field' do
|
124
|
+
Factory.create_financial_institution_payment.segment3[123,5].should == ''.ljust(5)
|
125
|
+
end
|
126
|
+
|
127
|
+
it 'should have a length of 128 characters' do
|
128
|
+
Factory.create_financial_institution_payment.segment3.size.should == 128
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
describe 'segment 4' do
|
133
|
+
it 'should set the segment field to 03' do
|
134
|
+
Factory.create_financial_institution_payment.segment4[0,2].should == '04'
|
135
|
+
end
|
136
|
+
|
137
|
+
it 'should have the beneficiarys bank account number' do
|
138
|
+
Factory.create_financial_institution_payment(:beneficiary_bank_account_number =>'111222333').segment4[2,24].should == '/C/111222333'.ljust(24)
|
139
|
+
end
|
140
|
+
|
141
|
+
it 'should have a address line 1' do
|
142
|
+
Factory.create_financial_institution_payment(:beneficiary_address_line1 => 'Michael Recipient').segment4[26,24].should == 'Michael Recipient'.ljust(24)
|
143
|
+
end
|
144
|
+
|
145
|
+
it 'should have a beneficiary address line 2' do
|
146
|
+
Factory.create_financial_institution_payment(:beneficiary_address_line2 => 'Empfaengerstrasse 1').segment4[50,24].should == 'Empfaengerstrasse 1'.ljust(24)
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'should have a beneficiary address line 3' do
|
150
|
+
Factory.create_financial_institution_payment(:beneficiary_address_line3 => '8640 Rapperswil').segment4[74,24].should == '8640 Rapperswil'.ljust(24)
|
151
|
+
end
|
152
|
+
|
153
|
+
it 'should have a beneficiary address line 4' do
|
154
|
+
Factory.create_financial_institution_payment(:beneficiary_address_line4 => 'Schweiz').segment4[98,24].should == 'Schweiz'.ljust(24)
|
155
|
+
end
|
156
|
+
|
157
|
+
it "should have a reserve field" do
|
158
|
+
Factory.create_financial_institution_payment.segment4[122,6].should == ''.ljust(6)
|
159
|
+
end
|
160
|
+
|
161
|
+
it 'should have a length of 128 characters' do
|
162
|
+
Factory.create_financial_institution_payment.segment4.size.should == 128
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
describe 'segment 5' do
|
167
|
+
it 'should set the segment field to 05' do
|
168
|
+
Factory.create_financial_institution_payment.segment5[0,2].should == '05'
|
169
|
+
end
|
170
|
+
|
171
|
+
it "should have a reason for payment message line 1" do
|
172
|
+
Factory.create_financial_institution_payment(:reason_for_payment_message_line1 => 'LINE1').segment5[2,30].should == 'LINE1'.ljust(30)
|
173
|
+
end
|
174
|
+
|
175
|
+
it "should have a reason for payment message line 2" do
|
176
|
+
Factory.create_financial_institution_payment(:reason_for_payment_message_line2 => 'LINE2').segment5[32,30].should == 'LINE2'.ljust(30)
|
177
|
+
end
|
178
|
+
|
179
|
+
it "should have a reason for payment message line 3" do
|
180
|
+
Factory.create_financial_institution_payment(:reason_for_payment_message_line3 => 'LINE3').segment5[62,30].should == 'LINE3'.ljust(30)
|
181
|
+
end
|
182
|
+
|
183
|
+
it "should have a reason for payment message line 4" do
|
184
|
+
Factory.create_financial_institution_payment(:reason_for_payment_message_line4 => 'LINE4').segment5[92,30].should == 'LINE4'.ljust(30)
|
185
|
+
end
|
186
|
+
|
187
|
+
it 'should have a reserve field' do
|
188
|
+
Factory.create_financial_institution_payment.segment5[122,6].should == ' '.ljust(6)
|
189
|
+
end
|
190
|
+
|
191
|
+
it 'should have a length of 128 characters' do
|
192
|
+
Factory.create_financial_institution_payment.segment5.size.should == 128
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
describe 'segment 6' do
|
197
|
+
it 'should set the segment field to 06' do
|
198
|
+
Factory.create_financial_institution_payment.segment6[0,2].should == '06'
|
199
|
+
end
|
200
|
+
|
201
|
+
it "should have bank payment instructions" do
|
202
|
+
Factory.create_financial_institution_payment(:bank_payment_instructions => "CHG/OUR").segment6[2,120].should == 'CHG/OUR'.ljust(120)
|
203
|
+
end
|
204
|
+
|
205
|
+
it 'should have a reserve field' do
|
206
|
+
Factory.create_financial_institution_payment.segment6[122,6].should == ' '.ljust(6)
|
207
|
+
end
|
208
|
+
|
209
|
+
it 'should have a length of 128 characters' do
|
210
|
+
Factory.create_financial_institution_payment.segment6.size.should == 128
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
describe 'comparison' do
|
215
|
+
it "should sort by issuer identification" do
|
216
|
+
@record1 = Factory.create_financial_institution_payment(:issuer_identification => "AAAAA")
|
217
|
+
@record2 = Factory.create_financial_institution_payment(:issuer_identification => "BBBBB")
|
218
|
+
|
219
|
+
(@record1 < @record2).should be_true
|
220
|
+
end
|
221
|
+
|
222
|
+
it "should sort by issuers clearing number when issuer identifications are equal" do
|
223
|
+
@record1 = Factory.create_financial_institution_payment( :issuer_identification => "AAAAA", :ordering_party_bank_clearing_number => '253')
|
224
|
+
@record2 = Factory.create_financial_institution_payment(:issuer_identification => "AAAAA", :ordering_party_bank_clearing_number => '254')
|
225
|
+
|
226
|
+
(@record1 < @record2).should be_true
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|