bankserv 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
@@ -11,6 +11,7 @@ module Bankserv
|
|
11
11
|
|
12
12
|
rejections = []
|
13
13
|
records_with_errors = []
|
14
|
+
reply_file_rejected = false
|
14
15
|
|
15
16
|
transactions.each do |transaction|
|
16
17
|
case transaction.record_type
|
@@ -27,10 +28,19 @@ module Bankserv
|
|
27
28
|
end
|
28
29
|
|
29
30
|
when "transmission_rejected_reason"
|
31
|
+
reply_file_rejected = true
|
32
|
+
|
30
33
|
input_document.error = {
|
31
34
|
code: transaction.data[:error_code],
|
32
35
|
message: transaction.data[:error_message]
|
33
36
|
}
|
37
|
+
|
38
|
+
if service.is_a?(Bankserv::CreditService) && transaction.data[:error_code] == "6"
|
39
|
+
# transmission number is incorrect, fetch the last accepted input file trans number and increment by 1
|
40
|
+
last_successful_submission = Bankserv::Document.where(type: 'input', client_code: service.client_code, reply_status: "ACCEPTED").last
|
41
|
+
service.config[:transmission_number] = (last_successful_submission.transmission_number.to_i + 1).to_s
|
42
|
+
service.save!
|
43
|
+
end
|
34
44
|
|
35
45
|
input_document.save!
|
36
46
|
when "ahv_status"
|
@@ -42,6 +52,22 @@ module Bankserv
|
|
42
52
|
set = input_document.set_with_generation_number(transaction.data[:user_code_generation_number])
|
43
53
|
set.reply_status = transaction.data[:user_set_status]
|
44
54
|
set.save!
|
55
|
+
|
56
|
+
if reply_file_rejected
|
57
|
+
rejections << transaction
|
58
|
+
|
59
|
+
if service.is_a? Bankserv::CreditService
|
60
|
+
set = input_document.set_with_generation_number(transaction.data[:user_code_generation_number])
|
61
|
+
next if set.contra_records.empty?
|
62
|
+
user_ref = set.contra_records.first.reference.match(/CONTRA([0-9]*)/)[1]
|
63
|
+
request_id = Bankserv::Credit.where(user_ref: user_ref)[0].bankserv_request_id
|
64
|
+
|
65
|
+
Bankserv::Credit.where(bankserv_request_id: request_id).each do |credit|
|
66
|
+
credit.renew!
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
45
71
|
when "accepted_report_reply"
|
46
72
|
# what do we do here.. what is an accepted report reply?
|
47
73
|
if transaction.data[:accepted_report_transaction][4,2] == "12" # Contra record
|
@@ -106,28 +132,13 @@ module Bankserv
|
|
106
132
|
|
107
133
|
unless rejections.empty?
|
108
134
|
service.config[:generation_number] = rejections.first.data[:user_code_generation_number].to_i
|
109
|
-
|
135
|
+
unless rejections.first.data.has_key?(:user_sequence_number) # Transmission number out of sequence, reset to 1
|
136
|
+
service.config[:sequence_number] = 1
|
137
|
+
else
|
138
|
+
service.config[:sequence_number] = rejections.first.data[:user_sequence_number].to_i
|
139
|
+
end
|
110
140
|
service.save!
|
111
141
|
end
|
112
|
-
|
113
|
-
#records_with_errors.uniq.each do |rwe|
|
114
|
-
|
115
|
-
#end
|
116
|
-
# rejections.each do |rejection|
|
117
|
-
|
118
|
-
# set = input_document.set_with_generation_number(rejection.data[:user_code_generation_number])
|
119
|
-
# user_ref = set.contra_records.first.reference.match(/CONTRA([0-9]*)/)[1]
|
120
|
-
# request_id = Bankserv::Credit.where(user_ref: user_ref)[0].bankserv_request_id
|
121
|
-
# # if service.is_a? Bankserv::CreditService
|
122
|
-
# # set = input_document.set_with_generation_number(transaction.data[:user_code_generation_number])
|
123
|
-
# # user_ref = set.contra_records.first.reference.match(/CONTRA([0-9]*)/)[1]
|
124
|
-
# # request_id = Bankserv::Credit.where(user_ref: user_ref)[0].bankserv_request_id
|
125
|
-
|
126
|
-
# # Bankserv::Credit.where(bankserv_request_id: request_id).each do |credit|
|
127
|
-
# # credit.renew!
|
128
|
-
# # end
|
129
|
-
# # end
|
130
|
-
# end
|
131
142
|
end
|
132
143
|
end
|
133
144
|
end
|
data/lib/bankserv/version.rb
CHANGED
@@ -0,0 +1,6 @@
|
|
1
|
+
000L2014072604136RENTAL CONNECT PTY LTD 000036900000 2431
|
2
|
+
020L04A8551407261407261407261407260000016535BATCH YY
|
3
|
+
020L1063200504079323748A85500000125400562270571576100000225194140726880 RAWSONPROP001701 LA HABANA BODY CORPORATE 00000000000000000000 21
|
4
|
+
020L1263200504079323748A85500000263200504079323748100000225194140726100000RAWSONPROPCONTRA6631
|
5
|
+
020L92A855000001000002140726140726000001000001000001000000225194000000225194066349895324
|
6
|
+
999L000000006
|
@@ -243,6 +243,64 @@ describe Bankserv::ReplyDocument do
|
|
243
243
|
end
|
244
244
|
|
245
245
|
end
|
246
|
+
|
247
|
+
context "Process a reply file with trans number not next in sequence" do
|
248
|
+
|
249
|
+
before(:each) do
|
250
|
+
tear_it_down
|
251
|
+
@cs = Bankserv::CreditService.register(client_code: '04136', client_name: "RENTAL CONNECT PTY LTD", client_abbreviated_name: 'RAWSONPROP', user_code: "A855", generation_number: 6365, transmission_status: "L", transmission_number: "369", sequence_number: 57)
|
252
|
+
|
253
|
+
Bankserv::Document.create!(type: "input", set_id: 18242, processed: true, transmission_status: "L", rec_status: "L", transmission_number: "367", reply_status: "ACCEPTED", error: nil, created_at: "2014-07-25 15:10:24", updated_at: "2014-07-25 16:30:22", client_code: "04136", user_ref: "2426")
|
254
|
+
@file_contents = File.open("./spec/examples/input_with_wrong_trans_num.txt", "rb").read
|
255
|
+
@input_document = Bankserv::InputDocument.store(@file_contents)
|
256
|
+
|
257
|
+
options = Absa::H2h::Transmission::Document.hash_from_s(@file_contents, 'input')
|
258
|
+
options[:data].each do |entry|
|
259
|
+
if entry[:data].count == 4
|
260
|
+
c = entry[:data].map {|x| x[:data]}
|
261
|
+
request = Bankserv::Request.create!({
|
262
|
+
type: "credit",
|
263
|
+
data: {
|
264
|
+
:type_of_service=>"BATCH",
|
265
|
+
:batches=>[{
|
266
|
+
:debit=>{:account_number=>c[2][:homing_account_number], :id_number=>"", :initials=>"", :account_name=>c[2][:homing_account_name], :branch_code=>c[2][:homing_branch], :account_type=>"cheque", :amount=>c[2][:amount], :user_ref=>c[2][:user_ref].gsub("RAWSONPROPCONTRA", ""), :action_date=>"2014-07-15".to_date},
|
267
|
+
:credit=>{:account_number=>c[1][:homing_account_number], :id_number=>"", :initials=>"", :account_name=>c[1][:homing_account_name], :branch_code=>c[1][:homing_branch], :account_type=>"cheque", :amount=>c[1][:amount], :user_ref=>c[1][:user_ref].gsub("RAWSONPROP", ""), :action_date=>"2014-07-15".to_date}
|
268
|
+
}]
|
269
|
+
}
|
270
|
+
})
|
271
|
+
|
272
|
+
request.service_id = @cs.id
|
273
|
+
request.save!
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
277
|
+
Bankserv::Credit.all.each {|x| x.status="pending";x.save!}
|
278
|
+
|
279
|
+
@file_contents = File.open("./spec/examples/reply/transnumber_wrong.txt", "rb").read
|
280
|
+
|
281
|
+
@document = Bankserv::ReplyDocument.store(@file_contents)
|
282
|
+
@document.process!
|
283
|
+
@cs.reload
|
284
|
+
end
|
285
|
+
|
286
|
+
it "should reverse the credit service transmission number by 1" do
|
287
|
+
Bankserv::CreditService.last.config[:transmission_number].should == "368"
|
288
|
+
end
|
289
|
+
|
290
|
+
it "should reset the generation number" do
|
291
|
+
Bankserv::CreditService.last.config[:generation_number].should == 6535
|
292
|
+
end
|
293
|
+
|
294
|
+
it "should reset the user sequence number" do
|
295
|
+
Bankserv::CreditService.last.config[:sequence_number].should == 1
|
296
|
+
end
|
297
|
+
|
298
|
+
it "should resubmit the credits" do
|
299
|
+
Bankserv::Credit.all.each do |credit|
|
300
|
+
credit.status.should == "new"
|
301
|
+
end
|
302
|
+
end
|
303
|
+
end
|
246
304
|
|
247
305
|
|
248
306
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 7
|
8
|
-
-
|
9
|
-
version: 0.7.
|
8
|
+
- 1
|
9
|
+
version: 0.7.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Jeffrey van Aswegen
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2014-07-
|
18
|
+
date: 2014-07-28 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -186,6 +186,7 @@ files:
|
|
186
186
|
- spec/examples/empty_output.txt
|
187
187
|
- spec/examples/failed_output_file.txt
|
188
188
|
- spec/examples/host2host/tmp.log
|
189
|
+
- spec/examples/input_with_wrong_trans_num.txt
|
189
190
|
- spec/examples/notify_me.xml
|
190
191
|
- spec/examples/notify_me_with_one_record.xml
|
191
192
|
- spec/examples/reply/accepted_and_rejected_transactions.txt
|
@@ -193,6 +194,7 @@ files:
|
|
193
194
|
- spec/examples/reply/rejected_transmission.txt
|
194
195
|
- spec/examples/reply/reply2.txt
|
195
196
|
- spec/examples/reply/reply_file.txt
|
197
|
+
- spec/examples/reply/transnumber_wrong.txt
|
196
198
|
- spec/examples/simple_input_file.txt
|
197
199
|
- spec/examples/statement4_unpacked.dat
|
198
200
|
- spec/examples/tmp/OUTPUT0412153500.txt
|
@@ -270,6 +272,7 @@ test_files:
|
|
270
272
|
- spec/examples/empty_output.txt
|
271
273
|
- spec/examples/failed_output_file.txt
|
272
274
|
- spec/examples/host2host/tmp.log
|
275
|
+
- spec/examples/input_with_wrong_trans_num.txt
|
273
276
|
- spec/examples/notify_me.xml
|
274
277
|
- spec/examples/notify_me_with_one_record.xml
|
275
278
|
- spec/examples/reply/accepted_and_rejected_transactions.txt
|
@@ -277,6 +280,7 @@ test_files:
|
|
277
280
|
- spec/examples/reply/rejected_transmission.txt
|
278
281
|
- spec/examples/reply/reply2.txt
|
279
282
|
- spec/examples/reply/reply_file.txt
|
283
|
+
- spec/examples/reply/transnumber_wrong.txt
|
280
284
|
- spec/examples/simple_input_file.txt
|
281
285
|
- spec/examples/statement4_unpacked.dat
|
282
286
|
- spec/examples/tmp/OUTPUT0412153500.txt
|