cats_core 1.3.10 → 1.3.14
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 +4 -4
- data/app/models/cats/core/monthly_plan.rb +18 -3
- data/app/models/cats/core/monthly_plan_item_detail.rb +1 -1
- data/app/models/cats/core/monthly_ration.rb +4 -0
- data/app/models/cats/core/plan.rb +3 -1
- data/db/migrate/20220107121752_create_cats_core_monthly_plans.rb +5 -7
- data/db/migrate/{20220107224630_create_cats_core_monthly_rations.rb → 20220107124630_create_cats_core_monthly_rations.rb} +0 -0
- data/db/migrate/20220107132433_create_cats_core_monthly_plan_item_details.rb +3 -3
- data/lib/cats/core/version.rb +1 -1
- data/spec/factories/cats/core/monthly_plan_item_details.rb +1 -1
- data/spec/factories/cats/core/monthly_plans.rb +3 -2
- metadata +3 -6
- data/app/models/cats/core/regional_request.rb +0 -36
- data/db/migrate/20220105084347_create_cats_core_regional_requests.rb +0 -20
- data/spec/factories/cats/core/regional_requests.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4be4eb5f572d4c38a09f3ddfb775497fd81c0c9e3a9053be1f03bfee51730308
|
4
|
+
data.tar.gz: 4bea5f8744afffa22bad84782ba5e40ef433a31b7c11719da8e910d849803d4c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f600c4c2170e448936f7860659533d22039b6815a4890cb9d0af81476c12f9ef7d28c5828887c73f146b44caa6b191bc57101f8b78a85521117e8c0b027ac1f3
|
7
|
+
data.tar.gz: 3153dc2e38a2d6f33ac3817ad67250a77a308c8ba3c67d4ced336f6aecea9bc9da64c6b35fc055c77a112f92f1dea5f2e2e618579fe7fe8b1e13e83f83c04838
|
@@ -1,17 +1,32 @@
|
|
1
1
|
module Cats
|
2
2
|
module Core
|
3
3
|
class MonthlyPlan < ApplicationRecord
|
4
|
-
belongs_to :ration
|
5
4
|
belongs_to :plan
|
6
|
-
belongs_to :
|
5
|
+
belongs_to :region, class_name: 'Cats::Core::Location'
|
7
6
|
|
8
7
|
has_many :monthly_plan_items
|
8
|
+
has_many :monthly_plan_item_details, through: :monthly_plan_items
|
9
9
|
has_many :monthly_rations
|
10
10
|
|
11
11
|
validates :reference_no, presence: true, uniqueness: true
|
12
12
|
validates :status, presence: true, inclusion: { in: Cats::Core::Plan::STATUSES }
|
13
|
+
validates :no_of_days, :month, presence: true, numericality: { greater_than: 0 }
|
14
|
+
validate :validate_month, :validate_region
|
13
15
|
|
14
|
-
delegate(:reference_no, to: :
|
16
|
+
delegate(:reference_no, to: :plan, prefix: true)
|
17
|
+
delegate(:name, to: :region, prefix: true)
|
18
|
+
|
19
|
+
def validate_month
|
20
|
+
return unless month
|
21
|
+
|
22
|
+
errors.add(:month, 'cannot be greater than 12.') if month > 12
|
23
|
+
end
|
24
|
+
|
25
|
+
def validate_region
|
26
|
+
return unless region
|
27
|
+
|
28
|
+
errors.add(:region, 'is not valid.') unless region.location_type == Cats::Core::Location::REGION
|
29
|
+
end
|
15
30
|
end
|
16
31
|
end
|
17
32
|
end
|
@@ -6,6 +6,10 @@ module Cats
|
|
6
6
|
belongs_to :monthly_plan
|
7
7
|
|
8
8
|
validates :amount, :no_of_days, presence: true, numericality: { greater_than: 0 }
|
9
|
+
|
10
|
+
delegate(:name, to: :commodity_category, prefix: true)
|
11
|
+
delegate(:abbreviation, to: :unit_of_measure, prefix: true)
|
12
|
+
delegate(:reference_no, to: :monthly_plan, prefix: true)
|
9
13
|
end
|
10
14
|
end
|
11
15
|
end
|
@@ -9,11 +9,13 @@ module Cats
|
|
9
9
|
|
10
10
|
BELG = 'Belg'.freeze
|
11
11
|
MEHER = 'Meher'.freeze
|
12
|
-
|
12
|
+
ANNUAL = 'Annual'.freeze
|
13
|
+
SEASONS = [BELG, MEHER, ANNUAL].freeze
|
13
14
|
|
14
15
|
belongs_to :program
|
15
16
|
belongs_to :ration, optional: true
|
16
17
|
has_many :plan_items
|
18
|
+
has_many :plan_item_details, through: :plan_items
|
17
19
|
|
18
20
|
validates :reference_no, :year, :status, presence: true
|
19
21
|
validates :season, presence: true, inclusion: { in: SEASONS }
|
@@ -2,19 +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
|
-
t.references :ration,
|
7
|
-
null: false,
|
8
|
-
index: { name: 'ration_on_mp_indx' },
|
9
|
-
foreign_key: { to_table: :cats_core_rations }
|
10
8
|
t.references :plan,
|
11
9
|
null: false,
|
12
10
|
index: { name: 'plan_on_mp_indx' },
|
13
11
|
foreign_key: { to_table: :cats_core_plans }
|
14
|
-
t.references :
|
12
|
+
t.references :region,
|
15
13
|
null: false,
|
16
|
-
index: { name: '
|
17
|
-
foreign_key: { to_table: :
|
14
|
+
index: { name: 'region_on_mp_indx' },
|
15
|
+
foreign_key: { to_table: :cats_core_locations }
|
18
16
|
|
19
17
|
t.timestamps
|
20
18
|
end
|
File without changes
|
@@ -5,10 +5,10 @@ class CreateCatsCoreMonthlyPlanItemDetails < ActiveRecord::Migration[6.1]
|
|
5
5
|
null: false,
|
6
6
|
index: { name: 'mpi_on_mpid_indx' },
|
7
7
|
foreign_key: { to_table: :cats_core_monthly_plan_items }
|
8
|
-
t.references :
|
8
|
+
t.references :monthly_ration,
|
9
9
|
null: false,
|
10
|
-
index: { name: '
|
11
|
-
foreign_key: { to_table: :
|
10
|
+
index: { name: 'ri_on_mr_indx' },
|
11
|
+
foreign_key: { to_table: :cats_core_monthly_rations }
|
12
12
|
t.float :amount, null: false
|
13
13
|
|
14
14
|
t.timestamps
|
data/lib/cats/core/version.rb
CHANGED
@@ -2,8 +2,9 @@ FactoryBot.define do
|
|
2
2
|
factory :monthly_plan, class: 'Cats::Core::MonthlyPlan' do
|
3
3
|
reference_no { FFaker::Name.name }
|
4
4
|
status { Cats::Core::Plan::DRAFT }
|
5
|
-
ration
|
6
5
|
plan
|
7
|
-
|
6
|
+
region factory: :location
|
7
|
+
month { 1 }
|
8
|
+
no_of_days { 30 }
|
8
9
|
end
|
9
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.
|
4
|
+
version: 1.3.14
|
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-
|
11
|
+
date: 2022-01-13 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,11 +384,10 @@ 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
|
388
|
+
- db/migrate/20220107124630_create_cats_core_monthly_rations.rb
|
390
389
|
- db/migrate/20220107125025_create_cats_core_monthly_plan_items.rb
|
391
390
|
- db/migrate/20220107132433_create_cats_core_monthly_plan_item_details.rb
|
392
|
-
- db/migrate/20220107224630_create_cats_core_monthly_rations.rb
|
393
391
|
- lib/cats/core.rb
|
394
392
|
- lib/cats/core/engine.rb
|
395
393
|
- lib/cats/core/version.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
|