cats_core 1.2.33 → 1.2.37

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: 3aed21bf180ae6d0331c1be25213c8d7d0f2ca5b42a4d4fa36f8d3951b8b9d33
4
- data.tar.gz: 33919ff035f5e95cdddd1f1b9f9571aa6575e889f866feca488f50600f217709
3
+ metadata.gz: 471fe3d0236f281a5c9a9107dce5729fa3822f00c2f23af1b2088ebee1f91cd3
4
+ data.tar.gz: 7a06684824637e7e58387d06f47a965fef6df4e09487994bf1476b27a760b689
5
5
  SHA512:
6
- metadata.gz: 746faa79cd09c46e2da93ac789ca288041ad89800ecd5b8f581692314d691a784c7d6beaecbda079b4e4e176eda80c977e9d149316bdc08061c1d206c617c05e
7
- data.tar.gz: 9f7e39feebfe124849351f697df18b3278e9e53128000d87312a0e18505ef46e43d2ce71db040b86a639daeda6cca6c9af372449fce080cb7b0dc90f80e4bac8
6
+ metadata.gz: 31c6b4b21641550b978598d882f3a2f5c2c76425daae4c985277df8a1bac80c53003c00b65176506a50331f1f845d9ae18afafbb6892a2c894a355a1db18224c
7
+ data.tar.gz: 7b433964536d6c96d59a2388b15f0d18ac60b41cc1a7c24ee85bc9558f093caf3527d3e55e257061297dbafe82375bb30434a54e1d6008c1b32b3b0b34f0f7bd
@@ -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,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
@@ -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,27 @@
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
+ def validate_region
17
+ return unless plan_type
18
+
19
+ errors.add(:region, 'should be null.') if plan_type == NON_REGIONAL && region
20
+
21
+ errors.add(:region, 'should not be null.') if plan_type == REGIONAL && !region
22
+
23
+ errors.add(:region, 'is not valid.') if region && region.location_type != Location::REGION
24
+ end
25
+ end
26
+ end
27
+ 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.33'.freeze
3
+ VERSION = '1.2.37'.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.33
4
+ version: 1.2.37
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-31 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