cats_core 1.0.39 → 1.0.43

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: dbd96f5c771c2adceaa0d3c058ba5643b6e38189b4a5afdfbe666affab5a3c36
4
- data.tar.gz: b55e4ab59388139d7c591194059f001af370df848077f446640ec3e1dc25f975
3
+ metadata.gz: bda6e203d5cc23b15dfdb7cf523a175b4a620b5bfb4e630e89c088bf220162f3
4
+ data.tar.gz: 2522727f3c712519f63681267b53405ce2b89a7dcdc599d1bc86810ce16b2bf5
5
5
  SHA512:
6
- metadata.gz: '0812bb8e9484cc6dd7f375434c294e7f82320999a9a3ae7a5793c6ede1592fe9eefe50895892895cabe240d1c0fa12197dd9bf2479e1f816d8d31f3c98fe7575'
7
- data.tar.gz: dc903f04dddb57c08c4c80c0a3c0135b85254a12bc634414a96eab76bdb39c85cf96e2f37abf47d4853b084651a843d45bd42b5cf2771d0667fdab152e260569
6
+ metadata.gz: eede7fe1153179c4f3349c0124cccfe6c97e49941ff0ab9a4465239bb5afd05ea40c6e6d156b2693c288d6a9de7ebbe049b05e98474f5d91c630808820fe74d7
7
+ data.tar.gz: 5c673873887a2cd373fc6c7fc586bd46477b9f377dfcab4b9328fc91cfb0ee515ac8c58ec3afd5139a7f99422019d68dbea709f24e6da8dfa312f2aecf23a33f
@@ -46,7 +46,7 @@ module Cats
46
46
  end
47
47
 
48
48
  def model_params
49
- params.require(:payload).permit(:name, :location_type, :description, :parent_id)
49
+ params.require(:payload).permit(:code, :name, :location_type, :description, :parent_id)
50
50
  end
51
51
  end
52
52
  end
@@ -8,11 +8,14 @@ module Cats
8
8
  belongs_to :donor
9
9
  belongs_to :hrp
10
10
  belongs_to :currency, optional: true
11
+ belongs_to :commodity_category, optional: true
12
+ belongs_to :unit_of_measure, optional: true
11
13
 
12
- validates :reference_no, :donation_type, :donated_on, presence: true
14
+ validates :reference_no, :amount, :donation_type, :donated_on, presence: true
13
15
  validates :reference_no, uniqueness: true
14
16
  validates :donation_type, inclusion: { in: DONATION_TYPES }
15
- validates :currency, :amount, presence: true, if: -> { donation_type == CASH }
17
+ validates :currency, presence: true, if: -> { donation_type == CASH }
18
+ validates :commodity_category, :unit_of_measure, presence: true, if: -> { donation_type == KIND }
16
19
 
17
20
  delegate(:name, to: :donor, prefix: true)
18
21
  delegate(:reference_no, to: :hrp, prefix: true)
@@ -9,6 +9,7 @@ module Cats
9
9
  MEHER = 'Meher'.freeze
10
10
  SEASONS = [BELG, MEHER].freeze
11
11
 
12
+ belongs_to :program
12
13
  belongs_to :ration, optional: true
13
14
  has_many :hrp_items
14
15
 
@@ -5,6 +5,8 @@ module Cats
5
5
  belongs_to :woreda, -> { where(location_type: Cats::Core::Location::WOREDA) }, class_name: 'Cats::Core::Location'
6
6
  belongs_to :operator
7
7
 
8
+ has_many :hrp_item_details
9
+
8
10
  validates :beneficiaries, presence: true, numericality: { greater_than: 0 }
9
11
  validates :hrp_id, uniqueness: { scope: :woreda_id }
10
12
 
@@ -12,7 +12,8 @@ module Cats
12
12
 
13
13
  has_ancestry
14
14
 
15
- validates :name, :location_type, presence: true
15
+ validates :code, :name, :location_type, presence: true
16
+ validates :code, uniqueness: true
16
17
  validates :location_type, inclusion: { in: LOCATION_TYPES }
17
18
  validate :validate_location_parent
18
19
 
@@ -1,6 +1,7 @@
1
1
  class CreateCatsCoreLocations < ActiveRecord::Migration[6.1]
2
2
  def change
3
3
  create_table :cats_core_locations do |t|
4
+ t.string :code, unique: true
4
5
  t.string :name, null: false
5
6
  t.string :location_type, null: false
6
7
  t.string :description
@@ -6,6 +6,10 @@ class CreateCatsCoreHrps < ActiveRecord::Migration[6.1]
6
6
  t.string :season, null: false
7
7
  t.string :status, null: false, default: 'Draft'
8
8
 
9
+ t.references :program,
10
+ null: false,
11
+ index: { name: 'program_on_hrp_indx' },
12
+ foreign_key: { to_table: :cats_core_programs }
9
13
  t.references :ration,
10
14
  null: true,
11
15
  index: { name: 'ration_on_hrp_indx' },
@@ -12,11 +12,19 @@ class CreateCatsCoreDonations < ActiveRecord::Migration[6.1]
12
12
  null: false,
13
13
  index: { name: 'hrp_on_donation_indx' },
14
14
  foreign_key: { to_table: :cats_core_hrps }
15
- t.float :amount
15
+ t.float :amount, null: false
16
16
  t.references :currency,
17
17
  null: true,
18
18
  index: { name: 'currency_on_donation_indx' },
19
19
  foreign_key: { to_table: :cats_core_currencies }
20
+ t.references :commodity_category,
21
+ null: true,
22
+ index: { name: 'cc_on_donation_indx' },
23
+ foreign_key: { to_table: :cats_core_commodity_categories }
24
+ t.references :unit_of_measure,
25
+ null: true,
26
+ index: { name: 'uom_on_donation_indx' },
27
+ foreign_key: { to_table: :cats_core_unit_of_measures }
20
28
 
21
29
  t.timestamps
22
30
  end
@@ -1,5 +1,5 @@
1
1
  module Cats
2
2
  module Core
3
- VERSION = '1.0.39'.freeze
3
+ VERSION = '1.0.43'.freeze
4
4
  end
5
5
  end
@@ -5,7 +5,9 @@ FactoryBot.define do
5
5
  donated_on { Date.today }
6
6
  donor
7
7
  hrp
8
- amount { nil }
8
+ amount { 100 }
9
9
  currency { nil }
10
+ commodity_category
11
+ unit_of_measure
10
12
  end
11
13
  end
@@ -4,6 +4,7 @@ FactoryBot.define do
4
4
  year { 1 }
5
5
  season { Cats::Core::Hrp::BELG }
6
6
  status { Cats::Core::Hrp::DRAFT }
7
+ program
7
8
  ration
8
9
  end
9
10
  end
@@ -1,5 +1,6 @@
1
1
  FactoryBot.define do
2
2
  factory :location, class: 'Cats::Core::Location', aliases: [:parent] do
3
+ code { FFaker::Name.name }
3
4
  name { FFaker::Name.name }
4
5
  location_type { Cats::Core::Location::REGION }
5
6
  ancestry { nil }
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.0.39
4
+ version: 1.0.43
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henock L.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-19 00:00:00.000000000 Z
11
+ date: 2021-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers