cats_core 1.2.34 → 1.2.38

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: 28997d39a875dc6d5747f18de4f4803264aa98e8a49ee6fd09d79da78bf6a959
4
- data.tar.gz: 2ce0c99ef80307ad76a4a070174898edda15ecc7a26b088f279109b9af065a8c
3
+ metadata.gz: 5171c4d2223bd7da58d76a43f140fd5e96f3b00efd377cc41a79e245cc8ad455
4
+ data.tar.gz: 21cc696b9784fbca0f6c8ab9ccdb133787164850d43d52516de8acf99c995855
5
5
  SHA512:
6
- metadata.gz: 6ce37b77dd8690b49307d4748a45ac60294e978d8ebb825e5f81324141ad464d0e021ba005dfa149553449f82e5e8fac68dbea2d679e13741d67b87cde1b75c0
7
- data.tar.gz: 03fe91c921eb78c722bf959b5ac6f6c6368a86da82100f4238e8b854d4ad4b87b30d9ce5a24c2289a864eeba0588e4b5fb7f8bb76c500540ccdce5a51f16a69e
6
+ metadata.gz: d8ded0f55e9f636f3e2726606cb1f14c412d0123cdef3d408503702e86f9cef373c68042cdb0a3e6c1279f96b6ea6c035f6f3c43c37424c33b3a4a76ae64eea6
7
+ data.tar.gz: bdf907e3fec9b8aab351977f0729f8cf3c41dafeef74b4fd5be6fd3800f9f556dbf96694b46055a65d5cc75c7a4ea225d948704063544ddc2eeaba38933592d4
@@ -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
@@ -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,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
@@ -1,5 +1,5 @@
1
1
  module Cats
2
2
  module Core
3
- VERSION = '1.2.34'.freeze
3
+ VERSION = '1.2.38'.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
@@ -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.34
4
+ version: 1.2.38
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