bankserv 0.2.2 → 0.2.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/lib/bankserv/engine.rb +1 -1
- data/lib/bankserv/transmission/set/eft.rb +4 -16
- data/lib/bankserv/version.rb +1 -1
- data/spec/examples/INPUT.120411110604.txt +8 -0
- data/spec/examples/credit_eft_input.txt +2 -2
- data/spec/examples/debit_eft_input_file.txt +2 -2
- data/spec/lib/bankserv/engine/engine_spec.rb +24 -5
- data/spec/lib/bankserv/transmission/set/credit_spec.rb +3 -5
- data/spec/lib/bankserv/transmission/set/debit_spec.rb +3 -5
- data/spec/support/helpers.rb +19 -0
- metadata +16 -14
data/lib/bankserv/engine.rb
CHANGED
@@ -91,7 +91,7 @@ module Bankserv
|
|
91
91
|
transmission = Absa::H2h::Transmission::Document.build([document.to_hash])
|
92
92
|
file_name = generate_input_file_name
|
93
93
|
File.open("#{Bankserv::Engine.input_directory}/#{file_name}", 'w') { |f|
|
94
|
-
f.
|
94
|
+
f.write transmission
|
95
95
|
}
|
96
96
|
@logs[:input_files] << "Input Document File created. File name: #{file_name}"
|
97
97
|
rescue Exception => e
|
@@ -139,27 +139,15 @@ module Bankserv
|
|
139
139
|
end
|
140
140
|
|
141
141
|
def first_action_date
|
142
|
-
|
143
|
-
transactions.map(&:data).each do |hash|
|
144
|
-
first = Date.strptime(hash[:action_date], "%y%m%d")
|
145
|
-
fad = first if first < fad
|
146
|
-
end
|
147
|
-
fad.strftime("%y%m%d")
|
142
|
+
transactions.min_by{|t| t.data[:action_date]}.data[:action_date]
|
148
143
|
end
|
149
144
|
|
150
|
-
def last_action_date
|
151
|
-
|
152
|
-
transactions.map(&:data).each do |hash|
|
153
|
-
last = Date.strptime(hash[:action_date], "%y%m%d")
|
154
|
-
lad = last if last < lad
|
155
|
-
end
|
156
|
-
lad = lad + 3.days
|
157
|
-
lad.strftime("%y%m%d")
|
145
|
+
def last_action_date
|
146
|
+
transactions.max_by{|t| t.data[:action_date]}.data[:action_date]
|
158
147
|
end
|
159
148
|
|
160
149
|
def purge_date
|
161
|
-
|
162
|
-
date.strftime("%y%m%d")
|
150
|
+
last_action_date
|
163
151
|
end
|
164
152
|
|
165
153
|
def hash_total_of_homing_account_numbers
|
data/lib/bankserv/version.rb
CHANGED
@@ -0,0 +1,8 @@
|
|
1
|
+
000L2012041012345TESTTEST 000000100000
|
2
|
+
001L0499991204101204111204111204110000010001TWO DAY
|
3
|
+
001L5025025504530495834999900000125065562097363670100000301400120411440 TESTTEST 544 DOUGLAS ANDERSON 00000000000000000000 21
|
4
|
+
001L5025025504530495834999900000263200509076546281200000315000120411440 TESTTEST 545 JEFFREY VAN ASWEGEN 00000000000000000000 21
|
5
|
+
001L5025025504530495834999900000302000900070440213100000279300120411440 TESTTEST 546 PETER DE VILLIERS 00000000000000000000 21
|
6
|
+
001L5225025504530495834999900000425025504530495834100000895700120411100000TESTTEST CONTRA19
|
7
|
+
001L929999000001000004120411120411000003000001000001000000895700000000895700075774845998
|
8
|
+
999L000000008
|
@@ -1,5 +1,5 @@
|
|
1
1
|
000L2008080800986TESTTEST 000084600000
|
2
|
-
|
2
|
+
020L0499990808080808080808080808080000780846BATCH YY
|
3
3
|
020L1063200504068123456999900007805002100081136250100001500000080808880 TESTTEST _2055185_PAY USER DEWEY ASSOCIATES 00000000000000000000 21
|
4
4
|
020L1063200504068123456999900007963200504051717311100000542380080808880 TESTTEST _2055184_PAY USER SURE SLIM WELLNESS CLINIC SA 00000000000000000000 21
|
5
5
|
020L1063200504068123456999900008063200509193079313100000224500080808880 TESTTEST _2055183_PAY USER RUGGA KIDS EAST RAND 00000000000000000000 21
|
@@ -162,5 +162,5 @@
|
|
162
162
|
020L1063200504068123456999900023725204562032469836100000314250080808880 TESTTEST _2055026_PAY USER COMPACT ACCOUNTING 00000000000000000000 21
|
163
163
|
020L1063200504068123456999900023816514501651343144100000086503080808880 TESTTEST _2055025_PAY USER BOSHOFF SMUTS ING 00000000000000000000 21
|
164
164
|
020L1263200504068123456999900023963200504068123456100127221665080808100000TESTTEST CONTRA_0000846_PMT
|
165
|
-
|
165
|
+
020L929999000078000239080808080808000001000161000001000127221665000127221665028905810181
|
166
166
|
999L000000166
|
@@ -1,5 +1,5 @@
|
|
1
1
|
000T2004052400010LDC USER 10 AFRICA (PTY) 000062100000
|
2
|
-
|
2
|
+
001T0495340405240405250405240405250000010037CORPSSV
|
3
3
|
001T5063200504053538939953400000163200501019611899100000001000040524440000ALIMITTST SPP 1040524 01 HENNIE DU TOIT 00000000000000000000 21
|
4
4
|
001T5063200504053538939953400000263200501019801892100000002000040524440000ALIMITTST SPP 1040524 02 TYRONE DREYDEN 00000000000000000000 21
|
5
5
|
001T5063200504053538939953400000363200501021131896100000003000040524440000ALIMITTST SPP 1040524 03 KEITH MEIKLEJOHN 00000000000000000000 21
|
@@ -16,5 +16,5 @@
|
|
16
16
|
001T5063200501004651894953400001463200501019591898100000060000040525440000ALIMITTST SPP 2040525 06 PETER HAUPT 00000000000000000000 21
|
17
17
|
001T5063200501004651894953400001563200501020861726100000070000040525440000ALIMITTST SPP 2040525 07 HADLEY RAW 00000000000000000000 21
|
18
18
|
001T5263200501004651894953400001663200501004651894100004280000040525100000ALIMITTST CONTRA2040525 08
|
19
|
-
|
19
|
+
001T929534000001000016040524040525000014000002000002000020308000000020308000036311034141
|
20
20
|
999T000000020
|
@@ -17,6 +17,7 @@ describe Bankserv::Engine do
|
|
17
17
|
|
18
18
|
FileUtils.rm_rf(Dir.pwd + "/spec/examples/host2host/archives", secure: true)
|
19
19
|
File.delete(Dir.pwd + "/spec/tmp/harry.txt")
|
20
|
+
File.delete(Dir.pwd + "/spec/tmp/sally.txt")
|
20
21
|
end
|
21
22
|
|
22
23
|
context "Prepare engine" do
|
@@ -134,7 +135,7 @@ describe Bankserv::Engine do
|
|
134
135
|
|
135
136
|
end
|
136
137
|
|
137
|
-
context "
|
138
|
+
context "integration testing" do
|
138
139
|
|
139
140
|
before(:each) do
|
140
141
|
Timecop.travel(Time.local(2012, 4, 10, 10, 5, 0))
|
@@ -143,20 +144,38 @@ describe Bankserv::Engine do
|
|
143
144
|
create(:configuration, client_code: "12345", client_name: "TESTTEST", user_code: "9999", user_generation_number: 1, client_abbreviated_name: "TESTTEST", department_code: "506")
|
144
145
|
Bankserv::EngineConfiguration.create!(interval_in_minutes: 15, input_directory: @tmpdir, output_directory: @tmpdir, archive_directory: @tmpdir)
|
145
146
|
end
|
146
|
-
|
147
|
-
it "should
|
147
|
+
|
148
|
+
it "should process ahv requests" do
|
148
149
|
Bankserv::AccountHolderVerification.should_receive(:generate_reference_number).exactly(8).times.and_return("AHV67","AHV68","AHV69","AHV70","AHV71","AHV72","AHV73","AHV74")
|
149
150
|
create_ahv_requests_scenario
|
150
151
|
e = Bankserv::Engine.new
|
151
152
|
e.should_receive(:generate_input_file_name).and_return("harry.txt")
|
152
153
|
e.process!
|
153
|
-
|
154
|
+
|
154
155
|
expected_string = File.open("./spec/examples/INPUT.120410144410.txt", "rb").read
|
155
156
|
got_string = File.open(@tmpdir + '/harry.txt', "rb").read
|
156
|
-
|
157
|
+
|
157
158
|
got_string.should == expected_string
|
158
159
|
end
|
160
|
+
|
161
|
+
it "should process debit requests" do
|
162
|
+
create_debit_requests_scenario
|
163
|
+
|
164
|
+
e = Bankserv::Engine.new
|
165
|
+
e.should_receive(:generate_input_file_name).and_return("sally.txt")
|
166
|
+
e.process!
|
167
|
+
puts e.inspect
|
159
168
|
|
169
|
+
expected_string = File.open("./spec/examples/INPUT.120411110604.txt", "rb").read
|
170
|
+
got_string = File.open(@tmpdir + '/sally.txt', "rb").read
|
171
|
+
|
172
|
+
got_string.should == expected_string
|
173
|
+
end
|
174
|
+
|
175
|
+
it "should process credit requests" do
|
176
|
+
pending
|
177
|
+
end
|
178
|
+
|
160
179
|
end
|
161
180
|
|
162
181
|
end
|
@@ -43,17 +43,15 @@ describe Bankserv::Transmission::UserSet::Credit do
|
|
43
43
|
end
|
44
44
|
|
45
45
|
it "should create a batch with a header when the job begins" do
|
46
|
-
purge = (Date.today + 7.days).strftime("%y%m%d")
|
47
|
-
|
48
46
|
@batch.header.data.should == {
|
49
47
|
rec_id: "020",
|
50
48
|
rec_status: "T",
|
51
49
|
bankserv_record_identifier: "04",
|
52
50
|
bankserv_user_code: "9534",
|
53
51
|
bankserv_creation_date: Time.now.strftime("%y%m%d"),
|
54
|
-
bankserv_purge_date:
|
52
|
+
bankserv_purge_date: Time.now.strftime("%y%m%d"),
|
55
53
|
first_action_date: Time.now.strftime("%y%m%d"),
|
56
|
-
last_action_date:
|
54
|
+
last_action_date: Time.now.strftime("%y%m%d"),
|
57
55
|
first_sequence_number: "1",
|
58
56
|
user_generation_number: "37",
|
59
57
|
type_of_service: "SAMEDAY",
|
@@ -75,7 +73,7 @@ describe Bankserv::Transmission::UserSet::Credit do
|
|
75
73
|
first_sequence_number: "1",
|
76
74
|
last_sequence_number: "8",
|
77
75
|
first_action_date: Time.now.strftime("%y%m%d"),
|
78
|
-
last_action_date:
|
76
|
+
last_action_date: Time.now.strftime("%y%m%d"),
|
79
77
|
no_debit_records: "2",
|
80
78
|
no_credit_records: "6",
|
81
79
|
no_contra_records: "2",
|
@@ -44,17 +44,15 @@ describe Bankserv::Transmission::UserSet::Debit do
|
|
44
44
|
batch = Bankserv::Transmission::UserSet::Debit.generate(rec_status: "T")
|
45
45
|
batch.save
|
46
46
|
|
47
|
-
purge = (Date.today + 7.days).strftime("%y%m%d")
|
48
|
-
|
49
47
|
batch.header.data.should == {
|
50
48
|
rec_id: "001",
|
51
49
|
rec_status: "T",
|
52
50
|
bankserv_record_identifier: "04",
|
53
51
|
bankserv_user_code: "9534",
|
54
52
|
bankserv_creation_date: Time.now.strftime("%y%m%d"),
|
55
|
-
bankserv_purge_date:
|
53
|
+
bankserv_purge_date: Time.now.strftime("%y%m%d"),
|
56
54
|
first_action_date: Time.now.strftime("%y%m%d"),
|
57
|
-
last_action_date:
|
55
|
+
last_action_date: Time.now.strftime("%y%m%d"),
|
58
56
|
first_sequence_number: "1",
|
59
57
|
user_generation_number: "37",
|
60
58
|
type_of_service: "SAMEDAY",
|
@@ -89,7 +87,7 @@ describe Bankserv::Transmission::UserSet::Debit do
|
|
89
87
|
first_sequence_number: "1",
|
90
88
|
last_sequence_number: "8",
|
91
89
|
first_action_date: Time.now.strftime("%y%m%d"),
|
92
|
-
last_action_date:
|
90
|
+
last_action_date: Time.now.strftime("%y%m%d"),
|
93
91
|
no_debit_records: "6",
|
94
92
|
no_credit_records: "2",
|
95
93
|
no_contra_records: "2",
|
data/spec/support/helpers.rb
CHANGED
@@ -202,5 +202,24 @@ module Helpers
|
|
202
202
|
info = {:data=>{:user_ref=>625, :bank_account=>{:account_number=>"070440213", :id_number=>"1116501771108", :initials=>"PDV", :account_name=>"Peter De Villiers", :branch_code=>"20009", :account_type=>"current"}}}
|
203
203
|
Bankserv::AccountHolderVerification.request(info)
|
204
204
|
end
|
205
|
+
|
206
|
+
def create_debit_requests_scenario
|
207
|
+
info = {
|
208
|
+
:type=>"debit",
|
209
|
+
:data=>{
|
210
|
+
:type_of_service=>"TWO DAY",
|
211
|
+
:batches=>[{
|
212
|
+
:debit=>[
|
213
|
+
{:account_number=>"62097363670", :id_number=>"6967756569139", :initials=>"DA", :account_name=>"Douglas Anderson", :branch_code=>"250655", :account_type=>"current", :amount=>301400, :user_ref=>544, :action_date=>Date.parse('Wed, 11 Apr 2012')},
|
214
|
+
{:account_number=>"9076546281", :id_number=>"2711783115132", :initials=>"JvA", :account_name=>"Jeffrey van Aswegen", :branch_code=>"632005", :account_type=>"savings", :amount=>315000, :user_ref=>545, :action_date=>Date.parse('Wed, 11 Apr 2012')},
|
215
|
+
{:account_number=>"070440213", :id_number=>"6175553360681", :initials=>"PDV", :account_name=>"Peter De Villiers", :branch_code=>"20009", :account_type=>"current", :amount=>279300, :user_ref=>546, :action_date=>Date.parse('Wed, 11 Apr 2012')}
|
216
|
+
],
|
217
|
+
:credit=>{:account_number=>"4530495834", :id_number=>"8008456465340", :initials=>"RC", :account_name=>"RC Transactional", :branch_code=>"250255", :account_type=>"savings", :amount=>895700, :user_ref=>19, :action_date=>Date.parse('Wed, 11 Apr 2012')}
|
218
|
+
}]
|
219
|
+
}
|
220
|
+
}
|
221
|
+
|
222
|
+
Bankserv::Debit.request(info)
|
223
|
+
end
|
205
224
|
end
|
206
225
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bankserv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-04-
|
13
|
+
date: 2012-04-11 00:00:00.000000000Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
17
|
-
requirement: &
|
17
|
+
requirement: &70140537134240 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *70140537134240
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: activerecord
|
28
|
-
requirement: &
|
28
|
+
requirement: &70140537133740 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: '3.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *70140537133740
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: i18n
|
39
|
-
requirement: &
|
39
|
+
requirement: &70140537133320 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ! '>='
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: '0'
|
45
45
|
type: :runtime
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *70140537133320
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: absa-h2h
|
50
|
-
requirement: &
|
50
|
+
requirement: &70140537132780 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ~>
|
@@ -55,10 +55,10 @@ dependencies:
|
|
55
55
|
version: 0.1.1
|
56
56
|
type: :runtime
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *70140537132780
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: absa-esd
|
61
|
-
requirement: &
|
61
|
+
requirement: &70140537132280 !ruby/object:Gem::Requirement
|
62
62
|
none: false
|
63
63
|
requirements:
|
64
64
|
- - ~>
|
@@ -66,10 +66,10 @@ dependencies:
|
|
66
66
|
version: 0.0.2
|
67
67
|
type: :runtime
|
68
68
|
prerelease: false
|
69
|
-
version_requirements: *
|
69
|
+
version_requirements: *70140537132280
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: combustion
|
72
|
-
requirement: &
|
72
|
+
requirement: &70140537131820 !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
75
|
- - ~>
|
@@ -77,7 +77,7 @@ dependencies:
|
|
77
77
|
version: 0.3.1
|
78
78
|
type: :development
|
79
79
|
prerelease: false
|
80
|
-
version_requirements: *
|
80
|
+
version_requirements: *70140537131820
|
81
81
|
description: ! "This engine allows users to inject requests into a queue to be processed.
|
82
82
|
\n \n The queue handles bank account validations, credit payments,
|
83
83
|
debit orders\n and collecting bank statements. "
|
@@ -129,6 +129,7 @@ files:
|
|
129
129
|
- lib/generators/active_record/bankserv_generator.rb
|
130
130
|
- lib/generators/active_record/templates/migration.rb
|
131
131
|
- spec/examples/INPUT.120410144410.txt
|
132
|
+
- spec/examples/INPUT.120411110604.txt
|
132
133
|
- spec/examples/ahv_input_file.txt
|
133
134
|
- spec/examples/ahv_output_file.txt
|
134
135
|
- spec/examples/credit_eft_input.txt
|
@@ -190,6 +191,7 @@ specification_version: 3
|
|
190
191
|
summary: A rails 3 engine wrapped around the Absa Host 2 Host gem.
|
191
192
|
test_files:
|
192
193
|
- spec/examples/INPUT.120410144410.txt
|
194
|
+
- spec/examples/INPUT.120411110604.txt
|
193
195
|
- spec/examples/ahv_input_file.txt
|
194
196
|
- spec/examples/ahv_output_file.txt
|
195
197
|
- spec/examples/credit_eft_input.txt
|