cats_core 1.2.17 → 1.2.18

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: d7fad29c6363b9f97a6cdf998aa0af3319adb3484d6c12ac363bd17058de3d0e
4
- data.tar.gz: 31efe7250a22930a60ad18ee7913530ef5c387b4f743e1f606fa91ab764b620d
3
+ metadata.gz: 0b93e9f178cac6984e2689146acb62925c8b1e5aae7ff52af44d1c66c61cbb1f
4
+ data.tar.gz: e86322ba7a49ed5d297d0ee908146c19cdc06379fa3e9378d2453299debe0a68
5
5
  SHA512:
6
- metadata.gz: ff6fa84f59e57e8e7ffe5bfa0e1c6028ecad74a36b98cdff4b189a08fcd367a7c565bd0b7e987a76753df9516d74ba163050ee024cf7659ff0ee98bfc40105bf
7
- data.tar.gz: 0672a380f2afef89c0ca904e27415c4286b36b13c844bcc6d7e5ac93cc767cd7fe225824a9c9116613a4601ac6dce1cbf777ac640832565311ff4ac511f34b71
6
+ metadata.gz: 11740fca3ba58526553c0a5ac21d2092ec1119ff7cfa78e2883d48f4e3bc4cc2fdde53e9276e2369ed173a2c94f8662fdcb5479daf06346e44d13d420c57c099
7
+ data.tar.gz: a03e11f02681870cb1552d4c4a05d7f1de37d25da9a50e98b29bc1ae7c8e4ef2c54b11cb7cb41bbcdec529851ec309596bba5d864fa957dbcede26cd6c96eca2
@@ -6,6 +6,8 @@ module Cats
6
6
  CLOSED = 'Closed'.freeze
7
7
  STATUSES = [NEW, OPEN, CLOSED].freeze
8
8
 
9
+ has_many :transport_bid_items
10
+
9
11
  validates :reference_no, presence: true, uniqueness: true
10
12
  validates :start_date, :end_date, :status, presence: true
11
13
  validates :status, inclusion: { in: STATUSES }
@@ -16,6 +18,26 @@ module Cats
16
18
 
17
19
  errors.add(:start_date, 'should be before end date.') if start_date >= end_date
18
20
  end
21
+
22
+ def open
23
+ raise(StandardError, 'Bid is already open.') if status == OPEN
24
+
25
+ raise(StandardError, 'Bid is empty.') if transport_bid_items.count.zero?
26
+
27
+ self.status = OPEN
28
+ save!
29
+ self
30
+ end
31
+
32
+ def close
33
+ raise(StandardError, 'Bid is already closed.') if status == CLOSED
34
+
35
+ raise(StandardError, 'Bid should first be open.') if status == NEW
36
+
37
+ self.status = CLOSED
38
+ save!
39
+ self
40
+ end
19
41
  end
20
42
  end
21
43
  end
@@ -1,5 +1,5 @@
1
1
  module Cats
2
2
  module Core
3
- VERSION = '1.2.17'.freeze
3
+ VERSION = '1.2.18'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cats_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.17
4
+ version: 1.2.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henock L.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-17 00:00:00.000000000 Z
11
+ date: 2021-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers