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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2a6a1ea34a4402faf06a312e6fddc4ce4809df7d509a598b6802e5ac639102ef
4
- data.tar.gz: a65237debf4b93fa53881922294caca38b7cd8079fd43a4d92d7cb072c2fa080
3
+ metadata.gz: d389154de04b724aa275e0366b01e9e95f2403b527166fee74f7e74c52d7b7a7
4
+ data.tar.gz: 5479c67c579b82d250c450efee99b911a67ef7456ecf63d9574e9737d83ff81f
5
5
  SHA512:
6
- metadata.gz: 6190f8e0a5cbb726cd0c06bcd7382683be8b570c9e6827d55791c9d949258c29a22b6a5b4a2918835e71d4d273df9e35796cc9ebed636a91e871ccefdba385a9
7
- data.tar.gz: ba4af2345cadf310c41a1b77345bc28fa877ee5b4c258ee0a89db3ec2c43316cdb7373a067dbe82f5bceb74e5e8a91f6491415bb27a7a16b4f7b0798234f4d6f
6
+ metadata.gz: 8a0f3e53d4703fec8e3cf60081cf322261f5c087b104c1bca7548c96bb894ffabc61190a17a256105d433f4fb236ad5dc2608b29787cb1b7541947599f9897a6
7
+ data.tar.gz: 953f1e60bfc7aa23d97b22785dcf1da05fe7f4881fdae9d0a1e82d60e14a647c7c0069e3b1ec7a941d585ef4a3c2b488b41e191ba87477686f006460e98c3512
@@ -6,7 +6,7 @@ module Cats
6
6
  DONATION_TYPES = [CASH, KIND].freeze
7
7
 
8
8
  belongs_to :donor
9
- belongs_to :plan
9
+ belongs_to :plan, optional: true
10
10
  belongs_to :currency, optional: true
11
11
  belongs_to :commodity_category, optional: true
12
12
  belongs_to :unit_of_measure, optional: true
@@ -1,7 +1,7 @@
1
1
  module Cats
2
2
  module Core
3
3
  class GiftCertificate < ApplicationRecord
4
- belongs_to :donation
4
+ belongs_to :donation, optional: true
5
5
  belongs_to :commodity_category
6
6
  belongs_to :unit_of_measure
7
7
 
@@ -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
@@ -11,6 +11,7 @@ module Cats
11
11
  has_many :transport_bid_items
12
12
  has_many :transport_offers
13
13
  has_many :offer_items, through: :transport_offers
14
+ has_many :tenderers
14
15
  belongs_to :region, class_name: 'Cats::Core::Location', optional: true
15
16
  belongs_to :transport_plan
16
17
 
@@ -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: false,
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: false,
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
@@ -1,5 +1,5 @@
1
1
  module Cats
2
2
  module Core
3
- VERSION = '1.3.2'.freeze
3
+ VERSION = '1.3.6'.freeze
4
4
  end
5
5
  end
@@ -1,6 +1,7 @@
1
1
  FactoryBot.define do
2
2
  factory :donation, class: 'Cats::Core::Donation' do
3
3
  reference_no { FFaker::Name.name }
4
+ description { FFaker::Name.name }
4
5
  donation_type { Cats::Core::Donation::KIND }
5
6
  donated_on { Date.today }
6
7
  donor
@@ -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.2
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-03 00:00:00.000000000 Z
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