cats_core 1.0.24 → 1.0.28
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/allocation.rb +13 -0
- data/app/models/cats/core/allocation_item.rb +18 -0
- data/app/models/cats/core/commodity.rb +13 -0
- data/app/models/cats/core/dispatch.rb +1 -1
- data/app/models/cats/core/rhn_request.rb +10 -0
- data/db/migrate/20210717033223_create_cats_core_commodities.rb +5 -0
- data/db/migrate/20210718042755_create_cats_core_rhn_requests.rb +15 -0
- data/db/migrate/{20210718042823_create_cats_core_commodity_allocations.rb → 20210718042823_create_cats_core_allocations.rb} +6 -6
- data/db/migrate/20210718043204_create_cats_core_allocation_items.rb +19 -0
- data/db/migrate/20210718045516_create_cats_core_dispatches.rb +3 -3
- data/lib/cats/core/version.rb +1 -1
- data/spec/factories/cats/core/allocation_items.rb +9 -0
- data/spec/factories/cats/core/{commodity_allocations.rb → allocations.rb} +2 -2
- data/spec/factories/cats/core/commodities.rb +2 -0
- data/spec/factories/cats/core/dispatches.rb +1 -1
- data/spec/factories/cats/core/rhn_requests.rb +8 -0
- metadata +11 -5
- data/app/models/cats/core/commodity_allocation.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b39ab8dfbbd491a6a9e68acfd75dcf77f88a477e5fe1eb2bce823a17dd857bd8
|
4
|
+
data.tar.gz: ffe26682256958cfb286feda0ae58f498922ed65c505af9401298fef5a7b7b44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16218f6af68d849f4550848cffc761e265b4cf80972d6befc8edbe19aed2eff86730299042c7ed098f372b8c55f77a698638fcaf8ca5317001db07bc0d21da86
|
7
|
+
data.tar.gz: e7a54575147d96397141682e144749767cc9be51abb89876c382202550531842876cba3c3a87800d01fc9671f3cc8fec056f29f992e3507a0f4a33423756f85b
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Cats
|
2
|
+
module Core
|
3
|
+
class Allocation < ApplicationRecord
|
4
|
+
belongs_to :rhn_request, optional: true
|
5
|
+
belongs_to :commodity
|
6
|
+
belongs_to :source, class_name: 'Cats::Core::Location'
|
7
|
+
|
8
|
+
validates :commodity_status, presence: true
|
9
|
+
validates :quantity, presence: true, numericality: { greater_than: 0 }
|
10
|
+
validates :commodity_status, inclusion: { in: Cats::Core::Commodity::COMMODITY_STATUSES }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Cats
|
2
|
+
module Core
|
3
|
+
class AllocationItem < ApplicationRecord
|
4
|
+
belongs_to :allocation
|
5
|
+
belongs_to :destination, class_name: 'Cats::Core::Location'
|
6
|
+
|
7
|
+
validates :from, :to, presence: true
|
8
|
+
validates :quantity, presence: true, numericality: { greater_than: 0 }
|
9
|
+
validate :validate_source_and_destination
|
10
|
+
|
11
|
+
def validate_source_and_destination
|
12
|
+
return unless allocation.present? && destination.present?
|
13
|
+
|
14
|
+
errors.add(:base, 'source and destination cannot be the same') if allocation.source == destination
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module Cats
|
2
2
|
module Core
|
3
3
|
class Commodity < ApplicationRecord
|
4
|
+
after_initialize :set_approved
|
5
|
+
|
4
6
|
# Commodity statuses
|
5
7
|
GOOD = 'Good'.freeze
|
6
8
|
DAMAGED = 'Damaged'.freeze
|
@@ -14,12 +16,23 @@ module Cats
|
|
14
16
|
|
15
17
|
belongs_to :unit_of_measure
|
16
18
|
belongs_to :source, polymorphic: true
|
19
|
+
belongs_to :commodity_category
|
17
20
|
|
18
21
|
validates :best_use_before, presence: true
|
19
22
|
validates :batch_no, presence: true, uniqueness: true
|
20
23
|
validates :quantity, presence: true, numericality: { greater_than: 0 }
|
21
24
|
validates :volume_per_metric_ton, numericality: { greater_than: 0, allow_nil: true }
|
22
25
|
validates :arrival_status, presence: true, inclusion: { in: ARRIVAL_STATUSES }
|
26
|
+
|
27
|
+
delegate(:abbreviation, to: :unit_of_measure, prefix: true)
|
28
|
+
delegate(:name, to: :commodity_category, prefix: true)
|
29
|
+
delegate(:reference_no, to: :source, prefix: true)
|
30
|
+
|
31
|
+
def set_approved
|
32
|
+
return unless new_record?
|
33
|
+
|
34
|
+
self.approved = false
|
35
|
+
end
|
23
36
|
end
|
24
37
|
end
|
25
38
|
end
|
@@ -3,7 +3,7 @@ module Cats
|
|
3
3
|
class Dispatch < ApplicationRecord
|
4
4
|
belongs_to :prepared_by, class_name: 'Cats::Core::User'
|
5
5
|
belongs_to :transporter
|
6
|
-
belongs_to :
|
6
|
+
belongs_to :allocation_item
|
7
7
|
|
8
8
|
validates :reference_no, :plate_no, :driver_name, :driver_phone, :quantity, :commodity_status, presence: true
|
9
9
|
validates :reference_no, uniqueness: true
|
@@ -6,12 +6,17 @@ class CreateCatsCoreCommodities < ActiveRecord::Migration[6.1]
|
|
6
6
|
null: false,
|
7
7
|
index: { name: 'uom_on_commodities_indx' },
|
8
8
|
foreign_key: { to_table: :cats_core_unit_of_measures }
|
9
|
+
t.references :commodity_category,
|
10
|
+
null: false,
|
11
|
+
index: { name: 'cc_on_commodities_indx' },
|
12
|
+
foreign_key: { to_table: :cats_core_commodity_categories }
|
9
13
|
t.references :source, polymorphic: true
|
10
14
|
t.float :quantity, null: false
|
11
15
|
t.string :description
|
12
16
|
t.date :best_use_before, null: false
|
13
17
|
t.float :volume_per_metric_ton
|
14
18
|
t.string :arrival_status, null: false, default: 'At Source'
|
19
|
+
t.boolean :approved, null: false, default: false
|
15
20
|
|
16
21
|
t.timestamps
|
17
22
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class CreateCatsCoreRhnRequests < ActiveRecord::Migration[6.1]
|
2
|
+
def change
|
3
|
+
create_table :cats_core_rhn_requests do |t|
|
4
|
+
t.string :reference_no, unique: true
|
5
|
+
t.references :commodity,
|
6
|
+
null: false,
|
7
|
+
index: { name: 'commodity_on_rhn_indx' },
|
8
|
+
foreign_key: { to_table: :cats_core_commodities }
|
9
|
+
t.date :request_date, null: false
|
10
|
+
t.string :requested_by
|
11
|
+
|
12
|
+
t.timestamps
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -1,6 +1,10 @@
|
|
1
|
-
class
|
1
|
+
class CreateCatsCoreAllocations < ActiveRecord::Migration[6.1]
|
2
2
|
def change
|
3
|
-
create_table :
|
3
|
+
create_table :cats_core_allocations do |t|
|
4
|
+
t.references :rhn_request,
|
5
|
+
null: true,
|
6
|
+
index: { name: 'rr_on_allocation_indx' },
|
7
|
+
foreign_key: { to_table: :cats_core_rhn_requests }
|
4
8
|
t.references :commodity,
|
5
9
|
null: false,
|
6
10
|
index: { name: 'ca_on_commodity_indx' },
|
@@ -9,10 +13,6 @@ class CreateCatsCoreCommodityAllocations < ActiveRecord::Migration[6.1]
|
|
9
13
|
null: false,
|
10
14
|
index: { name: 'ca_on_source_indx' },
|
11
15
|
foreign_key: { to_table: :cats_core_locations }
|
12
|
-
t.references :destination,
|
13
|
-
null: false,
|
14
|
-
index: { name: 'ca_on_destination_indx' },
|
15
|
-
foreign_key: { to_table: :cats_core_locations }
|
16
16
|
t.float :quantity, null: false
|
17
17
|
t.string :commodity_status, null: false, default: 'Good'
|
18
18
|
t.string :remark
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class CreateCatsCoreAllocationItems < ActiveRecord::Migration[6.1]
|
2
|
+
def change
|
3
|
+
create_table :cats_core_allocation_items do |t|
|
4
|
+
t.references :allocation,
|
5
|
+
null: false,
|
6
|
+
index: { name: 'allocation_on_ai_indx' },
|
7
|
+
foreign_key: { to_table: :cats_core_allocations }
|
8
|
+
t.references :destination,
|
9
|
+
null: false,
|
10
|
+
index: { name: 'destination_on_ai_indx'},
|
11
|
+
foreign_key: { to_table: :cats_core_locations }
|
12
|
+
t.float :quantity, null: false
|
13
|
+
t.date :from, null: false
|
14
|
+
t.date :to, null: false
|
15
|
+
|
16
|
+
t.timestamps
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -2,10 +2,10 @@ class CreateCatsCoreDispatches < ActiveRecord::Migration[6.1]
|
|
2
2
|
def change
|
3
3
|
create_table :cats_core_dispatches do |t|
|
4
4
|
t.string :reference_no, unique: true
|
5
|
-
t.references :
|
5
|
+
t.references :allocation_item,
|
6
6
|
null: false,
|
7
|
-
index: { name: '
|
8
|
-
foreign_key: { to_table: :
|
7
|
+
index: { name: 'ai_on_dispatches_indx' },
|
8
|
+
foreign_key: { to_table: :cats_core_allocation_items }
|
9
9
|
t.references :transporter,
|
10
10
|
null: false,
|
11
11
|
index: { name: 'transporter_on_dispatches_indx' },
|
data/lib/cats/core/version.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
FactoryBot.define do
|
2
|
-
factory :
|
2
|
+
factory :allocation, class: 'Cats::Core::Allocation' do
|
3
|
+
rhn_request { nil }
|
3
4
|
commodity
|
4
5
|
source factory: :location
|
5
|
-
destination factory: :location
|
6
6
|
quantity { 50 }
|
7
7
|
commodity_status { Cats::Core::Commodity::GOOD }
|
8
8
|
remark { FFaker::Name.name }
|
@@ -3,10 +3,12 @@ FactoryBot.define do
|
|
3
3
|
batch_no { FFaker::Name.name }
|
4
4
|
description { FFaker::Name.name }
|
5
5
|
unit_of_measure
|
6
|
+
commodity_category
|
6
7
|
source factory: :gift_certificate
|
7
8
|
quantity { 100 }
|
8
9
|
best_use_before { Date.today + 2.month }
|
9
10
|
volume_per_metric_ton { 10 }
|
10
11
|
arrival_status { Cats::Core::Commodity::AT_SOURCE }
|
12
|
+
approved { false }
|
11
13
|
end
|
12
14
|
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.0.
|
4
|
+
version: 1.0.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: 2021-09-
|
11
|
+
date: 2021-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_model_serializers
|
@@ -226,10 +226,11 @@ files:
|
|
226
226
|
- app/controllers/cats/core/roles_controller.rb
|
227
227
|
- app/controllers/cats/core/users_controller.rb
|
228
228
|
- app/jobs/cats/core/application_job.rb
|
229
|
+
- app/models/cats/core/allocation.rb
|
230
|
+
- app/models/cats/core/allocation_item.rb
|
229
231
|
- app/models/cats/core/application_module.rb
|
230
232
|
- app/models/cats/core/application_record.rb
|
231
233
|
- app/models/cats/core/commodity.rb
|
232
|
-
- app/models/cats/core/commodity_allocation.rb
|
233
234
|
- app/models/cats/core/commodity_category.rb
|
234
235
|
- app/models/cats/core/currency.rb
|
235
236
|
- app/models/cats/core/dispatch.rb
|
@@ -249,6 +250,7 @@ files:
|
|
249
250
|
- app/models/cats/core/ration.rb
|
250
251
|
- app/models/cats/core/receipt.rb
|
251
252
|
- app/models/cats/core/receipt_transaction.rb
|
253
|
+
- app/models/cats/core/rhn_request.rb
|
252
254
|
- app/models/cats/core/role.rb
|
253
255
|
- app/models/cats/core/role_menu.rb
|
254
256
|
- app/models/cats/core/stack.rb
|
@@ -293,7 +295,9 @@ files:
|
|
293
295
|
- db/migrate/20210717140855_create_cats_core_stores.rb
|
294
296
|
- db/migrate/20210717171101_create_cats_core_stacks.rb
|
295
297
|
- db/migrate/20210718042749_create_cats_core_transporters.rb
|
296
|
-
- db/migrate/
|
298
|
+
- db/migrate/20210718042755_create_cats_core_rhn_requests.rb
|
299
|
+
- db/migrate/20210718042823_create_cats_core_allocations.rb
|
300
|
+
- db/migrate/20210718043204_create_cats_core_allocation_items.rb
|
297
301
|
- db/migrate/20210718045516_create_cats_core_dispatches.rb
|
298
302
|
- db/migrate/20210718202957_create_cats_core_dispatch_transactions.rb
|
299
303
|
- db/migrate/20210719133710_create_cats_core_stacking_rules.rb
|
@@ -306,9 +310,10 @@ files:
|
|
306
310
|
- lib/cats/core/version.rb
|
307
311
|
- lib/cats_core.rb
|
308
312
|
- lib/tasks/cats_core_tasks.rake
|
313
|
+
- spec/factories/cats/core/allocation_items.rb
|
314
|
+
- spec/factories/cats/core/allocations.rb
|
309
315
|
- spec/factories/cats/core/application_modules.rb
|
310
316
|
- spec/factories/cats/core/commodities.rb
|
311
|
-
- spec/factories/cats/core/commodity_allocations.rb
|
312
317
|
- spec/factories/cats/core/commodity_categories.rb
|
313
318
|
- spec/factories/cats/core/currencies.rb
|
314
319
|
- spec/factories/cats/core/dispatch_transactions.rb
|
@@ -328,6 +333,7 @@ files:
|
|
328
333
|
- spec/factories/cats/core/rations.rb
|
329
334
|
- spec/factories/cats/core/receipt_transactions.rb
|
330
335
|
- spec/factories/cats/core/receipts.rb
|
336
|
+
- spec/factories/cats/core/rhn_requests.rb
|
331
337
|
- spec/factories/cats/core/role_menus.rb
|
332
338
|
- spec/factories/cats/core/roles.rb
|
333
339
|
- spec/factories/cats/core/stack_transactions.rb
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module Cats
|
2
|
-
module Core
|
3
|
-
class CommodityAllocation < ApplicationRecord
|
4
|
-
belongs_to :commodity
|
5
|
-
belongs_to :source, class_name: 'Cats::Core::Location'
|
6
|
-
belongs_to :destination, class_name: 'Cats::Core::Location'
|
7
|
-
|
8
|
-
validates :quantity, :commodity_status, presence: true
|
9
|
-
validates :commodity_status, inclusion: { in: Cats::Core::Commodity::COMMODITY_STATUSES }
|
10
|
-
validate :validate_source_and_destination
|
11
|
-
|
12
|
-
def validate_source_and_destination
|
13
|
-
return unless source.present? && destination.present?
|
14
|
-
|
15
|
-
errors.add(:base, 'source and destination cannot be the same') if source == destination
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|