bankserv 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -115,6 +115,15 @@ module Bankserv
115
115
  transactions.select{|rec| rec.data[:user_sequence_number] == sequence_number}.first
116
116
  end
117
117
 
118
+ def base_set
119
+ return parent.base_set if parent
120
+ self
121
+ end
122
+
123
+ def get_document
124
+ base_set.document
125
+ end
126
+
118
127
  end
119
128
 
120
129
  end
@@ -47,13 +47,17 @@ module Bankserv
47
47
  date.strftime("%y%m%d")
48
48
  end
49
49
 
50
- def last_sequence_number_today
51
- last = Record.where("date(created_at) = ? AND record_type = 'standard_record'", Date.today).last
50
+ def self.last_sequence_number_today
51
+ if last = Record.where("date(created_at) = ? AND record_type = 'standard_record'", Date.today).last
52
+ document = last.set.get_document
53
+ raise "Cannot determine sequence number" if ((document) && (document.reply_status != 'ACCEPTED'))
54
+ end
55
+
52
56
  last.nil? ? 0 : last.data[:user_sequence_number].to_i
53
57
  end
54
58
 
55
59
  def user_sequence_number
56
- (last_sequence_number_today + transactions.count + 1).to_s
60
+ (Bankserv::Transmission::UserSet::Eft::last_sequence_number_today + transactions.count + 1).to_s
57
61
  end
58
62
 
59
63
  def contra_records
@@ -75,7 +79,7 @@ module Bankserv
75
79
  record_data.merge!(
76
80
  rec_id: rec_id,
77
81
  bankserv_creation_date: Time.now.strftime("%y%m%d"),
78
- first_sequence_number: (last_sequence_number_today + 1).to_s,
82
+ first_sequence_number: (Bankserv::Transmission::UserSet::Eft.last_sequence_number_today + 1).to_s,
79
83
  user_generation_number: generation_number,
80
84
  type_of_service: @type_of_service,
81
85
  accepted_report: @accepted_report.nil? ? "" : @accepted_report,
@@ -1,3 +1,3 @@
1
1
  module Bankserv
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
@@ -116,7 +116,7 @@ describe Bankserv::Engine do
116
116
 
117
117
  Bankserv::Configuration.stub!(:live_env?).and_return(true)
118
118
  Bankserv::InputDocument.stub!(:fetch_next_transmission_number).and_return("846")
119
- Bankserv::Record.create! record_type:"standard_record", data: {user_sequence_number: 77}, set_id: 76876
119
+ Bankserv::Transmission::UserSet::Eft.stub!(:last_sequence_number_today).and_return(77)
120
120
 
121
121
  Bankserv::Engine.output_directory = Dir.pwd + "/spec/examples/host2host"
122
122
  Bankserv::Engine.input_directory = Dir.pwd + "/spec/examples/host2host"
@@ -185,10 +185,11 @@ describe Bankserv::InputDocument do
185
185
  end
186
186
 
187
187
  it "should build a new document with a credit set" do
188
+ Bankserv::Transmission::UserSet::Eft.stub!(:last_sequence_number_today).and_return(77)
188
189
  Bankserv::Configuration.stub!(:live_env?).and_return(true)
189
190
  Bankserv::InputDocument.stub!(:fetch_next_transmission_number).and_return("846")
190
191
 
191
- Bankserv::Record.create! record_type:"standard_record", data: {user_sequence_number: 77}, set_id: 76876
192
+ #Bankserv::Record.create! record_type:"standard_record", data: {user_sequence_number: 77}, set_id: 76876
192
193
 
193
194
  Bankserv::InputDocument.generate!(
194
195
  th_for_use_of_ld_user: ""
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.1.6
4
+ version: 0.1.7
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-04 00:00:00.000000000Z
13
+ date: 2012-04-05 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
17
- requirement: &70348632669320 !ruby/object:Gem::Requirement
17
+ requirement: &70135436090400 !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: *70348632669320
25
+ version_requirements: *70135436090400
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: activerecord
28
- requirement: &70348632649320 !ruby/object:Gem::Requirement
28
+ requirement: &70135436089760 !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: *70348632649320
36
+ version_requirements: *70135436089760
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: i18n
39
- requirement: &70348632648800 !ruby/object:Gem::Requirement
39
+ requirement: &70135436089260 !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: *70348632648800
47
+ version_requirements: *70135436089260
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: absa-h2h
50
- requirement: &70348632648220 !ruby/object:Gem::Requirement
50
+ requirement: &70135436088560 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ~>
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: 0.0.13
56
56
  type: :runtime
57
57
  prerelease: false
58
- version_requirements: *70348632648220
58
+ version_requirements: *70135436088560
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: absa-esd
61
- requirement: &70348632647700 !ruby/object:Gem::Requirement
61
+ requirement: &70135436087960 !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: *70348632647700
69
+ version_requirements: *70135436087960
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: combustion
72
- requirement: &70348632647240 !ruby/object:Gem::Requirement
72
+ requirement: &70135436087380 !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: *70348632647240
80
+ version_requirements: *70135436087380
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. "