cats_core 1.4.4 → 1.4.5
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/transport_requisition.rb +28 -0
- data/app/models/cats/core/transport_requisition_detail.rb +12 -0
- data/app/models/cats/core/transport_requisition_item.rb +14 -0
- data/app/serializers/cats/core/dispatch_plan_item_serializer.rb +1 -1
- data/db/migrate/20220417105839_create_cats_core_transport_requisitions.rb +26 -0
- data/db/migrate/20220417123835_create_cats_core_transport_requisition_items.rb +21 -0
- data/db/migrate/20220417151821_create_cats_core_transport_requisition_details.rb +17 -0
- data/lib/cats/core/version.rb +1 -1
- data/spec/factories/cats/core/locations.rb +13 -8
- data/spec/factories/cats/core/transport_requisition_details.rb +7 -0
- data/spec/factories/cats/core/transport_requisition_items.rb +8 -0
- data/spec/factories/cats/core/transport_requisitions.rb +10 -0
- metadata +10 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f6f8e286a7968b1159a3b0a7c9cb6e99f1637179ceb1d283d6b00f8c7e04d0b
|
4
|
+
data.tar.gz: a98a62f4250435c8611f1034e27e5dc0668ab1833ed8bdf42aa0b6ecdb47b4cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e8cfe8cacbf89d43b8a3552e2414d35081e2c4a92925f6c0a8678bc40822d34274961dd5bcb96c192e0b35ef6956cf709bea806676ff5dad7e84f73cae29888
|
7
|
+
data.tar.gz: 8d4e6d29a50e7ebc4fb2fa78dca753ca9d11ba90453c421ba77f7cf57819649e5027a40e76a298b14cdf20959f74b8fae2d57a265360a24d91ffe2e44df9134b
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Cats
|
2
|
+
module Core
|
3
|
+
class TransportRequisition < ApplicationRecord
|
4
|
+
DRAFT = 'Draft'.freeze
|
5
|
+
APPROVED = 'Approved'.freeze
|
6
|
+
STATUSES = [DRAFT, APPROVED].freeze
|
7
|
+
|
8
|
+
belongs_to :dispatch_plan
|
9
|
+
belongs_to :requested_by, class_name: 'Cats::Core::User'
|
10
|
+
belongs_to :approved_by, class_name: 'Cats::Core::User', optional: true
|
11
|
+
belongs_to :unit, class_name: 'Cats::Core::UnitOfMeasure'
|
12
|
+
|
13
|
+
has_many :transport_requisition_items
|
14
|
+
|
15
|
+
validates :reference_no, presence: true, uniqueness: true
|
16
|
+
validates :status, presence: true, inclusion: { in: STATUSES }
|
17
|
+
|
18
|
+
delegate(:full_name, to: :requested_by, prefix: 'requestor')
|
19
|
+
delegate(:full_name, to: :approved_by, prefix: 'approver')
|
20
|
+
delegate(:abbreviation, to: :unit, prefix: true)
|
21
|
+
|
22
|
+
def quantity
|
23
|
+
quantities = transport_requisition_items.map { |item| UnitConversion.convert(item.unit, unit, item.quantity) }
|
24
|
+
quantities.sum
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Cats
|
2
|
+
module Core
|
3
|
+
class TransportRequisitionDetail < ApplicationRecord
|
4
|
+
belongs_to :transport_requisition_item
|
5
|
+
belongs_to :fdp, class_name: 'Cats::Core::Location'
|
6
|
+
|
7
|
+
validates :quantity, presence: true, numericality: { greater_than: 0 }
|
8
|
+
|
9
|
+
delegate(:name, to: :fdp, prefix: true)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Cats
|
2
|
+
module Core
|
3
|
+
class TransportRequisitionItem < ApplicationRecord
|
4
|
+
belongs_to :transport_requisition
|
5
|
+
belongs_to :dispatch_plan_item
|
6
|
+
belongs_to :unit, class_name: 'Cats::Core::UnitOfMeasure'
|
7
|
+
|
8
|
+
validates :quantity, presence: true, numericality: { greater_than: 0 }
|
9
|
+
|
10
|
+
delegate(:reference_no, to: :transport_requisition, prefix: 'requisition')
|
11
|
+
delegate(:abbreviation, to: :unit, prefix: true)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -3,7 +3,7 @@ module Cats
|
|
3
3
|
class DispatchPlanItemSerializer < ActiveModel::Serializer
|
4
4
|
attributes :id, :dispatch_plan_id, :plan_reference_no, :source_id, :source_name, :destination_id,
|
5
5
|
:destination_name, :quantity, :source_location_type, :destination_location_type, :commodity_status,
|
6
|
-
:status
|
6
|
+
:status, :commodity_id, :commodity_name, :commodity_batch_no
|
7
7
|
end
|
8
8
|
end
|
9
9
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class CreateCatsCoreTransportRequisitions < ActiveRecord::Migration[7.0]
|
2
|
+
def change
|
3
|
+
create_table :cats_core_transport_requisitions do |t|
|
4
|
+
t.references :dispatch_plan,
|
5
|
+
null: false,
|
6
|
+
index: { name: 'dp_on_tr_indx' },
|
7
|
+
foreign_key: { to_table: :cats_core_dispatch_plans }
|
8
|
+
t.string :reference_no, null: false, unique: true
|
9
|
+
t.references :requested_by,
|
10
|
+
null: false,
|
11
|
+
index: { name: 'rb_on_tr_indx' },
|
12
|
+
foreign_key: { to_table: :cats_core_users }
|
13
|
+
t.references :approved_by,
|
14
|
+
null: true,
|
15
|
+
index: { name: 'ab_on_tr_indx' },
|
16
|
+
foreign_key: { to_table: :cats_core_users }
|
17
|
+
t.string :status, null: false
|
18
|
+
t.references :unit,
|
19
|
+
null: false,
|
20
|
+
index: { name: 'unit_on_tr_indx' },
|
21
|
+
foreign_key: { to_table: :cats_core_unit_of_measures }
|
22
|
+
|
23
|
+
t.timestamps
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class CreateCatsCoreTransportRequisitionItems < ActiveRecord::Migration[7.0]
|
2
|
+
def change
|
3
|
+
create_table :cats_core_transport_requisition_items do |t|
|
4
|
+
t.references :transport_requisition,
|
5
|
+
null: false,
|
6
|
+
index: { name: 'tr_on_tri_indx' },
|
7
|
+
foreign_key: { to_table: :cats_core_transport_requisitions }
|
8
|
+
t.references :dispatch_plan_item,
|
9
|
+
null: false,
|
10
|
+
index: { name: 'dpi_on_tri_indx' },
|
11
|
+
foreign_key: { to_table: :cats_core_dispatch_plan_items }
|
12
|
+
t.float :quantity, null: false
|
13
|
+
t.references :unit,
|
14
|
+
null: false,
|
15
|
+
index: { name: 'unit_on_tri_indx' },
|
16
|
+
foreign_key: { to_table: :cats_core_unit_of_measures }
|
17
|
+
|
18
|
+
t.timestamps
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class CreateCatsCoreTransportRequisitionDetails < ActiveRecord::Migration[7.0]
|
2
|
+
def change
|
3
|
+
create_table :cats_core_transport_requisition_details do |t|
|
4
|
+
t.references :transport_requisition_item,
|
5
|
+
null: false,
|
6
|
+
index: { name: 'tri_on_trd_indx'},
|
7
|
+
foreign_key: { to_table: :cats_core_transport_requisition_items }
|
8
|
+
t.float :quantity, null: false
|
9
|
+
t.references :fdp,
|
10
|
+
null: false,
|
11
|
+
index: { name: 'fdp_on_tri_indx'},
|
12
|
+
foreign_key: { to_table: :cats_core_locations }
|
13
|
+
|
14
|
+
t.timestamps
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/cats/core/version.rb
CHANGED
@@ -6,23 +6,28 @@ FactoryBot.define do
|
|
6
6
|
ancestry { nil }
|
7
7
|
end
|
8
8
|
|
9
|
-
factory :
|
10
|
-
location_type { Cats::Core::Location::
|
9
|
+
factory :zone, parent: :location, class: 'Cats::Core::Location' do
|
10
|
+
location_type { Cats::Core::Location::ZONE }
|
11
11
|
parent
|
12
12
|
end
|
13
13
|
|
14
|
-
factory :
|
15
|
-
location_type { Cats::Core::Location::
|
14
|
+
factory :woreda, parent: :location, class: 'Cats::Core::Location' do
|
15
|
+
location_type { Cats::Core::Location::WOREDA }
|
16
16
|
parent
|
17
17
|
end
|
18
18
|
|
19
|
-
factory :
|
20
|
-
location_type { Cats::Core::Location::
|
19
|
+
factory :fdp, parent: :woreda, class: 'Cats::Core::Location' do
|
20
|
+
location_type { Cats::Core::Location::FDP }
|
21
21
|
parent
|
22
22
|
end
|
23
23
|
|
24
|
-
factory :
|
25
|
-
location_type { Cats::Core::Location::
|
24
|
+
factory :hub, parent: :location, class: 'Cats::Core::Location' do
|
25
|
+
location_type { Cats::Core::Location::HUB }
|
26
|
+
parent
|
27
|
+
end
|
28
|
+
|
29
|
+
factory :warehouse, parent: :location, class: 'Cats::Core::Location' do
|
30
|
+
location_type { Cats::Core::Location::WAREHOUSE }
|
26
31
|
parent
|
27
32
|
end
|
28
33
|
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
FactoryBot.define do
|
2
|
+
factory :transport_requisition, class: 'Cats::Core::TransportRequisition' do
|
3
|
+
dispatch_plan
|
4
|
+
reference_no { FFaker::Name.name }
|
5
|
+
requested_by factory: :user
|
6
|
+
approved_by factory: :user
|
7
|
+
status { Cats::Core::TransportRequisition::DRAFT }
|
8
|
+
unit factory: :unit_of_measure
|
9
|
+
end
|
10
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cats_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henock L.
|
@@ -309,6 +309,9 @@ files:
|
|
309
309
|
- app/models/cats/core/transport_offer.rb
|
310
310
|
- app/models/cats/core/transport_plan.rb
|
311
311
|
- app/models/cats/core/transport_plan_item.rb
|
312
|
+
- app/models/cats/core/transport_requisition.rb
|
313
|
+
- app/models/cats/core/transport_requisition_detail.rb
|
314
|
+
- app/models/cats/core/transport_requisition_item.rb
|
312
315
|
- app/models/cats/core/transporter.rb
|
313
316
|
- app/models/cats/core/unit_conversion.rb
|
314
317
|
- app/models/cats/core/unit_of_measure.rb
|
@@ -404,6 +407,9 @@ files:
|
|
404
407
|
- db/migrate/20220107132433_create_cats_core_monthly_plan_item_details.rb
|
405
408
|
- db/migrate/20220209083928_create_cats_core_hub_authorizations.rb
|
406
409
|
- db/migrate/20220416143416_create_cats_core_unit_conversions.rb
|
410
|
+
- db/migrate/20220417105839_create_cats_core_transport_requisitions.rb
|
411
|
+
- db/migrate/20220417123835_create_cats_core_transport_requisition_items.rb
|
412
|
+
- db/migrate/20220417151821_create_cats_core_transport_requisition_details.rb
|
407
413
|
- lib/cats/core.rb
|
408
414
|
- lib/cats/core/engine.rb
|
409
415
|
- lib/cats/core/version.rb
|
@@ -460,6 +466,9 @@ files:
|
|
460
466
|
- spec/factories/cats/core/transport_offers.rb
|
461
467
|
- spec/factories/cats/core/transport_plan_items.rb
|
462
468
|
- spec/factories/cats/core/transport_plans.rb
|
469
|
+
- spec/factories/cats/core/transport_requisition_details.rb
|
470
|
+
- spec/factories/cats/core/transport_requisition_items.rb
|
471
|
+
- spec/factories/cats/core/transport_requisitions.rb
|
463
472
|
- spec/factories/cats/core/transporters.rb
|
464
473
|
- spec/factories/cats/core/unit_conversions.rb
|
465
474
|
- spec/factories/cats/core/unit_of_measures.rb
|