cats_core 1.2.32 → 1.2.36

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: 28dccafb9f531a0e9c13331b7a3c0cb807ddfeb42504bb1b484e58837c852219
4
- data.tar.gz: 92f65296583c53ef16ac6e07fc849b6541fa5d69ba0f8d5f1b2920b16bdd2924
3
+ metadata.gz: 496524a19290b62ba488dca18f3d4f33c650e6af6702381e698cde2dbd6d9497
4
+ data.tar.gz: e1ca7c19c73a9eb79aec8a25b4ea833501285dac8d715a4779e618f10e0bd519
5
5
  SHA512:
6
- metadata.gz: aa1f417bf917a6d670ac4e787343b520650f46d05d43ec77cd0b747484b3114abee8f03136b9aa71f247b188dfc4a062c6710c8dda44f29b4ba47f20dc271ed5
7
- data.tar.gz: 8583a0ba4f7354469161c43e95fe150a3156b4ec3c1c08b0f0ed1f44924e7b7a620a763dd02c134b6a0c8c0ce34b6f2075e21d0209e43e3f5b392365b341f834
6
+ metadata.gz: e600dd3870ed29dc8762c214335c71435761ef87f62370a8408d60aba84a7128355bcf818a94cd24d70f1f727646341d735ecc4b2520c1cdae0ab94b216ac070
7
+ data.tar.gz: 5028a95e9fd176960f12ebcfab91731737b5928d97f4bcd5a7649325e830d4e1c95817d45351f7e16a61266f1a6eefbdd03977c57393d2ad0c25cb5d34bf54d1
@@ -5,7 +5,7 @@ module Cats
5
5
  belongs_to :ration
6
6
  belongs_to :unit_of_measure
7
7
 
8
- validates :amount, presence: true, numericality: { greater_than: 0 }
8
+ validates :amount, :no_of_days, presence: true, numericality: { greater_than: 0 }
9
9
 
10
10
  delegate(:name, to: :commodity_category, prefix: true)
11
11
  delegate(:abbreviation, to: :unit_of_measure, prefix: true)
@@ -8,22 +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
13
+ has_many :offer_items, through: :transport_offers
18
14
  belongs_to :region, class_name: 'Cats::Core::Location', optional: true
15
+ belongs_to :transport_plan
19
16
 
20
17
  validates :reference_no, presence: true, uniqueness: true
21
- 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
22
19
  validates :bid_bond_amount, numericality: { greater_than_or_equal_to: 0 }
23
20
  validates :status, inclusion: { in: STATUSES }
24
- validates :bid_type, inclusion: { in: BID_TYPES }
25
21
  validate :validate_start_date_against_end_date
26
- validate :validate_region
27
22
 
28
23
  def validate_start_date_against_end_date
29
24
  return unless start_date && end_date
@@ -31,16 +26,6 @@ module Cats
31
26
  errors.add(:start_date, 'should be before end date.') if start_date >= end_date
32
27
  end
33
28
 
34
- def validate_region
35
- return unless bid_type
36
-
37
- errors.add(:region, 'should be null.') if bid_type == NON_REGIONAL && region
38
-
39
- errors.add(:region, 'should not be null.') if bid_type == REGIONAL && !region
40
-
41
- errors.add(:region, 'is not valid.') if region && region.location_type != Location::REGION
42
- end
43
-
44
29
  def open
45
30
  raise(StandardError, 'Bid is already open.') if status == OPEN
46
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
@@ -1,7 +1,6 @@
1
1
  module Cats
2
2
  module Core
3
3
  class TransportContract < ApplicationRecord
4
- belongs_to :region, class_name: 'Cats::Core::Location'
5
4
  belongs_to :transporter
6
5
  belongs_to :transport_bid
7
6
  has_many :contract_items
@@ -9,7 +8,6 @@ module Cats
9
8
  validates :contract_no, presence: true, uniqueness: true
10
9
  validates :contract_date, :expires_on, presence: true
11
10
 
12
- delegate(:name, to: :region, prefix: true)
13
11
  delegate(:name, to: :transporter, prefix: true)
14
12
  delegate(:reference_no, to: :transport_bid, prefix: :bid)
15
13
  end
@@ -0,0 +1,26 @@
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
+
11
+ validates :reference_no, presence: true, uniqueness: true
12
+ validates :plan_type, presence: true, inclusion: { in: PLAN_TYPES }
13
+ validate :validate_region
14
+
15
+ def validate_region
16
+ return unless plan_type
17
+
18
+ errors.add(:region, 'should be null.') if plan_type == NON_REGIONAL && region
19
+
20
+ errors.add(:region, 'should not be null.') if plan_type == REGIONAL && !region
21
+
22
+ errors.add(:region, 'is not valid.') if region && region.location_type != Location::REGION
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,14 @@
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
+ end
13
+ end
14
+ end
@@ -14,6 +14,7 @@ class CreateCatsCoreRationItems < ActiveRecord::Migration[6.1]
14
14
  index: { name: 'uom_on_ration_indx' },
15
15
  foreign_key: { to_table: :cats_core_unit_of_measures }
16
16
  t.float :amount, null: false
17
+ t.integer :no_of_days, null: false
17
18
 
18
19
  t.timestamps
19
20
  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
@@ -2,10 +2,6 @@ class CreateCatsCoreTransportContracts < ActiveRecord::Migration[6.1]
2
2
  def change
3
3
  create_table :cats_core_transport_contracts do |t|
4
4
  t.string :contract_no, unique: true
5
- t.references :region,
6
- null: false,
7
- index: { name: 'region_on_tc_indx' },
8
- foreign_key: { to_table: :cats_core_locations }
9
5
  t.references :transporter,
10
6
  null: false,
11
7
  index: { name: 'transporter_on_tc_indx' },
@@ -1,5 +1,5 @@
1
1
  module Cats
2
2
  module Core
3
- VERSION = '1.2.32'.freeze
3
+ VERSION = '1.2.36'.freeze
4
4
  end
5
5
  end
@@ -4,5 +4,6 @@ FactoryBot.define do
4
4
  ration
5
5
  amount { 150 }
6
6
  unit_of_measure
7
+ no_of_days { 1 }
7
8
  end
8
9
  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
@@ -1,7 +1,6 @@
1
1
  FactoryBot.define do
2
2
  factory :transport_contract, class: 'Cats::Core::TransportContract' do
3
3
  contract_no { FFaker::Name.name }
4
- region factory: :location
5
4
  transporter
6
5
  transport_bid
7
6
  contract_date { Date.today }
@@ -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.32
4
+ version: 1.2.36
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-26 00:00:00.000000000 Z
11
+ date: 2022-01-02 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