bankserv 0.5.4 → 0.5.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -38,5 +38,10 @@ module Bankserv
38
38
  def set_with_generation_number(generation_number)
39
39
  sets.select{|set| set.generation_number == generation_number}.first
40
40
  end
41
+
42
+
43
+ def set_with_dept_code(dept_code)
44
+ sets.select{|set| set.header.data[:dept_code] == dept_code}.first
45
+ end
41
46
  end
42
47
  end
@@ -1,4 +1,13 @@
1
1
  class Bankserv::InputDocument < Bankserv::Document
2
+
3
+ after_create :set_th_ld_for_user
4
+
5
+ def set_th_ld_for_user
6
+ self.set.header.data[:th_for_use_of_ld_user] ||= self.id.to_s
7
+ self.set.header.data[:th_for_use_of_ld_user] = self.id.to_s if self.set.header.data[:th_for_use_of_ld_user] == "0"
8
+ self.user_ref = self.set.header.data[:th_for_use_of_ld_user]
9
+ save!
10
+ end
2
11
 
3
12
  def self.document_type
4
13
  'input'
@@ -104,7 +113,7 @@ class Bankserv::InputDocument < Bankserv::Document
104
113
  document.set.sets << set.generate(hash)
105
114
  document.set.sets[-1].set = document.set # whaaaaaa?
106
115
  end
107
-
116
+
108
117
  document.save!
109
118
  document
110
119
  end
@@ -120,5 +129,9 @@ class Bankserv::InputDocument < Bankserv::Document
120
129
  def self.for_transmission_number(transmission_number)
121
130
  where(type: 'input', transmission_number: transmission_number).first
122
131
  end
123
-
132
+
133
+ def self.for_user_ref(user_ref)
134
+ where(type: 'input', user_ref: user_ref).first
135
+ end
136
+
124
137
  end
@@ -5,40 +5,42 @@ module Bankserv
5
5
  class Reply < Set
6
6
 
7
7
  def process
8
- document = nil
8
+ input_document = Bankserv::InputDocument.for_user_ref(self.set.header.data[:th_for_use_of_ld_user])
9
9
 
10
10
  transactions.each do |transaction|
11
11
  case transaction.record_type
12
12
  when "transmission_status"
13
- document = Bankserv::InputDocument.for_transmission_number(transaction.data[:transmission_number])
14
- document.reply_status = transaction.data[:transmission_status]
15
- document.save!
13
+ # document = Bankserv::InputDocument.for_transmission_number(transaction.data[:transmission_number])
14
+ # document = Bankserv::InputDocument.for_user_ref(transaction.data[:th_for_use_of_ld_user])
15
+ input_document.reply_status = transaction.data[:transmission_status]
16
+ input_document.save!
16
17
 
17
- if document.accepted?
18
- Bankserv::Service.for_client_code(document.client_code).active.each do |service|
18
+ if input_document.accepted?
19
+ Bankserv::Service.for_client_code(input_document.client_code).active.each do |service|
19
20
  service.update_transmission_number!
20
21
  end
21
22
  end
22
23
 
23
24
  when "transmission_rejected_reason"
24
- document.error = {
25
+ input_document.error = {
25
26
  code: transaction.data[:error_code],
26
27
  message: transaction.data[:error_message]
27
28
  }
28
29
 
29
- document.save!
30
+ input_document.save!
30
31
  when "ahv_status"
31
- set = document.set_with_generation_number(transaction.data[:user_code_generation_number])
32
+ # set = document.set_with_generation_number(transaction.data[:user_code_generation_number])
33
+ set = input_document.set_with_dept_code(transaction.data[:user_code_generation_number])
32
34
  set.reply_status = transaction.data[:user_set_status]
33
35
  set.save!
34
36
  when "eft_status"
35
- set = document.set_with_generation_number(transaction.data[:user_code_generation_number])
37
+ set = input_document.set_with_generation_number(transaction.data[:user_code_generation_number])
36
38
  set.reply_status = transaction.data[:user_set_status]
37
39
  set.save!
38
40
  when "accepted_report_reply"
39
41
  # what do we do here.. what is an accepted report reply?
40
42
  when "rejected_message"
41
- set = document.set_with_generation_number(transaction.data[:user_code_generation_number])
43
+ set = input_document.set_with_generation_number(transaction.data[:user_code_generation_number])
42
44
  record = set.record_with_sequence_number(transaction.data[:user_sequence_number])
43
45
 
44
46
  record.error = {
@@ -1,3 +1,3 @@
1
1
  module Bankserv
2
- VERSION = "0.5.4"
2
+ VERSION = "0.5.5"
3
3
  end
@@ -106,6 +106,7 @@ class CreateBankservTables < ActiveRecord::Migration
106
106
  t.string :transmission_number
107
107
  t.string :reply_status
108
108
  t.text :error
109
+ t.string :user_ref
109
110
  t.timestamps
110
111
  end
111
112
 
@@ -1,4 +1,4 @@
1
- 000L2009070302236TEST 000000000000 0
1
+ 000L2009070302236TEST 000000000000 198
2
2
  030L0000001AHVINT
3
3
  031L00000010000000010944025246703085829086M CHAUKE 00000000AHV1
4
4
  031L00000020000000029684746696103120039082A VAN MOLENDORF 00000000AHV2
@@ -1,4 +1,4 @@
1
- 000T2004052400010LDC USER 10 AFRICA (PTY) 000062100000
1
+ 000T2004052400010LDC USER 10 AFRICA (PTY) 000062100000 123
2
2
  001T0495340405240405310405240405270000010037CORPSSV
3
3
  001T5063200504053538939953400000163200501019611899100000001000040524440000ALIMITTST SPP 1040524 01 HENNIE DU TOIT 00000000000000000000 21
4
4
  001T929534000001000016040524040527000014000002000002000020308000000020308000036311034141
@@ -0,0 +1,4 @@
1
+ 000T2004052400000LCD USER 10 AFRICA (PTY) 000012300010 198
2
+ 900T000 TRANSMISSION 00010-0000621 ACCEPTED
3
+ 900T030 AHV USER SET AHVEXT-0000001-ACCEPTED
4
+ 999T000000005
@@ -1,4 +1,4 @@
1
- 000T2004052400000LCD USER 10 AFRICA (PTY) 000012300010
1
+ 000T2004052400000LCD USER 10 AFRICA (PTY) 000012300010 123
2
2
  900T000 TRANSMISSION 00010-0000621 ACCEPTED
3
3
  900T001 ACB USER SET 9534-0000037-000016 ACCEPTED
4
4
  900T001 ACB USER SET 9534-0000038-000032 ACCEPTED
@@ -105,6 +105,7 @@ ActiveRecord::Schema.define do
105
105
  t.string :transmission_number
106
106
  t.string :reply_status
107
107
  t.text :error
108
+ t.string :user_ref
108
109
  t.timestamps
109
110
  end
110
111
 
@@ -77,6 +77,7 @@ describe Bankserv::InputDocument do
77
77
 
78
78
  string = File.open("./spec/examples/ahv_input_file.txt", "rb").read
79
79
  options = Absa::H2h::Transmission::Document.hash_from_s(string, 'input')
80
+ options[:data].first[:data][:th_for_use_of_ld_user] = @document.user_ref
80
81
  hash.should == options
81
82
  end
82
83
 
@@ -70,6 +70,27 @@ describe Bankserv::ReplyDocument do
70
70
  end
71
71
 
72
72
  end
73
+
74
+ context "processing an accepted ahv reply file" do
75
+ before(:all) do
76
+ tear_it_down
77
+ Bankserv::AHVService.register(client_code: '10', client_name: "TESTTEST", client_abbreviated_name: 'TESTTEST', user_code: "9999", generation_number: 1, transmission_status: "L", transmission_number: "1")
78
+ @file_contents = File.open("./spec/examples/ahv_input_file.txt", "rb").read
79
+ @input_document = Bankserv::InputDocument.store(@file_contents)
80
+
81
+ @file_contents = File.open("./spec/examples/reply/reply2.txt", "rb").read
82
+ @options = Absa::H2h::Transmission::Document.hash_from_s(@file_contents, 'output')
83
+
84
+ @reply_document = Bankserv::ReplyDocument.store(@file_contents)
85
+
86
+ @reply_document.process!
87
+ @input_document.reload
88
+ end
89
+
90
+ it "should mark the reply documents reply status as accepted" do
91
+ @input_document.reply_status.should == "ACCEPTED"
92
+ end
93
+ end
73
94
 
74
95
  context "processing a reply file reporting that a transmission was rejected" do
75
96
 
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.5.4
4
+ version: 0.5.5
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-07-10 00:00:00.000000000Z
13
+ date: 2012-07-11 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
17
- requirement: &70245834811860 !ruby/object:Gem::Requirement
17
+ requirement: &70101475587840 !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: *70245834811860
25
+ version_requirements: *70101475587840
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: activerecord
28
- requirement: &70245834811240 !ruby/object:Gem::Requirement
28
+ requirement: &70101475587240 !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: *70245834811240
36
+ version_requirements: *70101475587240
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: i18n
39
- requirement: &70245834810720 !ruby/object:Gem::Requirement
39
+ requirement: &70101475586800 !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: *70245834810720
47
+ version_requirements: *70101475586800
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: absa-h2h
50
- requirement: &70245834810100 !ruby/object:Gem::Requirement
50
+ requirement: &70101475586120 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ~>
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: 0.1.5
56
56
  type: :runtime
57
57
  prerelease: false
58
- version_requirements: *70245834810100
58
+ version_requirements: *70101475586120
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: absa-esd
61
- requirement: &70245834809540 !ruby/object:Gem::Requirement
61
+ requirement: &70101475585520 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ~>
@@ -66,10 +66,10 @@ dependencies:
66
66
  version: 0.0.3
67
67
  type: :runtime
68
68
  prerelease: false
69
- version_requirements: *70245834809540
69
+ version_requirements: *70101475585520
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: absa-notify-me
72
- requirement: &70245834808960 !ruby/object:Gem::Requirement
72
+ requirement: &70101475585000 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
75
  - - ~>
@@ -77,10 +77,10 @@ dependencies:
77
77
  version: 0.0.7
78
78
  type: :runtime
79
79
  prerelease: false
80
- version_requirements: *70245834808960
80
+ version_requirements: *70101475585000
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: combustion
83
- requirement: &70245834808380 !ruby/object:Gem::Requirement
83
+ requirement: &70101475584520 !ruby/object:Gem::Requirement
84
84
  none: false
85
85
  requirements:
86
86
  - - ~>
@@ -88,7 +88,7 @@ dependencies:
88
88
  version: 0.3.1
89
89
  type: :development
90
90
  prerelease: false
91
- version_requirements: *70245834808380
91
+ version_requirements: *70101475584520
92
92
  description: ! "This engine allows users to inject requests into a queue to be processed.
93
93
  \n \n The queue handles bank account validations, credit payments,
94
94
  debit orders\n and collecting bank statements/notify me statements. "
@@ -157,6 +157,7 @@ files:
157
157
  - spec/examples/notify_me.xml
158
158
  - spec/examples/notify_me_with_one_record.xml
159
159
  - spec/examples/reply/rejected_transmission.txt
160
+ - spec/examples/reply/reply2.txt
160
161
  - spec/examples/reply/reply_file.txt
161
162
  - spec/examples/statement4_unpacked.dat
162
163
  - spec/examples/tmp/OUTPUT0412153500.txt
@@ -226,6 +227,7 @@ test_files:
226
227
  - spec/examples/notify_me.xml
227
228
  - spec/examples/notify_me_with_one_record.xml
228
229
  - spec/examples/reply/rejected_transmission.txt
230
+ - spec/examples/reply/reply2.txt
229
231
  - spec/examples/reply/reply_file.txt
230
232
  - spec/examples/statement4_unpacked.dat
231
233
  - spec/examples/tmp/OUTPUT0412153500.txt