bankserv 0.4.7 → 0.4.8
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/bankserv/account_holder_verification.rb +0 -15
- data/lib/bankserv/credit.rb +0 -13
- data/lib/bankserv/debit.rb +0 -11
- data/lib/bankserv/eft.rb +0 -4
- data/lib/bankserv/service.rb +16 -1
- data/lib/bankserv/transmission/document.rb +0 -2
- data/lib/bankserv/transmission/input_document.rb +17 -3
- data/lib/bankserv/transmission/reply_document.rb +1 -1
- data/lib/bankserv/transmission/set/account_holder_verification.rb +11 -5
- data/lib/bankserv/transmission/set/account_holder_verification_output.rb +1 -4
- data/lib/bankserv/transmission/set/eft_redirect.rb +1 -1
- data/lib/bankserv/transmission/set/eft_unpaid.rb +1 -4
- data/lib/bankserv/transmission/set/reply.rb +7 -3
- data/lib/bankserv/version.rb +1 -1
- data/lib/generators/active_record/templates/migration.rb +0 -3
- data/spec/examples/ahv_input_file.txt +2 -2
- data/spec/examples/ahv_output_file.txt +3 -3
- data/spec/examples/credit_eft_input.txt +1 -1
- data/spec/examples/debit_eft_input_file.txt +1 -1
- data/spec/examples/reply/rejected_transmission.txt +1 -1
- data/spec/examples/reply/reply_file.txt +1 -1
- data/spec/internal/db/schema.rb +0 -3
- data/spec/lib/bankserv/account_holder_verification_spec.rb +0 -5
- data/spec/lib/bankserv/credit_spec.rb +0 -9
- data/spec/lib/bankserv/debit_spec.rb +0 -9
- data/spec/lib/bankserv/transmission/input_document_spec.rb +14 -8
- data/spec/lib/bankserv/transmission/output_document_spec.rb +24 -36
- data/spec/lib/bankserv/transmission/reply_document_spec.rb +16 -4
- data/spec/lib/bankserv/transmission/set/account_holder_verification_spec.rb +18 -11
- metadata +16 -16
@@ -11,17 +11,6 @@ module Bankserv
|
|
11
11
|
scope :internal, where(internal: true)
|
12
12
|
scope :external, where(internal: false)
|
13
13
|
|
14
|
-
after_create :generate_internal_user_ref
|
15
|
-
|
16
|
-
def generate_internal_user_ref
|
17
|
-
self.internal_user_ref = Bankserv::AccountHolderVerification.generate_reference_number(self)
|
18
|
-
save!
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.generate_reference_number(ahv)
|
22
|
-
"AHV#{ahv.id}"
|
23
|
-
end
|
24
|
-
|
25
14
|
def self.service
|
26
15
|
Bankserv::AHVService.where(active: true).last
|
27
16
|
end
|
@@ -30,10 +19,6 @@ module Bankserv
|
|
30
19
|
self.where(:user_ref => reference)
|
31
20
|
end
|
32
21
|
|
33
|
-
def self.for_internal_reference(reference)
|
34
|
-
self.where(:internal_user_ref => reference)
|
35
|
-
end
|
36
|
-
|
37
22
|
def self.build!(options)
|
38
23
|
bank_account = BankAccount.new(options.delete(:bank_account))
|
39
24
|
is_internal = bank_account.branch_code == self.service.config[:internal_branch_code]
|
data/lib/bankserv/credit.rb
CHANGED
@@ -9,8 +9,6 @@ module Bankserv
|
|
9
9
|
belongs_to :bank_account, :foreign_key => 'bankserv_bank_account_id'
|
10
10
|
belongs_to :request, :foreign_key => 'bankserv_request_id'
|
11
11
|
|
12
|
-
after_create :generate_internal_user_ref
|
13
|
-
|
14
12
|
def self.bankserv_service
|
15
13
|
Bankserv::CreditService.where(active: true).last
|
16
14
|
end
|
@@ -19,19 +17,10 @@ module Bankserv
|
|
19
17
|
Bankserv::Credit.bankserv_service
|
20
18
|
end
|
21
19
|
|
22
|
-
def generate_internal_user_ref
|
23
|
-
self.internal_user_ref = "CREDIT#{id}"
|
24
|
-
save!
|
25
|
-
end
|
26
|
-
|
27
20
|
def self.for_reference(reference)
|
28
21
|
self.where(:user_ref => reference)
|
29
22
|
end
|
30
23
|
|
31
|
-
def self.for_internal_reference(reference)
|
32
|
-
self.where(:internal_user_ref => reference)
|
33
|
-
end
|
34
|
-
|
35
24
|
def new?
|
36
25
|
status == "new"
|
37
26
|
end
|
@@ -74,7 +63,5 @@ module Bankserv
|
|
74
63
|
self.bank_account
|
75
64
|
end
|
76
65
|
end
|
77
|
-
|
78
66
|
end
|
79
|
-
|
80
67
|
end
|
data/lib/bankserv/debit.rb
CHANGED
@@ -9,8 +9,6 @@ module Bankserv
|
|
9
9
|
belongs_to :bank_account, :foreign_key => 'bankserv_bank_account_id'
|
10
10
|
belongs_to :request, :foreign_key => 'bankserv_request_id'
|
11
11
|
|
12
|
-
after_create :generate_internal_user_ref
|
13
|
-
|
14
12
|
def self.bankserv_service
|
15
13
|
Bankserv::DebitService.where(active: true).last
|
16
14
|
end
|
@@ -19,11 +17,6 @@ module Bankserv
|
|
19
17
|
Bankserv::Debit.bankserv_service
|
20
18
|
end
|
21
19
|
|
22
|
-
def generate_internal_user_ref
|
23
|
-
self.internal_user_ref = "DEBIT#{id}"
|
24
|
-
save!
|
25
|
-
end
|
26
|
-
|
27
20
|
def standard?
|
28
21
|
record_type == "standard"
|
29
22
|
end
|
@@ -54,10 +47,6 @@ module Bankserv
|
|
54
47
|
self.where(:user_ref => reference)
|
55
48
|
end
|
56
49
|
|
57
|
-
def self.for_internal_reference(reference)
|
58
|
-
self.where(:internal_user_ref => reference)
|
59
|
-
end
|
60
|
-
|
61
50
|
def process_response(data)
|
62
51
|
save_data = if data[:response_status] == 'unpaid'
|
63
52
|
{
|
data/lib/bankserv/eft.rb
CHANGED
data/lib/bankserv/service.rb
CHANGED
@@ -4,6 +4,8 @@ module Bankserv
|
|
4
4
|
|
5
5
|
has_many :requests
|
6
6
|
serialize :config
|
7
|
+
|
8
|
+
scope :for_client_code, lambda {|client_code| where(client_code: client_code)}
|
7
9
|
|
8
10
|
def self.register(params)
|
9
11
|
s = new
|
@@ -54,6 +56,11 @@ module Bankserv
|
|
54
56
|
def can_transmit?
|
55
57
|
false
|
56
58
|
end
|
59
|
+
|
60
|
+
def update_transmission_number!
|
61
|
+
config[:transmission_number] = (config[:transmission_number].to_i + 1).to_s
|
62
|
+
save!
|
63
|
+
end
|
57
64
|
|
58
65
|
end
|
59
66
|
|
@@ -90,7 +97,15 @@ module Bankserv
|
|
90
97
|
|
91
98
|
def can_transmit?
|
92
99
|
true
|
93
|
-
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def has_work?
|
103
|
+
if self.config[:internal]
|
104
|
+
Bankserv::AccountHolderVerification.internal.unprocessed.count > 0
|
105
|
+
else
|
106
|
+
Bankserv::AccountHolderVerification.external.unprocessed.count > 0
|
107
|
+
end
|
108
|
+
end
|
94
109
|
end
|
95
110
|
|
96
111
|
class StatementService < Service
|
@@ -37,6 +37,10 @@ class Bankserv::InputDocument < Bankserv::Document
|
|
37
37
|
def self.has_test_work?
|
38
38
|
sets_with_test_work.any?
|
39
39
|
end
|
40
|
+
|
41
|
+
def accepted?
|
42
|
+
reply_status == "ACCEPTED"
|
43
|
+
end
|
40
44
|
|
41
45
|
def self.generate!(bankserv_service)
|
42
46
|
if bankserv_service.is_test_env?
|
@@ -49,7 +53,14 @@ class Bankserv::InputDocument < Bankserv::Document
|
|
49
53
|
options.merge! rec_status: bankserv_service.config[:transmission_status]
|
50
54
|
options.merge! client_code: bankserv_service.client_code
|
51
55
|
options.merge! client_name: bankserv_service.config[:client_name]
|
52
|
-
options.merge! th_for_use_of_ld_user:
|
56
|
+
options.merge! th_for_use_of_ld_user: bankserv_service.config[:transmission_number]
|
57
|
+
|
58
|
+
if bankserv_service.config.has_key? :internal
|
59
|
+
# swap the internal status and check if the service has any work.
|
60
|
+
bankserv_service.config[:internal] = !bankserv_service.config[:internal]
|
61
|
+
bankserv_service.save
|
62
|
+
return unless bankserv_service.has_work?
|
63
|
+
end
|
53
64
|
|
54
65
|
transmission_status = bankserv_service.config[:transmission_status]
|
55
66
|
raise "Transmission status not specified" if transmission_status.nil?
|
@@ -75,8 +86,11 @@ class Bankserv::InputDocument < Bankserv::Document
|
|
75
86
|
input_sets.select!{|s| s.bankserv_service.client_code == bankserv_service.client_code}
|
76
87
|
return unless input_sets.count > 0
|
77
88
|
|
78
|
-
input_sets.each do |set|
|
79
|
-
|
89
|
+
input_sets.each do |set|
|
90
|
+
hash = {rec_status: document.rec_status}
|
91
|
+
hash.merge!(internal: bankserv_service.config[:internal]) if bankserv_service.config.has_key?(:internal)
|
92
|
+
|
93
|
+
document.set.sets << set.generate(hash)
|
80
94
|
document.set.sets[-1].set = document.set # whaaaaaa?
|
81
95
|
end
|
82
96
|
|
@@ -4,9 +4,12 @@ module Bankserv
|
|
4
4
|
class AccountHolderVerification < Set
|
5
5
|
|
6
6
|
before_create :set_header, :set_trailer, :decorate_records
|
7
|
+
|
8
|
+
attr_accessor :department_code
|
7
9
|
|
8
10
|
def self.generate(options = {})
|
9
|
-
[:internal
|
11
|
+
arr = options[:internal] ? [:internal] : [:external]
|
12
|
+
arr.collect do |type|
|
10
13
|
ahvs = Bankserv::AccountHolderVerification.unprocessed.send(type)
|
11
14
|
|
12
15
|
if options[:rec_status] == "L"
|
@@ -17,7 +20,7 @@ module Bankserv
|
|
17
20
|
|
18
21
|
if ahvs.count > 0
|
19
22
|
set = self.new
|
20
|
-
set.build_header
|
23
|
+
set.build_header(type: type)
|
21
24
|
ahvs.each{|ahv| set.build_transaction(ahv)}
|
22
25
|
set.build_trailer
|
23
26
|
set
|
@@ -46,7 +49,7 @@ module Bankserv
|
|
46
49
|
id_number: ahv.bank_account.id_number,
|
47
50
|
initials: ahv.bank_account.initials,
|
48
51
|
surname: ahv.bank_account.account_name,
|
49
|
-
user_ref: ahv.
|
52
|
+
user_ref: ahv.user_ref
|
50
53
|
)
|
51
54
|
|
52
55
|
record_data.merge!(branch_code: ahv.bank_account.branch_code) if ahv.external?
|
@@ -70,9 +73,13 @@ module Bankserv
|
|
70
73
|
end
|
71
74
|
|
72
75
|
def set_header
|
76
|
+
type = header[:data].delete(:type)
|
77
|
+
department_code = "AHVEXT"
|
78
|
+
department_code = "AHVINT" if type == :internal
|
79
|
+
|
73
80
|
self.generation_number = bankserv_service.reserve_generation_number!.to_s
|
74
81
|
header.data[:gen_no] = generation_number
|
75
|
-
header.data[:dept_code] =
|
82
|
+
header.data[:dept_code] = department_code
|
76
83
|
end
|
77
84
|
|
78
85
|
def set_trailer
|
@@ -81,6 +88,5 @@ module Bankserv
|
|
81
88
|
end
|
82
89
|
|
83
90
|
end
|
84
|
-
|
85
91
|
end
|
86
92
|
end
|
@@ -6,12 +6,9 @@ module Bankserv
|
|
6
6
|
|
7
7
|
def process
|
8
8
|
transactions.each do |transaction|
|
9
|
-
Bankserv::AccountHolderVerification.
|
9
|
+
Bankserv::AccountHolderVerification.for_reference(transaction.reference).first.process_response(transaction.data)
|
10
10
|
end
|
11
11
|
end
|
12
|
-
|
13
12
|
end
|
14
|
-
|
15
13
|
end
|
16
|
-
|
17
14
|
end
|
@@ -6,7 +6,7 @@ module Bankserv
|
|
6
6
|
|
7
7
|
def process
|
8
8
|
transactions.each do |transaction|
|
9
|
-
eft = Bankserv::Eft.
|
9
|
+
eft = Bankserv::Eft.for_reference(transaction.reference).first
|
10
10
|
eft.process_response(transaction.data.merge(response_status: 'redirect')) if eft
|
11
11
|
end
|
12
12
|
end
|
@@ -6,13 +6,10 @@ module Bankserv
|
|
6
6
|
|
7
7
|
def process
|
8
8
|
transactions.each do |transaction|
|
9
|
-
eft = Bankserv::Eft.
|
9
|
+
eft = Bankserv::Eft.for_reference(transaction.reference).first
|
10
10
|
eft.process_response(transaction.data.merge(response_status: 'unpaid')) if eft
|
11
11
|
end
|
12
12
|
end
|
13
|
-
|
14
13
|
end
|
15
|
-
|
16
14
|
end
|
17
|
-
|
18
15
|
end
|
@@ -13,6 +13,13 @@ module Bankserv
|
|
13
13
|
document = Bankserv::InputDocument.for_transmission_number(transaction.data[:transmission_number])
|
14
14
|
document.reply_status = transaction.data[:transmission_status]
|
15
15
|
document.save!
|
16
|
+
|
17
|
+
if document.accepted?
|
18
|
+
Bankserv::Service.for_client_code(document.client_code).active.each do |service|
|
19
|
+
service.update_transmission_number!
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
16
23
|
when "transmission_rejected_reason"
|
17
24
|
document.error = {
|
18
25
|
code: transaction.data[:error_code],
|
@@ -43,9 +50,6 @@ module Bankserv
|
|
43
50
|
end
|
44
51
|
end
|
45
52
|
end
|
46
|
-
|
47
53
|
end
|
48
|
-
|
49
54
|
end
|
50
|
-
|
51
55
|
end
|
data/lib/bankserv/version.rb
CHANGED
@@ -67,7 +67,6 @@ class CreateBankservTables < ActiveRecord::Migration
|
|
67
67
|
t.string :status, :default => "new"
|
68
68
|
t.text :response
|
69
69
|
t.string :user_ref
|
70
|
-
t.string :internal_user_ref
|
71
70
|
t.timestamps
|
72
71
|
end
|
73
72
|
|
@@ -81,7 +80,6 @@ class CreateBankservTables < ActiveRecord::Migration
|
|
81
80
|
t.string :status, :default => "new"
|
82
81
|
t.text :response
|
83
82
|
t.string :user_ref
|
84
|
-
t.string :internal_user_ref
|
85
83
|
t.timestamps
|
86
84
|
end
|
87
85
|
|
@@ -95,7 +93,6 @@ class CreateBankservTables < ActiveRecord::Migration
|
|
95
93
|
t.string :status, :default => "new"
|
96
94
|
t.text :response
|
97
95
|
t.string :user_ref
|
98
|
-
t.string :internal_user_ref
|
99
96
|
t.timestamps
|
100
97
|
end
|
101
98
|
|
@@ -1,5 +1,5 @@
|
|
1
|
-
000L2009070302236TEST 000000000000
|
2
|
-
|
1
|
+
000L2009070302236TEST 000000000000 0
|
2
|
+
030L0000001AHVINT
|
3
3
|
031L00000010000000010944025246703085829086M CHAUKE 00000000AHV1
|
4
4
|
031L00000020000000029684746696103120039082A VAN MOLENDORF 00000000AHV2
|
5
5
|
031L00000030000000024920081778801261110087U NKWEBA 00000000AHV3
|
@@ -1,7 +1,7 @@
|
|
1
1
|
000L2009070302236TEST 00000001000000
|
2
2
|
030L0000001000001
|
3
|
-
031L00000010000000010944025246703085829086M CHAUKE
|
4
|
-
031L00000020000000029684746696103120039082A VAN MOLENDORF
|
5
|
-
031L00000030000000024920081778801261110087U NKWEBA
|
3
|
+
031L00000010000000010944025246703085829086M CHAUKE 00000000149505000000000223600000008000
|
4
|
+
031L00000020000000029684746696103120039082A VAN MOLENDORF 00020304198841000000000223600000000000
|
5
|
+
031L00000030000000024920081778801261110087U NKWEBA 00000000149205000000000223605000700000
|
6
6
|
039L0000003000000006554885370
|
7
7
|
999L000000007
|
@@ -1,4 +1,4 @@
|
|
1
|
-
000L2008080800986TESTTEST 000084600000
|
1
|
+
000L2008080800986TESTTEST 000084600000 846
|
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
|
@@ -1,4 +1,4 @@
|
|
1
|
-
000T2004052400010LDC USER 10 AFRICA (PTY) 000062100000
|
1
|
+
000T2004052400010LDC USER 10 AFRICA (PTY) 000062100000 621
|
2
2
|
001T0495340405240405250405240405250000010037CORPSSV
|
3
3
|
001T5063200504053538939953400000163200501019611899100000001000040524440000ALIMITTST SPP 1040524 01 HENNIE DU TOIT 00000000000000000000 21
|
4
4
|
001T5063200504053538939953400000263200501019801892100000002000040524440000ALIMITTST SPP 1040524 02 TYRONE DREYDEN 00000000000000000000 21
|
data/spec/internal/db/schema.rb
CHANGED
@@ -66,7 +66,6 @@ ActiveRecord::Schema.define do
|
|
66
66
|
t.string :status, :default => "new"
|
67
67
|
t.text :response
|
68
68
|
t.string :user_ref
|
69
|
-
t.string :internal_user_ref
|
70
69
|
t.timestamps
|
71
70
|
end
|
72
71
|
|
@@ -80,7 +79,6 @@ ActiveRecord::Schema.define do
|
|
80
79
|
t.string :status, :default => "new"
|
81
80
|
t.text :response
|
82
81
|
t.string :user_ref
|
83
|
-
t.string :internal_user_ref
|
84
82
|
t.timestamps
|
85
83
|
end
|
86
84
|
|
@@ -94,7 +92,6 @@ ActiveRecord::Schema.define do
|
|
94
92
|
t.string :status, :default => "new"
|
95
93
|
t.text :response
|
96
94
|
t.string :user_ref
|
97
|
-
t.string :internal_user_ref
|
98
95
|
t.timestamps
|
99
96
|
end
|
100
97
|
|
@@ -70,11 +70,6 @@ describe Bankserv::AccountHolderVerification do
|
|
70
70
|
ahv.should be_external
|
71
71
|
end
|
72
72
|
|
73
|
-
it "should generate a unique internal reference" do
|
74
|
-
@ahv_service.request(@hash)
|
75
|
-
Bankserv::AccountHolderVerification.last.internal_user_ref.should match /AHV[0-9]+/
|
76
|
-
end
|
77
|
-
|
78
73
|
end
|
79
74
|
|
80
75
|
context "when processing an account holder verification response" do
|
@@ -2,15 +2,6 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Bankserv::Debit do
|
4
4
|
|
5
|
-
context "creating a new credit" do
|
6
|
-
|
7
|
-
it "should generate a unique internal reference" do
|
8
|
-
create(:credit)
|
9
|
-
Bankserv::Credit.last.internal_user_ref.should match /CREDIT[0-9]+/
|
10
|
-
end
|
11
|
-
|
12
|
-
end
|
13
|
-
|
14
5
|
context "queuing a batch of credit orders" do
|
15
6
|
|
16
7
|
before(:all) do
|
@@ -2,15 +2,6 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Bankserv::Debit do
|
4
4
|
|
5
|
-
context "creating a new debit" do
|
6
|
-
|
7
|
-
it "should generate a unique internal reference" do
|
8
|
-
create(:debit)
|
9
|
-
Bankserv::Debit.last.internal_user_ref.should match /DEBIT[0-9]+/
|
10
|
-
end
|
11
|
-
|
12
|
-
end
|
13
|
-
|
14
5
|
context "queuing a batch of debit orders" do
|
15
6
|
|
16
7
|
before(:all) do
|
@@ -7,7 +7,7 @@ describe Bankserv::InputDocument do
|
|
7
7
|
|
8
8
|
before(:each) do
|
9
9
|
tear_it_down
|
10
|
-
bankserv_service = Bankserv::AHVService.register(client_code: '2236', internal_branch_code: '632005', department_code: "000001", client_name: "TEST", client_abbreviated_name: 'TESTTEST', generation_number: 1, transmission_status: "L", transmission_number: "0")
|
10
|
+
bankserv_service = Bankserv::AHVService.register(client_code: '2236', internal_branch_code: '632005', department_code: "000001", client_name: "TEST", client_abbreviated_name: 'TESTTEST', generation_number: 1, transmission_status: "L", transmission_number: "0", internal: false)
|
11
11
|
|
12
12
|
ahv_attributes = {
|
13
13
|
bank_account: {
|
@@ -18,13 +18,12 @@ describe Bankserv::InputDocument do
|
|
18
18
|
initials: "M",
|
19
19
|
account_name: "CHAUKE"
|
20
20
|
},
|
21
|
-
user_ref: "
|
21
|
+
user_ref: "AHV1"
|
22
22
|
}
|
23
23
|
|
24
24
|
bankserv_service.request(type: 'ahv', data: ahv_attributes)
|
25
25
|
ahv = Bankserv::AccountHolderVerification.last
|
26
26
|
ahv.internal = true
|
27
|
-
ahv.internal_user_ref = "AHV1"
|
28
27
|
ahv.save!
|
29
28
|
|
30
29
|
ahv_attributes = {
|
@@ -36,13 +35,12 @@ describe Bankserv::InputDocument do
|
|
36
35
|
initials: "A",
|
37
36
|
account_name: "VAN MOLENDORF"
|
38
37
|
},
|
39
|
-
user_ref: "
|
38
|
+
user_ref: "AHV2"
|
40
39
|
}
|
41
40
|
|
42
41
|
bankserv_service.request(type: 'ahv', data: ahv_attributes)
|
43
42
|
ahv = Bankserv::AccountHolderVerification.last
|
44
43
|
ahv.internal = true
|
45
|
-
ahv.internal_user_ref = "AHV2"
|
46
44
|
ahv.save!
|
47
45
|
|
48
46
|
ahv_attributes = {
|
@@ -54,13 +52,12 @@ describe Bankserv::InputDocument do
|
|
54
52
|
initials: "U",
|
55
53
|
account_name: "NKWEBA"
|
56
54
|
},
|
57
|
-
user_ref: "
|
55
|
+
user_ref: "AHV3"
|
58
56
|
}
|
59
57
|
|
60
58
|
bankserv_service.request(type: 'ahv', data: ahv_attributes)
|
61
59
|
ahv = Bankserv::AccountHolderVerification.last
|
62
60
|
ahv.internal = true
|
63
|
-
ahv.internal_user_ref = "AHV3"
|
64
61
|
ahv.save!
|
65
62
|
|
66
63
|
t = Time.local(2009, 7, 3, 10, 5, 0)
|
@@ -80,7 +77,6 @@ describe Bankserv::InputDocument do
|
|
80
77
|
|
81
78
|
string = File.open("./spec/examples/ahv_input_file.txt", "rb").read
|
82
79
|
options = Absa::H2h::Transmission::Document.hash_from_s(string, 'input')
|
83
|
-
|
84
80
|
hash.should == options
|
85
81
|
end
|
86
82
|
|
@@ -88,6 +84,16 @@ describe Bankserv::InputDocument do
|
|
88
84
|
@document.mark_processed!
|
89
85
|
@document.processed.should be_true
|
90
86
|
end
|
87
|
+
|
88
|
+
it "should mark the ahv services internal status to true" do
|
89
|
+
Bankserv::AHVService.active.first.config[:internal].should be_true
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should not build a document if no sets could be generated" do
|
93
|
+
Bankserv::Transmission::UserSet::Document.all.count.should == 1
|
94
|
+
Bankserv::InputDocument.generate!(Bankserv::AHVService.active.first)
|
95
|
+
Bankserv::Transmission::UserSet::Document.all.count.should == 1
|
96
|
+
end
|
91
97
|
end
|
92
98
|
|
93
99
|
context "building a transmission document two batches of debit order requests" do
|
@@ -67,8 +67,6 @@ describe Bankserv::OutputDocument do
|
|
67
67
|
internal: true
|
68
68
|
)
|
69
69
|
|
70
|
-
ahv1.save!
|
71
|
-
ahv1.internal_user_ref = "AHV1"
|
72
70
|
ahv1.save!
|
73
71
|
|
74
72
|
ahv2 = Bankserv::AccountHolderVerification.new(
|
@@ -85,9 +83,7 @@ describe Bankserv::OutputDocument do
|
|
85
83
|
)
|
86
84
|
|
87
85
|
ahv2.save!
|
88
|
-
|
89
|
-
ahv2.save!
|
90
|
-
|
86
|
+
|
91
87
|
ahv3 = Bankserv::AccountHolderVerification.new(
|
92
88
|
bank_account: Bankserv::BankAccount.new(
|
93
89
|
account_number: "2492008177",
|
@@ -101,8 +97,6 @@ describe Bankserv::OutputDocument do
|
|
101
97
|
internal: true
|
102
98
|
)
|
103
99
|
|
104
|
-
ahv3.save!
|
105
|
-
ahv3.internal_user_ref = "AHV3"
|
106
100
|
ahv3.save!
|
107
101
|
|
108
102
|
Bankserv::AccountHolderVerification.for_reference("149505000000000223600000008000").first.completed?.should be_false
|
@@ -158,38 +152,32 @@ describe Bankserv::OutputDocument do
|
|
158
152
|
|
159
153
|
it "should be able to process the document, updating any related debit or credit requests" do
|
160
154
|
debits = []
|
161
|
-
debits << Bankserv::Debit.create!(record_type: "standard", amount: 7627, batch_id: 1, user_ref: "
|
162
|
-
debits << Bankserv::Debit.create!(record_type: "standard", amount: 9964, batch_id: 1, user_ref: "
|
163
|
-
debits << Bankserv::Debit.create!(record_type: "standard", amount: 10851, batch_id: 2, user_ref: "
|
164
|
-
debits << Bankserv::Debit.create!(record_type: "standard", amount: 31700, batch_id: 3, user_ref: "
|
165
|
-
debits << Bankserv::Debit.create!(record_type: "standard", amount: 13755, batch_id: 3, user_ref: "
|
166
|
-
debits << Bankserv::Debit.create!(record_type: "standard", amount: 22935, batch_id: 4, user_ref: "
|
167
|
-
debits << Bankserv::Debit.create!(record_type: "standard", amount: 15198, batch_id: 4, user_ref: "
|
168
|
-
debits << Bankserv::Debit.create!(record_type: "standard", amount: 12720, batch_id: 4, user_ref: "
|
169
|
-
debits << Bankserv::Debit.create!(record_type: "standard", amount: 9345, batch_id: 4, user_ref: "
|
170
|
-
debits << Bankserv::Debit.create!(record_type: "standard", amount: 13420, batch_id: 4, user_ref: "
|
171
|
-
debits << Bankserv::Debit.create!(record_type: "standard", amount: 15300, batch_id: 4, user_ref: "
|
172
|
-
debits << Bankserv::Debit.create!(record_type: "standard", amount: 7790, batch_id: 4, user_ref: "
|
173
|
-
debits << Bankserv::Debit.create!(record_type: "standard", amount: 19698, batch_id: 4, user_ref: "
|
174
|
-
debits << Bankserv::Debit.create!(record_type: "standard", amount: 5000, batch_id: 4, user_ref: "
|
175
|
-
debits << Bankserv::Debit.create!(record_type: "standard", amount: 10420, batch_id: 4, user_ref: "
|
176
|
-
debits << Bankserv::Debit.create!(record_type: "standard", amount: 10000, batch_id: 4, user_ref: "
|
177
|
-
debits << Bankserv::Debit.create!(record_type: "standard", amount: 15000, batch_id: 4, user_ref: "
|
178
|
-
debits << Bankserv::Debit.create!(record_type: "standard", amount: 10000, batch_id: 4, user_ref: "
|
179
|
-
debits << Bankserv::Debit.create!(record_type: "standard", amount: 16150, batch_id: 4, user_ref: "
|
180
|
-
debits << Bankserv::Debit.create!(record_type: "standard", amount: 12300, batch_id: 4, user_ref: "
|
181
|
-
debits << Bankserv::Debit.create!(record_type: "standard", amount: 20000, batch_id: 4, user_ref: "
|
182
|
-
debits << Bankserv::Debit.create!(record_type: "standard", amount: 6287, batch_id: 4, user_ref: "
|
183
|
-
debits << Bankserv::Debit.create!(record_type: "standard", amount: 8954, batch_id: 4, user_ref: "
|
155
|
+
debits << Bankserv::Debit.create!(record_type: "standard", amount: 7627, batch_id: 1, user_ref: "DEBIT1")
|
156
|
+
debits << Bankserv::Debit.create!(record_type: "standard", amount: 9964, batch_id: 1, user_ref: "DEBIT2")
|
157
|
+
debits << Bankserv::Debit.create!(record_type: "standard", amount: 10851, batch_id: 2, user_ref: "DEBIT3")
|
158
|
+
debits << Bankserv::Debit.create!(record_type: "standard", amount: 31700, batch_id: 3, user_ref: "DEBIT4")
|
159
|
+
debits << Bankserv::Debit.create!(record_type: "standard", amount: 13755, batch_id: 3, user_ref: "DEBIT5")
|
160
|
+
debits << Bankserv::Debit.create!(record_type: "standard", amount: 22935, batch_id: 4, user_ref: "DEBIT6")
|
161
|
+
debits << Bankserv::Debit.create!(record_type: "standard", amount: 15198, batch_id: 4, user_ref: "DEBIT7")
|
162
|
+
debits << Bankserv::Debit.create!(record_type: "standard", amount: 12720, batch_id: 4, user_ref: "DEBIT8")
|
163
|
+
debits << Bankserv::Debit.create!(record_type: "standard", amount: 9345, batch_id: 4, user_ref: "DEBIT9")
|
164
|
+
debits << Bankserv::Debit.create!(record_type: "standard", amount: 13420, batch_id: 4, user_ref: "DEBIT10")
|
165
|
+
debits << Bankserv::Debit.create!(record_type: "standard", amount: 15300, batch_id: 4, user_ref: "DEBIT11")
|
166
|
+
debits << Bankserv::Debit.create!(record_type: "standard", amount: 7790, batch_id: 4, user_ref: "DEBIT12")
|
167
|
+
debits << Bankserv::Debit.create!(record_type: "standard", amount: 19698, batch_id: 4, user_ref: "DEBIT13")
|
168
|
+
debits << Bankserv::Debit.create!(record_type: "standard", amount: 5000, batch_id: 4, user_ref: "DEBIT14")
|
169
|
+
debits << Bankserv::Debit.create!(record_type: "standard", amount: 10420, batch_id: 4, user_ref: "DEBIT15")
|
170
|
+
debits << Bankserv::Debit.create!(record_type: "standard", amount: 10000, batch_id: 4, user_ref: "DEBIT16")
|
171
|
+
debits << Bankserv::Debit.create!(record_type: "standard", amount: 15000, batch_id: 4, user_ref: "DEBIT17")
|
172
|
+
debits << Bankserv::Debit.create!(record_type: "standard", amount: 10000, batch_id: 4, user_ref: "DEBIT18")
|
173
|
+
debits << Bankserv::Debit.create!(record_type: "standard", amount: 16150, batch_id: 4, user_ref: "DEBIT19")
|
174
|
+
debits << Bankserv::Debit.create!(record_type: "standard", amount: 12300, batch_id: 4, user_ref: "DEBIT20")
|
175
|
+
debits << Bankserv::Debit.create!(record_type: "standard", amount: 20000, batch_id: 4, user_ref: "DEBIT21")
|
176
|
+
debits << Bankserv::Debit.create!(record_type: "standard", amount: 6287, batch_id: 4, user_ref: "DEBIT22")
|
177
|
+
debits << Bankserv::Debit.create!(record_type: "standard", amount: 8954, batch_id: 4, user_ref: "DEBIT23")
|
184
178
|
|
185
179
|
counter = 1
|
186
180
|
|
187
|
-
debits.each do |debit|
|
188
|
-
debit.internal_user_ref = "DEBIT#{counter}"
|
189
|
-
debit.save!
|
190
|
-
counter += 1
|
191
|
-
end
|
192
|
-
|
193
181
|
Bankserv::Debit.all.each{|debit| debit.completed?.should be_false}
|
194
182
|
@document.process!
|
195
183
|
|
@@ -8,6 +8,7 @@ describe Bankserv::ReplyDocument do
|
|
8
8
|
before(:all) do
|
9
9
|
tear_it_down
|
10
10
|
Bankserv::DebitService.register(client_code: '12346', client_name: "TESTTEST", client_abbreviated_name: 'TESTTEST', user_code: "9999", generation_number: 1, transmission_status: "L", transmission_number: "1")
|
11
|
+
Bankserv::CreditService.register(client_code: '12346', client_name: "TESTTEST", client_abbreviated_name: 'TESTTEST', user_code: "9999", generation_number: 1, transmission_status: "L", transmission_number: "1")
|
11
12
|
|
12
13
|
@file_contents = File.open("./spec/examples/reply/reply_file.txt", "rb").read
|
13
14
|
@options = Absa::H2h::Transmission::Document.hash_from_s(@file_contents, 'output')
|
@@ -34,7 +35,8 @@ describe Bankserv::ReplyDocument do
|
|
34
35
|
|
35
36
|
before(:each) do
|
36
37
|
tear_it_down
|
37
|
-
Bankserv::DebitService.register(client_code: '
|
38
|
+
Bankserv::DebitService.register(client_code: '10', client_name: "TESTTEST", client_abbreviated_name: 'TESTTEST', user_code: "9999", generation_number: 1, transmission_status: "L", transmission_number: "1")
|
39
|
+
Bankserv::CreditService.register(client_code: '10', client_name: "TESTTEST", client_abbreviated_name: 'TESTTEST', user_code: "9999", generation_number: 1, transmission_status: "L", transmission_number: "1")
|
38
40
|
|
39
41
|
@file_contents = File.open("./spec/examples/eft_input_with_2_sets.txt", "rb").read
|
40
42
|
@input_document = Bankserv::InputDocument.store(@file_contents)
|
@@ -42,12 +44,11 @@ describe Bankserv::ReplyDocument do
|
|
42
44
|
@file_contents = File.open("./spec/examples/reply/reply_file.txt", "rb").read
|
43
45
|
@options = Absa::H2h::Transmission::Document.hash_from_s(@file_contents, 'output')
|
44
46
|
|
45
|
-
@reply_document = Bankserv::
|
47
|
+
@reply_document = Bankserv::ReplyDocument.store(@file_contents)
|
46
48
|
end
|
47
49
|
|
48
50
|
it "should mark the original input document as ACCEPTED if the transmission was accepted" do
|
49
51
|
@input_document.reply_status.should be_nil
|
50
|
-
|
51
52
|
@reply_document.process!
|
52
53
|
|
53
54
|
@input_document.reload
|
@@ -62,6 +63,11 @@ describe Bankserv::ReplyDocument do
|
|
62
63
|
set.reply_status.should == "ACCEPTED"
|
63
64
|
end
|
64
65
|
end
|
66
|
+
|
67
|
+
it "should update the tranmission number of the service" do
|
68
|
+
@reply_document.process!
|
69
|
+
Bankserv::DebitService.last.config[:transmission_number].should == "2"
|
70
|
+
end
|
65
71
|
|
66
72
|
end
|
67
73
|
|
@@ -69,7 +75,8 @@ describe Bankserv::ReplyDocument do
|
|
69
75
|
|
70
76
|
before(:all) do
|
71
77
|
tear_it_down
|
72
|
-
Bankserv::DebitService.register(client_code: '
|
78
|
+
Bankserv::DebitService.register(client_code: '10', client_name: "TESTTEST", client_abbreviated_name: 'TESTTEST', user_code: "9999", generation_number: 1, transmission_status: "L", transmission_number: "1")
|
79
|
+
Bankserv::CreditService.register(client_code: '10', client_name: "TESTTEST", client_abbreviated_name: 'TESTTEST', user_code: "9999", generation_number: 1, transmission_status: "L", transmission_number: "1")
|
73
80
|
|
74
81
|
@file_contents = File.open("./spec/examples/eft_input_with_2_sets.txt", "rb").read
|
75
82
|
@input_document = Bankserv::InputDocument.store(@file_contents)
|
@@ -82,6 +89,11 @@ describe Bankserv::ReplyDocument do
|
|
82
89
|
@reply_document.process!
|
83
90
|
@input_document.reload
|
84
91
|
end
|
92
|
+
|
93
|
+
it "should not update the tranmission number of the services" do
|
94
|
+
Bankserv::DebitService.last.config[:transmission_number].should == "1"
|
95
|
+
Bankserv::CreditService.last.config[:transmission_number].should == "1"
|
96
|
+
end
|
85
97
|
|
86
98
|
context "processing a transmission status record" do
|
87
99
|
it "should mark the document's reply status as REJECTED" do
|
@@ -5,7 +5,7 @@ describe Bankserv::Transmission::UserSet::AccountHolderVerification do
|
|
5
5
|
|
6
6
|
before(:all) do
|
7
7
|
tear_it_down
|
8
|
-
ahv_service = Bankserv::AHVService.register(client_code: '12345', internal_branch_code: '632005', department_code: "506", client_name: "TESTTEST", client_abbreviated_name: 'TESTTEST', generation_number: 1, transmission_status: "T", transmission_number: "1")
|
8
|
+
ahv_service = Bankserv::AHVService.register(client_code: '12345', internal_branch_code: '632005', department_code: "506", client_name: "TESTTEST", client_abbreviated_name: 'TESTTEST', generation_number: 1, transmission_status: "T", transmission_number: "1", internal: true)
|
9
9
|
|
10
10
|
@ahv_list = [
|
11
11
|
ahv_service.request(type: 'ahv', data: attributes_for(:internal_ahv).merge(bank_account: attributes_for(:internal_bank_account))),
|
@@ -21,20 +21,26 @@ describe Bankserv::Transmission::UserSet::AccountHolderVerification do
|
|
21
21
|
it "should report when there are account holder verification requests that need to be processed" do
|
22
22
|
Bankserv::Transmission::UserSet::AccountHolderVerification.has_test_work?.should be_true
|
23
23
|
end
|
24
|
-
|
25
|
-
it "should
|
26
|
-
sets = Bankserv::Transmission::UserSet::AccountHolderVerification.generate(rec_status: "T")
|
27
|
-
|
28
|
-
sets.count.should ==
|
24
|
+
|
25
|
+
it "should process the external account holder verifications" do
|
26
|
+
sets = Bankserv::Transmission::UserSet::AccountHolderVerification.generate(rec_status: "T", internal: false)
|
27
|
+
|
28
|
+
sets.count.should == 1
|
29
|
+
sets.first.transactions.count.should == 3
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should process the internal account holder verifications" do
|
33
|
+
sets = Bankserv::Transmission::UserSet::AccountHolderVerification.generate(rec_status: "T", internal: true)
|
34
|
+
|
35
|
+
sets.count.should == 1
|
29
36
|
sets.first.transactions.count.should == 2
|
30
|
-
sets.last.transactions.count.should == 3
|
31
37
|
end
|
32
38
|
|
33
39
|
context "Building an account holder verification set" do
|
34
40
|
|
35
41
|
before(:each) do
|
36
42
|
tear_it_down
|
37
|
-
ahv_service = Bankserv::AHVService.register(client_code: '12345', internal_branch_code: '632005', department_code: "506", client_name: "TESTTEST", client_abbreviated_name: 'TESTTEST', generation_number: 1, transmission_status: "T", transmission_number: "1")
|
43
|
+
ahv_service = Bankserv::AHVService.register(client_code: '12345', internal_branch_code: '632005', department_code: "506", client_name: "TESTTEST", client_abbreviated_name: 'TESTTEST', generation_number: 1, transmission_status: "T", transmission_number: "1", internal: false)
|
38
44
|
|
39
45
|
@ahv_list = [
|
40
46
|
ahv_service.request(type: 'ahv', data: attributes_for(:internal_ahv).merge(bank_account: attributes_for(:internal_bank_account))),
|
@@ -49,7 +55,7 @@ describe Bankserv::Transmission::UserSet::AccountHolderVerification do
|
|
49
55
|
context "creating a header" do
|
50
56
|
|
51
57
|
before(:each) do
|
52
|
-
@set = Bankserv::Transmission::UserSet::AccountHolderVerification.generate(rec_status: "T").first
|
58
|
+
@set = Bankserv::Transmission::UserSet::AccountHolderVerification.generate(rec_status: "T", internal: true).first
|
53
59
|
@set.save
|
54
60
|
end
|
55
61
|
|
@@ -67,13 +73,14 @@ describe Bankserv::Transmission::UserSet::AccountHolderVerification do
|
|
67
73
|
|
68
74
|
it "should store the specified department code" do
|
69
75
|
@set.header.data.has_key?(:dept_code).should be_true
|
76
|
+
@set.header.data[:dept_code].should == "AHVINT"
|
70
77
|
end
|
71
78
|
end
|
72
79
|
|
73
80
|
context "creating a trailer" do
|
74
81
|
|
75
82
|
before(:each) do
|
76
|
-
@set = Bankserv::Transmission::UserSet::AccountHolderVerification.generate(rec_status: "T").first
|
83
|
+
@set = Bankserv::Transmission::UserSet::AccountHolderVerification.generate(rec_status: "T", internal: true).first
|
77
84
|
@set.save
|
78
85
|
end
|
79
86
|
|
@@ -98,7 +105,7 @@ describe Bankserv::Transmission::UserSet::AccountHolderVerification do
|
|
98
105
|
end
|
99
106
|
|
100
107
|
it "should create a batch of transactions when the job begins" do
|
101
|
-
batch = Bankserv::Transmission::UserSet::AccountHolderVerification.generate(rec_status: "T").first
|
108
|
+
batch = Bankserv::Transmission::UserSet::AccountHolderVerification.generate(rec_status: "T", internal: true).first
|
102
109
|
batch.save
|
103
110
|
batch.transactions.first.record_type.should == "internal_account_detail"
|
104
111
|
end
|
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.4.
|
4
|
+
version: 0.4.8
|
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-29 00:00:00.000000000Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
17
|
-
requirement: &
|
17
|
+
requirement: &70159062700580 !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: *70159062700580
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: activerecord
|
28
|
-
requirement: &
|
28
|
+
requirement: &70159062700000 !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: *70159062700000
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: i18n
|
39
|
-
requirement: &
|
39
|
+
requirement: &70159062699300 !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: *70159062699300
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: absa-h2h
|
50
|
-
requirement: &
|
50
|
+
requirement: &70159062698560 !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: *
|
58
|
+
version_requirements: *70159062698560
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: absa-esd
|
61
|
-
requirement: &
|
61
|
+
requirement: &70159062697860 !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: *
|
69
|
+
version_requirements: *70159062697860
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: absa-notify-me
|
72
|
-
requirement: &
|
72
|
+
requirement: &70159062697200 !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
75
|
- - ~>
|
@@ -77,10 +77,10 @@ dependencies:
|
|
77
77
|
version: 0.0.5
|
78
78
|
type: :runtime
|
79
79
|
prerelease: false
|
80
|
-
version_requirements: *
|
80
|
+
version_requirements: *70159062697200
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
82
|
name: combustion
|
83
|
-
requirement: &
|
83
|
+
requirement: &70159062696640 !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: *
|
91
|
+
version_requirements: *70159062696640
|
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. "
|