cats_core 1.0.42 → 1.0.46
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/dispatch.rb +10 -0
- data/app/models/cats/core/donation.rb +9 -2
- data/app/models/cats/core/gift_certificate.rb +0 -3
- data/db/migrate/20210717032330_create_cats_core_donations.rb +9 -1
- data/db/migrate/20210717032602_create_cats_core_gift_certificates.rb +0 -4
- data/db/migrate/20210718045516_create_cats_core_dispatches.rb +1 -0
- data/lib/cats/core/version.rb +1 -1
- data/spec/factories/cats/core/dispatches.rb +1 -0
- data/spec/factories/cats/core/donations.rb +3 -1
- data/spec/factories/cats/core/gift_certificates.rb +0 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f434d12f124bafbd6d7e1800ccb5ef123afc5a41d496e1fbe3e8f241fc17cbb
|
4
|
+
data.tar.gz: d73d97c1d94a4bddb94b3f7a9608b16b1f3311d86ffafeb50008737a02f6a07a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aaa5cc4c199c9d2aff261b684fa8036dbc6313dd66885adea3584efe667f3892fb21332fde6725361d30939fd3d837d389ed005021b93af97d35e40723129e28
|
7
|
+
data.tar.gz: f9d62619ee798259d384788386873b11279e3f30ac5e9ad18fcbe4713dae6e454190aaf816e3e4adf5eb06f7ddd5735c908329ccf89293c6ec79cf488f9628a4
|
@@ -1,14 +1,24 @@
|
|
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 }
|
19
|
+
|
20
|
+
delegate(:name, to: :transporter, prefix: true)
|
21
|
+
delegate(:email, to: :prepared_by, prefix: true)
|
12
22
|
end
|
13
23
|
end
|
14
24
|
end
|
@@ -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,
|
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,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
|
data/lib/cats/core/version.rb
CHANGED
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.
|
4
|
+
version: 1.0.46
|
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-
|
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
|