cats_core 1.0.41 → 1.0.45

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: 1a3d6fa190673652349c149ea87b314da07a74f00c600d774f2911ca4da24a35
4
- data.tar.gz: 7c29148233b0fc4a2e9efc1c114cb02910967d679420cfa5f40aca7eb0a92083
3
+ metadata.gz: 296c1ea2692ccbfda9597044d6dd6f92a26dae42d008448d492a38b746906bc5
4
+ data.tar.gz: 37594e0dff5425a1f6e037cf427793b1ca6af54b6fe1b2a04e00b139a96b5417
5
5
  SHA512:
6
- metadata.gz: f37e6d2c1f1ff4d5c75df983a259c739d65de04d8d6da3f853dbe8994133f9ec7779c7b0948130ec9081e7127de062287271aa69703f0c5aa790588af6110a58
7
- data.tar.gz: 7b4f03e36d240e6ae05d04f46c9cef15f9ec86c0cf6f1bbc871eda27fa5f5d5cd9d0971f016a55ef97e8a7b71413d88ec9d1d156bb376506ad8e68e57be83d21
6
+ metadata.gz: af90696c4bfd02c65eb3b5d37a0be9a446d4a627e75c10ab2925d42038ff7113dfd2f56b8fd47403ffabeb106066e0644202f64cca49611956819eaf898989d3
7
+ data.tar.gz: '007480b8cb6ded9688d94736634593e3004e6a1dc874a9e34d05674b9580c937046922d6dffd9a1d812501d09c2a188f4929ad9f23371ac82d43664a14653c55'
@@ -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
@@ -1,11 +1,18 @@
1
1
  module Cats
2
2
  module Core
3
3
  class Dispatch < ApplicationRecord
4
+ DRAFT = 'Draft'.freeze
5
+ APPROVED = 'Approved'.freeze
6
+ STARTED = 'Started'.freeze
7
+
8
+ DISPATCH_STATUSES = [DRAFT, APPROVED, STARTED].freeze
9
+
4
10
  belongs_to :prepared_by, class_name: 'Cats::Core::User'
5
11
  belongs_to :transporter
6
12
  belongs_to :allocation_item
7
13
 
8
14
  validates :reference_no, :plate_no, :driver_name, :driver_phone, :quantity, :commodity_status, presence: true
15
+ validates :dispatch_status, presence: true, inclusion: { in: DISPATCH_STATUSES }
9
16
  validates :reference_no, uniqueness: true
10
17
  validates :quantity, numericality: { greater_than: 0 }
11
18
  validates :commodity_status, inclusion: { in: Cats::Core::Commodity::COMMODITY_STATUSES }
@@ -8,14 +8,21 @@ 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, presence: true, if: -> { donation_type == KIND }
19
+ validates :unit_of_measure, presence: true, if: -> { donation_type == KIND }
16
20
 
17
21
  delegate(:name, to: :donor, prefix: true)
18
22
  delegate(:reference_no, to: :hrp, prefix: true)
23
+ delegate(:name, to: :commodity_category, prefix: true, allow_nil: true)
24
+ delegate(:code, to: :currency, prefix: true, allow_nil: true)
25
+ delegate(:abbreviation, to: :unit_of_measure, prefix: true, allow_nil: true)
19
26
  end
20
27
  end
21
28
  end
@@ -2,12 +2,9 @@ module Cats
2
2
  module Core
3
3
  class GiftCertificate < ApplicationRecord
4
4
  belongs_to :donation
5
- belongs_to :commodity_category
6
5
 
7
6
  validates :reference_no, presence: true, uniqueness: true
8
7
  validates :gift_date, presence: true
9
-
10
- delegate(:name, to: :commodity_category, prefix: true)
11
8
  end
12
9
  end
13
10
  end
@@ -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
@@ -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
@@ -8,10 +8,6 @@ class CreateCatsCoreGiftCertificates < ActiveRecord::Migration[6.1]
8
8
  null: false,
9
9
  index: { name: 'gc_on_donation_indx' },
10
10
  foreign_key: { to_table: :cats_core_donations }
11
- t.references :commodity_category,
12
- null: false,
13
- index: { name: 'gc_on_cc_indx' },
14
- foreign_key: { to_table: :cats_core_commodity_categories }
15
11
 
16
12
  t.string :vessel
17
13
  t.string :port
@@ -20,6 +20,7 @@ class CreateCatsCoreDispatches < ActiveRecord::Migration[6.1]
20
20
  null: false,
21
21
  index: { name: 'pb_on_dispatches_indx' },
22
22
  foreign_key: { to_table: :cats_core_users }
23
+ t.string :dispatch_status, null: false
23
24
 
24
25
  t.timestamps
25
26
  end
@@ -1,5 +1,5 @@
1
1
  module Cats
2
2
  module Core
3
- VERSION = '1.0.41'.freeze
3
+ VERSION = '1.0.45'.freeze
4
4
  end
5
5
  end
@@ -9,5 +9,6 @@ FactoryBot.define do
9
9
  quantity { 50 }
10
10
  remark { FFaker::Name.name }
11
11
  prepared_by factory: :user
12
+ dispatch_status { Cats::Core::Dispatch::DRAFT }
12
13
  end
13
14
  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
@@ -3,7 +3,6 @@ FactoryBot.define do
3
3
  reference_no { FFaker::Name.name }
4
4
  gift_date { Date.today - 1.month }
5
5
  donation
6
- commodity_category
7
6
  vessel { FFaker::Name.name }
8
7
  port { FFaker::Name.name }
9
8
  customs_declaration_no { FFaker::Name.name }
@@ -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.41
4
+ version: 1.0.45
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