cats_core 1.3.2 → 1.3.6
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/gift_certificate.rb +1 -1
- data/app/models/cats/core/regional_request.rb +28 -0
- data/app/models/cats/core/transport_bid.rb +1 -0
- data/db/migrate/20210717032330_create_cats_core_donations.rb +2 -1
- data/db/migrate/20210717032602_create_cats_core_gift_certificates.rb +2 -2
- data/db/migrate/20211215124452_create_cats_core_transport_bid_items.rb +1 -1
- data/db/migrate/20220105084347_create_cats_core_regional_requests.rb +16 -0
- data/lib/cats/core/version.rb +1 -1
- data/spec/factories/cats/core/donations.rb +1 -0
- data/spec/factories/cats/core/regional_requests.rb +13 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d389154de04b724aa275e0366b01e9e95f2403b527166fee74f7e74c52d7b7a7
|
4
|
+
data.tar.gz: 5479c67c579b82d250c450efee99b911a67ef7456ecf63d9574e9737d83ff81f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a0f3e53d4703fec8e3cf60081cf322261f5c087b104c1bca7548c96bb894ffabc61190a17a256105d433f4fb236ad5dc2608b29787cb1b7541947599f9897a6
|
7
|
+
data.tar.gz: 953f1e60bfc7aa23d97b22785dcf1da05fe7f4881fdae9d0a1e82d60e14a647c7c0069e3b1ec7a941d585ef4a3c2b488b41e191ba87477686f006460e98c3512
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Cats
|
2
|
+
module Core
|
3
|
+
class RegionalRequest < ApplicationRecord
|
4
|
+
belongs_to :plan
|
5
|
+
|
6
|
+
validates :reference_no, presence: true, uniqueness: true
|
7
|
+
validates :beneficiaries, :no_of_days, :month, presence: true, numericality: { greater_than: 0 }
|
8
|
+
validate :validate_month, :validate_beneficiaries
|
9
|
+
|
10
|
+
delegate(:reference_no, to: :plan, prefix: true)
|
11
|
+
|
12
|
+
def validate_month
|
13
|
+
return unless month
|
14
|
+
|
15
|
+
errors.add(:month, 'cannot be greater than 12.') if month > 12
|
16
|
+
end
|
17
|
+
|
18
|
+
def validate_beneficiaries
|
19
|
+
return unless beneficiaries
|
20
|
+
|
21
|
+
return unless plan
|
22
|
+
|
23
|
+
total = plan.plan_items.sum(:beneficiaries)
|
24
|
+
errors.add(:beneficiaries, "cannot be higher than #{total}.") if total < beneficiaries
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
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
|
@@ -5,10 +5,10 @@ class CreateCatsCoreGiftCertificates < ActiveRecord::Migration[6.1]
|
|
5
5
|
t.date :gift_date, null: false
|
6
6
|
|
7
7
|
t.references :donation,
|
8
|
-
null:
|
8
|
+
null: true,
|
9
9
|
index: { name: 'gc_on_donation_indx' },
|
10
10
|
foreign_key: { to_table: :cats_core_donations }
|
11
|
-
|
11
|
+
|
12
12
|
t.string :vessel
|
13
13
|
t.string :port
|
14
14
|
t.string :customs_declaration_no
|
@@ -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,16 @@
|
|
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
|
+
|
13
|
+
t.timestamps
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/cats/core/version.rb
CHANGED
@@ -0,0 +1,13 @@
|
|
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
|
+
reference_no { FFaker::Name.name }
|
9
|
+
beneficiaries { 100 }
|
10
|
+
month { 1 }
|
11
|
+
no_of_days { 30 }
|
12
|
+
end
|
13
|
+
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.6
|
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-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_model_serializers
|
@@ -282,6 +282,7 @@ files:
|
|
282
282
|
- app/models/cats/core/ration_item.rb
|
283
283
|
- app/models/cats/core/receipt.rb
|
284
284
|
- app/models/cats/core/receipt_transaction.rb
|
285
|
+
- app/models/cats/core/regional_request.rb
|
285
286
|
- app/models/cats/core/rhn_request.rb
|
286
287
|
- app/models/cats/core/role.rb
|
287
288
|
- app/models/cats/core/role_menu.rb
|
@@ -380,6 +381,7 @@ files:
|
|
380
381
|
- db/migrate/20211229160128_create_cats_core_contract_items.rb
|
381
382
|
- db/migrate/20211229160129_create_cats_core_commodity_substitutions.rb
|
382
383
|
- db/migrate/20220103152802_create_cats_core_tenderers.rb
|
384
|
+
- db/migrate/20220105084347_create_cats_core_regional_requests.rb
|
383
385
|
- lib/cats/core.rb
|
384
386
|
- lib/cats/core/engine.rb
|
385
387
|
- lib/cats/core/version.rb
|
@@ -416,6 +418,7 @@ files:
|
|
416
418
|
- spec/factories/cats/core/rations.rb
|
417
419
|
- spec/factories/cats/core/receipt_transactions.rb
|
418
420
|
- spec/factories/cats/core/receipts.rb
|
421
|
+
- spec/factories/cats/core/regional_requests.rb
|
419
422
|
- spec/factories/cats/core/rhn_requests.rb
|
420
423
|
- spec/factories/cats/core/role_menus.rb
|
421
424
|
- spec/factories/cats/core/roles.rb
|