cats_core 1.3.12 → 1.3.13

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '08f2f20d4acef0ef129992bee4c7f78ef4bfbd3fe239e500487ff6a2a3a247ae'
4
- data.tar.gz: d01a26f3a74c9cf2a0ce1ef0545a8a4c09cb8a28cd7249772df7bfa43fc46432
3
+ metadata.gz: d8384e95d3bf98191d6f0fb04ce96f6180daf53d653d954ef1470282bf3b4782
4
+ data.tar.gz: 00a0000dba254d8f02dcb8f97fe37b268137d1fe19e03f5c385f2724cb03442b
5
5
  SHA512:
6
- metadata.gz: d7b74a89b8a98f3c3a42281cd6cb8fe7f951b4cca766c089890e0e51361594e989c310b71fd194ee6ffeddd614f80d587056aea8269b9725fdbe31c4b2d44d88
7
- data.tar.gz: 860b2fdfd704fbc6cbbc31c57816f097edef10f94911d9d4f1f59503e8e96da8229fa40fbdd47f15604d34de5fa17148dd7c46968187068429a7cddfe25dbbd6
6
+ metadata.gz: 2d6cdb1dcd812695e16f53ee1a613a834fa7683eb982d54b62cd1662a2082f147b0000ba2fa7453a7fedf5e5a003f94197eadeca05b7768fa104a9fb4655ab53
7
+ data.tar.gz: 7426544df6c7c89477936e11cff07b9ac047c46617b199e02853822cb67260d5b94e08816b51dd7c881173d85e0700a4ddcc3d3a4ab01523f42b2a6ae4e591a6
@@ -2,15 +2,30 @@ module Cats
2
2
  module Core
3
3
  class MonthlyPlan < ApplicationRecord
4
4
  belongs_to :plan
5
- belongs_to :regional_request
5
+ belongs_to :region, class_name: 'Cats::Core::Location'
6
6
 
7
7
  has_many :monthly_plan_items
8
8
  has_many :monthly_rations
9
9
 
10
10
  validates :reference_no, presence: true, uniqueness: true
11
11
  validates :status, presence: true, inclusion: { in: Cats::Core::Plan::STATUSES }
12
+ validates :no_of_days, :month, presence: true, numericality: { greater_than: 0 }
13
+ validate :validate_month, :validate_region
12
14
 
13
- delegate(:reference_no, to: :regional_request, prefix: 'request')
15
+ delegate(:reference_no, to: :plan, prefix: true)
16
+ delegate(:name, to: :region, prefix: true)
17
+
18
+ def validate_month
19
+ return unless month
20
+
21
+ errors.add(:month, 'cannot be greater than 12.') if month > 12
22
+ end
23
+
24
+ def validate_region
25
+ return unless region
26
+
27
+ errors.add(:region, 'is not valid.') unless region.location_type == Cats::Core::Location::REGION
28
+ end
14
29
  end
15
30
  end
16
31
  end
@@ -2,15 +2,17 @@ class CreateCatsCoreMonthlyPlans < ActiveRecord::Migration[6.1]
2
2
  def change
3
3
  create_table :cats_core_monthly_plans do |t|
4
4
  t.string :reference_no, unique: true
5
+ t.integer :month, null: false
6
+ t.integer :no_of_days, null: false
5
7
  t.string :status, null: false, default: 'Draft'
6
8
  t.references :plan,
7
9
  null: false,
8
10
  index: { name: 'plan_on_mp_indx' },
9
11
  foreign_key: { to_table: :cats_core_plans }
10
- t.references :regional_request,
12
+ t.references :region,
11
13
  null: false,
12
- index: { name: 'rr_on_mp_indx' },
13
- foreign_key: { to_table: :cats_core_regional_requests }
14
+ index: { name: 'region_on_mp_indx' },
15
+ foreign_key: { to_table: :cats_core_locations }
14
16
 
15
17
  t.timestamps
16
18
  end
@@ -1,5 +1,5 @@
1
1
  module Cats
2
2
  module Core
3
- VERSION = '1.3.12'.freeze
3
+ VERSION = '1.3.13'.freeze
4
4
  end
5
5
  end
@@ -3,6 +3,8 @@ FactoryBot.define do
3
3
  reference_no { FFaker::Name.name }
4
4
  status { Cats::Core::Plan::DRAFT }
5
5
  plan
