cats_core 1.3.4 → 1.3.5

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: c44a1c208dbd4626ab5eb07ff44c2282e62d37f9ed2023f192de81f948db2b1b
4
- data.tar.gz: aaad5e4d7d06b00d6277b60abd7b04e398e01122599f225c99fdfe2d777ddad3
3
+ metadata.gz: 0c3d4ff631edb9b8c8b84475b5dbc38866a8dc7ee2e6b91d1ae7d0e986ae22c1
4
+ data.tar.gz: ffb3251702f63bba57a7f3c89f960b175b1d341d03ce35468fef4a5b660531e7
5
5
  SHA512:
6
- metadata.gz: adde6b14c19da6ea4f651351f42249804a5fe4404293f9a7f80e860c3e11527821016859372307a0b4be13d2b007ffdc5171efd87bdb8a397567db468f12acd8
7
- data.tar.gz: f28db6afdbab5f01ad463293132d697bbb94870b841833fb795ff6af0a771ca6bf61bc75df9c3067495001055bb50ecb5749ec9dcbaa8e3f9619d4f28f1553dc
6
+ metadata.gz: 11f445e39c09484942cd571ec81bf78b23a182dac03f37f89270c359902f75103e2ce0ca0240b9954c5fc580b7af34ac16686d2eaf05ea7dcd9193172abfba60
7
+ data.tar.gz: 9b0dc2b6d6eded7d43aec38c7c9742e4bf10c2f33be48315f172fdb3b278ef697e0e00a2febd5451bb9fbb0d096b2f8977fa2a31fbd7723721813ab5725bd48e
@@ -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
@@ -0,0 +1,26 @@
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
+ def validate_month
11
+ return unless month
12
+
13
+ errors.add(:month, 'cannot be greater than 12.') if month > 12
14
+ end
15
+
16
+ def validate_beneficiaries
17
+ return unless beneficiaries
18
+
19
+ return unless plan
20
+
21
+ total = plan.plan_items.sum(:beneficiaries)
22
+ errors.add(:beneficiaries, "cannot be higher than #{total}.") if total < beneficiaries
23
+ end
24
+ end
25
+ end
26
+ 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: 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
@@ -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.4'.freeze
3
+ VERSION = '1.3.5'.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.4
4
+ version: 1.3.5
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-04 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