cats_core 1.2.35 → 1.2.39

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: 7642c89b1980407bb2366d413f35325fa547cf339131269638d41069112504ce
4
- data.tar.gz: a749c65316d24bf37deac90a7b35fa01cf7a463a793a5140f982ad380320d62a
3
+ metadata.gz: 2dd8f771f3ee41bb9c72fc0eece0531aaca3eb3a1fc9722859b67d2eb8b5ef59
4
+ data.tar.gz: 3881439fd98966fde7d3261354f65a18348424ef1732193e4250763cca938517
5
5
  SHA512:
6
- metadata.gz: 957c5ce09ad50fe4e0bcef7ded61b11f6de78a3b0ec4c4055c047186c73f27951050d3c708c37bebca4984ea20b2f360e63e106936c9e2611aff4036cb8dd53e
7
- data.tar.gz: f5a9ed6b97b4bf5e59e11c7a876c9962fef4eb1194e8e242c578ad77675e969071945f2fc423e7765e00f5daddb492f0262f8a79dd3376324863f408ec0b9817
6
+ metadata.gz: d558bbbfb5ae14033312066581de38f6e8dceec258002c72f03b8aec8194d22968efcf47372b5ea7446e63b71fed229d57ce0af11b21453af73f6a39863734c0
7
+ data.tar.gz: fe6eeec34ae2d998d41eff5631c626467162b5592045aa744c6fd0b83587350372b592d57f522dd058359ef00fcb92c754d2ee33ff077c4d3d01d39259a84745
@@ -8,23 +8,17 @@ module Cats
8
8
  WINNERS_DECLARED = 'Winner Declared'.freeze
9
9
  STATUSES = [NEW, OPEN, CLOSED, RANKED, WINNERS_DECLARED].freeze
10
10
 
11
- # Bid types
12
- REGIONAL = 'Regional'.freeze
13
- NON_REGIONAL = 'Non Regional'.freeze
14
- BID_TYPES = [REGIONAL, NON_REGIONAL].freeze
15
-
16
11
  has_many :transport_bid_items
17
12
  has_many :transport_offers
18
13
  has_many :offer_items, through: :transport_offers
19
14
  belongs_to :region, class_name: 'Cats::Core::Location', optional: true
15
+ belongs_to :transport_plan
20
16
 
21
17
  validates :reference_no, presence: true, uniqueness: true
22
- validates :start_date, :end_date, :status, :bid_type, :bid_bond_amount, presence: true
18
+ validates :start_date, :end_date, :status, :bid_bond_amount, presence: true
23
19
  validates :bid_bond_amount, numericality: { greater_than_or_equal_to: 0 }
24
20
  validates :status, inclusion: { in: STATUSES }
25
- validates :bid_type, inclusion: { in: BID_TYPES }
26
21
  validate :validate_start_date_against_end_date
27
- validate :validate_region
28
22
 
29
23
  def validate_start_date_against_end_date
30
24
  return unless start_date && end_date
@@ -32,16 +26,6 @@ module Cats
32
26
  errors.add(:start_date, 'should be before end date.') if start_date >= end_date
33
27
  end
34
28
 
35
- def validate_region
36
- return unless bid_type
37
-
38
- errors.add(:region, 'should be null.') if bid_type == NON_REGIONAL && region
39
-
40
- errors.add(:region, 'should not be null.') if bid_type == REGIONAL && !region
41
-
42
- errors.add(:region, 'is not valid.') if region && region.location_type != Location::REGION
43
- end
44
-
45
29
  def open
46
30
  raise(StandardError, 'Bid is already open.') if status == OPEN
47
31
 
@@ -2,15 +2,13 @@ module Cats
2
2
  module Core
3
3
  class TransportBidItem < ApplicationRecord
4
4
  belongs_to :transport_bid
5
- belongs_to :route
6
- belongs_to :unit, class_name: 'Cats::Core::UnitOfMeasure', optional: true
5
+ belongs_to :transport_plan_item
7
6
 
8
7
  has_many :offer_items
9
8
 
10
9
  validates :quantity, presence: true, numericality: { greater_than: 0 }
10
+ validates :transport_plan_item_id, uniqueness: true
11
11
 
12
- delegate(:name, to: :route, prefix: true)
13
- delegate(:name, to: :unit, prefix: true, allow_nil: true)
14
12
  delegate(:reference_no, to: :transport_bid, prefix: true)
