cats_core 1.2.26 → 1.2.30
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/cats/core/routes_controller.rb +1 -1
- data/app/models/cats/core/contract_item.rb +2 -0
- data/app/models/cats/core/route.rb +20 -0
- data/app/models/cats/core/transport_contract.rb +5 -0
- data/db/migrate/20210718040129_create_cats_core_routes.rb +5 -1
- data/db/migrate/20211229160127_create_cats_core_transport_contracts.rb +2 -0
- data/lib/cats/core/version.rb +1 -1
- data/spec/factories/cats/core/routes.rb +3 -2
- data/spec/factories/cats/core/transport_contracts.rb +1 -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: 7d71e458593e0bfa2d57ddcba1e5ea4f1392df4223cff0c2b7ef5d1150859463
|
4
|
+
data.tar.gz: 4d2798fd1957265c3493ee8dca89b759d674d2e029489dc7382e7a6d5f62b0c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 739d0d54055f96059cfb2818f86026ac46518e3c64eaa81762e984ea803e95650c56f28f11ee738fe29254deeb9b5e76a668b037c0454c40c3e4a308db6001d0
|
7
|
+
data.tar.gz: e64a2e770bd662c26218e6d67a1c76d32ddf881deae9e77faecf3aa52628b1f19ac84f71fad4b202dcb200f8cc23aed3c2274f03aa8ff4513fba24b36ee7b254
|
@@ -3,16 +3,36 @@ module Cats
|
|
3
3
|
class Route < ApplicationRecord
|
4
4
|
before_validation :set_name, on: %i[create update]
|
5
5
|
|
6
|
+
belongs_to :region, class_name: 'Cats::Core::Location'
|
6
7
|
belongs_to :source, class_name: 'Cats::Core::Location'
|
7
8
|
belongs_to :destination, class_name: 'Cats::Core::Location'
|
8
9
|
|
9
10
|
validates :source_id, uniqueness: { scope: :destination_id }
|
11
|
+
validate :validate_region, :validate_source, :validate_destination
|
10
12
|
|
11
13
|
def set_name
|
12
14
|
return unless source && destination
|
13
15
|
|
14
16
|
self.name = "#{source.name} - #{destination.name}"
|
15
17
|
end
|
18
|
+
|
19
|
+
def validate_region
|
20
|
+
return unless region
|
21
|
+
|
22
|
+
errors.add(:region, 'should be a valid region.') unless region.location_type == Location::REGION
|
23
|
+
end
|
24
|
+
|
25
|
+
def validate_source
|
26
|
+
return unless source
|
27
|
+
|
28
|
+
errors.add(:source, 'cannot be a region.') if source.location_type == Location::REGION
|
29
|
+
end
|
30
|
+
|
31
|
+
def validate_destination
|
32
|
+
return unless destination
|
33
|
+
|
34
|
+
errors.add(:destination, 'cannot be a region.') if destination.location_type == Location::REGION
|
35
|
+
end
|
16
36
|
end
|
17
37
|
end
|
18
38
|
end
|
@@ -5,7 +5,12 @@ module Cats
|
|
5
5
|
belongs_to :transporter
|
6
6
|
belongs_to :transport_bid
|
7
7
|
|
8
|
+
validates :contract_no, presence: true, uniqueness: true
|
8
9
|
validates :contract_date, :expires_on, presence: true
|
10
|
+
|
11
|
+
delegate(:name, to: :region, prefix: true)
|
12
|
+
delegate(:name, to: :transporter, prefix: true)
|
13
|
+
delegate(:reference_no, to: :transport_bid, prefix: :bid)
|
9
14
|
end
|
10
15
|
end
|
11
16
|
end
|
@@ -2,6 +2,10 @@ class CreateCatsCoreRoutes < ActiveRecord::Migration[6.1]
|
|
2
2
|
def change
|
3
3
|
create_table :cats_core_routes do |t|
|
4
4
|
t.string :name, null: false
|
5
|
+
t.references :region,
|
6
|
+
null: false,
|
7
|
+
index: { name: 'region_on_routes_indx' },
|
8
|
+
foreign_key: { to_table: :cats_core_locations }
|
5
9
|
t.references :source,
|
6
10
|
null: false,
|
7
11
|
index: { name: 'source_on_routes_indx' },
|
@@ -13,7 +17,7 @@ class CreateCatsCoreRoutes < ActiveRecord::Migration[6.1]
|
|
13
17
|
|
14
18
|
t.timestamps
|
15
19
|
|
16
|
-
t.index [
|
20
|
+
t.index %i[source_id destination_id], unique: true
|
17
21
|
end
|
18
22
|
end
|
19
23
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
class CreateCatsCoreTransportContracts < ActiveRecord::Migration[6.1]
|
2
2
|
def change
|
3
3
|
create_table :cats_core_transport_contracts do |t|
|
4
|
+
t.string :contract_no, unique: true
|
4
5
|
t.references :region,
|
5
6
|
null: false,
|
6
7
|
index: { name: 'region_on_tc_indx' },
|
@@ -16,6 +17,7 @@ class CreateCatsCoreTransportContracts < ActiveRecord::Migration[6.1]
|
|
16
17
|
t.date :contract_date, null: false
|
17
18
|
t.date :expires_on, null: false
|
18
19
|
t.string :payment_term
|
20
|
+
t.boolean :signed, null: false, default: false
|
19
21
|
|
20
22
|
t.timestamps
|
21
23
|
end
|
data/lib/cats/core/version.rb
CHANGED
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.2.
|
4
|
+
version: 1.2.30
|
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-12-
|
11
|
+
date: 2021-12-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_model_serializers
|