6
- regional_request
6
+ region factory: :location
7
+ month { 1 }
8
+ no_of_days { 30 }
7
9
  end
8
10
  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.3.12
4
+ version: 1.3.13
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-08 00:00:00.000000000 Z
11
+ date: 2022-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers
@@ -286,7 +286,6 @@ files:
286
286
  - app/models/cats/core/ration_item.rb
287
287
  - app/models/cats/core/receipt.rb
288
288
  - app/models/cats/core/receipt_transaction.rb
289
- - app/models/cats/core/regional_request.rb
290
289
  - app/models/cats/core/rhn_request.rb
291
290
  - app/models/cats/core/role.rb
292
291
  - app/models/cats/core/role_menu.rb
@@ -385,7 +384,6 @@ files:
385
384
  - db/migrate/20211229160128_create_cats_core_contract_items.rb
386
385
  - db/migrate/20211229160129_create_cats_core_commodity_substitutions.rb
387
386
  - db/migrate/20220103152802_create_cats_core_tenderers.rb
388
- - db/migrate/20220105084347_create_cats_core_regional_requests.rb
389
387
  - db/migrate/20220107121752_create_cats_core_monthly_plans.rb
390
388
  - db/migrate/20220107125025_create_cats_core_monthly_plan_items.rb
391
389
  - db/migrate/20220107132433_create_cats_core_monthly_plan_item_details.rb
@@ -430,7 +428,6 @@ files:
430
428
  - spec/factories/cats/core/rations.rb
431
429
  - spec/factories/cats/core/receipt_transactions.rb
432
430
  - spec/factories/cats/core/receipts.rb
433
- - spec/factories/cats/core/regional_requests.rb
434
431
  - spec/factories/cats/core/rhn_requests.rb
435
432
  - spec/factories/cats/core/role_menus.rb
436
433
  - spec/factories/cats/core/roles.rb
@@ -1,36 +0,0 @@
1
- module Cats
2
- module Core
3
- class RegionalRequest < ApplicationRecord
4
- belongs_to :plan
5
- belongs_to :region, class_name: 'Cats::Core::Location'
6
-
7
- validates :reference_no, presence: true, uniqueness: true
8
- validates :beneficiaries, :no_of_days, :month, presence: true, numericality: { greater_than: 0 }
9
- validate :validate_month, :validate_beneficiaries, :validate_region
10
-
11
- delegate(:reference_no, to: :plan, prefix: true)
12
- delegate(:name, to: :region, prefix: true)
13
-
14
- def validate_month
15
- return unless month
16
-
17
- errors.add(:month, 'cannot be greater than 12.') if month > 12
18
- end
19
-
20
- def validate_beneficiaries
21
- return unless beneficiaries
22
-
23
- return unless plan
24
-
25
- total = plan.plan_items.sum(:beneficiaries)
26
- errors.add(:beneficiaries, "cannot be higher than #{total}.") if total < beneficiaries
27
- end
28
-
29
- def validate_region
30
- return unless region
31
-
32
- errors.add(:region, 'is not valid.') unless region.location_type == Cats::Core::Location::REGION
33
- end
34
- end
35
- end
36
- end
@@ -1,20 +0,0 @@
1
- class CreateCatsCoreRegionalRequests < ActiveRecord::Migration[6.1]
2
- def change
3
- create_table :cats_core_regional_requests do |t|
4
- t.string :reference_no, unique: true
5
- t.integer :beneficiaries, null: false
6
- t.integer :month, null: false
7
- t.integer :no_of_days, null: false
8
- t.references :plan,
9
- null: false,
10
- index: { name: 'plan_on_rr_indx' },
11
- foreign_key: { to_table: :cats_core_plans }
12
- t.references :region,
13
- null: false,
14
- index: { name: 'region_on_rr_indx' },
15
- foreign_key: { to_table: :cats_core_locations }
16
-
17
- t.timestamps
18
- end
19
- end
20
- end
@@ -1,14 +0,0 @@
1
- FactoryBot.define do
2
- factory :regional_request, class: 'Cats::Core::RegionalRequest' do
3
- plan do
4
- pl = create(:plan)
5
- 3.times { create(:plan_item, plan: pl, beneficiaries: 100) }
6
- pl
7
- end
8
- region factory: :location
9
- reference_no { FFaker::Name.name }
10
- beneficiaries { 100 }
11
- month { 1 }
12
- no_of_days { 30 }
13
- end
14
- end