15
13
  end
16
14
  end
@@ -0,0 +1,29 @@
1
+ module Cats
2
+ module Core
3
+ class TransportPlan < ApplicationRecord
4
+ # Plan types
5
+ REGIONAL = 'Regional'.freeze
6
+ NON_REGIONAL = 'Non Regional'.freeze
7
+ PLAN_TYPES = [REGIONAL, NON_REGIONAL].freeze
8
+
9
+ belongs_to :region, class_name: 'Cats::Core::Location', optional: true
10
+ has_many :transport_plan_items
11
+
12
+ validates :reference_no, presence: true, uniqueness: true
13
+ validates :plan_type, presence: true, inclusion: { in: PLAN_TYPES }
14
+ validate :validate_region
15
+
16
+ delegate(:name, to: :region, prefix: true)
17
+
18
+ def validate_region
19
+ return unless plan_type
20
+
21
+ errors.add(:region, 'should be null.') if plan_type == NON_REGIONAL && region
22
+
23
+ errors.add(:region, 'should not be null.') if plan_type == REGIONAL && !region
24
+
25
+ errors.add(:region, 'is not valid.') if region && region.location_type != Location::REGION
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,15 @@
1
+ module Cats
2
+ module Core
3
+ class TransportPlanItem < ApplicationRecord
4
+ belongs_to :route
5
+ belongs_to :transport_plan
6
+ belongs_to :unit, class_name: 'Cats::Core::UnitOfMeasure'
7
+
8
+ validates :quantity, presence: true, numericality: { greater_than: 0 }
9
+
10
+ delegate(:name, to: :route, prefix: true)
11
+ delegate(:name, to: :unit, prefix: true)
12
+ delegate(:reference_no, to: :transport_plan)
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,14 @@
1
+ class CreateCatsCoreTransportPlans < ActiveRecord::Migration[6.1]
2
+ def change
3
+ create_table :cats_core_transport_plans do |t|
4
+ t.string :reference_no, unique: true
5
+ t.string :plan_type, null: false, default: 'Regional'
6
+ t.references :region,
7
+ null: true,
8
+ index: { name: 'region_on_tp_indx' },
9
+ foreign_key: { to_table: :cats_core_locations }
10
+
11
+ t.timestamps
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,22 @@
1
+ class CreateCatsCoreTransportPlanItems < ActiveRecord::Migration[6.1]
2
+ def change
3
+ create_table :cats_core_transport_plan_items do |t|
4
+ t.references :route,
5
+ null: false,
6
+ index: { name: 'route_on_tpi_indx' },
7
+ foreign_key: { to_table: :cats_core_routes }
8
+ t.references :transport_plan,
9
+ null: false,
10
+ index: { name: 'tp_on_tpi_indx' },
11
+ foreign_key: { to_table: :cats_core_transport_plans }
12
+ t.float :quantity, null: false
13
+ t.references :unit,
14
+ null: false,
15
+ index: { name: 'unit_on_tpi_indx' },
16
+ foreign_key: { to_table: :cats_core_unit_of_measures }
17
+ t.boolean :planned, null: false, default: false
18
+
19
+ t.timestamps
20
+ end
21
+ end
22
+ end
@@ -6,12 +6,11 @@ class CreateCatsCoreTransportBids < ActiveRecord::Migration[6.1]
6
6
  t.date :start_date, null: false
7
7
  t.date :end_date, null: false
8
8
  t.string :status, null: false, default: 'New'
9
- t.string :bid_type, null: false, default: 'Regional'
10
- t.references :region,
11
- null: true,
12
- index: { name: 'region_on_tb_indx' },
13
- foreign_key: { to_table: :cats_core_locations }
14
9
  t.float :bid_bond_amount, null: false, default: 0
10
+ t.references :transport_plan,
11
+ null: false,
12
+ index: { name: 'tp_on_tb_indx' },
13
+ foreign_key: { to_table: :cats_core_transport_plans }
15
14
 
16
15
  t.timestamps
17
16
  end
@@ -5,17 +5,15 @@ class CreateCatsCoreTransportBidItems < ActiveRecord::Migration[6.1]
5
5
  null: false,
6
6
  index: { name: 'tb_on_tbi_indx' },
7
7
  foreign_key: { to_table: :cats_core_transport_bids }
8
- t.references :route,
8
+ t.references :transport_plan_item,
9
9
  null: false,
