et_fake_ccd 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d58e1dffa3e4e623f19f9cab517c6747b73e523fb9abff1cf9a3b080c3e556ee
4
- data.tar.gz: ef9e99c2c7e0e7e7704e584b9987008e3048ef9369f9edcb0372538dc50c4dd1
3
+ metadata.gz: 6e08f42381f699dd1162eb4918819f72ba0271c4ca3aedb5010aa4ac35f4af38
4
+ data.tar.gz: 91148e9f12ab4a6342191541285c162140be9ffbfa51549a1dfef19d50bfe51f
5
5
  SHA512:
6
- metadata.gz: fafbcc1a3b81302e0ef4396020ea0bb226f883b978476f59fcfc58ecbc0c60d42b418db9d3aa9d2065ac3ac6a4904cd20829e4e0e4d57e36a5e406ee9da2fa08
7
- data.tar.gz: 7e43ee0f4f5a1af640d7dab207c8c5be3271d94ae796f7b4687a28f3267e100218550af74bf03baceb8b4c6bbdb334ec64930209e7e6ec27261d9fc7e2b7241b
6
+ metadata.gz: f746897d1a9ab5fd1c606bb037a3ba696770fbea3c97851c72cceb3572bebe0420695eef3fc55b8f2d20e15aa89666ed45fd0f856e7ab81c948806343e03efb3
7
+ data.tar.gz: 985d3be8c217a4a6fb0ceb03e122230bcf9643b5b2eef6774d5ac932db75a77ee94ca028db84752e7cf45b3ca609d290ffdb4bee610e1f4e2eb9f43916a4fc3c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- et_fake_ccd (1.0.4)
4
+ et_fake_ccd (1.0.5)
5
5
  activemodel (>= 5.2.3)
6
6
  iodine (~> 0.7)
7
7
  json-schema (~> 2.5)
@@ -18,8 +18,7 @@ module EtFakeCcd
18
18
  end
19
19
 
20
20
  def call
21
- adapter.reserve_reference_numbers_for(command.case_type_id, quantity: command.case_ref_number_count)
22
- start_reference = adapter.last_case_reference(command.case_type_id) - command.case_ref_number_count
21
+ start_reference = adapter.reserve_reference_numbers_for(command.case_type_id, quantity: command.case_ref_number_count)
23
22
  formatted_ref = "#{office_code_for(command.case_type_id)}#{start_reference.to_s.rjust(5, '0')}/#{Time.now.year}"
24
23
  formatted_multiple = "#{office_code_for(command.case_type_id)}#{adapter.build_multiple_reference(command.case_type_id).to_s.rjust(5, '0')}/#{Time.now.year}"
25
24
  Response.new(command.case_ref_number_count, formatted_ref, formatted_multiple).freeze
@@ -46,18 +45,12 @@ module EtFakeCcd
46
45
  self.data = {}
47
46
  end
48
47
 
49
- def last_case_reference(case_type_id)
50
- last_ref = data.dig(case_type_id, :case_reference)
51
- raise "Case reference not generated for #{case_type_id}" if last_ref.nil?
52
-
53
- last_ref
54
- end
55
-
56
-
57
48
  def reserve_reference_numbers_for(case_type_id, quantity:)
58
49
  data[case_type_id] ||= {}
59
- data[case_type_id][:case_reference] ||= 0
60
- data[case_type_id][:case_reference] += quantity
50
+ data[case_type_id][:next_case_reference] ||= 1
51
+ start = data[case_type_id][:next_case_reference]
52
+ data[case_type_id][:next_case_reference] += quantity
53
+ start
61
54
  end
62
55
 
63
56
  def build_multiple_reference(case_type_id)
@@ -1,3 +1,3 @@
1
1
  module EtFakeCcd
2
- VERSION = "1.0.4"
2
+ VERSION = "1.0.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: et_fake_ccd
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gary Taylor