bankserv 0.6.5 → 0.6.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/bankserv/credit.rb +5 -0
- data/lib/bankserv/engine.rb +55 -81
- data/lib/bankserv/transmission/set/reply.rb +54 -5
- data/lib/bankserv/version.rb +1 -1
- data/spec/examples/accepted_and_rejected_input_file.txt +114 -0
- data/spec/examples/reply/accepted_and_rejected_transactions.txt +102 -0
- data/spec/lib/bankserv/transmission/output_document_spec.rb +0 -2
- data/spec/lib/bankserv/transmission/reply_document_spec.rb +59 -4
- metadata +7 -3
data/lib/bankserv/credit.rb
CHANGED
data/lib/bankserv/engine.rb
CHANGED
@@ -5,21 +5,22 @@ module Bankserv
|
|
5
5
|
|
6
6
|
def initialize(service)
|
7
7
|
@service = service
|
8
|
+
@success = true
|
8
9
|
@logs = {
|
9
10
|
reply_files: [],
|
10
11
|
output_files: [],
|
11
12
|
input_files: []
|
12
13
|
}
|
13
|
-
|
14
|
-
@success = true
|
15
14
|
end
|
16
15
|
|
17
16
|
def process!
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
17
|
+
EngineProcess.transaction do
|
18
|
+
self.start!
|
19
|
+
self.process_reply_files
|
20
|
+
self.process_output_files
|
21
|
+
self.process_input_files
|
22
|
+
self.finish!
|
23
|
+
end
|
23
24
|
# self.perform_post_checks!
|
24
25
|
end
|
25
26
|
|
@@ -28,25 +29,19 @@ module Bankserv
|
|
28
29
|
end
|
29
30
|
|
30
31
|
def process_reply_files
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
@logs[:reply_files] << "#{file} Archived."
|
45
|
-
end
|
46
|
-
rescue Exception => e
|
47
|
-
@logs[:reply_files] << "Error occured! #{e.message}"
|
48
|
-
@logs[:reply_files] << "Backtrace: #{e.backtrace}"
|
49
|
-
@success = false
|
32
|
+
Engine.reply_files(@service).each do |file|
|
33
|
+
@logs[:reply_files] << "Processing #{file}."
|
34
|
+
|
35
|
+
# contents = File.open("#{Bankserv::Engine.output_directory}/#{file}", "rb").read
|
36
|
+
contents = File.open("#{@service.config[:reply_directory]}/#{file}", "rb").read
|
37
|
+
|
38
|
+
document = Bankserv::ReplyDocument.store(contents)
|
39
|
+
document.process!
|
40
|
+
|
41
|
+
@logs[:reply_files] << "Processing #{file}. Complete."
|
42
|
+
|
43
|
+
self.archive_file!("#{@service.config[:incoming_directory]}/#{file}")
|
44
|
+
@logs[:reply_files] << "#{file} Archived."
|
50
45
|
end
|
51
46
|
end
|
52
47
|
|
@@ -54,57 +49,43 @@ module Bankserv
|
|
54
49
|
# ------------------------------------------------------------------------------------------------------------
|
55
50
|
# | NB: ABSA place output files in our incoming directory! They take our input files from our outgoing folder.|
|
56
51
|
# ------------------------------------------------------------------------------------------------------------
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
document = Bankserv::OutputDocument.store(contents)
|
69
|
-
end
|
70
|
-
|
71
|
-
document.process!
|
72
|
-
|
73
|
-
@logs[:output_files] << "Processing #{file}. Complete."
|
74
|
-
|
75
|
-
self.archive_file!("#{@service.config[:incoming_directory]}/#{file}")
|
76
|
-
@logs[:output_files] << "#{file} Archived."
|
52
|
+
Engine.output_files(@service).each do |file|
|
53
|
+
@logs[:output_files] << "Processing #{file}."
|
54
|
+
|
55
|
+
contents = File.open("#{@service.config[:incoming_directory]}/#{file}", "rb").read
|
56
|
+
|
57
|
+
if @service.is_a? Bankserv::StatementService
|
58
|
+
document = Bankserv::Statement.store(contents)
|
59
|
+
elsif @service.is_a? Bankserv::NotifyMeStatementService
|
60
|
+
document = Bankserv::NotifyMeStatement.store("#{@service.config[:incoming_directory]}/#{file}")
|
61
|
+
else
|
62
|
+
document = Bankserv::OutputDocument.store(contents)
|
77
63
|
end
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
@
|
64
|
+
|
65
|
+
document.process!
|
66
|
+
|
67
|
+
@logs[:output_files] << "Processing #{file}. Complete."
|
68
|
+
|
69
|
+
self.archive_file!("#{@service.config[:incoming_directory]}/#{file}")
|
70
|
+
@logs[:output_files] << "#{file} Archived."
|
82
71
|
end
|
83
72
|
end
|
84
73
|
|
85
|
-
def process_input_files
|
86
|
-
|
87
|
-
begin
|
88
|
-
return if self.expecting_reply_file?(@service)
|
74
|
+
def process_input_files
|
75
|
+
return if self.expecting_reply_file?(@service)
|
89
76
|
|
90
|
-
|
77
|
+
document = nil
|
91
78
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
end
|
79
|
+
Bankserv::Service.transaction do
|
80
|
+
document = Bankserv::InputDocument.generate!(@service)
|
81
|
+
if document
|
82
|
+
@logs[:input_files] << "Input Document created with id: #{document.id}"
|
83
|
+
|
84
|
+
if self.write_file!(document)
|
85
|
+
document.mark_processed!
|
100
86
|
end
|
101
87
|
end
|
102
|
-
rescue Exception => e
|
103
|
-
@logs[:input_files] << "Error occured! #{e.message}"
|
104
|
-
@logs[:input_files] << "Backtrace: #{e.backtrace}"
|
105
|
-
@success = false
|
106
88
|
end
|
107
|
-
# end
|
108
89
|
end
|
109
90
|
|
110
91
|
def input_services
|
@@ -112,20 +93,13 @@ module Bankserv
|
|
112
93
|
end
|
113
94
|
|
114
95
|
def write_file!(document)
|
115
|
-
|
116
|
-
|
117
|
-
file_name = generate_input_file_name(document)
|
118
|
-
|
119
|
-
File.open("#{@service.config[:outgoing_directory]}/#{file_name}", 'w') { |f|
|
120
|
-
f.write transmission
|
121
|
-
}
|
122
|
-
@logs[:input_files] << "Input Document File created. File name: #{file_name}"
|
123
|
-
rescue Exception => e
|
124
|
-
@logs[:input_files] << "Error occured. #{e.message}"
|
125
|
-
@logs[:input_files] << "Backtrace: #{e.backtrace}"
|
126
|
-
return false
|
127
|
-
end
|
96
|
+
transmission = Absa::H2h::Transmission::Document.build([document.to_hash])
|
97
|
+
file_name = generate_input_file_name(document)
|
128
98
|
|
99
|
+
File.open("#{@service.config[:outgoing_directory]}/#{file_name}", 'w') { |f|
|
100
|
+
f.write transmission
|
101
|
+
}
|
102
|
+
@logs[:input_files] << "Input Document File created. File name: #{file_name}"
|
129
103
|
true
|
130
104
|
end
|
131
105
|
|
@@ -9,6 +9,9 @@ module Bankserv
|
|
9
9
|
#service = Bankserv::Service.active.select {|s| s.config[:user_code] == self.records.first.data[:user_code]}.last
|
10
10
|
service = Bankserv::Service.active.select {|s| s.client_code.to_i.to_s == self.records.first.data[:user_code]}.last
|
11
11
|
|
12
|
+
rejections = []
|
13
|
+
records_with_errors = []
|
14
|
+
|
12
15
|
transactions.each do |transaction|
|
13
16
|
case transaction.record_type
|
14
17
|
when "transmission_status"
|
@@ -44,6 +47,7 @@ module Bankserv
|
|
44
47
|
if transaction.data[:accepted_report_transaction][4,2] == "12" # Contra record
|
45
48
|
if service.is_a? Bankserv::CreditService
|
46
49
|
user_ref = transaction.data[:accepted_report_transaction].match(/CONTRA([0-9]*)/)[1]
|
50
|
+
|
47
51
|
request_id = Bankserv::Credit.where(user_ref: user_ref)[0].bankserv_request_id
|
48
52
|
Bankserv::Credit.where(bankserv_request_id: request_id).each do |credit|
|
49
53
|
credit.accept!
|
@@ -51,19 +55,64 @@ module Bankserv
|
|
51
55
|
end
|
52
56
|
end
|
53
57
|
when "rejected_message"
|
58
|
+
rejections << transaction
|
59
|
+
|
54
60
|
if transaction.data[:user_sequence_number].to_i > 0
|
55
61
|
set = input_document.set_with_generation_number(transaction.data[:user_code_generation_number])
|
56
62
|
record = set.record_with_sequence_number(transaction.data[:user_sequence_number])
|
57
|
-
|
58
|
-
record.error
|
59
|
-
|
60
|
-
|
61
|
-
|
63
|
+
|
64
|
+
if record.error.nil?
|
65
|
+
record.error = [{
|
66
|
+
code: transaction.data[:error_code],
|
67
|
+
message: transaction.data[:error_message]
|
68
|
+
}]
|
69
|
+
else
|
70
|
+
record.error << {
|
71
|
+
code: transaction.data[:error_code],
|
72
|
+
message: transaction.data[:error_message]
|
73
|
+
}
|
74
|
+
end
|
62
75
|
|
63
76
|
record.save!
|
77
|
+
|
78
|
+
if service.is_a? Bankserv::CreditService
|
79
|
+
next if set.contra_records.empty?
|
80
|
+
|
81
|
+
set = input_document.set_with_generation_number(transaction.data[:user_code_generation_number])
|
82
|
+
user_ref = set.contra_records.first.reference.match(/CONTRA([0-9]*)/)[1]
|
83
|
+
request_id = Bankserv::Credit.where(user_ref: user_ref)[0].bankserv_request_id
|
84
|
+
|
85
|
+
Bankserv::Credit.where(bankserv_request_id: request_id).each do |credit|
|
86
|
+
credit.renew!
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
records_with_errors << record
|
91
|
+
else
|
92
|
+
# Only 1 error due to a transaction above it failing. We can requeue this transaction to be processed again
|
93
|
+
|
94
|
+
if service.is_a? Bankserv::CreditService
|
95
|
+
set = input_document.set_with_generation_number(transaction.data[:user_code_generation_number])
|
96
|
+
user_ref = set.contra_records.first.reference.match(/CONTRA([0-9]*)/)[1]
|
97
|
+
request_id = Bankserv::Credit.where(user_ref: user_ref)[0].bankserv_request_id
|
98
|
+
|
99
|
+
Bankserv::Credit.where(bankserv_request_id: request_id).each do |credit|
|
100
|
+
credit.renew!
|
101
|
+
end
|
102
|
+
end
|
64
103
|
end
|
65
104
|
end
|
66
105
|
end
|
106
|
+
|
107
|
+
unless rejections.empty?
|
108
|
+
service.config[:generation_number] = rejections.first.data[:user_code_generation_number].to_i
|
109
|
+
service.config[:sequence_number] = rejections.first.data[:user_sequence_number].to_i
|
110
|
+
service.save!
|
111
|
+
end
|
112
|
+
|
113
|
+
records_with_errors.uniq.each do |rwe|
|
114
|
+
#puts rwe.error.inspect
|
115
|
+
end
|
67
116
|
end
|
68
117
|
end
|
69
118
|
end
|
data/lib/bankserv/version.rb
CHANGED
@@ -0,0 +1,114 @@
|
|
1
|
+
000L2014071504136RENTAL CONNECT PTY LTD 000035000000 2363
|
2
|
+
020L04A8551407151407151407151407150000016338BATCH YY
|
3
|
+
020L1033560904084166276A85500000133560904084166616100000820000140715880 RAWSONPROPRC162657556 FIXTRADE 58 (PTY) LTD 00000000000000000000 21
|
4
|
+
020L1233560904084166276A85500000233560904084166276100000820000140715100000RAWSONPROPCONTRA6410
|
5
|
+
020L92A855000001000002140715140715000001000001000001000000820000000000820000008168332892
|
6
|
+
020L04A8551407151407151407151407150000036339BATCH YY
|
7
|
+
020L1033560904084166276A85500000325400562223889091100000139200140715880 RAWSONPROPBG0001 FIXTRADE 58 PTY LTD 00000000000000000000 21
|
8
|
+
020L1233560904084166276A85500000433560904084166276100000139200140715100000RAWSONPROPCONTRA6411
|
9
|
+
020L92A855000003000004140715140715000001000001000001000000139200000000139200066308055367
|
10
|
+
020L04A8551407151407151407151407150000056340BATCH YY
|
11
|
+
020L1033560904084166276A85500000505100100074146866200000360800140715880 RAWSONPROPBG0001 JULY A W MARAIS 00000000000000000000 21
|
12
|
+
020L1233560904084166276A85500000633560904084166276100000360800140715100000RAWSONPROPCONTRA6412
|
13
|
+
020L92A855000005000006140715140715000001000001000001000000360800000000360800004158313142
|
14
|
+
020L04A8551407151407151407151407150000076341BATCH YY
|
15
|
+
020L1063200504083387001A85500000763200504056584569100000084100140715880 RAWSONPROP211111105 CAPE TOWN ADMINISTRATION 00000000000000000000 21
|
16
|
+
020L1263200504083387001A85500000863200504083387001100000084100140715100000RAWSONPROPCONTRA6420
|
17
|
+
020L92A855000007000008140715140715000001000001000001000000084100000000084100008139971570
|
18
|
+
020L04A8551407151407151407151407150000096342BATCH YY
|
19
|
+
020L1063200504083387001A85500000963200504056584569100000012173140715880 RAWSONPROP205521324 CAPE TOWN ADMINISTRATION 00000000000000000000 21
|
20
|
+
020L1263200504083387001A85500001063200504083387001100000012173140715100000RAWSONPROPCONTRA6421
|
21
|
+
020L92A855000009000010140715140715000001000001000001000000012173000000012173008139971570
|
22
|
+
020L04A8551407151407151407151407150000116343BATCH YY
|
23
|
+
020L1063200504083387001A85500001163200504056584569100000002405140715880 RAWSONPROP205521324 CAPE TOWN ADMINISTRATION 00000000000000000000 21
|
24
|
+
020L1263200504083387001A85500001263200504083387001100000002405140715100000RAWSONPROPCONTRA6422
|
25
|
+
020L92A855000011000012140715140715000001000001000001000000002405000000002405008139971570
|
26
|
+
020L04A8551407151407151407151407150000136344BATCH YY
|
27
|
+
020L1063200504083387001A85500001363200504055905940100000015000140715880 RAWSONPROPL/F 26 KETTLEY BLUE PLATINUM BUSINESS ACCOUNT00000000000000000000 21
|
28
|
+
020L1263200504083387001A85500001463200504083387001100000015000140715100000RAWSONPROPCONTRA6423
|
29
|
+
020L92A855000013000014140715140715000001000001000001000000015000000000015000008139292941
|
30
|
+
020L04A8551407151407151407151407150000156345BATCH YY
|
31
|
+
020L1063200504083387001A85500001563200504056584569100000002513140715880 RAWSONPROP205521324 CAPE TOWN ADMINISTRATION 00000000000000000000 21
|
32
|
+
020L1263200504083387001A85500001663200504083387001100000002513140715100000RAWSONPROPCONTRA6424
|
33
|
+
020L92A855000015000016140715140715000001000001000001000000002513000000002513008139971570
|
34
|
+
020L04A8551407151407151407151407150000176346BATCH YY
|
35
|
+
020L1063200504083387001A85500001763200504056584569100000041450140715880 RAWSONPROP220325564 CAPE TOWN ADMINISTRATION 00000000000000000000 21
|
36
|
+
020L1263200504083387001A85500001863200504083387001100000041450140715100000RAWSONPROPCONTRA6440
|
37
|
+
020L92A855000017000018140715140715000001000001000001000000041450000000041450008139971570
|
38
|
+
020L04A8551407151407151407151407150000196347BATCH YY
|
39
|
+
020L1063200504083387001A85500001963200504055905940100000004000140715880 RAWSONPROPLOD SHANNONS BLUE PLATINUM VENTURES 43 (PTY00000000000000000000 21
|
40
|
+
020L1263200504083387001A85500002063200504083387001100000004000140715100000RAWSONPROPCONTRA6441
|
41
|
+
020L92A855000019000020140715140715000001000001000001000000004000000000004000008139292941
|
42
|
+
020L04A8551407151407151407151407150000216348BATCH YY
|
43
|
+
020L1063200504083387001A85500002163200504056584569100000000083140715880 RAWSONPROP220325564 CAPE TOWN ADMINISTRATION 00000000000000000000 21
|
44
|
+
020L1263200504083387001A85500002263200504083387001100000000083140715100000RAWSONPROPCONTRA6442
|
45
|
+
020L92A855000021000022140715140715000001000001000001000000000083000000000083008139971570
|
46
|
+
020L04A8551407151407151407151407150000236349BATCH YY
|
47
|
+
020L1063200504083387001A85500002363200504055905940100000030000140715880 RAWSONPROPAPP FEES BLUE PLATINUM BUSINESS ACCOUNT00000000000000000000 21
|
48
|
+
020L1263200504083387001A85500002463200504083387001100000030000140715100000RAWSONPROPCONTRA6446
|
49
|
+
020L92A855000023000024140715140715000001000001000001000000030000000000030000008139292941
|
50
|
+
020L04A8551407151407151407151407150000256350BATCH YY
|
51
|
+
020L1063200504079322530A85500002563200504079329299100001237500140715880 RAWSONPROPRC162662585 KIH TRADING (PTY) LTD 00000000000000000000 21
|
52
|
+
020L1263200504079322530A85500002663200504079322530100001237500140715100000RAWSONPROPCONTRA6425
|
53
|
+
020L92A855000025000026140715140715000001000001000001000001237500000001237500008158651829
|
54
|
+
020L04A8551407151407151407151407150000276351BATCH YY
|
55
|
+
020L1063200504079322530A85500002702620900332817407100000100000140715880 RAWSONPROPL/A FEE LNL030 KIH TRADING (PTY)LTD 00000000000000000000 21
|
56
|
+
020L1263200504079322530A85500002863200504079322530100000100000140715100000RAWSONPROPCONTRA6426
|
57
|
+
020L92A855000027000028140715140715000001000001000001000000100000000000100000004412139937
|
58
|
+
020L04A8551407151407151407151407150000296352BATCH YY
|
59
|
+
020L1063200504079322530A85500002902620900332817407100000363538140715880 RAWSONPROPCOMMISSION KIH TRADING (PTY) LTD 00000000000000000000 21
|
60
|
+
020L1263200504079322530A85500003063200504079322530100000363538140715100000RAWSONPROPCONTRA6427
|
61
|
+
020L92A855000029000030140715140715000001000001000001000000363538000000363538004412139937
|
62
|
+
020L04A8551407151407151407151407150000316353BATCH YY
|
63
|
+
020L1063200504079322530A85500003102620900370830555100000095000140715880 RAWSONPROPACE MANAGEMENT C AND E HOLDINGS(PTY) LTD 00000000000000000000 21
|
64
|
+
020L1263200504079322530A85500003263200504079322530100000095000140715100000RAWSONPROPCONTRA6438
|
65
|
+
020L92A855000031000032140715140715000001000001000001000000095000000000095000004450153085
|
66
|
+
020L04A8551407151407151407151407150000336354BATCH YY
|
67
|
+
020L1063200504079322530A85500003305100100071707719100004405000140715880 RAWSONPROP6 MONTHS U/F KWESI DZAPONG LWAZI PRAH 00000000000000000000 21
|
68
|
+
020L1263200504079322530A85500003463200504079322530100004405000140715100000RAWSONPROPCONTRA6439
|
69
|
+
020L92A855000033000034140715140715000001000001000001000004405000000004405000004151030249
|
70
|
+
020L04A8551407151407151407151407150000356355BATCH YY
|
71
|
+
020L1063200504084166234A85500003563200504084166593100000819268140715880 RAWSONPROPRC162660201 TRESSO TRADING 1044 00000000000000000000 21
|
72
|
+
020L1263200504084166234A85500003663200504084166234100000819268140715100000RAWSONPROPCONTRA6428
|
73
|
+
020L92A855000035000036140715140715000001000001000001000000819268000000819268008168332827
|
74
|
+
020L04A8551407151407151407151407150000376356BATCH YY
|
75
|
+
020L1063200504084166234A85500003763200504084166593100000810910140715880 RAWSONPROPRC162669074 TRESSO TRADING 1044 00000000000000000000 21
|
76
|
+
020L1263200504084166234A85500003863200504084166234100000810910140715100000RAWSONPROPCONTRA6429
|
77
|
+
020L92A855000037000038140715140715000001000001000001000000810910000000810910008168332827
|
78
|
+
020L04A8551407151407151407151407150000396357BATCH YY
|
79
|
+
020L1063200504084166234A85500003963200504084166593100002356116140715880 RAWSONPROPRC162665775 TRESSO TRADING 1044 00000000000000000000 21
|
80
|
+
020L1263200504084166234A85500004063200504084166234100002356116140715100000RAWSONPROPCONTRA6430
|
81
|
+
020L92A855000039000040140715140715000001000001000001000002356116000002356116008168332827
|
82
|
+
020L04A8551407151407151407151407150000416358BATCH YY
|
83
|
+
020L1063200504084166234A85500004163200504084166593100000530000140715880 RAWSONPROPRC162663754 TRESSO TRADING 1044 00000000000000000000 21
|
84
|
+
020L1263200504084166234A85500004263200504084166234100000530000140715100000RAWSONPROPCONTRA6432
|
85
|
+
020L92A855000041000042140715140715000001000001000001000000530000000000530000008168332827
|
86
|
+
020L04A8551407151407151407151407150000436359BATCH YY
|
87
|
+
020L1063200504084166234A85500004363200504084166593100000707502140715880 RAWSONPROPRC162668267 TRESSO TRADING 1044 00000000000000000000 21
|
88
|
+
020L1263200504084166234A85500004463200504084166234100000707502140715100000RAWSONPROPCONTRA6433
|
89
|
+
020L92A855000043000044140715140715000001000001000001000000707502000000707502008168332827
|
90
|
+
020L04A8551407151407151407151407150000456360BATCH YY
|
91
|
+
020L1063200504084166234A85500004563200504084166593100000667005140715880 RAWSONPROPRC162667995 TRESSO TRADING 1044 00000000000000000000 21
|
92
|
+
020L1263200504084166234A85500004663200504084166234100000667005140715100000RAWSONPROPCONTRA6434
|
93
|
+
020L92A855000045000046140715140715000001000001000001000000667005000000667005008168332827
|
94
|
+
020L04A8551407151407151407151407150000476361BATCH YY
|
95
|
+
020L1063200504084166234A85500004763200504084166593100000789125140715880 RAWSONPROPRC162664289 TRESSO TRADING 1044 00000000000000000000 21
|
96
|
+
020L1263200504084166234A85500004863200504084166234100000789125140715100000RAWSONPROPCONTRA6435
|
97
|
+
020L92A855000047000048140715140715000001000001000001000000789125000000789125008168332827
|
98
|
+
020L04A8551407151407151407151407150000496362BATCH YY
|
99
|
+
020L1063200504084166234A85500004963200504084166593100000912275140715880 RAWSONPROPRC162660289 TRESSO TRADING 1044 00000000000000000000 21
|
100
|
+
020L1263200504084166234A85500005063200504084166234100000912275140715100000RAWSONPROPCONTRA6436
|
101
|
+
020L92A855000049000050140715140715000001000001000001000000912275000000912275008168332827
|
102
|
+
020L04A8551407151407151407151407150000516363BATCH YY
|
103
|
+
020L1063200504084166234A85500005163200504084166593100000800000140715880 RAWSONPROPRC162662332 TRESSO TRADING 1044 00000000000000000000 21
|
104
|
+
020L1263200504084166234A85500005263200504084166234100000800000140715100000RAWSONPROPCONTRA6437
|
105
|
+
020L92A855000051000052140715140715000001000001000001000000800000000000800000008168332827
|
106
|
+
020L04A8551407151407151407151407150000536364BATCH YY
|
107
|
+
020L1063200504079323625A85500005363200504059585754100000057000140715880 RAWSONPROP4 LA RUE DE COMM SWEETWATER PROPERTIES 12CC 00000000000000000000 21
|
108
|
+
020L1263200504079323625A85500005463200504079323625100000057000140715100000RAWSONPROPCONTRA6443
|
109
|
+
020L92A855000053000054140715140715000001000001000001000000057000000000057000008138909379
|
110
|
+
020L04A8551407151407151407151407150000556365BATCH YY
|
111
|
+
020L1063200504079323625A85500005501800500021665265100000443000140715880 RAWSONPROP4 LA RUE DES RENT RT ATKINSON 00000000000000000000 21
|
112
|
+
020L1263200504079323625A85500005663200504079323625100000443000140715100000RAWSONPROPCONTRA6444
|
113
|
+
020L92A855000055000056140715140715000001000001000001000000443000000000443000004100988890
|
114
|
+
999L000000114
|
@@ -0,0 +1,102 @@
|
|
1
|
+
000L2014071500000RENTAL CONNECT PTY LTD 000119704136 2363
|
2
|
+
900L000 TRANSMISSION 04136-0000350 ACCEPTED
|
3
|
+
900L020 ACB USER SET A855-0006338-000002 ACCEPTED
|
4
|
+
903L020L1033560904084166276A85500000133560904084166616100000820000140715880 RAWSONPROPRC162657556 FIXTRADE 58 (PTY) LTD 00000000000000000000 21
|
5
|
+
903L020L1233560904084166276A85500000233560904084166276100000820000140715100000RAWSONPROPCONTRA6410
|
6
|
+
900L020 ACB USER SET A855-0006339-000004 ACCEPTED
|
7
|
+
903L020L1033560904084166276A85500000325400562223889091100000139200140715880 RAWSONPROPBG0001 FIXTRADE 58 PTY LTD 00000000000000000000 21
|
8
|
+
903L020L1233560904084166276A85500000433560904084166276100000139200140715100000RAWSONPROPCONTRA6411
|
9
|
+
900L020 ACB USER SET A855-0006340-000006 ACCEPTED
|
10
|
+
903L020L1033560904084166276A85500000505100100074146866200000360800140715880 RAWSONPROPBG0001 JULY A W MARAIS 00000000000000000000 21
|
11
|
+
903L020L1233560904084166276A85500000633560904084166276100000360800140715100000RAWSONPROPCONTRA6412
|
12
|
+
900L020 ACB USER SET A855-0006341-000008 ACCEPTED
|
13
|
+
903L020L1063200504083387001A85500000763200504056584569100000084100140715880 RAWSONPROP211111105 CAPE TOWN ADMINISTRATION 00000000000000000000 21
|
14
|
+
903L020L1263200504083387001A85500000863200504083387001100000084100140715100000RAWSONPROPCONTRA6420
|
15
|
+
900L020 ACB USER SET A855-0006342-000010 ACCEPTED
|
16
|
+
903L020L1063200504083387001A85500000963200504056584569100000012173140715880 RAWSONPROP205521324 CAPE TOWN ADMINISTRATION 00000000000000000000 21
|
17
|
+
903L020L1263200504083387001A85500001063200504083387001100000012173140715100000RAWSONPROPCONTRA6421
|
18
|
+
900L020 ACB USER SET A855-0006343-000012 ACCEPTED
|
19
|
+
903L020L1063200504083387001A85500001163200504056584569100000002405140715880 RAWSONPROP205521324 CAPE TOWN ADMINISTRATION 00000000000000000000 21
|
20
|
+
903L020L1263200504083387001A85500001263200504083387001100000002405140715100000RAWSONPROPCONTRA6422
|
21
|
+
900L020 ACB USER SET A855-0006344-000014 ACCEPTED
|
22
|
+
903L020L1063200504083387001A85500001363200504055905940100000015000140715880 RAWSONPROPL/F 26 KETTLEY BLUE PLATINUM BUSINESS ACCOUNT00000000000000000000 21
|
23
|
+
903L020L1263200504083387001A85500001463200504083387001100000015000140715100000RAWSONPROPCONTRA6423
|
24
|
+
900L020 ACB USER SET A855-0006345-000016 ACCEPTED
|
25
|
+
903L020L1063200504083387001A85500001563200504056584569100000002513140715880 RAWSONPROP205521324 CAPE TOWN ADMINISTRATION 00000000000000000000 21
|
26
|
+
903L020L1263200504083387001A85500001663200504083387001100000002513140715100000RAWSONPROPCONTRA6424
|
27
|
+
900L020 ACB USER SET A855-0006346-000018 ACCEPTED
|
28
|
+
903L020L1063200504083387001A85500001763200504056584569100000041450140715880 RAWSONPROP220325564 CAPE TOWN ADMINISTRATION 00000000000000000000 21
|
29
|
+
903L020L1263200504083387001A85500001863200504083387001100000041450140715100000RAWSONPROPCONTRA6440
|
30
|
+
900L020 ACB USER SET A855-0006347-000020 ACCEPTED
|
31
|
+
903L020L1063200504083387001A85500001963200504055905940100000004000140715880 RAWSONPROPLOD SHANNONS BLUE PLATINUM VENTURES 43 (PTY00000000000000000000 21
|
32
|
+
903L020L1263200504083387001A85500002063200504083387001100000004000140715100000RAWSONPROPCONTRA6441
|
33
|
+
900L020 ACB USER SET A855-0006348-000022 ACCEPTED
|
34
|
+
903L020L1063200504083387001A85500002163200504056584569100000000083140715880 RAWSONPROP220325564 CAPE TOWN ADMINISTRATION 00000000000000000000 21
|
35
|
+
903L020L1263200504083387001A85500002263200504083387001100000000083140715100000RAWSONPROPCONTRA6442
|
36
|
+
900L020 ACB USER SET A855-0006349-000024 ACCEPTED
|
37
|
+
903L020L1063200504083387001A85500002363200504055905940100000030000140715880 RAWSONPROPAPP FEES BLUE PLATINUM BUSINESS ACCOUNT00000000000000000000 21
|
38
|
+
903L020L1263200504083387001A85500002463200504083387001100000030000140715100000RAWSONPROPCONTRA6446
|
39
|
+
900L020 ACB USER SET A855-0006350-000026 ACCEPTED
|
40
|
+
903L020L1063200504079322530A85500002563200504079329299100001237500140715880 RAWSONPROPRC162662585 KIH TRADING (PTY) LTD 00000000000000000000 21
|
41
|
+
903L020L1263200504079322530A85500002663200504079322530100001237500140715100000RAWSONPROPCONTRA6425
|
42
|
+
900L020 ACB USER SET A855-0006351-000028 ACCEPTED
|
43
|
+
903L020L1063200504079322530A85500002702620900332817407100000100000140715880 RAWSONPROPL/A FEE LNL030 KIH TRADING (PTY)LTD 00000000000000000000 21
|
44
|
+
903L020L1263200504079322530A85500002863200504079322530100000100000140715100000RAWSONPROPCONTRA6426
|
45
|
+
900L020 ACB USER SET A855-0006352-000030 ACCEPTED
|
46
|
+
903L020L1063200504079322530A85500002902620900332817407100000363538140715880 RAWSONPROPCOMMISSION KIH TRADING (PTY) LTD 00000000000000000000 21
|
47
|
+
903L020L1263200504079322530A85500003063200504079322530100000363538140715100000RAWSONPROPCONTRA6427
|
48
|
+
900L020 ACB USER SET A855-0006353-000032 ACCEPTED
|
49
|
+
903L020L1063200504079322530A85500003102620900370830555100000095000140715880 RAWSONPROPACE MANAGEMENT C AND E HOLDINGS(PTY) LTD 00000000000000000000 21
|
50
|
+
903L020L1263200504079322530A85500003263200504079322530100000095000140715100000RAWSONPROPCONTRA6438
|
51
|
+
900L020 ACB USER SET A855-0006354-000034 ACCEPTED
|
52
|
+
903L020L1063200504079322530A85500003305100100071707719100004405000140715880 RAWSONPROP6 MONTHS U/F KWESI DZAPONG LWAZI PRAH 00000000000000000000 21
|
53
|
+
903L020L1263200504079322530A85500003463200504079322530100004405000140715100000RAWSONPROPCONTRA6439
|
54
|
+
900L020 ACB USER SET A855-0006355-000000 REJECTED
|
55
|
+
901L020 A855/0006355/000035 00023-*** USER BRANCH NOT = CONTROL ***
|
56
|
+
901L020 A855/0006355/000036 00045-*** CONTRA USER BRANCH ERROR ***
|
57
|
+
901L020 A855/0006355/000036 00050-*** CONTRA HOM. BRANCH ERROR ***
|
58
|
+
900L020 ACB USER SET A855-0006356-000000 REJECTED
|
59
|
+
901L020 A855/0006356/000000 00006-*** USER GEN NUMBER NOT NEXT IN SEQUENCE ***
|
60
|
+
901L020 A855/0006356/000037 00023-*** USER BRANCH NOT = CONTROL ***
|
61
|
+
901L020 A855/0006356/000038 00045-*** CONTRA USER BRANCH ERROR ***
|
62
|
+
901L020 A855/0006356/000038 00050-*** CONTRA HOM. BRANCH ERROR ***
|
63
|
+
900L020 ACB USER SET A855-0006357-000000 REJECTED
|
64
|
+
901L020 A855/0006357/000000 00006-*** USER GEN NUMBER NOT NEXT IN SEQUENCE ***
|
65
|
+
901L020 A855/0006357/000039 00023-*** USER BRANCH NOT = CONTROL ***
|
66
|
+
901L020 A855/0006357/000040 00045-*** CONTRA USER BRANCH ERROR ***
|
67
|
+
901L020 A855/0006357/000040 00050-*** CONTRA HOM. BRANCH ERROR ***
|
68
|
+
900L020 ACB USER SET A855-0006358-000000 REJECTED
|
69
|
+
901L020 A855/0006358/000000 00006-*** USER GEN NUMBER NOT NEXT IN SEQUENCE ***
|
70
|
+
901L020 A855/0006358/000041 00023-*** USER BRANCH NOT = CONTROL ***
|
71
|
+
901L020 A855/0006358/000042 00045-*** CONTRA USER BRANCH ERROR ***
|
72
|
+
901L020 A855/0006358/000042 00050-*** CONTRA HOM. BRANCH ERROR ***
|
73
|
+
900L020 ACB USER SET A855-0006359-000000 REJECTED
|
74
|
+
901L020 A855/0006359/000000 00006-*** USER GEN NUMBER NOT NEXT IN SEQUENCE ***
|
75
|
+
901L020 A855/0006359/000043 00023-*** USER BRANCH NOT = CONTROL ***
|
76
|
+
901L020 A855/0006359/000044 00045-*** CONTRA USER BRANCH ERROR ***
|
77
|
+
901L020 A855/0006359/000044 00050-*** CONTRA HOM. BRANCH ERROR ***
|
78
|
+
900L020 ACB USER SET A855-0006360-000000 REJECTED
|
79
|
+
901L020 A855/0006360/000000 00006-*** USER GEN NUMBER NOT NEXT IN SEQUENCE ***
|
80
|
+
901L020 A855/0006360/000045 00023-*** USER BRANCH NOT = CONTROL ***
|
81
|
+
901L020 A855/0006360/000046 00045-*** CONTRA USER BRANCH ERROR ***
|
82
|
+
901L020 A855/0006360/000046 00050-*** CONTRA HOM. BRANCH ERROR ***
|
83
|
+
900L020 ACB USER SET A855-0006361-000000 REJECTED
|
84
|
+
901L020 A855/0006361/000000 00006-*** USER GEN NUMBER NOT NEXT IN SEQUENCE ***
|
85
|
+
901L020 A855/0006361/000047 00023-*** USER BRANCH NOT = CONTROL ***
|
86
|
+
901L020 A855/0006361/000048 00045-*** CONTRA USER BRANCH ERROR ***
|
87
|
+
901L020 A855/0006361/000048 00050-*** CONTRA HOM. BRANCH ERROR ***
|
88
|
+
900L020 ACB USER SET A855-0006362-000000 REJECTED
|
89
|
+
901L020 A855/0006362/000000 00006-*** USER GEN NUMBER NOT NEXT IN SEQUENCE ***
|
90
|
+
901L020 A855/0006362/000049 00023-*** USER BRANCH NOT = CONTROL ***
|
91
|
+
901L020 A855/0006362/000050 00045-*** CONTRA USER BRANCH ERROR ***
|
92
|
+
901L020 A855/0006362/000050 00050-*** CONTRA HOM. BRANCH ERROR ***
|
93
|
+
900L020 ACB USER SET A855-0006363-000000 REJECTED
|
94
|
+
901L020 A855/0006363/000000 00006-*** USER GEN NUMBER NOT NEXT IN SEQUENCE ***
|
95
|
+
901L020 A855/0006363/000051 00023-*** USER BRANCH NOT = CONTROL ***
|
96
|
+
901L020 A855/0006363/000052 00045-*** CONTRA USER BRANCH ERROR ***
|
97
|
+
901L020 A855/0006363/000052 00050-*** CONTRA HOM. BRANCH ERROR ***
|
98
|
+
900L020 ACB USER SET A855-0006364-000000 REJECTED
|
99
|
+
901L020 A855/0006364/000000 00006-*** USER GEN NUMBER NOT NEXT IN SEQUENCE ***
|
100
|
+
900L020 ACB USER SET A855-0006365-000000 REJECTED
|
101
|
+
901L020 A855/0006365/000000 00006-*** USER GEN NUMBER NOT NEXT IN SEQUENCE ***
|
102
|
+
999L000000102
|
@@ -178,10 +178,7 @@ describe Bankserv::ReplyDocument do
|
|
178
178
|
context "processing a rejected message record" do
|
179
179
|
it "should update the related record with error information" do
|
180
180
|
record = @input_document.set.sets.last.transactions.first
|
181
|
-
record.error
|
182
|
-
record.error[:message].should == "HI THIS IS REJECTED MESSAGE"
|
183
|
-
|
184
|
-
puts record.inspect
|
181
|
+
record.error.should == [{:code=>"12345", :message=>"HI THIS IS REJECTED MESSAGE"}]
|
185
182
|
end
|
186
183
|
end
|
187
184
|
|
@@ -190,6 +187,64 @@ describe Bankserv::ReplyDocument do
|
|
190
187
|
end
|
191
188
|
|
192
189
|
end
|
190
|
+
|
191
|
+
context "Process a reply file with accepted and rejected records" do
|
192
|
+
|
193
|
+
before(:each) do
|
194
|
+
tear_it_down
|
195
|
+
@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: "350", sequence_number: 57)
|
196
|
+
|
197
|
+
@file_contents = File.open("./spec/examples/accepted_and_rejected_input_file.txt", "rb").read
|
198
|
+
@input_document = Bankserv::InputDocument.store(@file_contents)
|
199
|
+
|
200
|
+
options = Absa::H2h::Transmission::Document.hash_from_s(@file_contents, 'input')
|
201
|
+
options[:data].each do |entry|
|
202
|
+
if entry[:data].count == 4
|
203
|
+
c = entry[:data].map {|x| x[:data]}
|
204
|
+
request = Bankserv::Request.create!({
|
205
|
+
type: "credit",
|
206
|
+
data: {
|
207
|
+
:type_of_service=>"BATCH",
|
208
|
+
:batches=>[{
|
209
|
+
: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},
|
210
|
+
: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}
|
211
|
+
}]
|
212
|
+
}
|
213
|
+
})
|
214
|
+
|
215
|
+
request.service_id = @cs.id
|
216
|
+
request.save!
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
Bankserv::Credit.all.each {|x| x.status="pending";x.save!}
|
221
|
+
|
222
|
+
@file_contents = File.open("./spec/examples/reply/accepted_and_rejected_transactions.txt", "rb").read
|
223
|
+
|
224
|
+
@document = Bankserv::ReplyDocument.store(@file_contents)
|
225
|
+
@document.process!
|
226
|
+
@cs.reload
|
227
|
+
end
|
228
|
+
|
229
|
+
it "should reset the credit service generation number to 6355" do
|
230
|
+
@cs.config[:generation_number].should == 6355
|
231
|
+
end
|
232
|
+
|
233
|
+
it "should set the credit service sequence number to 35" do
|
234
|
+
@cs.config[:sequence_number].should == 35
|
235
|
+
end
|
236
|
+
|
237
|
+
it "should have rejected transactions" do
|
238
|
+
Bankserv::Credit.all.each do |c|
|
239
|
+
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
it "should reset some of the credits to new" do
|
244
|
+
|
245
|
+
end
|
246
|
+
|
247
|
+
end
|
193
248
|
|
194
249
|
|
195
250
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 6
|
8
|
-
-
|
9
|
-
version: 0.6.
|
8
|
+
- 6
|
9
|
+
version: 0.6.6
|
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-21 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -175,6 +175,7 @@ files:
|
|
175
175
|
- spec/examples/INPUT.120411124123.txt
|
176
176
|
- spec/examples/TJRRECF.0602
|
177
177
|
- spec/examples/TJRRECF.0605
|
178
|
+
- spec/examples/accepted_and_rejected_input_file.txt
|
178
179
|
- spec/examples/ahv_input_file.txt
|
179
180
|
- spec/examples/ahv_output_file.txt
|
180
181
|
- spec/examples/blank_statement.dat
|
@@ -187,6 +188,7 @@ files:
|
|
187
188
|
- spec/examples/host2host/tmp.log
|
188
189
|
- spec/examples/notify_me.xml
|
189
190
|
- spec/examples/notify_me_with_one_record.xml
|
191
|
+
- spec/examples/reply/accepted_and_rejected_transactions.txt
|
190
192
|
- spec/examples/reply/accepted_reply.txt
|
191
193
|
- spec/examples/reply/rejected_transmission.txt
|
192
194
|
- spec/examples/reply/reply2.txt
|
@@ -257,6 +259,7 @@ test_files:
|
|
257
259
|
- spec/examples/INPUT.120411124123.txt
|
258
260
|
- spec/examples/TJRRECF.0602
|
259
261
|
- spec/examples/TJRRECF.0605
|
262
|
+
- spec/examples/accepted_and_rejected_input_file.txt
|
260
263
|
- spec/examples/ahv_input_file.txt
|
261
264
|
- spec/examples/ahv_output_file.txt
|
262
265
|
- spec/examples/blank_statement.dat
|
@@ -269,6 +272,7 @@ test_files:
|
|
269
272
|
- spec/examples/host2host/tmp.log
|
270
273
|
- spec/examples/notify_me.xml
|
271
274
|
- spec/examples/notify_me_with_one_record.xml
|
275
|
+
- spec/examples/reply/accepted_and_rejected_transactions.txt
|
272
276
|
- spec/examples/reply/accepted_reply.txt
|
273
277
|
- spec/examples/reply/rejected_transmission.txt
|
274
278
|
- spec/examples/reply/reply2.txt
|