10
- index: { name: 'route_on_tbi_indx' },
11
- foreign_key: { to_table: :cats_core_routes }
12
- t.references :unit,
13
- null: true,
14
- index: { name: 'unit_on_tbi_indx' },
15
- foreign_key: { to_table: :cats_core_unit_of_measures }
10
+ index: { name: 'tpi_on_tbi_indx' },
11
+ foreign_key: { to_table: :cats_core_transport_plan_items }
16
12
  t.float :quantity, null: false
17
13
 
18
14
  t.timestamps
19
15
  end
16
+
17
+ add_index :cats_core_transport_bid_items, :transport_plan_item_id, unique: true
20
18
  end
21
19
  end
@@ -1,5 +1,5 @@
1
1
  module Cats
2
2
  module Core
3
- VERSION = '1.2.35'.freeze
3
+ VERSION = '1.2.39'.freeze
4
4
  end
5
5
  end
@@ -1,8 +1,7 @@
1
1
  FactoryBot.define do
2
2
  factory :transport_bid_item, class: 'Cats::Core::TransportBidItem' do
3
3
  transport_bid
4
- route
5
- unit factory: :unit_of_measure
4
+ transport_plan_item
6
5
  quantity { 100 }
7
6
  end
8
7
  end
@@ -4,8 +4,7 @@ FactoryBot.define do
4
4
  description { FFaker::Name.name }
5
5
  start_date { Date.today - 1.week }
6
6
  end_date { Date.today }
7
- bid_type { Cats::Core::TransportBid::REGIONAL }
8
- region factory: :location
9
7
  bid_bond_amount { 100 }
8
+ transport_plan
10
9
  end
11
10
  end
@@ -0,0 +1,9 @@
1
+ FactoryBot.define do
2
+ factory :transport_plan_item, class: 'Cats::Core::TransportPlanItem' do
3
+ route
4
+ transport_plan
5
+ quantity { 100 }
6
+ unit factory: :unit_of_measure
7
+ planned { false }
8
+ end
9
+ end
@@ -0,0 +1,7 @@
1
+ FactoryBot.define do
2
+ factory :transport_plan, class: 'Cats::Core::TransportPlan' do
3
+ reference_no { FFaker::Name.name }
4
+ plan_type { Cats::Core::TransportPlan::REGIONAL }
5
+ region factory: :location
6
+ end
7
+ 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.35
4
+ version: 1.2.39
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henock L.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-02 00:00:00.000000000 Z
11
+ date: 2022-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers
@@ -296,6 +296,8 @@ files:
296
296
  - app/models/cats/core/transport_bid_item.rb
297
297
  - app/models/cats/core/transport_contract.rb
298
298
  - app/models/cats/core/transport_offer.rb
299
+ - app/models/cats/core/transport_plan.rb
300
+ - app/models/cats/core/transport_plan_item.rb
299
301
  - app/models/cats/core/transporter.rb
300
302
  - app/models/cats/core/unit_of_measure.rb
301
303
  - app/models/cats/core/user.rb
@@ -367,6 +369,8 @@ files:
367
369
  - db/migrate/20211002050739_create_cats_core_notification_rules.rb
368
370
  - db/migrate/20211024063240_add_status_to_cats_core_rhn_requests.rb
369
371
  - db/migrate/20211030133752_add_status_to_cats_core_commodities.rb
372
+ - db/migrate/20211215114737_create_cats_core_transport_plans.rb
373
+ - db/migrate/20211215114835_create_cats_core_transport_plan_items.rb
370
374
  - db/migrate/20211215121151_create_cats_core_transport_bids.rb
371
375
  - db/migrate/20211215124452_create_cats_core_transport_bid_items.rb
372
376
  - db/migrate/20211229160125_create_cats_core_transport_offers.rb
@@ -423,6 +427,8 @@ files:
423
427
  - spec/factories/cats/core/transport_bids.rb
424
428
  - spec/factories/cats/core/transport_contracts.rb
425
429
  - spec/factories/cats/core/transport_offers.rb
430
+ - spec/factories/cats/core/transport_plan_items.rb
431
+ - spec/factories/cats/core/transport_plans.rb
426
432
  - spec/factories/cats/core/transporters.rb
427
433
  - spec/factories/cats/core/unit_of_measures.rb
428
434
  - spec/factories/cats/core/users.rb