cats_core 1.3.23 → 1.3.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/models/cats/core/commodity.rb +12 -2
- data/app/models/cats/core/dispatch_plan.rb +4 -0
- data/app/models/cats/core/donation.rb +1 -1
- data/app/models/cats/core/purchase_order.rb +9 -1
- data/app/serializers/cats/core/transporter_serializer.rb +6 -2
- data/app/services/cats/core/dispatch_plan_service.rb +1 -1
- data/db/migrate/20210717032330_create_cats_core_donations.rb +1 -0
- data/db/migrate/20210717032855_create_cats_core_purchase_orders.rb +6 -0
- data/lib/cats/core/version.rb +1 -1
- data/spec/factories/cats/core/dispatch_plans.rb +4 -0
- data/spec/factories/cats/core/donations.rb +1 -0
- data/spec/factories/cats/core/purchase_orders.rb +3 -0
- 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: 1076d840160f1faee39901d7f1d9ccf7926c0413739ebed870a740c66f2e2f08
|
4
|
+
data.tar.gz: cfb54300abc22e4889a0cd75c83c47bf355f089cf84ca7645f743ee65ea4b69a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e68a5e3f35ea31220701ca97df067eb03a16983ff8b32431b7a04c415d1ca1ea09b1943149cd098d52b3c704ca2a5ca0b9ca363e2bc3db5a92d1871e2202a11
|
7
|
+
data.tar.gz: 5d90ebf4ed67ee13e9a351e7feea4d90429f6299e40a7349d23faf033ec1a41bcf6aed6c7023bb965451378d28242675c6af099a0d67d331ca053466b624f1c7
|
@@ -14,9 +14,19 @@ module Cats
|
|
14
14
|
|
15
15
|
# Arrival Statuses
|
16
16
|
AT_SOURCE = 'At Source'.freeze
|
17
|
-
|
17
|
+
AT_ORIGIN_PORT = 'At Origin Port'.freeze
|
18
|
+
IN_LOCAL_TRANSIT = 'In Local Transit'.freeze
|
19
|
+
IN_INTERNATIONAL_TRANSIT = 'In International Transit'.freeze
|
20
|
+
AT_DESTINATION_PORT = 'At Destination Port'.freeze
|
18
21
|
ARRIVED = 'Arrived'.freeze
|
19
|
-
ARRIVAL_STATUSES = [
|
22
|
+
ARRIVAL_STATUSES = [
|
23
|
+
AT_SOURCE,
|
24
|
+
AT_ORIGIN_PORT,
|
25
|
+
IN_LOCAL_TRANSIT,
|
26
|
+
IN_INTERNATIONAL_TRANSIT,
|
27
|
+
AT_DESTINATION_PORT,
|
28
|
+
ARRIVED
|
29
|
+
].freeze
|
20
30
|
|
21
31
|
belongs_to :unit_of_measure
|
22
32
|
belongs_to :source, polymorphic: true
|
@@ -19,6 +19,10 @@ module Cats
|
|
19
19
|
delegate(:request_reference, to: :dispatchable, allow_nil: true)
|
20
20
|
delegate(:request_quantity, to: :dispatchable, allow_nil: true)
|
21
21
|
|
22
|
+
before_save do |plan|
|
23
|
+
plan.upstream = !plan.dispatchable.nil? && plan.dispatchable_type == RhnRequest.name
|
24
|
+
end
|
25
|
+
|
22
26
|
def approve
|
23
27
|
raise(StandardError, 'Dispatch plan already approved.') if status == APPROVED
|
24
28
|
|
@@ -11,7 +11,7 @@ module Cats
|
|
11
11
|
belongs_to :commodity_category, optional: true
|
12
12
|
belongs_to :unit_of_measure, optional: true
|
13
13
|
|
14
|
-
validates :reference_no, :amount, :donation_type, :donated_on, presence: true
|
14
|
+
validates :reference_no, :amount, :donation_type, :donated_on, :agency, presence: true
|
15
15
|
validates :reference_no, uniqueness: true
|
16
16
|
validates :donation_type, inclusion: { in: DONATION_TYPES }
|
17
17
|
validates :currency, presence: true, if: -> { donation_type == CASH }
|
@@ -1,13 +1,21 @@
|
|
1
1
|
module Cats
|
2
2
|
module Core
|
3
3
|
class PurchaseOrder < ApplicationRecord
|
4
|
+
LOCAL = 'Local'.freeze
|
5
|
+
FOREIGN = 'Foreign'.freeze
|
6
|
+
PURCHASE_TYPES = [LOCAL, FOREIGN].freeze
|
7
|
+
|
4
8
|
belongs_to :donation
|
5
9
|
belongs_to :commodity_category
|
10
|
+
belongs_to :unit, class_name: 'Cats::Core::UnitOfMeasure'
|
6
11
|
|
7
|
-
validates :reference_no, :order_date, :supplier, presence: true
|
12
|
+
validates :reference_no, :order_date, :supplier, :quantity, :purchase_type, presence: true
|
8
13
|
validates :reference_no, uniqueness: true
|
14
|
+
validates :purchase_type, inclusion: { in: PURCHASE_TYPES }
|
15
|
+
validates :quantity, numericality: { greater_than: 0 }
|
9
16
|
|
10
17
|
delegate(:name, to: :commodity_category, prefix: true)
|
18
|
+
delegate(:name, to: :unit, prefix: true)
|
11
19
|
|
12
20
|
after_create :update_donation
|
13
21
|
|
@@ -1,3 +1,7 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
module Cats
|
2
|
+
module Core
|
3
|
+
class TransporterSerializer < ActiveModel::Serializer
|
4
|
+
attributes :id, :code, :name, :address, :contact_phone
|
5
|
+
end
|
6
|
+
end
|
3
7
|
end
|
@@ -5,6 +5,7 @@ class CreateCatsCoreDonations < ActiveRecord::Migration[6.1]
|
|
5
5
|
t.string :description
|
6
6
|
t.string :donation_type, null: false
|
7
7
|
t.date :donated_on, null: false
|
8
|
+
t.string :agency, null: false
|
8
9
|
t.references :donor,
|
9
10
|
null: false,
|
10
11
|
index: { name: 'donor_on_donation_indx' },
|
@@ -5,6 +5,8 @@ class CreateCatsCorePurchaseOrders < ActiveRecord::Migration[6.1]
|
|
5
5
|
t.date :order_date, null: false
|
6
6
|
t.string :requisition_no
|
7
7
|
t.string :supplier, null: false
|
8
|
+
t.float :quantity, null: false
|
9
|
+
t.string :purchase_type, null: false
|
8
10
|
|
9
11
|
t.references :donation,
|
10
12
|
null: false,
|
@@ -14,6 +16,10 @@ class CreateCatsCorePurchaseOrders < ActiveRecord::Migration[6.1]
|
|
14
16
|
null: false,
|
15
17
|
index: { name: 'po_on_cc_indx' },
|
16
18
|
foreign_key: { to_table: :cats_core_commodity_categories }
|
19
|
+
t.references :unit,
|
20
|
+
null: false,
|
21
|
+
index: { name: 'unit_on_po_indx' },
|
22
|
+
foreign_key: { to_table: :cats_core_unit_of_measures }
|
17
23
|
|
18
24
|
t.timestamps
|
19
25
|
end
|
data/lib/cats/core/version.rb
CHANGED
@@ -4,7 +4,10 @@ FactoryBot.define do
|
|
4
4
|
order_date { Date.today }
|
5
5
|
requisition_no { FFaker::Name.name }
|
6
6
|
supplier { FFaker::Name.name }
|
7
|
+
quantity { 100 }
|
8
|
+
purchase_type { Cats::Core::PurchaseOrder::LOCAL }
|
7
9
|
donation
|
8
10
|
commodity_category
|
11
|
+
unit factory: :unit_of_measure
|
9
12
|
end
|
10
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
|
+
version: 1.3.27
|
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-02-
|
11
|
+
date: 2022-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_model_serializers
|