cats_core 1.3.4 → 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/donation.rb +1 -1
- data/app/models/cats/core/monthly_plan.rb +14 -0
- data/app/models/cats/core/monthly_plan_item.rb +10 -0
- data/app/models/cats/core/monthly_plan_item_detail.rb +10 -0
- data/app/models/cats/core/regional_request.rb +36 -0
- data/db/migrate/20210717032330_create_cats_core_donations.rb +2 -1
- data/db/migrate/20211215124452_create_cats_core_transport_bid_items.rb +1 -1
- data/db/migrate/20220105084347_create_cats_core_regional_requests.rb +20 -0
- data/db/migrate/20220107121752_create_cats_core_monthly_plans.rb +22 -0
- data/db/migrate/20220107125025_create_cats_core_monthly_plan_items.rb +17 -0
- data/db/migrate/20220107132433_create_cats_core_monthly_plan_item_details.rb +17 -0
- data/lib/cats/core/version.rb +1 -1
- data/spec/factories/cats/core/donations.rb +1 -0
- data/spec/factories/cats/core/monthly_plan_item_details.rb +7 -0
- data/spec/factories/cats/core/monthly_plan_items.rb +7 -0
- data/spec/factories/cats/core/monthly_plans.rb +9 -0
- data/spec/factories/cats/core/regional_requests.rb +14 -0
- metadata +14 -2
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
|
@@ -0,0 +1,14 @@
|
|
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
|
+
validates :reference_no, presence: true, uniqueness: true
|
9
|
+
validates :status, presence: true, inclusion: { in: Cats::Core::Plan::STATUSES }
|
10
|
+
|
11
|
+
delegate(:reference_no, to: :regional_request, prefix: 'request')
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,36 @@
|
|
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
|
@@ -2,6 +2,7 @@ class CreateCatsCoreDonations < ActiveRecord::Migration[6.1]
|
|
2
2
|
def change
|
3
3
|
create_table :cats_core_donations do |t|
|
4
4
|
t.string :reference_no, unique: true
|
5
|
+
t.string :description
|
5
6
|
t.string :donation_type, null: false
|
6
7
|
t.date :donated_on, null: false
|
7
8
|
t.references :donor,
|
@@ -9,7 +10,7 @@ class CreateCatsCoreDonations < ActiveRecord::Migration[6.1]
|
|
9
10
|
index: { name: 'donor_on_donation_indx' },
|
10
11
|
foreign_key: { to_table: :cats_core_donors }
|
11
12
|
t.references :plan,
|
12
|
-
null:
|
13
|
+
null: true,
|
13
14
|
index: { name: 'plan_on_donation_indx' },
|
14
15
|
foreign_key: { to_table: :cats_core_plans }
|
15
16
|
t.float :amount, null: false
|
@@ -14,6 +14,6 @@ class CreateCatsCoreTransportBidItems < ActiveRecord::Migration[6.1]
|
|
14
14
|
t.timestamps
|
15
15
|
end
|
16
16
|
|
17
|
-
add_index :cats_core_transport_bid_items, :transport_plan_item_id, unique: true
|
17
|
+
add_index :cats_core_transport_bid_items, :transport_plan_item_id, unique: true, name: 'tbi_on_tpi_uniq_indx'
|
18
18
|
end
|
19
19
|
end
|
@@ -0,0 +1,20 @@
|
|
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
|
@@ -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
|
data/lib/cats/core/version.rb
CHANGED
@@ -0,0 +1,14 @@
|
|
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
|
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.8
|
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-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
|
@@ -282,6 +285,7 @@ files:
|
|
282
285
|
- app/models/cats/core/ration_item.rb
|
283
286
|
- app/models/cats/core/receipt.rb
|
284
287
|
- app/models/cats/core/receipt_transaction.rb
|
288
|
+
- app/models/cats/core/regional_request.rb
|
285
289
|
- app/models/cats/core/rhn_request.rb
|
286
290
|
- app/models/cats/core/role.rb
|
287
291
|
- app/models/cats/core/role_menu.rb
|
@@ -380,6 +384,10 @@ files:
|
|
380
384
|
- db/migrate/20211229160128_create_cats_core_contract_items.rb
|
381
385
|
- db/migrate/20211229160129_create_cats_core_commodity_substitutions.rb
|
382
386
|
- db/migrate/20220103152802_create_cats_core_tenderers.rb
|
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
|
383
391
|
- lib/cats/core.rb
|
384
392
|
- lib/cats/core/engine.rb
|
385
393
|
- lib/cats/core/version.rb
|
@@ -403,6 +411,9 @@ files:
|
|
403
411
|
- spec/factories/cats/core/locations.rb
|
404
412
|
- spec/factories/cats/core/menu_items.rb
|
405
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
|
406
417
|
- spec/factories/cats/core/notification_rules.rb
|
407
418
|
- spec/factories/cats/core/notifications.rb
|
408
419
|
- spec/factories/cats/core/offer_items.rb
|
@@ -416,6 +427,7 @@ files:
|
|
416
427
|
- spec/factories/cats/core/rations.rb
|
417
428
|
- spec/factories/cats/core/receipt_transactions.rb
|
418
429
|
- spec/factories/cats/core/receipts.rb
|
430
|
+
- spec/factories/cats/core/regional_requests.rb
|
419
431
|
- spec/factories/cats/core/rhn_requests.rb
|
420
432
|
- spec/factories/cats/core/role_menus.rb
|
421
433
|
- spec/factories/cats/core/roles.rb
|