bankserv 0.1.3
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/.gitignore +6 -0
- data/.rvmrc +1 -0
- data/Gemfile +16 -0
- data/Rakefile +8 -0
- data/bankserv.gemspec +31 -0
- data/config.ru +7 -0
- data/lib/bankserv.rb +48 -0
- data/lib/bankserv/account_holder_verification.rb +90 -0
- data/lib/bankserv/bank_account.rb +19 -0
- data/lib/bankserv/configuration.rb +67 -0
- data/lib/bankserv/credit.rb +70 -0
- data/lib/bankserv/debit.rb +94 -0
- data/lib/bankserv/eft.rb +83 -0
- data/lib/bankserv/engine.rb +183 -0
- data/lib/bankserv/engine/engine_configuration.rb +12 -0
- data/lib/bankserv/engine/engine_process.rb +3 -0
- data/lib/bankserv/request.rb +27 -0
- data/lib/bankserv/transaction.rb +22 -0
- data/lib/bankserv/transmission/document.rb +43 -0
- data/lib/bankserv/transmission/input_document.rb +84 -0
- data/lib/bankserv/transmission/output_document.rb +27 -0
- data/lib/bankserv/transmission/record.rb +13 -0
- data/lib/bankserv/transmission/reply_document.rb +27 -0
- data/lib/bankserv/transmission/set.rb +120 -0
- data/lib/bankserv/transmission/set/account_holder_verification.rb +81 -0
- data/lib/bankserv/transmission/set/account_holder_verification_output.rb +17 -0
- data/lib/bankserv/transmission/set/credit.rb +44 -0
- data/lib/bankserv/transmission/set/debit.rb +44 -0
- data/lib/bankserv/transmission/set/document.rb +45 -0
- data/lib/bankserv/transmission/set/eft.rb +228 -0
- data/lib/bankserv/transmission/set/eft_output.rb +12 -0
- data/lib/bankserv/transmission/set/eft_redirect.rb +18 -0
- data/lib/bankserv/transmission/set/eft_unpaid.rb +18 -0
- data/lib/bankserv/transmission/set/reply.rb +47 -0
- data/lib/bankserv/transmission/statement.rb +46 -0
- data/lib/bankserv/version.rb +3 -0
- data/lib/config/ahv.yml +9 -0
- data/lib/core_extensions.rb +37 -0
- data/lib/generators/active_record/bankserv_generator.rb +30 -0
- data/lib/generators/active_record/templates/migration.rb +141 -0
- data/spec/examples/ahv_input_file.txt +7 -0
- data/spec/examples/ahv_output_file.txt +7 -0
- data/spec/examples/credit_eft_input.txt +166 -0
- data/spec/examples/debit_eft_input_file.txt +20 -0
- data/spec/examples/eft_input_with_2_sets.txt +8 -0
- data/spec/examples/eft_output_file.txt +35 -0
- data/spec/examples/host2host/tmp.log +1 -0
- data/spec/examples/reply/rejected_transmission.txt +7 -0
- data/spec/examples/reply/reply_file.txt +5 -0
- data/spec/examples/statement4_unpacked.dat +51 -0
- data/spec/examples/tmp/OUTPUT0412153500.txt +35 -0
- data/spec/examples/tmp/REPLY0412153000.txt +5 -0
- data/spec/factories.rb +90 -0
- data/spec/internal/config/database.yml.sample +3 -0
- data/spec/internal/config/routes.rb +3 -0
- data/spec/internal/db/schema.rb +138 -0
- data/spec/internal/log/.gitignore +1 -0
- data/spec/internal/public/favicon.ico +0 -0
- data/spec/lib/bankserv/account_holder_verification_spec.rb +104 -0
- data/spec/lib/bankserv/configuration_spec.rb +34 -0
- data/spec/lib/bankserv/core_ext_spec.rb +43 -0
- data/spec/lib/bankserv/credit_spec.rb +92 -0
- data/spec/lib/bankserv/debit_spec.rb +187 -0
- data/spec/lib/bankserv/engine/engine_spec.rb +142 -0
- data/spec/lib/bankserv/transaction_spec.rb +32 -0
- data/spec/lib/bankserv/transmission/input_document_spec.rb +207 -0
- data/spec/lib/bankserv/transmission/output_document_spec.rb +210 -0
- data/spec/lib/bankserv/transmission/reply_document_spec.rb +117 -0
- data/spec/lib/bankserv/transmission/set/account_holder_verification_spec.rb +108 -0
- data/spec/lib/bankserv/transmission/set/credit_spec.rb +96 -0
- data/spec/lib/bankserv/transmission/set/debit_spec.rb +103 -0
- data/spec/lib/bankserv/transmission/statement_spec.rb +109 -0
- data/spec/spec_helper.rb +28 -0
- data/spec/support/helpers.rb +207 -0
- metadata +223 -0
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Bankserv::Transaction do
|
4
|
+
include Helpers
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
tear_it_down
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should default the transaction to unprocessed when it is created" do
|
11
|
+
Bankserv::Transaction.create!
|
12
|
+
|
13
|
+
Bankserv::Transaction.last.processed.should == false
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should retrieve all unprocessed records" do
|
17
|
+
Bankserv::Transaction.create! data: {}, client_code: "1"
|
18
|
+
Bankserv::Transaction.create! data: {}, client_code: "2", processed: true
|
19
|
+
Bankserv::Transaction.create! data: {}, client_code: "3"
|
20
|
+
|
21
|
+
Bankserv::Transaction.unprocessed.count.should == 2
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should retrieve records by client code" do
|
25
|
+
transactions = 3.times.map do |i|
|
26
|
+
Bankserv::Transaction.create! data: {}, client_code: "345#{i}"
|
27
|
+
end
|
28
|
+
|
29
|
+
Bankserv::Transaction.for_client_code("3451").count.should == 1
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,207 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Bankserv::InputDocument do
|
4
|
+
include Helpers
|
5
|
+
|
6
|
+
context "building a transmission document containing two account holder verification requests" do
|
7
|
+
|
8
|
+
before(:each) do
|
9
|
+
tear_it_down
|
10
|
+
create(:configuration)
|
11
|
+
|
12
|
+
ahv_attributes = {
|
13
|
+
bank_account: {
|
14
|
+
account_number: "1094402524",
|
15
|
+
branch_code: "250255",
|
16
|
+
account_type: 'savings',
|
17
|
+
id_number: '6703085829086',
|
18
|
+
initials: "M",
|
19
|
+
account_name: "CHAUKE"
|
20
|
+
},
|
21
|
+
user_ref: "149505000060000223600000000000"
|
22
|
+
}
|
23
|
+
|
24
|
+
Bankserv::AccountHolderVerification.request(type: 'ahv', data: ahv_attributes)
|
25
|
+
ahv = Bankserv::AccountHolderVerification.last
|
26
|
+
ahv.internal = true
|
27
|
+
ahv.internal_user_ref = "AHV1"
|
28
|
+
ahv.save!
|
29
|
+
|
30
|
+
ahv_attributes = {
|
31
|
+
bank_account: {
|
32
|
+
account_number: "2968474669",
|
33
|
+
branch_code: "253265",
|
34
|
+
account_type: 'cheque',
|
35
|
+
id_number: '6103120039082',
|
36
|
+
initials: "A",
|
37
|
+
account_name: "VAN MOLENDORF"
|
38
|
+
},
|
39
|
+
user_ref: "198841000060000223600000000000"
|
40
|
+
}
|
41
|
+
|
42
|
+
Bankserv::AccountHolderVerification.request(type: 'ahv', data: ahv_attributes)
|
43
|
+
ahv = Bankserv::AccountHolderVerification.last
|
44
|
+
ahv.internal = true
|
45
|
+
ahv.internal_user_ref = "AHV2"
|
46
|
+
ahv.save!
|
47
|
+
|
48
|
+
ahv_attributes = {
|
49
|
+
bank_account: {
|
50
|
+
account_number: "2492008177",
|
51
|
+
branch_code: "253265",
|
52
|
+
account_type: 'cheque',
|
53
|
+
id_number: '8801261110087',
|
54
|
+
initials: "U",
|
55
|
+
account_name: "NKWEBA"
|
56
|
+
},
|
57
|
+
user_ref: "149205000060000223600000000000"
|
58
|
+
}
|
59
|
+
|
60
|
+
Bankserv::AccountHolderVerification.request(type: 'ahv', data: ahv_attributes)
|
61
|
+
ahv = Bankserv::AccountHolderVerification.last
|
62
|
+
ahv.internal = true
|
63
|
+
ahv.internal_user_ref = "AHV3"
|
64
|
+
ahv.save!
|
65
|
+
|
66
|
+
Bankserv::Configuration.should_receive(:department_code).and_return("000001")
|
67
|
+
t = Time.local(2009, 7, 3, 10, 5, 0)
|
68
|
+
Timecop.travel(t)
|
69
|
+
|
70
|
+
Bankserv::Configuration.stub!(:reserve_user_generation_number!).and_return("1")
|
71
|
+
Bankserv::InputDocument.stub!(:fetch_next_transmission_number).and_return("0")
|
72
|
+
Bankserv::Configuration.stub!(:live_env?).and_return(true)
|
73
|
+
|
74
|
+
Bankserv::InputDocument.generate!(
|
75
|
+
client_code: "2236",
|
76
|
+
client_name: "TEST",
|
77
|
+
th_for_use_of_ld_user: ""
|
78
|
+
)
|
79
|
+
|
80
|
+
@document = Bankserv::Document.last
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should mark the document as an input transmission" do
|
84
|
+
@document.type.should == "input"
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should build a new document" do
|
88
|
+
hash = @document.to_hash
|
89
|
+
|
90
|
+
string = File.open("./spec/examples/ahv_input_file.txt", "rb").read
|
91
|
+
options = Absa::H2h::Transmission::Document.hash_from_s(string, 'input')
|
92
|
+
|
93
|
+
hash.should == options
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should be able to mark a document as processed" do
|
97
|
+
@document.mark_processed!
|
98
|
+
@document.processed.should be_true
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
context "building a transmission document two batches of debit order requests" do
|
103
|
+
before(:all) do
|
104
|
+
Bankserv::Document.delete_all
|
105
|
+
Bankserv::Set.delete_all
|
106
|
+
Bankserv::Record.delete_all
|
107
|
+
Bankserv::AccountHolderVerification.delete_all
|
108
|
+
Bankserv::Debit.delete_all
|
109
|
+
|
110
|
+
tear_it_down
|
111
|
+
create(:configuration, client_code: "10", client_name: "LDC USER 10 AFRICA (PTY)", user_code: "9534", user_generation_number: 37, client_abbreviated_name: "ALIMITTST")
|
112
|
+
|
113
|
+
t = Time.local(2004, 5, 24, 10, 5, 0)
|
114
|
+
Timecop.travel(t)
|
115
|
+
|
116
|
+
debit = Bankserv::Debit.test_request({
|
117
|
+
type: 'debit',
|
118
|
+
data: {
|
119
|
+
type_of_service: "CORPSSV",
|
120
|
+
batches: [{
|
121
|
+
credit: {
|
122
|
+
account_number: "4053538939", branch_code: "632005", account_type: '1', id_number: '8207205263083', initials: "RC", account_name: "ALIMITTST", amount: 160280.00, user_ref: "CONTRA1040524 08", action_date: Date.today
|
123
|
+
},
|
124
|
+
debit: [
|
125
|
+
{ account_number: '1019611899', branch_code: "632005", account_type: "1", id_number: '', amount: 10.00, action_date: Date.today, account_name: "HENNIE DU TOIT", user_ref: 'SPP 1040524 01'},
|
126
|
+
{ account_number: '1019801892', branch_code: "632005", account_type: "1", id_number: '', amount: 20.00, action_date: Date.today, account_name: "TYRONE DREYDEN", user_ref: "SPP 1040524 02"},
|
127
|
+
{ account_number: '1021131896', branch_code: "632005", account_type: "1", id_number: '', amount: 30.00, action_date: Date.today, account_name: "KEITH MEIKLEJOHN",user_ref: "SPP 1040524 03"},
|
128
|
+
{ account_number: '1022131890', branch_code: "632005", account_type: "1", id_number: '', amount: 40.00, action_date: Date.today, account_name: "CHRISTO SPIES", user_ref: "SPP 1040524 04"},
|
129
|
+
{ account_number: '1057401890', branch_code: "632005", account_type: "1", id_number: '', amount: 60050.00, action_date: Date.today, account_name: "DENISE RETIEF", user_ref: "SPP 1040524 05"},
|
130
|
+
{ account_number: '18000010304',branch_code: "632005", account_type: "1", id_number: '', amount: 30060.00, action_date: Date.today, account_name: "PETER HAUPT", user_ref: "SPP 1040524 06"},
|
131
|
+
{ account_number: '1020861726', branch_code: "632005", account_type: "1", id_number: '', amount: 70070.00, action_date: Date.today, account_name: "HADLEY RAW", user_ref: "SPP 1040524 07"}
|
132
|
+
]
|
133
|
+
}, {
|
134
|
+
credit: {
|
135
|
+
account_number: "1004651894", branch_code: "632005", account_type: '1', id_number: '8207205263083', initials: "RC", account_name: "ALIMITTST", amount: 42800.00, user_ref: "CONTRA2040525 08", action_date: Date.tomorrow
|
136
|
+
},
|
137
|
+
debit: [
|
138
|
+
{ account_number: '1006221897', branch_code: "632005", account_type: "1", id_number: '', amount: 100.00, action_date: Date.tomorrow, account_name: "HENNIE DU TOIT", user_ref: 'SPP 2040525 01'},
|
139
|
+
{ account_number: '1006241898', branch_code: "632005", account_type: "1", id_number: '', amount: 200.00, action_date: Date.tomorrow, account_name: "TYRONE DREYDEN", user_ref: "SPP 2040525 02"},
|
140
|
+
{ account_number: '1009831891', branch_code: "632005", account_type: "1", id_number: '', amount: 40300.00,action_date: Date.tomorrow, account_name: "KEITH MEIKLEJOHN",user_ref: "SPP 2040525 03"},
|
141
|
+
{ account_number: '1010000609', branch_code: "632005", account_type: "1", id_number: '', amount: 400.00, action_date: Date.tomorrow, account_name: "CHRISTO SPIES", user_ref: "SPP 2040525 04"},
|
142
|
+
{ account_number: '1019141892', branch_code: "632005", account_type: "1", id_number: '', amount: 500.00, action_date: Date.tomorrow, account_name: "DENISE RETIEF", user_ref: "SPP 2040525 05"},
|
143
|
+
{ account_number: '1019591898', branch_code: "632005", account_type: "1", id_number: '', amount: 600.00, action_date: Date.tomorrow, account_name: "PETER HAUPT", user_ref: "SPP 2040525 06"},
|
144
|
+
{ account_number: '1020861726', branch_code: "632005", account_type: "1", id_number: '', amount: 700.00, action_date: Date.tomorrow, account_name: "HADLEY RAW", user_ref: "SPP 2040525 07"}
|
145
|
+
]
|
146
|
+
}]
|
147
|
+
}
|
148
|
+
})
|
149
|
+
end
|
150
|
+
|
151
|
+
it "should build a new document with debit sets and a header" do
|
152
|
+
Bankserv::InputDocument.stub!(:fetch_next_transmission_number).and_return("621")
|
153
|
+
|
154
|
+
Bankserv::InputDocument.generate_test!(
|
155
|
+
th_for_use_of_ld_user: ""
|
156
|
+
)
|
157
|
+
|
158
|
+
document = Bankserv::Document.last
|
159
|
+
hash = document.to_hash
|
160
|
+
|
161
|
+
string = File.open("./spec/examples/debit_eft_input_file.txt", "rb").read
|
162
|
+
options = Absa::H2h::Transmission::Document.hash_from_s(string, 'input')
|
163
|
+
|
164
|
+
hash.should == options
|
165
|
+
end
|
166
|
+
|
167
|
+
end
|
168
|
+
|
169
|
+
context "building a transmission document credit order requests" do
|
170
|
+
before(:all) do
|
171
|
+
Bankserv::Document.delete_all
|
172
|
+
Bankserv::Set.delete_all
|
173
|
+
Bankserv::Record.delete_all
|
174
|
+
Bankserv::AccountHolderVerification.delete_all
|
175
|
+
Bankserv::Debit.delete_all
|
176
|
+
Bankserv::Credit.delete_all
|
177
|
+
|
178
|
+
tear_it_down
|
179
|
+
create(:configuration, client_code: "986", client_name: "TESTTEST", user_code: "9999", user_generation_number: 846, client_abbreviated_name: "TESTTEST")
|
180
|
+
|
181
|
+
t = Time.local(2008, 8, 8, 10, 5, 0)
|
182
|
+
Timecop.travel(t)
|
183
|
+
|
184
|
+
create_credit_request
|
185
|
+
end
|
186
|
+
|
187
|
+
it "should build a new document with a credit set" do
|
188
|
+
Bankserv::Configuration.stub!(:live_env?).and_return(true)
|
189
|
+
Bankserv::InputDocument.stub!(:fetch_next_transmission_number).and_return("846")
|
190
|
+
|
191
|
+
Bankserv::Record.create! record_type:"standard_record", data: {user_sequence_number: 77}, set_id: 76876
|
192
|
+
|
193
|
+
Bankserv::InputDocument.generate!(
|
194
|
+
th_for_use_of_ld_user: ""
|
195
|
+
)
|
196
|
+
|
197
|
+
document = Bankserv::Document.last
|
198
|
+
hash = document.to_hash
|
199
|
+
|
200
|
+
string = File.open("./spec/examples/credit_eft_input.txt", "rb").read
|
201
|
+
options = Absa::H2h::Transmission::Document.hash_from_s(string, 'input')
|
202
|
+
|
203
|
+
hash.should == options
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
end
|
@@ -0,0 +1,210 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Bankserv::OutputDocument do
|
4
|
+
include Helpers
|
5
|
+
|
6
|
+
context "processing an output document" do
|
7
|
+
|
8
|
+
it "should raise an exception if the document has already been processed" do
|
9
|
+
document = create(:output_document, :processed)
|
10
|
+
|
11
|
+
lambda { document.process! }.should raise_error(Exception, "Document already processed")
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should mark the document as processed once the document's set has been processed" do
|
15
|
+
document_set = mock(Bankserv::Set)
|
16
|
+
document_set.should_receive(:process)
|
17
|
+
|
18
|
+
document = create(:output_document)
|
19
|
+
document.stub!(:set).and_return(document_set)
|
20
|
+
|
21
|
+
document.process!
|
22
|
+
Bankserv::Document.last.should be_processed
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context "storing an output transmission containing an account holder verification set" do
|
27
|
+
|
28
|
+
before(:all) do
|
29
|
+
tear_it_down
|
30
|
+
create(:configuration)
|
31
|
+
|
32
|
+
@file_contents = File.open("./spec/examples/ahv_output_file.txt", "rb").read
|
33
|
+
@options = Absa::H2h::Transmission::Document.hash_from_s(@file_contents, 'output')
|
34
|
+
|
35
|
+
@document = Bankserv::OutputDocument.store(@file_contents)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should mark the document as an output transmission" do
|
39
|
+
@document.type.should == "output"
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should store a document, set and records that produce the same data as was provided" do
|
43
|
+
@document.to_hash.should == @options
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should produce the exact same file contents when the transmission is rebuilt" do
|
47
|
+
absa_document = Absa::H2h::Transmission::Document.build(@document.to_hash[:data])
|
48
|
+
absa_document.to_s.should == @file_contents
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should be able to process the document, updating any related account holder verifications" do
|
52
|
+
ahv1 = Bankserv::AccountHolderVerification.new(
|
53
|
+
bank_account: Bankserv::BankAccount.new(
|
54
|
+
account_number: "1094402524",
|
55
|
+
branch_code: "250255",
|
56
|
+
account_type: 'savings',
|
57
|
+
id_number: '6703085829086',
|
58
|
+
initials: "M",
|
59
|
+
account_name: "CHAUKE"
|
60
|
+
),
|
61
|
+
user_ref: "149505000000000223600000008000",
|
62
|
+
internal: true
|
63
|
+
)
|
64
|
+
|
65
|
+
ahv1.save!
|
66
|
+
ahv1.internal_user_ref = "AHV1"
|
67
|
+
ahv1.save!
|
68
|
+
|
69
|
+
ahv2 = Bankserv::AccountHolderVerification.new(
|
70
|
+
bank_account: Bankserv::BankAccount.new(
|
71
|
+
account_number: "2968474669",
|
72
|
+
branch_code: "253265",
|
73
|
+
account_type: 'cheque',
|
74
|
+
id_number: '6103120039082',
|
75
|
+
initials: "A",
|
76
|
+
account_name: "VAN MOLENDORF"
|
77
|
+
),
|
78
|
+
user_ref: "198841000000000223600000000000",
|
79
|
+
internal: true
|
80
|
+
)
|
81
|
+
|
82
|
+
ahv2.save!
|
83
|
+
ahv2.internal_user_ref = "AHV2"
|
84
|
+
ahv2.save!
|
85
|
+
|
86
|
+
ahv3 = Bankserv::AccountHolderVerification.new(
|
87
|
+
bank_account: Bankserv::BankAccount.new(
|
88
|
+
account_number: "2492008177",
|
89
|
+
branch_code: "253265",
|
90
|
+
account_type: 'cheque',
|
91
|
+
id_number: '8801261110087',
|
92
|
+
initials: "U",
|
93
|
+
account_name: "NKWEBA"
|
94
|
+
),
|
95
|
+
user_ref: "149205000000000223605000700000",
|
96
|
+
internal: true
|
97
|
+
)
|
98
|
+
|
99
|
+
ahv3.save!
|
100
|
+
ahv3.internal_user_ref = "AHV3"
|
101
|
+
ahv3.save!
|
102
|
+
|
103
|
+
Bankserv::AccountHolderVerification.for_reference("149505000000000223600000008000").first.completed?.should be_false
|
104
|
+
Bankserv::AccountHolderVerification.for_reference("198841000000000223600000000000").first.completed?.should be_false
|
105
|
+
Bankserv::AccountHolderVerification.for_reference("149205000000000223605000700000").first.completed?.should be_false
|
106
|
+
|
107
|
+
@document.process!
|
108
|
+
|
109
|
+
Bankserv::AccountHolderVerification.for_reference("149505000000000223600000008000").first.completed?.should be_true
|
110
|
+
Bankserv::AccountHolderVerification.for_reference("198841000000000223600000000000").first.completed?.should be_true
|
111
|
+
Bankserv::AccountHolderVerification.for_reference("149205000000000223605000700000").first.completed?.should be_true
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
115
|
+
|
116
|
+
context "storing an output transmission containing an eft set of debit transactions" do
|
117
|
+
|
118
|
+
before(:all) do
|
119
|
+
tear_it_down
|
120
|
+
create(:configuration)
|
121
|
+
|
122
|
+
@file_contents = File.open("./spec/examples/eft_output_file.txt", "rb").read
|
123
|
+
@options = Absa::H2h::Transmission::Document.hash_from_s(@file_contents, 'output')
|
124
|
+
|
125
|
+
@document = Bankserv::OutputDocument.store(@file_contents)
|
126
|
+
end
|
127
|
+
|
128
|
+
it "should mark the document as an output transmission" do
|
129
|
+
@document.should be_output
|
130
|
+
end
|
131
|
+
|
132
|
+
it "should mark the document as requiring processing" do
|
133
|
+
@document.should_not be_processed
|
134
|
+
end
|
135
|
+
|
136
|
+
it "should store a document, set and records that produce the same data as was provided" do
|
137
|
+
@document.to_hash.should == @options
|
138
|
+
end
|
139
|
+
|
140
|
+
end
|
141
|
+
|
142
|
+
context "processing an output document containing an eft set of debit transactions" do
|
143
|
+
|
144
|
+
before(:each) do
|
145
|
+
tear_it_down
|
146
|
+
create(:configuration)
|
147
|
+
|
148
|
+
@file_contents = File.open("./spec/examples/eft_output_file.txt", "rb").read
|
149
|
+
@options = Absa::H2h::Transmission::Document.hash_from_s(@file_contents, 'output')
|
150
|
+
|
151
|
+
@document = Bankserv::OutputDocument.store(@file_contents)
|
152
|
+
end
|
153
|
+
|
154
|
+
it "should be able to process the document, updating any related debit or credit requests" do
|
155
|
+
debits = []
|
156
|
+
debits << Bankserv::Debit.create!(record_type: "standard", amount: 7627, batch_id: 1, user_ref: "A LDC TESTY PREMIE AL0597626X5")
|
157
|
+
debits << Bankserv::Debit.create!(record_type: "standard", amount: 9964, batch_id: 1, user_ref: "A LDC TESTY PREMIE AL0394056X3")
|
158
|
+
debits << Bankserv::Debit.create!(record_type: "standard", amount: 10851, batch_id: 2, user_ref: "A LDC TESTY PREMIE AL0620127X9")
|
159
|
+
debits << Bankserv::Debit.create!(record_type: "standard", amount: 31700, batch_id: 3, user_ref: "A LDC TESTM PREMIE AL0876267X2")
|
160
|
+
debits << Bankserv::Debit.create!(record_type: "standard", amount: 13755, batch_id: 3, user_ref: "A LDC TESTY PREMIE AL0699555X1")
|
161
|
+
debits << Bankserv::Debit.create!(record_type: "standard", amount: 22935, batch_id: 4, user_ref: "A LDC TESTSALARIS BL ROODT")
|
162
|
+
debits << Bankserv::Debit.create!(record_type: "standard", amount: 15198, batch_id: 4, user_ref: "A LDC TESTKREDITEUR L0844622KL")
|
163
|
+
debits << Bankserv::Debit.create!(record_type: "standard", amount: 12720, batch_id: 4, user_ref: "A LDC TESTVERSEKERING 01BLOR3")
|
164
|
+
debits << Bankserv::Debit.create!(record_type: "standard", amount: 9345, batch_id: 4, user_ref: "A LDC TESTSALARIS SOEKIE 12345")
|
165
|
+
debits << Bankserv::Debit.create!(record_type: "standard", amount: 13420, batch_id: 4, user_ref: "A LDC TESTSALARIS BL ROODT")
|
166
|
+
debits << Bankserv::Debit.create!(record_type: "standard", amount: 15300, batch_id: 4, user_ref: "A LDC TESTSALARIS BL ROODT")
|
167
|
+
debits << Bankserv::Debit.create!(record_type: "standard", amount: 7790, batch_id: 4, user_ref: "A LDC TESTSANLAM AL0849 61X3")
|
168
|
+
debits << Bankserv::Debit.create!(record_type: "standard", amount: 19698, batch_id: 4, user_ref: "A LDC TESTSOUTHERN LIFE 4627K5")
|
169
|
+
debits << Bankserv::Debit.create!(record_type: "standard", amount: 5000, batch_id: 4, user_ref: "A LDC TESTHUISVERBAND 98173587")
|
170
|
+
debits << Bankserv::Debit.create!(record_type: "standard", amount: 10420, batch_id: 4, user_ref: "A LDC TESTPERSOONLIKE LENING")
|
171
|
+
debits << Bankserv::Debit.create!(record_type: "standard", amount: 10000, batch_id: 4, user_ref: "A LDC TESTSPAARKLUB OKT 2001")
|
172
|
+
debits << Bankserv::Debit.create!(record_type: "standard", amount: 15000, batch_id: 4, user_ref: "A LDC TESTY PREMIE XAZAP1163V5")
|
173
|
+
debits << Bankserv::Debit.create!(record_type: "standard", amount: 10000, batch_id: 4, user_ref: "A LDC TESTQ PREMIE BLASNK158X4")
|
174
|
+
debits << Bankserv::Debit.create!(record_type: "standard", amount: 16150, batch_id: 4, user_ref: "A LDC TESTY PREMIE ALONE6728X1")
|
175
|
+
debits << Bankserv::Debit.create!(record_type: "standard", amount: 12300, batch_id: 4, user_ref: "A LDC TESTM PREMIUM LZANA602F3")
|
176
|
+
debits << Bankserv::Debit.create!(record_type: "standard", amount: 20000, batch_id: 4, user_ref: "A LDC TESTY PREMIE SP0001453X0")
|
177
|
+
debits << Bankserv::Debit.create!(record_type: "standard", amount: 6287, batch_id: 4, user_ref: "A LDC TESTW INSTALMENT ND263XZ")
|
178
|
+
debits << Bankserv::Debit.create!(record_type: "standard", amount: 8954, batch_id: 4, user_ref: "A LDC TESTY PROTECTION 9697523")
|
179
|
+
|
180
|
+
counter = 1
|
181
|
+
|
182
|
+
debits.each do |debit|
|
183
|
+
debit.internal_user_ref = "DEBIT#{counter}"
|
184
|
+
debit.save!
|
185
|
+
counter += 1
|
186
|
+
end
|
187
|
+
|
188
|
+
Bankserv::Debit.all.each{|debit| debit.completed?.should be_false}
|
189
|
+
@document.process!
|
190
|
+
|
191
|
+
Bankserv::Debit.all.each do |debit|
|
192
|
+
(debit.completed? or debit.unpaid? or debit.redirect?).should be_true
|
193
|
+
|
194
|
+
if debit.unpaid?
|
195
|
+
debit.response.has_key?(:rejection_reason).should be_true
|
196
|
+
debit.response.has_key?(:rejection_reason_description).should be_true
|
197
|
+
debit.response.has_key?(:rejection_qualifier).should be_true
|
198
|
+
debit.response.has_key?(:rejection_qualifier_description).should be_true
|
199
|
+
elsif debit.redirect?
|
200
|
+
debit.response.has_key?(:new_homing_branch).should be_true
|
201
|
+
debit.response.has_key?(:new_homing_account_number).should be_true
|
202
|
+
debit.response.has_key?(:new_homing_account_type).should be_true
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
end
|
208
|
+
|
209
|
+
|
210
|
+
end
|