bankserv 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/bankserv/engine.rb +8 -3
- data/lib/bankserv/version.rb +1 -1
- data/spec/examples/TJRRECF.0602 +8 -0
- data/spec/examples/TJRRECF.0605 +9 -0
- data/spec/lib/bankserv/engine/engine_spec.rb +48 -45
- metadata +18 -14
data/lib/bankserv/engine.rb
CHANGED
@@ -52,14 +52,18 @@ module Bankserv
|
|
52
52
|
# ------------------------------------------------------------------------------------------------------------
|
53
53
|
# | NB: ABSA place output files in our incoming directory! They take our input files from our outgoing folder.|
|
54
54
|
# ------------------------------------------------------------------------------------------------------------
|
55
|
-
|
56
55
|
begin
|
57
56
|
Engine.output_files(@service).each do |file|
|
58
57
|
@logs[:output_files] << "Processing #{file}."
|
59
58
|
|
60
59
|
# contents = File.open("#{Bankserv::Engine.output_directory}/#{file}", "rb").read
|
61
60
|
contents = File.open("#{@service.config[:incoming_directory]}/#{file}", "rb").read
|
62
|
-
|
61
|
+
if @service.kind_of? StatementService
|
62
|
+
document = Bankserv::Statement.store(contents)
|
63
|
+
else
|
64
|
+
document = Bankserv::OutputDocument.store(contents)
|
65
|
+
end
|
66
|
+
|
63
67
|
document.process!
|
64
68
|
|
65
69
|
@logs[:output_files] << "Processing #{file}. Complete."
|
@@ -193,7 +197,8 @@ module Bankserv
|
|
193
197
|
end
|
194
198
|
|
195
199
|
def self.output_files(service)
|
196
|
-
Dir.entries(service.config[:incoming_directory]).select {|file| file.upcase.starts_with? "OUTPUT" }
|
200
|
+
return Dir.entries(service.config[:incoming_directory]).select {|file| file.upcase.starts_with? "OUTPUT" } unless service.kind_of? StatementService
|
201
|
+
Dir.entries(service.config[:incoming_directory]).delete_if {|element| File.directory?(element)}
|
197
202
|
end
|
198
203
|
|
199
204
|
end
|
data/lib/bankserv/version.rb
CHANGED
@@ -0,0 +1,8 @@
|
|
1
|
+
00000000000000000000P2012060210831RENTAL CONNECT PTY LTD 10831 000000028
|
2
|
+
10000000004079058521000290000120120601 +000000000000000+00000000000034862 AA0A 000000028
|
3
|
+
2000000000407905852100029000012012060120120601000000000000000000-000000000006180+00000000000028682MIN SERVICE FEE HEADOFFICE CG71SERM+000000000 +000000000+000000000 000000096000000003000003405000000000000000000000000000000 3491 000000000000000 0000000000000000 0000000000000000000 0000000280404
|
4
|
+
2000000000407905852100029000012012060120120601000000000000000000-000000000021600+00000000000007082ADMIN CHARGE HEADOFFICE CG71ADMC+000000000 +000000000+000000000 000000096000000004000000000000000000000000000000000000000 0100 000000000000000 0000000000000000 0000000000000000000 0000000280505
|
5
|
+
2000000000407905852100029000012012060120120601000000000000000000-000000000000075+00000000000007007DEBIT INTEREST HEADOFFICE IN71INDR+000000000 +000000000+000000000 000000097000000005000000000000000000000000000000000000000 2160 000000000000000 0000000000000000 0000000000000000000 0000000280808
|
6
|
+
2000000000407905852100029000012012060120120601000000000000000000-000000000000066+00000000000006941INT ON EXCESS AMNT HEADOFFICE IN71PENI+000000000 +000000000+000000000 000000097000000006000000000000000000000000000000000000000 2650 000000000000000 0000000000000000 0000000000000000000 0000000280808
|
7
|
+
89999999999999999999 -00000000000027921 0000000006 000000028
|
8
|
+
99999999999999999999P20120602 0000000008 000000028
|
@@ -0,0 +1,9 @@
|
|
1
|
+
00000000000000000000P2012060510831RENTAL CONNECT PTY LTD 10831 000000031
|
2
|
+
10000000004079058521000320000120120604 +000000000000000+00000000000006941 AA0A 000000031
|
3
|
+
2000000000407905852100032000012012060420120604000000000000000102-000000000005245+00000000000001696ABSA FEE SETTLEMENT Business Integrator Fees FN71CGW +000000000 +000000000+000000000 000000102000000004000000000000000000000000000000000000000 0710 000000000000000 0000000000000000 0000000000000000000 0000000310404
|
4
|
+
2000000000407905852100032000012012060420120604000000000000000104-000000000005860-00000000000004164ABSA FEE SETTLEMENT Business Integrator Fees FN71CGW +000000000 +000000000+000000000 000000104000000006000000000000000000000000000000000000000 0710 000000000000000 0000000000000000 0000000000000000000 0000000310404
|
5
|
+
2000000000407905852100032000012012060420120604000000000000000105-000000000005245-00000000000009409ABSA FEE SETTLEMENT Business Integrator Fees FN71CGW +000000000 +000000000+000000000 000000105000000008000000000000000000000000000000000000000 0710 000000000000000 0000000000000000 0000000000000000000 0000000310404
|
6
|
+
2000000000407905852100032000012012060420120604000000000000000106-000000000008446-00000000000017855ABSA FEE SETTLEMENT Business Integrator Fees FN71CGW +000000000 +000000000+000000000 000000106000000010000000000000000000000000000000000000000 0710 000000000000000 0000000000000000 0000000000000000000 0000000310404
|
7
|
+
2000000000407905852100032000012012060420120604000000000000000107-000000000005521-00000000000023376ABSA FEE SETTLEMENT Business Integrator Fees FN71CGW +000000000 +000000000+000000000 000000107000000012000000000000000000000000000000000000000 0710 000000000000000 0000000000000000 0000000000000000000 0000000310404
|
8
|
+
89999999999999999999 -00000000000030317 0000000007 000000031
|
9
|
+
99999999999999999999P20120605 0000000009 000000031
|
@@ -26,6 +26,12 @@ describe Bankserv::Engine do
|
|
26
26
|
FileUtils.mkdir(Dir.pwd + "/spec/examples/95345/incoming") unless File.directory?(Dir.pwd + "/spec/examples/95345/incoming")
|
27
27
|
FileUtils.mkdir(Dir.pwd + "/spec/examples/95345/outgoing") unless File.directory?(Dir.pwd + "/spec/examples/95345/outgoing")
|
28
28
|
|
29
|
+
FileUtils.mkdir(Dir.pwd + "/spec/examples/K010831") unless File.directory?(Dir.pwd + "/spec/examples/K010831")
|
30
|
+
FileUtils.mkdir(Dir.pwd + "/spec/examples/K010831/archive") unless File.directory?(Dir.pwd + "/spec/examples/K010831/archive")
|
31
|
+
FileUtils.mkdir(Dir.pwd + "/spec/examples/K010831/incoming") unless File.directory?(Dir.pwd + "/spec/examples/K010831/incoming")
|
32
|
+
FileUtils.copy(Dir.pwd + "/spec/examples/TJRRECF.0602", Dir.pwd + "/spec/examples/K010831/incoming/")
|
33
|
+
FileUtils.copy(Dir.pwd + "/spec/examples/TJRRECF.0605", Dir.pwd + "/spec/examples/K010831/incoming/")
|
34
|
+
|
29
35
|
FileUtils.copy(Dir.pwd + "/spec/examples/tmp/OUTPUT0412153500.txt", Dir.pwd + "/spec/examples/9534/incoming/")
|
30
36
|
FileUtils.copy(Dir.pwd + "/spec/examples/tmp/REPLY0412153000.txt", Dir.pwd + "/spec/examples/9534/incoming/")
|
31
37
|
Bankserv::EngineConfiguration.create!(interval_in_minutes: 15, input_directory: "/tmp", output_directory: "/tmp", archive_directory: "/tmp")
|
@@ -41,9 +47,10 @@ describe Bankserv::Engine do
|
|
41
47
|
FileUtils.rm_rf(Dir.pwd + "/spec/examples/9999", secure: true)
|
42
48
|
FileUtils.rm_rf(Dir.pwd + "/spec/examples/99999", secure: true)
|
43
49
|
FileUtils.rm_rf(Dir.pwd + "/spec/examples/95345", secure: true)
|
44
|
-
File.delete(Dir.pwd + "/spec/tmp/harry.txt")
|
45
|
-
File.delete(Dir.pwd + "/spec/tmp/sally.txt")
|
46
|
-
File.delete(Dir.pwd + "/spec/tmp/molly.txt")
|
50
|
+
File.delete(Dir.pwd + "/spec/tmp/harry.txt") if File.exists?(Dir.pwd + "/spec/tmp/harry.txt")
|
51
|
+
File.delete(Dir.pwd + "/spec/tmp/sally.txt") if File.exists?(Dir.pwd + "/spec/tmp/sally.txt")
|
52
|
+
File.delete(Dir.pwd + "/spec/tmp/molly.txt") if File.exists?(Dir.pwd + "/spec/tmp/molly.txt")
|
53
|
+
FileUtils.rm_rf(Dir.pwd + "/spec/examples/K010831", secure: true)
|
47
54
|
end
|
48
55
|
|
49
56
|
context "Prepare engine" do
|
@@ -170,48 +177,44 @@ describe Bankserv::Engine do
|
|
170
177
|
|
171
178
|
end
|
172
179
|
|
173
|
-
context "
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
# expected_string = File.open("#{Dir.pwd}/spec/examples/9999/outgoing/INPUT.120411124123.txt", "rb").read
|
212
|
-
# got_string = File.open(@tmpdir + '/molly.txt', "rb").read
|
213
|
-
# got_string.should == expected_string
|
214
|
-
# end
|
180
|
+
context "Integration testing for statement service" do
|
181
|
+
before(:all) do
|
182
|
+
tear_it_down
|
183
|
+
|
184
|
+
Bankserv::StatementService.register({
|
185
|
+
client_code: "10831",
|
186
|
+
client_name: "RENTAL CONNECT PTY LTD",
|
187
|
+
user_code: "AA0A",
|
188
|
+
transmission_status: "L",
|
189
|
+
transmission_number: "1",
|
190
|
+
incoming_directory: Dir.pwd + "/spec/examples/K010831/incoming",
|
191
|
+
outgoing_directory: Dir.pwd + "/spec/examples/K010831/outgoing",
|
192
|
+
reply_directory: Dir.pwd + "/spec/examples/K010831/incoming",
|
193
|
+
archive_directory: Dir.pwd + "/spec/examples/K010831/archive",
|
194
|
+
generation_number: 27
|
195
|
+
})
|
196
|
+
|
197
|
+
Bankserv::Engine.start
|
198
|
+
end
|
199
|
+
|
200
|
+
it "should process all statement files" do
|
201
|
+
Bankserv::Statement.all.size.should == 2
|
202
|
+
end
|
203
|
+
|
204
|
+
it "should mark the statements as processed" do
|
205
|
+
Bankserv::Statement.all.each do |statement|
|
206
|
+
statement.should be_processed
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
it "should move the statements to the archive directory" do
|
211
|
+
Dir.entries(Dir.pwd + "/spec/examples/K010831/incoming").should == [".", ".."]
|
212
|
+
Dir.entries(Dir.pwd + "/spec/examples/K010831/archive").should == [".", "..", "2008"]
|
213
|
+
end
|
214
|
+
|
215
|
+
it "should mark the engines process as completed" do
|
216
|
+
Bankserv::Engine.running?.should be_false
|
217
|
+
end
|
215
218
|
|
216
219
|
end
|
217
220
|
|
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.3.
|
4
|
+
version: 0.3.4
|
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-06-
|
13
|
+
date: 2012-06-11 00:00:00.000000000Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
17
|
-
requirement: &
|
17
|
+
requirement: &70316513421580 !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: *70316513421580
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: activerecord
|
28
|
-
requirement: &
|
28
|
+
requirement: &70316513420820 !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: *70316513420820
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: i18n
|
39
|
-
requirement: &
|
39
|
+
requirement: &70316513420360 !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: *70316513420360
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: absa-h2h
|
50
|
-
requirement: &
|
50
|
+
requirement: &70316513418580 !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: *70316513418580
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: absa-esd
|
61
|
-
requirement: &
|
61
|
+
requirement: &70316513418080 !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: *70316513418080
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: combustion
|
72
|
-
requirement: &
|
72
|
+
requirement: &70316513417600 !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: *70316513417600
|
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. "
|
@@ -131,6 +131,8 @@ files:
|
|
131
131
|
- spec/examples/INPUT.120410144410.txt
|
132
132
|
- spec/examples/INPUT.120411110604.txt
|
133
133
|
- spec/examples/INPUT.120411124123.txt
|
134
|
+
- spec/examples/TJRRECF.0602
|
135
|
+
- spec/examples/TJRRECF.0605
|
134
136
|
- spec/examples/ahv_input_file.txt
|
135
137
|
- spec/examples/ahv_output_file.txt
|
136
138
|
- spec/examples/credit_eft_input.txt
|
@@ -194,6 +196,8 @@ test_files:
|
|
194
196
|
- spec/examples/INPUT.120410144410.txt
|
195
197
|
- spec/examples/INPUT.120411110604.txt
|
196
198
|
- spec/examples/INPUT.120411124123.txt
|
199
|
+
- spec/examples/TJRRECF.0602
|
200
|
+
- spec/examples/TJRRECF.0605
|
197
201
|
- spec/examples/ahv_input_file.txt
|
198
202
|
- spec/examples/ahv_output_file.txt
|
199
203
|
- spec/examples/credit_eft_input.txt
|