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,48 @@
|
|
1
|
+
require 'payment_dta/payments/base'
|
2
|
+
require 'payment_dta/payment_sorting'
|
3
|
+
|
4
|
+
class ESRPayment < DTA::Payments::Base
|
5
|
+
include DTA::Payment::Sortable
|
6
|
+
|
7
|
+
def record
|
8
|
+
@record ||= segment1 + segment2 + segment3
|
9
|
+
end
|
10
|
+
|
11
|
+
def transaction_type
|
12
|
+
'826'
|
13
|
+
end
|
14
|
+
|
15
|
+
def payment_type
|
16
|
+
'0'
|
17
|
+
end
|
18
|
+
|
19
|
+
def beneficiarys_esr_party_number
|
20
|
+
"/C/#{@data[:beneficiarys_esr_party_number].to_s.rjust(9,'0')}"
|
21
|
+
end
|
22
|
+
|
23
|
+
def reason_for_payment_esr_reference_number
|
24
|
+
if @data[:beneficiarys_esr_party_number].to_s.size == 5
|
25
|
+
@data[:reason_for_payment_esr_reference_number].to_s.ljust(27)
|
26
|
+
else
|
27
|
+
@data[:reason_for_payment_esr_reference_number].to_s.rjust(27,'0')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def beneficiarys_esr_party_number_check
|
32
|
+
@data[:beneficiarys_esr_party_number_check].to_s.ljust(2)
|
33
|
+
end
|
34
|
+
|
35
|
+
protected
|
36
|
+
|
37
|
+
def build_segment1
|
38
|
+
super + reference_number + account_to_be_debited + payment_amount + reserve_field(14)
|
39
|
+
end
|
40
|
+
|
41
|
+
def build_segment2
|
42
|
+
super + ordering_partys_address(20) + reserve_field(46)
|
43
|
+
end
|
44
|
+
|
45
|
+
def build_segment3
|
46
|
+
super + beneficiarys_esr_party_number + beneficiary_address(20) + reason_for_payment_esr_reference_number + beneficiarys_esr_party_number_check + reserve_field(5)
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'payment_dta/payments/base'
|
2
|
+
require 'payment_dta/payment_sorting'
|
3
|
+
|
4
|
+
class FinancialInstitutionPayment < DTA::Payments::Base
|
5
|
+
include DTA::Payment::Sortable
|
6
|
+
|
7
|
+
def transaction_type
|
8
|
+
'830'
|
9
|
+
end
|
10
|
+
|
11
|
+
def payment_type
|
12
|
+
'0'
|
13
|
+
end
|
14
|
+
|
15
|
+
def requested_processing_date
|
16
|
+
'000000'
|
17
|
+
end
|
18
|
+
|
19
|
+
def payment_amount_value
|
20
|
+
@data[:payment_amount].to_s.ljust(15)
|
21
|
+
end
|
22
|
+
|
23
|
+
def payment_amount_value_date
|
24
|
+
@data[:payment_amount_value_date].to_s.ljust(6)
|
25
|
+
end
|
26
|
+
|
27
|
+
def convertion_rate
|
28
|
+
@data[:convertion_rate].to_s.ljust(12)
|
29
|
+
end
|
30
|
+
|
31
|
+
protected
|
32
|
+
|
33
|
+
def build_segment1
|
34
|
+
super + reference_number + account_to_be_debited + payment_amount + reserve_field(11)
|
35
|
+
end
|
36
|
+
|
37
|
+
def build_segment2
|
38
|
+
super + convertion_rate + ordering_partys_address(24) + reserve_field(18)
|
39
|
+
end
|
40
|
+
|
41
|
+
def build_segment3
|
42
|
+
super + identification_bank_address + beneficiary_institution_bank_account_number + beneficiary_institution_address + reserve_field(5)
|
43
|
+
end
|
44
|
+
|
45
|
+
def build_segment4
|
46
|
+
super + beneficiary_bank_account_number + beneficiary_address(24) + reserve_field(6)
|
47
|
+
end
|
48
|
+
|
49
|
+
def build_segment5
|
50
|
+
super + reason_for_payment_message(30) + reserve_field(6)
|
51
|
+
end
|
52
|
+
|
53
|
+
def build_segment6
|
54
|
+
super + bank_payment_instructions + reserve_field(6)
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'payment_dta/payments/base'
|
2
|
+
require 'payment_dta/payment_sorting'
|
3
|
+
|
4
|
+
class IBANPayment < DTA::Payments::Base
|
5
|
+
include DTA::Payment::Sortable
|
6
|
+
|
7
|
+
def record
|
8
|
+
@record ||= segment1 + segment2 + segment3 + segment4 + segment5
|
9
|
+
end
|
10
|
+
|
11
|
+
def transaction_type
|
12
|
+
'836'
|
13
|
+
end
|
14
|
+
|
15
|
+
def payment_type
|
16
|
+
'1'
|
17
|
+
end
|
18
|
+
|
19
|
+
def requested_processing_date
|
20
|
+
'000000'
|
21
|
+
end
|
22
|
+
|
23
|
+
def payment_amount_value_date
|
24
|
+
@data[:payment_amount_value_date].to_s.ljust(6)
|
25
|
+
end
|
26
|
+
|
27
|
+
def payment_amount_value
|
28
|
+
@data[:payment_amount].to_s.ljust(15)
|
29
|
+
end
|
30
|
+
|
31
|
+
def convertion_rate
|
32
|
+
@data[:convertion_rate].to_s.ljust(12)
|
33
|
+
end
|
34
|
+
|
35
|
+
def ordering_partys_address(line_size = 35)
|
36
|
+
ordering_partys_address_line1(line_size) + ordering_partys_address_line2(line_size) + ordering_partys_address_line3(line_size)
|
37
|
+
end
|
38
|
+
|
39
|
+
def identification_bank_address
|
40
|
+
@data[:identification_bank_address].to_s
|
41
|
+
end
|
42
|
+
|
43
|
+
def beneficiary_institution_address(line_size=24)
|
44
|
+
if identification_bank_address == 'A'
|
45
|
+
@data[:beneficiarys_institution_swift_address_].to_s.ljust(70)
|
46
|
+
else
|
47
|
+
@data[:beneficiary_institution_address_line1].to_s.ljust(35) + @data[:beneficiary_institution_address_line2].to_s.ljust(35)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def beneficiary_address(line_size=35)
|
52
|
+
beneficiary_address_line1(line_size) + beneficiary_address_line2(line_size) + beneficiary_address_line3(line_size)
|
53
|
+
end
|
54
|
+
|
55
|
+
protected
|
56
|
+
|
57
|
+
def build_segment1
|
58
|
+
super + reference_number + account_to_be_debited + payment_amount + reserve_field(11)
|
59
|
+
end
|
60
|
+
|
61
|
+
def build_segment2
|
62
|
+
super + convertion_rate + ordering_partys_address + reserve_field(9)
|
63
|
+
end
|
64
|
+
|
65
|
+
def build_segment3
|
66
|
+
super + identification_bank_address + beneficiary_institution_address + beneficiary_iban_number + reserve_field(21)
|
67
|
+
end
|
68
|
+
|
69
|
+
def build_segment4
|
70
|
+
super + beneficiary_address + reserve_field(21)
|
71
|
+
end
|
72
|
+
|
73
|
+
def build_segment5
|
74
|
+
super + identification_purpose + purpose + rule_of_charge + reserve_field(19)
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'payment_dta/payments/base'
|
2
|
+
require 'payment_dta/payment_sorting'
|
3
|
+
|
4
|
+
class SpecialFinancialInstitutionPayment < DTA::Payments::Base
|
5
|
+
include DTA::Payment::Sortable
|
6
|
+
|
7
|
+
def record
|
8
|
+
@record ||= segment1 + segment2 + segment3 + segment4 + segment5
|
9
|
+
end
|
10
|
+
|
11
|
+
def transaction_type
|
12
|
+
'837'
|
13
|
+
end
|
14
|
+
|
15
|
+
def payment_type
|
16
|
+
'1'
|
17
|
+
end
|
18
|
+
|
19
|
+
def requested_processing_date
|
20
|
+
'000000'
|
21
|
+
end
|
22
|
+
|
23
|
+
def account_to_be_debited
|
24
|
+
@data[:account_to_be_debited].to_s.ljust(34)
|
25
|
+
end
|
26
|
+
|
27
|
+
def payment_amount_value
|
28
|
+
@data[:payment_amount].to_s.ljust(15)
|
29
|
+
end
|
30
|
+
|
31
|
+
def payment_amount_value_date
|
32
|
+
@data[:payment_amount_value_date].to_s.ljust(6)
|
33
|
+
end
|
34
|
+
|
35
|
+
def convertion_rate
|
36
|
+
@data[:convertion_rate].to_s.ljust(12)
|
37
|
+
end
|
38
|
+
|
39
|
+
protected
|
40
|
+
|
41
|
+
def build_segment1
|
42
|
+
super + reference_number + account_to_be_debited + payment_amount + reserve_field(1)
|
43
|
+
end
|
44
|
+
|
45
|
+
def build_segment2
|
46
|
+
super + convertion_rate + ordering_partys_address(24) + reserve_field(18)
|
47
|
+
end
|
48
|
+
|
49
|
+
def build_segment3
|
50
|
+
super + identification_bank_address + beneficiary_institution_bank_account_number + beneficiary_institution_address + reserve_field(5)
|
51
|
+
end
|
52
|
+
|
53
|
+
def build_segment4
|
54
|
+
super + beneficiary_bank_account_number + beneficiary_address(24) + reserve_field(6)
|
55
|
+
end
|
56
|
+
|
57
|
+
def build_segment5
|
58
|
+
super + beneficiary_iban_number + reserve_field(92)
|
59
|
+
end
|
60
|
+
|
61
|
+
def build_segment6
|
62
|
+
super + identification_purpose + purpose + rule_of_charge + reserve_field(19)
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'payment_dta/payments/base'
|
2
|
+
|
3
|
+
class TotalRecord < DTA::Payments::Base
|
4
|
+
def segment1
|
5
|
+
super + total_amount + reserve_field(59)
|
6
|
+
end
|
7
|
+
|
8
|
+
def record
|
9
|
+
segment1
|
10
|
+
end
|
11
|
+
|
12
|
+
def total_amount
|
13
|
+
@data[:total_amount].to_s.gsub(/\./,',').ljust(16)
|
14
|
+
end
|
15
|
+
|
16
|
+
def ordering_party_bank_clearing_number
|
17
|
+
''.ljust(7)
|
18
|
+
end
|
19
|
+
|
20
|
+
def transaction_type
|
21
|
+
'890'
|
22
|
+
end
|
23
|
+
|
24
|
+
def payment_type
|
25
|
+
'0'
|
26
|
+
end
|
27
|
+
|
28
|
+
def requested_processing_date
|
29
|
+
'000000'
|
30
|
+
end
|
31
|
+
end
|
data/script/destroy
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/destroy'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :test_unit]
|
14
|
+
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/generate'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :test_unit]
|
14
|
+
RubiGen::Scripts::Generate.new.run(ARGV)
|
data/spec/factory.rb
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'payment_dta/payments/esr_payment'
|
2
|
+
require 'payment_dta/payments/total_record'
|
3
|
+
class Factory
|
4
|
+
def self.create_payment(type, attributes = {})
|
5
|
+
send("create_#{type.to_s}_payment",attributes)
|
6
|
+
end
|
7
|
+
def self.create_esr_payment(attributes = {})
|
8
|
+
default_attributes = {
|
9
|
+
:requested_processing_date => Date.today.strftime('%y%m%d'),
|
10
|
+
:payers_clearing_number => '254',
|
11
|
+
:account_to_be_debited => '10235678',
|
12
|
+
:payment_amount => '3949.75',
|
13
|
+
:ordering_party_bank_clearing_number => '253'
|
14
|
+
}.merge(attributes)
|
15
|
+
ESRPayment.new(build_attributes(default_attributes))
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.create_domestic_chf_payment(attributes = {})
|
19
|
+
default_attributes = {
|
20
|
+
:requested_processing_date => Date.today.strftime('%y%m%d'),
|
21
|
+
}.merge(attributes)
|
22
|
+
DomesticCHFPayment.new(build_attributes(default_attributes))
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.create_financial_institution_payment(attributes = {})
|
26
|
+
default_attributes = {
|
27
|
+
:identification_bank_address => 'A',
|
28
|
+
}.merge(attributes)
|
29
|
+
FinancialInstitutionPayment.new(build_attributes(default_attributes))
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.create_special_financial_institution_payment(attributes = {})
|
33
|
+
default_attributes = {
|
34
|
+
:identification_bank_address => 'A',
|
35
|
+
:identification_purpose => 'I',
|
36
|
+
:purpose_structured_reference_number => 'i3or6cev1wog5ez5og8j',
|
37
|
+
:rule_of_charge => '2'
|
38
|
+
}.merge(attributes)
|
39
|
+
SpecialFinancialInstitutionPayment.new(build_attributes(default_attributes))
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.create_bank_cheque_payment(attributes = {})
|
43
|
+
default_attributes = {
|
44
|
+
|
45
|
+
}.merge(attributes)
|
46
|
+
BankChequePayment.new(build_attributes(default_attributes))
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.create_iban_payment(attributes = {})
|
50
|
+
default_attributes = {
|
51
|
+
:identification_bank_address => 'A',
|
52
|
+
:identification_purpose => 'I',
|
53
|
+
:purpose_structured_reference_number => 'i3or6cev1wog5ez5og8j',
|
54
|
+
:rule_of_charge => '2'
|
55
|
+
}.merge(attributes)
|
56
|
+
IBANPayment.new(build_attributes(default_attributes))
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.create_total_payment(attributes = {})
|
60
|
+
default_attributes = {
|
61
|
+
:data_file_sender_identification => 'ÄÜ2',
|
62
|
+
:total_amount => 233.451,
|
63
|
+
}.merge(attributes)
|
64
|
+
TotalRecord.new(default_attributes)
|
65
|
+
end
|
66
|
+
class << self
|
67
|
+
alias :create_total_record :create_total_payment
|
68
|
+
end
|
69
|
+
|
70
|
+
private
|
71
|
+
|
72
|
+
def self.build_attributes(attributes = {})
|
73
|
+
{
|
74
|
+
:data_file_sender_identification => 'ÄÜ2',
|
75
|
+
:payment_amount_currency => 'CHF',
|
76
|
+
:issuer_identification => 'ABC01',
|
77
|
+
:transaction_number => rand(100000000000).to_s,
|
78
|
+
:output_sequence_number => 1,
|
79
|
+
:payment_amount_value_date => Date.today.strftime('%y%m%d')
|
80
|
+
}.merge(attributes)
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,178 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
require 'payments/bank_cheque_payment'
|
3
|
+
|
4
|
+
describe BankChequePayment do
|
5
|
+
it "should have a total length of 640 characters" do
|
6
|
+
Factory.create_bank_cheque_payment.record.size.should == 640
|
7
|
+
end
|
8
|
+
|
9
|
+
describe 'segment 1' do
|
10
|
+
it 'should set the segment field to 01' do
|
11
|
+
Factory.create_bank_cheque_payment.segment1[0,2].should == '01'
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should have a reference number' do
|
15
|
+
Factory.create_bank_cheque_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_bank_cheque_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_bank_cheque_payment(:account_to_be_debited => 'CH9300762011623852957').segment1[69,24].should == 'CH9300762011623852957 '
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should have a payment amount value date yymmdd' do
|
27
|
+
Factory.create_bank_cheque_payment(:payment_amount_value_date => '051031').segment1[93,6].should == '051031'
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should have a payment amount currency code' do
|
31
|
+
Factory.create_bank_cheque_payment(:payment_amount_currency => 'USD').segment1[99,3].should == 'USD'
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should have a payment amount justified left filled with blanks' do
|
35
|
+
Factory.create_bank_cheque_payment(:payment_amount => '3949.75').segment1[102,15].should == '3949.75'.ljust(15)
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should have a reserve field' do
|
39
|
+
Factory.create_bank_cheque_payment.segment1[114,11].should == ' '.ljust(11)
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should have a total length of 128 characters' do
|
43
|
+
Factory.create_bank_cheque_payment.segment1.size.should == 128
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe 'segment 2' do
|
48
|
+
it 'should set the segment field to 02' do
|
49
|
+
Factory.create_bank_cheque_payment.segment2[0,2].should == '02'
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should set the conversion rate if given' do
|
53
|
+
Factory.create_bank_cheque_payment(:convertion_rate => '0.9543').segment2[2,12].should == '0.9543'.ljust(12)
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should have an ordering partys address line 1' do
|
57
|
+
Factory.create_bank_cheque_payment(:ordering_partys_address_line1 => 'John Doe').segment2[14,24].should == 'John Doe'.ljust(24)
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should have an ordering partys address line 2' do
|
61
|
+
Factory.create_bank_cheque_payment(:ordering_partys_address_line2 => 'Bahnhofstrasse 1').segment2[38,24].should == 'Bahnhofstrasse 1'.ljust(24)
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'should have an ordering partys address line 3' do
|
65
|
+
Factory.create_bank_cheque_payment(:ordering_partys_address_line3 => '8000 Zurich').segment2[62,24].should == '8000 Zurich'.ljust(24)
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'should have an ordering partys address line 4' do
|
69
|
+
Factory.create_bank_cheque_payment(:ordering_partys_address_line4 => 'Schweiz').segment2[86,24].should == 'Schweiz'.ljust(24)
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'should have a reserve field' do
|
73
|
+
Factory.create_bank_cheque_payment.segment2[82,18].should == ''.ljust(18)
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'should have a length of 128 characters' do
|
77
|
+
Factory.create_bank_cheque_payment.segment2.size.should == 128
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe 'segment 3' do
|
82
|
+
it 'should set the segment field to 03' do
|
83
|
+
Factory.create_bank_cheque_payment.segment3[0,2].should == '03'
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'should set the beneficiarys bank account number to /C/' do
|
87
|
+
Factory.create_bank_cheque_payment.segment3[2,24].should == '/C/'.ljust(24)
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'should have a address line 1' do
|
91
|
+
Factory.create_bank_cheque_payment(:beneficiary_address_line1 => 'Michael Recipient').segment3[26,24].should == 'Michael Recipient'.ljust(24)
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'should have a beneficiary address line 2' do
|
95
|
+
Factory.create_bank_cheque_payment(:beneficiary_address_line2 => 'Empfaengerstrasse 1').segment3[50,24].should == 'Empfaengerstrasse 1'.ljust(24)
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'should have a beneficiary address line 3' do
|
99
|
+
Factory.create_bank_cheque_payment(:beneficiary_address_line3 => '8640 Rapperswil').segment3[74,24].should == '8640 Rapperswil'.ljust(24)
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'should have a beneficiary address line 4' do
|
103
|
+
Factory.create_bank_cheque_payment(:beneficiary_address_line4 => 'Schweiz').segment3[98,24].should == 'Schweiz'.ljust(24)
|
104
|
+
end
|
105
|
+
|
106
|
+
it "should have a reserve field" do
|
107
|
+
Factory.create_bank_cheque_payment.segment3[122,6].should == ''.ljust(6)
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'should have a length of 128 characters' do
|
111
|
+
Factory.create_bank_cheque_payment.segment3.size.should == 128
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
describe 'segment 4' do
|
116
|
+
it 'should set the segment field to 04' do
|
117
|
+
Factory.create_bank_cheque_payment.segment4[0,2].should == '04'
|
118
|
+
end
|
119
|
+
|
120
|
+
it "should have a reson for payment message line 1" do
|
121
|
+
Factory.create_bank_cheque_payment(:reason_for_payment_message_line1 => 'LINE1').segment4[2,28].should == 'LINE1'.ljust(28)
|
122
|
+
end
|
123
|
+
|
124
|
+
it "should have a reson for payment message line 2" do
|
125
|
+
Factory.create_bank_cheque_payment(:reason_for_payment_message_line2 => 'LINE2').segment4[30,28].should == 'LINE2'.ljust(28)
|
126
|
+
end
|
127
|
+
|
128
|
+
it "should have a reson for payment message line 3" do
|
129
|
+
Factory.create_bank_cheque_payment(:reason_for_payment_message_line3 => 'LINE3').segment4[58,28].should == 'LINE3'.ljust(28)
|
130
|
+
end
|
131
|
+
|
132
|
+
it "should have a reson for payment message line 4" do
|
133
|
+
Factory.create_bank_cheque_payment(:reason_for_payment_message_line4 => 'LINE4').segment4[86,28].should == 'LINE4'.ljust(28)
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'should have a reserve field' do
|
137
|
+
Factory.create_bank_cheque_payment.segment4[114,14].should == ' '.ljust(14)
|
138
|
+
end
|
139
|
+
|
140
|
+
it 'should have a length of 128 characters' do
|
141
|
+
Factory.create_bank_cheque_payment.segment4.size.should == 128
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
describe 'segment 5' do
|
146
|
+
it 'should set the segment field to 05' do
|
147
|
+
Factory.create_bank_cheque_payment.segment5[0,2].should == '05'
|
148
|
+
end
|
149
|
+
|
150
|
+
it "should have bank payment instructions" do
|
151
|
+
Factory.create_bank_cheque_payment(:bank_payment_instructions => "CHG/OUR").segment5[2,120].should == 'CHG/OUR'.ljust(120)
|
152
|
+
end
|
153
|
+
|
154
|
+
it 'should have a reserve field' do
|
155
|
+
Factory.create_bank_cheque_payment.segment5[122,6].should == ' '.ljust(6)
|
156
|
+
end
|
157
|
+
|
158
|
+
it 'should have a length of 128 characters' do
|
159
|
+
Factory.create_bank_cheque_payment.segment5.size.should == 128
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
describe 'comparison' do
|
164
|
+
it "should sort by issuer identification" do
|
165
|
+
@record1 = Factory.create_bank_cheque_payment(:issuer_identification => "AAAAA")
|
166
|
+
@record2 = Factory.create_bank_cheque_payment(:issuer_identification => "BBBBB")
|
167
|
+
|
168
|
+
(@record1 < @record2).should be_true
|
169
|
+
end
|
170
|
+
|
171
|
+
it "should sort by issuers clearing number when issuer identifications are equal" do
|
172
|
+
@record1 = Factory.create_bank_cheque_payment(:issuer_identification => "AAAAA", :ordering_party_bank_clearing_number => '253')
|
173
|
+
@record2 = Factory.create_bank_cheque_payment(:issuer_identification => "AAAAA", :ordering_party_bank_clearing_number => '254')
|
174
|
+
|
175
|
+
(@record1 < @record2).should be_true
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|