cats_core 1.3.5 → 1.3.9

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: 0c3d4ff631edb9b8c8b84475b5dbc38866a8dc7ee2e6b91d1ae7d0e986ae22c1
4
- data.tar.gz: ffb3251702f63bba57a7f3c89f960b175b1d341d03ce35468fef4a5b660531e7
3
+ metadata.gz: 060d0c6d315bf7f71c6745ceb159793b3815e1656ba8894f0e00e2672a25b315
4
+ data.tar.gz: 4506f7254df1d32e8ff3560fcfa556a83b9c536e7a775eb2753dc01b8a8ecf41
5
5
  SHA512:
6
- metadata.gz: 11f445e39c09484942cd571ec81bf78b23a182dac03f37f89270c359902f75103e2ce0ca0240b9954c5fc580b7af34ac16686d2eaf05ea7dcd9193172abfba60
7
- data.tar.gz: 9b0dc2b6d6eded7d43aec38c7c9742e4bf10c2f33be48315f172fdb3b278ef697e0e00a2febd5451bb9fbb0d096b2f8977fa2a31fbd7723721813ab5725bd48e
6
+ metadata.gz: 05070066e3f2ff98cf049935d6e04c1cc6b20ebe22fe7bedcc304ec858cdf07d72bacc354349989095377333069ab37f342fc834924a40e96d68ffdd4a1c4d32
7
+ data.tar.gz: e244c97987112f7c0a82f6f0086d05ebcbe993a14a5c975c2fe99b4b2cf818e946072155b941ba889a0247217bf4998ef3b6877bb8babad4759c3e8466b6f587
@@ -0,0 +1,16 @@
1
+ module Cats
2
+ module Core
3
+ class MonthlyPlan < ApplicationRecord
4
+ belongs_to :ration
5
+ belongs_to :plan
6
+ belongs_to :regional_request
7
+
8
+ has_many :monthly_plan_items
9
+
10
+ validates :reference_no, presence: true, uniqueness: true
11
+ validates :status, presence: true, inclusion: { in: Cats::Core::Plan::STATUSES }
12
+
13
+ delegate(:reference_no, to: :regional_request, prefix: 'request')
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,12 @@
1
+ module Cats
2
+ module Core
3
+ class MonthlyPlanItem < ApplicationRecord
4
+ belongs_to :monthly_plan
5
+ belongs_to :plan_item
6
+
7
+ has_many :monthly_plan_item_details
8
+
9
+ validates :beneficiaries, presence: true, numericality: { greater_than: 0 }
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,10 @@
1
+ module Cats
2
+ module Core
3
+ class MonthlyPlanItemDetail < ApplicationRecord
4
+ belongs_to :monthly_plan_item
5
+ belongs_to :ration_item
6
+
7
+ validates :amount, presence: true, numericality: { greater_than: 0 }
8
+ end
9
+ end
10
+ end
@@ -2,10 +2,14 @@ module Cats
2
2
  module Core
3
3
  class RegionalRequest < ApplicationRecord
4
4
  belongs_to :plan
5
+ belongs_to :region, class_name: 'Cats::Core::Location'
5
6
 
6
7
  validates :reference_no, presence: true, uniqueness: true
7
8
  validates :beneficiaries, :no_of_days, :month, presence: true, numericality: { greater_than: 0 }
8
- validate :validate_month, :validate_beneficiaries
9
+ validate :validate_month, :validate_beneficiaries, :validate_region
10
+
11
+ delegate(:reference_no, to: :plan, prefix: true)
12
+ delegate(:name, to: :region, prefix: true)
9
13
 
10
14
  def validate_month
11
15
  return unless month
@@ -21,6 +25,12 @@ module Cats
21
25
  total = plan.plan_items.sum(:beneficiaries)
22
26
  errors.add(:beneficiaries, "cannot be higher than #{total}.") if total < beneficiaries
23
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
24
34
  end
25
35
  end
26
36
  end
@@ -9,6 +9,10 @@ class CreateCatsCoreRegionalRequests < ActiveRecord::Migration[6.1]
9
9
  null: false,
10
10
  index: { name: 'plan_on_rr_indx' },
11
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 }
12
16
 
13
17
  t.timestamps
14
18
  end
@@ -0,0 +1,22 @@
1
+ class CreateCatsCoreMonthlyPlans < ActiveRecord::Migration[6.1]
2
+ def change
3
+ create_table :cats_core_monthly_plans do |t|
4
+ t.string :reference_no, unique: true
5
+ t.string :status, null: false, default: 'Draft'
6
+ t.references :ration,
7
+ null: false,
8
+ index: { name: 'ration_on_mp_indx' },
9
+ foreign_key: { to_table: :cats_core_rations }
10
+ t.references :plan,
11
+ null: false,
12
+ index: { name: 'plan_on_mp_indx' },
13
+ foreign_key: { to_table: :cats_core_plans }
14
+ t.references :regional_request,
15
+ null: false,
16
+ index: { name: 'rr_on_mp_indx' },
17
+ foreign_key: { to_table: :cats_core_regional_requests }
18
+
19
+ t.timestamps
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,17 @@
1
+ class CreateCatsCoreMonthlyPlanItems < ActiveRecord::Migration[6.1]
2
+ def change
3
+ create_table :cats_core_monthly_plan_items do |t|
4
+ t.references :monthly_plan,
5
+ null: false,
6
+ index: { name: 'mp_on_mpi_indx' },
7
+ foreign_key: { to_table: :cats_core_monthly_plans }
8
+ t.integer :beneficiaries, null: false
9
+ t.references :plan_item,
10
+ null: false,
11
+ index: { name: 'pi_on_mpi_indx' },
12
+ foreign_key: { to_table: :cats_core_plan_items }
13
+
14
+ t.timestamps
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ class CreateCatsCoreMonthlyPlanItemDetails < ActiveRecord::Migration[6.1]
2
+ def change
3
+ create_table :cats_core_monthly_plan_item_details do |t|
4
+ t.references :monthly_plan_item,
5
+ null: false,
6
+ index: { name: 'mpi_on_mpid_indx' },
7
+ foreign_key: { to_table: :cats_core_monthly_plan_items }
8
+ t.references :ration_item,
9
+ null: false,
10
+ index: { name: 'ri_on_mpid_indx' },
11
+ foreign_key: { to_table: :cats_core_ration_items }
12
+ t.float :amount, null: false
13
+
14
+ t.timestamps
15
+ end
16
+ end
17
+ end
@@ -1,5 +1,5 @@
1
1
  module Cats
2
2
  module Core
3
- VERSION = '1.3.5'.freeze
3
+ VERSION = '1.3.9'.freeze
4
4
  end
5
5
  end
@@ -0,0 +1,7 @@
1
+ FactoryBot.define do
2
+ factory :monthly_plan_item_detail, class: 'Cats::Core::MonthlyPlanItemDetail' do
3
+ monthly_plan_item
4
+ ration_item
5
+ amount { 150 }
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ FactoryBot.define do
2
+ factory :monthly_plan_item, class: 'Cats::Core::MonthlyPlanItem' do
3
+ monthly_plan
4
+ beneficiaries { 100 }
5
+ plan_item
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ FactoryBot.define do
2
+ factory :monthly_plan, class: 'Cats::Core::MonthlyPlan' do
3
+ reference_no { FFaker::Name.name }
4
+ status { Cats::Core::Plan::DRAFT }
5
+ ration
6
+ plan
7
+ regional_request
8
+ end
9
+ end
@@ -5,6 +5,7 @@ FactoryBot.define do
5
5
  3.times { create(:plan_item, plan: pl, beneficiaries: 100) }
6
6
  pl
7
7
  end
8
+ region factory: :location
8
9
  reference_no { FFaker::Name.name }
9
10
  beneficiaries { 100 }
10
11
  month { 1 }
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.5
4
+ version: 1.3.9
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-06 00:00:00.000000000 Z
11
+ date: 2022-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers
@@ -269,6 +269,9 @@ files:
269
269
  - app/models/cats/core/location.rb
270
270
  - app/models/cats/core/menu.rb
271
271
  - app/models/cats/core/menu_item.rb
272
+ - app/models/cats/core/monthly_plan.rb
273
+ - app/models/cats/core/monthly_plan_item.rb
274
+ - app/models/cats/core/monthly_plan_item_detail.rb
272
275
  - app/models/cats/core/notification.rb
273
276
  - app/models/cats/core/notification_rule.rb
274
277
  - app/models/cats/core/offer_item.rb
@@ -382,6 +385,9 @@ files:
382
385
  - db/migrate/20211229160129_create_cats_core_commodity_substitutions.rb
383
386
  - db/migrate/20220103152802_create_cats_core_tenderers.rb
384
387
  - db/migrate/20220105084347_create_cats_core_regional_requests.rb
388
+ - db/migrate/20220107121752_create_cats_core_monthly_plans.rb
389
+ - db/migrate/20220107125025_create_cats_core_monthly_plan_items.rb
390
+ - db/migrate/20220107132433_create_cats_core_monthly_plan_item_details.rb
385
391
  - lib/cats/core.rb
386
392
  - lib/cats/core/engine.rb
387
393
  - lib/cats/core/version.rb
@@ -405,6 +411,9 @@ files:
405
411
  - spec/factories/cats/core/locations.rb
406
412
  - spec/factories/cats/core/menu_items.rb
407
413
  - spec/factories/cats/core/menus.rb
414
+ - spec/factories/cats/core/monthly_plan_item_details.rb
415
+ - spec/factories/cats/core/monthly_plan_items.rb
416
+ - spec/factories/cats/core/monthly_plans.rb
408
417
  - spec/factories/cats/core/notification_rules.rb
409
418
  - spec/factories/cats/core/notifications.rb
410
419
  - spec/factories/cats/core/offer_items.rb