cats_core 1.2.20 → 1.2.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/models/cats/core/commodity_substitution.rb +23 -0
- data/app/models/cats/core/transport_bid.rb +3 -1
- data/app/models/cats/core/transport_contract.rb +1 -0
- data/db/migrate/20211229160127_create_cats_core_transport_contracts.rb +4 -0
- data/db/migrate/20211229160129_create_cats_core_commodity_substitutions.rb +23 -0
- data/lib/cats/core/version.rb +1 -1
- data/spec/factories/cats/core/commodity_substitutions.rb +8 -0
- data/spec/factories/cats/core/transport_contracts.rb +1 -0
- metadata +5 -4
- data/app/models/cats/core/transport_request.rb +0 -46
- data/app/models/cats/core/transport_request_item.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c1981cb078f54862e1d8a5a0189f5c30af4a39e27c0640743b516467929e19d
|
4
|
+
data.tar.gz: cc7bd6720e152ff653970291073fc3e597b1387052dde5b8fcc33f886eff2eba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c001644ba4030047ff818acc88225a7b374fdf4a3fb098e645698dae0c5f54e7723aef86ea7ffa98109d4fc596dfc76fa9e6c0d67a1c69e6e7f72392793a7ac8
|
7
|
+
data.tar.gz: cb482c5b61c5d7dbe7f2d692d547dc7ae5c4e2a0443d979f66b0e0db486e0aa041df9e1c798546e6729080fddb4dc6dede4eccf2ea7c72090399bb831f9c20c8
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Cats
|
2
|
+
module Core
|
3
|
+
class CommoditySubstitution < ApplicationRecord
|
4
|
+
belongs_to :program
|
5
|
+
belongs_to :commodity, class_name: 'Cats::Core::CommodityCategory'
|
6
|
+
belongs_to :replaced_by, class_name: 'Cats::Core::CommodityCategory'
|
7
|
+
|
8
|
+
validates :ratio, presence: true
|
9
|
+
validates :program_id, uniqueness: { scope: %i[commodity_id replaced_by_id] }
|
10
|
+
validate :validate_ratio
|
11
|
+
|
12
|
+
def validate_ratio
|
13
|
+
return unless ratio
|
14
|
+
|
15
|
+
left, right = ratio.split(':')
|
16
|
+
left_correct = Integer(left).is_a?(Integer) rescue false
|
17
|
+
right_correct = Integer(right).is_a?(Integer) rescue false
|
18
|
+
|
19
|
+
errors.add(:ratio, 'is not in correct format.') unless left_correct && right_correct
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -4,7 +4,9 @@ module Cats
|
|
4
4
|
NEW = 'New'.freeze
|
5
5
|
OPEN = 'Open'.freeze
|
6
6
|
CLOSED = 'Closed'.freeze
|
7
|
-
|
7
|
+
RANKED = 'Ranked'.freeze
|
8
|
+
WINNERS_DECLARED = 'Winner Declared'.freeze
|
9
|
+
STATUSES = [NEW, OPEN, CLOSED, RANKED, WINNERS_DECLARED].freeze
|
8
10
|
|
9
11
|
has_many :transport_bid_items
|
10
12
|
|
@@ -9,6 +9,10 @@ class CreateCatsCoreTransportContracts < ActiveRecord::Migration[6.1]
|
|
9
9
|
null: false,
|
10
10
|
index: { name: 'transporter_on_tc_indx' },
|
11
11
|
foreign_key: { to_table: :cats_core_transporters }
|
12
|
+
t.references :transport_bid,
|
13
|
+
null: false,
|
14
|
+
index: { name: 'tb_on_tc_indx' },
|
15
|
+
foreign_key: { to_table: :cats_core_transport_bids }
|
12
16
|
t.date :contract_date, null: false
|
13
17
|
t.date :expires_on, null: false
|
14
18
|
t.string :payment_term
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class CreateCatsCoreCommoditySubstitutions < ActiveRecord::Migration[6.1]
|
2
|
+
def change
|
3
|
+
create_table :cats_core_commodity_substitutions do |t|
|
4
|
+
t.references :program,
|
5
|
+
null: false,
|
6
|
+
index: { name: 'program_on_cs_indx' },
|
7
|
+
foreign_key: { to_table: :cats_core_programs }
|
8
|
+
t.references :commodity,
|
9
|
+
null: false,
|
10
|
+
index: { name: 'commodity_on_cs_indx' },
|
11
|
+
foreign_key: { to_table: :cats_core_commodity_categories }
|
12
|
+
t.references :replaced_by,
|
13
|
+
null: false,
|
14
|
+
index: { name: 'rb_on_cs_indx' },
|
15
|
+
foreign_key: { to_table: :cats_core_commodity_categories }
|
16
|
+
t.string :ratio, null: false
|
17
|
+
|
18
|
+
t.timestamps
|
19
|
+
|
20
|
+
t.index [:program_id, :commodity_id, :replaced_by_id], unique: true, name: 'pcr_on_cs_indx'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/cats/core/version.rb
CHANGED
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.
|
4
|
+
version: 1.2.24
|
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-
|
11
|
+
date: 2021-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_model_serializers
|
@@ -256,6 +256,7 @@ files:
|
|
256
256
|
- app/models/cats/core/application_record.rb
|
257
257
|
- app/models/cats/core/commodity.rb
|
258
258
|
- app/models/cats/core/commodity_category.rb
|
259
|
+
- app/models/cats/core/commodity_substitution.rb
|
259
260
|
- app/models/cats/core/contract_item.rb
|
260
261
|
- app/models/cats/core/currency.rb
|
261
262
|
- app/models/cats/core/dispatch.rb
|
@@ -294,8 +295,6 @@ files:
|
|
294
295
|
- app/models/cats/core/transport_bid_item.rb
|
295
296
|
- app/models/cats/core/transport_contract.rb
|
296
297
|
- app/models/cats/core/transport_offer.rb
|
297
|
-
- app/models/cats/core/transport_request.rb
|
298
|
-
- app/models/cats/core/transport_request_item.rb
|
299
298
|
- app/models/cats/core/transporter.rb
|
300
299
|
- app/models/cats/core/unit_of_measure.rb
|
301
300
|
- app/models/cats/core/user.rb
|
@@ -372,6 +371,7 @@ files:
|
|
372
371
|
- db/migrate/20211229160126_create_cats_core_transport_offers.rb
|
373
372
|
- db/migrate/20211229160127_create_cats_core_transport_contracts.rb
|
374
373
|
- db/migrate/20211229160128_create_cats_core_contract_items.rb
|
374
|
+
- db/migrate/20211229160129_create_cats_core_commodity_substitutions.rb
|
375
375
|
- lib/cats/core.rb
|
376
376
|
- lib/cats/core/engine.rb
|
377
377
|
- lib/cats/core/version.rb
|
@@ -382,6 +382,7 @@ files:
|
|
382
382
|
- spec/factories/cats/core/application_modules.rb
|
383
383
|
- spec/factories/cats/core/commodities.rb
|
384
384
|
- spec/factories/cats/core/commodity_categories.rb
|
385
|
+
- spec/factories/cats/core/commodity_substitutions.rb
|
385
386
|
- spec/factories/cats/core/contract_items.rb
|
386
387
|
- spec/factories/cats/core/currencies.rb
|
387
388
|
- spec/factories/cats/core/dispatch_plan_items.rb
|
@@ -1,46 +0,0 @@
|
|
1
|
-
module Cats
|
2
|
-
module Core
|
3
|
-
class TransportRequest < ApplicationRecord
|
4
|
-
DRAFT = 'Draft'.freeze
|
5
|
-
APPROVED = 'Approved'.freeze
|
6
|
-
OPEN = 'Open'.freeze
|
7
|
-
CLOSED = 'Closed'.freeze
|
8
|
-
STATUSES = [DRAFT, APPROVED, OPEN, CLOSED].freeze
|
9
|
-
|
10
|
-
belongs_to :requested_by, class_name: 'Cats::Core::User'
|
11
|
-
belongs_to :approved_by, class_name: 'Cats::Core::User', optional: true
|
12
|
-
has_many :transport_request_items
|
13
|
-
|
14
|
-
validates :reference_no, :request_date, :status, presence: true
|
15
|
-
validates :reference_no, uniqueness: true
|
16
|
-
validates :status, inclusion: { in: STATUSES }
|
17
|
-
|
18
|
-
delegate(:full_name, to: :requested_by, prefix: true, allow_nil: true)
|
19
|
-
delegate(:full_name, to: :approved_by, prefix: true, allow_nil: true)
|
20
|
-
|
21
|
-
def approve(approver)
|
22
|
-
raise(StandardError, 'Request is not open for approval.') unless status == DRAFT
|
23
|
-
|
24
|
-
raise(StandardError, 'Request is empty.') if transport_request_items.count.zero?
|
25
|
-
|
26
|
-
self.approved_by = approver
|
27
|
-
self.status = APPROVED
|
28
|
-
save!
|
29
|
-
end
|
30
|
-
|
31
|
-
def open
|
32
|
-
raise(StandardError, 'Request is not approved for opening.') unless status == APPROVED
|
33
|
-
|
34
|
-
self.status = OPEN
|
35
|
-
save!
|
36
|
-
end
|
37
|
-
|
38
|
-
def close
|
39
|
-
raise(StandardError, 'Request is not open.') unless status == OPEN
|
40
|
-
|
41
|
-
self.status = CLOSED
|
42
|
-
save!
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module Cats
|
2
|
-
module Core
|
3
|
-
class TransportRequestItem < ApplicationRecord
|
4
|
-
belongs_to :transport_request
|
5
|
-
belongs_to :source, class_name: 'Cats::Core::Location'
|
6
|
-
belongs_to :destination, class_name: 'Cats::Core::Location'
|
7
|
-
belongs_to :commodity
|
8
|
-
|
9
|
-
has_many :transport_offers
|
10
|
-
|
11
|
-
delegate(:name, to: :source, prefix: true)
|
12
|
-
delegate(:name, to: :destination, prefix: true)
|
13
|
-
delegate(:name, to: :commodity, prefix: true)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|