cats_core 1.3.7 → 1.3.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/cats/core/monthly_plan.rb +3 -0
- data/app/models/cats/core/regional_request.rb +9 -1
- data/db/migrate/20220105084347_create_cats_core_regional_requests.rb +4 -0
- data/db/migrate/20220107121752_create_cats_core_monthly_plans.rb +4 -0
- data/lib/cats/core/version.rb +1 -1
- data/spec/factories/cats/core/monthly_plans.rb +1 -0
- data/spec/factories/cats/core/regional_requests.rb +1 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b1553e2d695935cb7ac616b368580c59cef5f8a92b277829e41a8dd4ca7ff46b
|
4
|
+
data.tar.gz: 47d3a8a40f9e0c6ac3a8bddd98d2fb60943ade15288a3453b168273205f8f726
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c78f415988f1055f643caa4e6479c94b72f92b9c76775a1ab5bcd8578e52b999d49f43884d7b6177b7f76113db3571924bc2226390235057e244d695a060bd54
|
7
|
+
data.tar.gz: 1a7d8a00314ad8a56e0bc802f164fc9d48e600d9b97cfe609db2c81ef69fd175f44b28dbeae46e4a0d0a498586ddd35c8af98b6f394675cfdddae23b79dd0175
|
@@ -3,9 +3,12 @@ module Cats
|
|
3
3
|
class MonthlyPlan < ApplicationRecord
|
4
4
|
belongs_to :ration
|
5
5
|
belongs_to :plan
|
6
|
+
belongs_to :regional_request
|
6
7
|
|
7
8
|
validates :reference_no, presence: true, uniqueness: true
|
8
9
|
validates :status, presence: true, inclusion: { in: Cats::Core::Plan::STATUSES }
|
10
|
+
|
11
|
+
delegate(:reference_no, to: :regional_request, prefix: 'request')
|
9
12
|
end
|
10
13
|
end
|
11
14
|
end
|
@@ -2,12 +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
|
9
10
|
|
10
11
|
delegate(:reference_no, to: :plan, prefix: true)
|
12
|
+
delegate(:name, to: :region, prefix: true)
|
11
13
|
|
12
14
|
def validate_month
|
13
15
|
return unless month
|
@@ -23,6 +25,12 @@ module Cats
|
|
23
25
|
total = plan.plan_items.sum(:beneficiaries)
|
24
26
|
errors.add(:beneficiaries, "cannot be higher than #{total}.") if total < beneficiaries
|
25
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
|
26
34
|
end
|
27
35
|
end
|
28
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
|
@@ -11,6 +11,10 @@ class CreateCatsCoreMonthlyPlans < ActiveRecord::Migration[6.1]
|
|
11
11
|
null: false,
|
12
12
|
index: { name: 'plan_on_mp_indx' },
|
13
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 }
|
14
18
|
|
15
19
|
t.timestamps
|
16
20
|
end
|
data/lib/cats/core/version.rb
CHANGED