cats_core 1.3.24 → 1.3.28

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: 2531c2f89fe44de09ddf14fd923e8d990a3e1926775eea0962b5a3d4787d7457
4
- data.tar.gz: ec9cbed2a69e8f62884556108dbbc1ab448a360a7273fe2843f3fb754a3982c4
3
+ metadata.gz: 83f9bfdc22317ca433717055d41463cf8d70aed78994c62a9a924bcead85c561
4
+ data.tar.gz: ffcb5a3122bd29126aa6902388af57a8979b414fa8378f5bd9f4c364aea6029d
5
5
  SHA512:
6
- metadata.gz: 52d97959257855990865164a5f63ff2b529b17c97995de5c30ee658ae169ec8a77c3b3ff52a459b658e6dd4f93757ff1db4b64e2c33fb5de004dcd5106b688b6
7
- data.tar.gz: 64edb99aecf7615a963971661748cdef7d62faf0d7450dcdebf0b2ffb1100373ce60a8aa79f261ed884542812530c60f1b8cefcdb4e5f21a59e0c296dec07ed5
6
+ metadata.gz: 5b77e70633822f0dcc6db6caedd36c1f7baecd232b466a1bc975c02b29c32e7129fd6d767e800a5dd1c7b17ff9e2da9250f74d136797591a9c19043b07bddd8d
7
+ data.tar.gz: 2d29e1087a864c93d57a050f5fa6df3ff993abd63b060604f88bc7d2df282aa94ca5f48e1183b852a2974c1e5c0b36d5fd94082f3517181f1a2023363fb819bb
@@ -14,9 +14,19 @@ module Cats
14
14
 
15
15
  # Arrival Statuses
16
16
  AT_SOURCE = 'At Source'.freeze
17
- IN_TRANSIT = 'In Transit'.freeze
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 = [AT_SOURCE, IN_TRANSIT, ARRIVED].freeze
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 }
@@ -4,9 +4,10 @@ module Cats
4
4
  belongs_to :donation, optional: true
5
5
  belongs_to :commodity_category
6
6
  belongs_to :unit_of_measure
7
+ belongs_to :destination_warehouse, class_name: 'Cats::Core::Location'
7
8
 
8
9
  validates :reference_no, presence: true, uniqueness: true
9
- validates :gift_date, :quantity, presence: true
10
+ validates :gift_date, :quantity, :requested_by, :request_reference, presence: true
10
11
  validates :quantity, numericality: { greater_than: 0 }
11
12
 
12
13
  delegate(:name, to: :commodity_category, prefix: true)
@@ -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
 
@@ -4,7 +4,7 @@ module Cats
4
4
  def approve(plan)
5
5
  plan.approve
6
6
 
7
- plan.dispatchable.allocate if plan.dispatchable_type == Cats::Core::RhnRequest.name
7
+ plan.dispatchable.allocate if plan.dispatchable_type == RhnRequest.name
8
8
  # send_notification(plan)
9
9
  plan
10
10
  end
@@ -4,7 +4,9 @@ class CreateCatsCoreDonations < ActiveRecord::Migration[6.1]
4
4
  t.string :reference_no, unique: true
5
5
  t.string :description
6
6
  t.string :donation_type, null: false
7
+ t.string :shipping_reference
7
8
  t.date :donated_on, null: false
9
+ t.string :agency, null: false
8
10
  t.references :donor,
9
11
  null: false,
10
12
  index: { name: 'donor_on_donation_indx' },
@@ -24,8 +24,15 @@ class CreateCatsCoreGiftCertificates < ActiveRecord::Migration[6.1]
24
24
  null: false,
25
25
  index: { name: 'uom_on_gc_indx' },
26
26
  foreign_key: { to_table: :cats_core_unit_of_measures }
27
+ t.references :destination_warehouse,
28
+ null: false,
29
+ index: { name: 'dw_on_gc_indx' },
30
+ foreign_key: { to_table: :cats_core_locations }
27
31
  t.float :estimated_price
28
32
  t.float :estimated_tax
33
+ t.string :registration_no
34
+ t.string :requested_by, null: false
35
+ t.string :request_reference, null: false
29
36
 
30
37
  t.timestamps
31
38
  end
@@ -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
@@ -1,5 +1,5 @@
1
1
  module Cats
2
2
  module Core
3
- VERSION = '1.3.24'.freeze
3
+ VERSION = '1.3.28'.freeze
4
4
  end
5
5
  end
@@ -7,5 +7,9 @@ FactoryBot.define do
7
7
  commodity
8
8
  prepared_by factory: :user
9
9
  approved_by { nil }
10
+
11
+ trait :with_rhn do
12
+ dispatchable { create(:rhn_request) }
13
+ end
10
14
  end
11
15
  end
@@ -3,7 +3,9 @@ FactoryBot.define do
3
3
  reference_no { FFaker::Name.name }
4
4
  description { FFaker::Name.name }
5
5
  donation_type { Cats::Core::Donation::KIND }
6
+ shipping_reference { FFaker::Name.name }
6
7
  donated_on { Date.today }
8
+ agency { 'WFP' }
7
9
  donor
8
10
  plan
9
11
  amount { 100 }
@@ -5,6 +5,7 @@ FactoryBot.define do
5
5
  donation
6
6
  commodity_category { donation.commodity_category }
7
7
  unit_of_measure
8
+ destination_warehouse factory: :warehouse
8
9
  vessel { FFaker::Name.name }
9
10
  port { FFaker::Name.name }
10
11
  customs_declaration_no { FFaker::Name.name }
@@ -14,5 +15,8 @@ FactoryBot.define do
14
15
  quantity { 1.5 }
15
16
  estimated_price { 1.5 }
16
17
  estimated_tax { 1.5 }
18
+ registration_no { FFaker::Name.name }
19
+ requested_by { FFaker::Name.name }
20
+ request_reference { FFaker::Name.name }
17
21
  end
18
22
  end
@@ -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.24
4
+ version: 1.3.28
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-03 00:00:00.000000000 Z
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