cats_core 1.2.21 → 1.2.22
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5139b115f1503157e1d5f53a0a013b72d1296a0cd1fe808c1fd117a4a813830
|
4
|
+
data.tar.gz: eaf56d0ba167f6360144a4d7e6152eba2e0375b7c272ea271cfc9805178e781b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bad07930acac569a78aee9152527d95c390f48eb3a69070894c888a3ff8de74f07f0904730aa59446b17a9b1979a0cdbd8e898b23eeb231b1693f449f664be7b
|
7
|
+
data.tar.gz: ab180af55c2610e87a0f1f7f7f1031a8730f9cccbae2ea1c0f5bc58cc6cf219dfac657e3078624e2624f38230b950dd49d708d44691f8ed47db55652262852d3
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Cats
|
2
|
+
module Core
|
3
|
+
class CommoditySubstitution < ApplicationRecord
|
4
|
+
belongs_to :program
|
5
|
+
belongs_to :commodity, class_name: 'Cats::Core::CommodityCategory'
|
6
|
+
belongs_to :replaced_by, class_name: 'Cats::Core::CommodityCategory'
|
7
|
+
|
8
|
+
validates :ratio, presence: true
|
9
|
+
validates :program_id, uniqueness: { scope: %i[commodity_id replaced_by_id] }
|
10
|
+
validate :validate_ratio
|
11
|
+
|
12
|
+
def validate_ratio
|
13
|
+
return unless ratio
|
14
|
+
|
15
|
+
left, right = ratio.split(':')
|
16
|
+
left_correct = Integer(left).is_a?(Integer) rescue false
|
17
|
+
right_correct = Integer(right).is_a?(Integer) rescue false
|
18
|
+
|
19
|
+
errors.add(:ratio, 'is not in correct format.') unless left_correct && right_correct
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class CreateCatsCoreCommoditySubstitutions < ActiveRecord::Migration[6.1]
|
2
|
+
def change
|
3
|
+
create_table :cats_core_commodity_substitutions do |t|
|
4
|
+
t.references :program,
|
5
|
+
null: false,
|
6
|
+
index: { name: 'program_on_cs_indx' },
|
7
|
+
foreign_key: { to_table: :cats_core_programs }
|
8
|
+
t.references :commodity,
|
9
|
+
null: false,
|
10
|
+
index: { name: 'commodity_on_cs_indx' },
|
11
|
+
foreign_key: { to_table: :cats_core_commodity_categories }
|
12
|
+
t.references :replaced_by,
|
13
|
+
null: false,
|
14
|
+
index: { name: 'rb_on_cs_indx' },
|
15
|
+
foreign_key: { to_table: :cats_core_commodity_categories }
|
16
|
+
t.string :ratio, null: false
|
17
|
+
|
18
|
+
t.timestamps
|
19
|
+
|
20
|
+
t.index [:program_id, :commodity_id, :replaced_by_id], unique: true, name: 'pcr_on_cs_indx'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/cats/core/version.rb
CHANGED
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.2.
|
4
|
+
version: 1.2.22
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henock L.
|
@@ -256,6 +256,7 @@ files:
|
|
256
256
|
- app/models/cats/core/application_record.rb
|
257
257
|
- app/models/cats/core/commodity.rb
|
258
258
|
- app/models/cats/core/commodity_category.rb
|
259
|
+
- app/models/cats/core/commodity_substitution.rb
|
259
260
|
- app/models/cats/core/contract_item.rb
|
260
261
|
- app/models/cats/core/currency.rb
|
261
262
|
- app/models/cats/core/dispatch.rb
|
@@ -372,6 +373,7 @@ files:
|
|
372
373
|
- db/migrate/20211229160126_create_cats_core_transport_offers.rb
|
373
374
|
- db/migrate/20211229160127_create_cats_core_transport_contracts.rb
|
374
375
|
- db/migrate/20211229160128_create_cats_core_contract_items.rb
|
376
|
+
- db/migrate/20211229160129_create_cats_core_commodity_substitutions.rb
|
375
377
|
- lib/cats/core.rb
|
376
378
|
- lib/cats/core/engine.rb
|
377
379
|
- lib/cats/core/version.rb
|
@@ -382,6 +384,7 @@ files:
|
|
382
384
|
- spec/factories/cats/core/application_modules.rb
|
383
385
|
- spec/factories/cats/core/commodities.rb
|
384
386
|
- spec/factories/cats/core/commodity_categories.rb
|
387
|
+
- spec/factories/cats/core/commodity_substitutions.rb
|
385
388
|
- spec/factories/cats/core/contract_items.rb
|
386
389
|
- spec/factories/cats/core/currencies.rb
|
387
390
|
- spec/factories/cats/core/dispatch_plan_items.rb
|