cats_core 1.3.9 → 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 +4 -4
- data/app/models/cats/core/monthly_plan.rb +18 -3
- data/app/models/cats/core/monthly_ration.rb +15 -0
- data/db/migrate/20220107121752_create_cats_core_monthly_plans.rb +5 -7
- data/db/migrate/20220107224630_create_cats_core_monthly_rations.rb +22 -0
- data/lib/cats/core/version.rb +1 -1
- data/spec/factories/cats/core/monthly_plans.rb +3 -2
- data/spec/factories/cats/core/monthly_rations.rb +9 -0
- metadata +5 -5
- 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: d8384e95d3bf98191d6f0fb04ce96f6180daf53d653d954ef1470282bf3b4782
|
4
|
+
data.tar.gz: 00a0000dba254d8f02dcb8f97fe37b268137d1fe19e03f5c385f2724cb03442b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d6cdb1dcd812695e16f53ee1a613a834fa7683eb982d54b62cd1662a2082f147b0000ba2fa7453a7fedf5e5a003f94197eadeca05b7768fa104a9fb4655ab53
|
7
|
+
data.tar.gz: 7426544df6c7c89477936e11cff07b9ac047c46617b199e02853822cb67260d5b94e08816b51dd7c881173d85e0700a4ddcc3d3a4ab01523f42b2a6ae4e591a6
|
@@ -1,16 +1,31 @@
|
|
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_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: :
|
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
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Cats
|
2
|
+
module Core
|
3
|
+
class MonthlyRation < ApplicationRecord
|
4
|
+
belongs_to :commodity_category
|
5
|
+
belongs_to :unit_of_measure
|
6
|
+
belongs_to :monthly_plan
|
7
|
+
|
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)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -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
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class CreateCatsCoreMonthlyRations < ActiveRecord::Migration[6.1]
|
2
|
+
def change
|
3
|
+
create_table :cats_core_monthly_rations do |t|
|
4
|
+
t.references :commodity_category,
|
5
|
+
null: false,
|
6
|
+
index: { name: 'cc_on_mr_indx' },
|
7
|
+
foreign_key: { to_table: :cats_core_commodity_categories }
|
8
|
+
t.float :amount, null: false
|
9
|
+
t.references :unit_of_measure,
|
10
|
+
null: false,
|
11
|
+
index: { name: 'uom_on_mr_indx' },
|
12
|
+
foreign_key: { to_table: :cats_core_unit_of_measures }
|
13
|
+
t.integer :no_of_days, null: false
|
14
|
+
t.references :monthly_plan,
|
15
|
+
index: { name: 'mp_on_mr_indx' },
|
16
|
+
null: false,
|
17
|
+
foreign_key: { to_table: :cats_core_monthly_plans }
|
18
|
+
|
19
|
+
t.timestamps
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
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.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-
|
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
|
@@ -272,6 +272,7 @@ files:
|
|
272
272
|
- app/models/cats/core/monthly_plan.rb
|
273
273
|
- app/models/cats/core/monthly_plan_item.rb
|
274
274
|
- app/models/cats/core/monthly_plan_item_detail.rb
|
275
|
+
- app/models/cats/core/monthly_ration.rb
|
275
276
|
- app/models/cats/core/notification.rb
|
276
277
|
- app/models/cats/core/notification_rule.rb
|
277
278
|
- app/models/cats/core/offer_item.rb
|
@@ -285,7 +286,6 @@ files:
|
|
285
286
|
- app/models/cats/core/ration_item.rb
|
286
287
|
- app/models/cats/core/receipt.rb
|
287
288
|
- app/models/cats/core/receipt_transaction.rb
|
288
|
-
- app/models/cats/core/regional_request.rb
|
289
289
|
- app/models/cats/core/rhn_request.rb
|
290
290
|
- app/models/cats/core/role.rb
|
291
291
|
- app/models/cats/core/role_menu.rb
|
@@ -384,10 +384,10 @@ files:
|
|
384
384
|
- db/migrate/20211229160128_create_cats_core_contract_items.rb
|
385
385
|
- db/migrate/20211229160129_create_cats_core_commodity_substitutions.rb
|
386
386
|
- db/migrate/20220103152802_create_cats_core_tenderers.rb
|
387
|
-
- db/migrate/20220105084347_create_cats_core_regional_requests.rb
|
388
387
|
- db/migrate/20220107121752_create_cats_core_monthly_plans.rb
|
389
388
|
- db/migrate/20220107125025_create_cats_core_monthly_plan_items.rb
|
390
389
|
- db/migrate/20220107132433_create_cats_core_monthly_plan_item_details.rb
|
390
|
+
- db/migrate/20220107224630_create_cats_core_monthly_rations.rb
|
391
391
|
- lib/cats/core.rb
|
392
392
|
- lib/cats/core/engine.rb
|
393
393
|
- lib/cats/core/version.rb
|
@@ -414,6 +414,7 @@ files:
|
|
414
414
|
- spec/factories/cats/core/monthly_plan_item_details.rb
|
415
415
|
- spec/factories/cats/core/monthly_plan_items.rb
|
416
416
|
- spec/factories/cats/core/monthly_plans.rb
|
417
|
+
- spec/factories/cats/core/monthly_rations.rb
|
417
418
|
- spec/factories/cats/core/notification_rules.rb
|
418
419
|
- spec/factories/cats/core/notifications.rb
|
419
420
|
- spec/factories/cats/core/offer_items.rb
|
@@ -427,7 +428,6 @@ files:
|
|
427
428
|
- spec/factories/cats/core/rations.rb
|
428
429
|
- spec/factories/cats/core/receipt_transactions.rb
|
429
430
|
- spec/factories/cats/core/receipts.rb
|
430
|
-
- spec/factories/cats/core/regional_requests.rb
|
431
431
|
- spec/factories/cats/core/rhn_requests.rb
|
432
432
|
- spec/factories/cats/core/role_menus.rb
|
433
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
|