cats_core 1.2.8 → 1.2.12
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_service_offer.rb → transport_offer.rb} +4 -2
- data/app/models/cats/core/transport_request.rb +44 -0
- data/app/models/cats/core/transport_request_item.rb +14 -0
- data/db/migrate/{20211209155113_create_cats_core_transport_service_requests.rb → 20211209155113_create_cats_core_transport_requests.rb} +2 -2
- data/db/migrate/{20211209155915_create_cats_core_transport_service_request_items.rb → 20211209155915_create_cats_core_transport_request_items.rb} +8 -8
- data/db/migrate/20211209160126_create_cats_core_transport_offers.rb +17 -0
- data/lib/cats/core/version.rb +1 -1
- data/spec/factories/cats/core/transport_offers.rb +7 -0
- data/spec/factories/cats/core/transport_request_items.rb +8 -0
- data/spec/factories/cats/core/{transport_service_requests.rb → transport_requests.rb} +1 -1
- metadata +11 -11
- data/app/models/cats/core/transport_service_request.rb +0 -19
- data/app/models/cats/core/transport_service_request_item.rb +0 -10
- data/db/migrate/20211209160126_create_cats_core_transport_service_offers.rb +0 -17
- data/spec/factories/cats/core/transport_service_offers.rb +0 -7
- data/spec/factories/cats/core/transport_service_request_items.rb +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6d9c981d6dfe00647462832e97d47af7fc677b5e092a5f675366ae1e49ac8dc
|
4
|
+
data.tar.gz: b24adf0ed11330190cfd57050c94ead1f871e183339351d2caebcc2b09597536
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56857803a15398dadccd2396e3a2d1b4124b392258ecc180f678d70ddca5a3dafa7b222774b34a9b2d93e8d23aa928622de3d78772017020c7c67f7996ede95c
|
7
|
+
data.tar.gz: f7b0c9cdbacfec2c9836a80560b2c93a69281e4be503e850ee433ca64917d1703c4bf83d2d59c668495f93fa4371350e9573569ce87ea5207b45a54a18d8b8ac
|
@@ -1,10 +1,12 @@
|
|
1
1
|
module Cats
|
2
2
|
module Core
|
3
|
-
class
|
4
|
-
belongs_to :
|
3
|
+
class TransportOffer < ApplicationRecord
|
4
|
+
belongs_to :transport_request_item
|
5
5
|
belongs_to :transporter
|
6
6
|
|
7
7
|
validates :price, presence: true, numericality: { greater_than: 0 }
|
8
|
+
|
9
|
+
delegate(:name, to: :transporter, prefix: true)
|
8
10
|
end
|
9
11
|
end
|
10
12
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Cats
|
2
|
+
module Core
|
3
|
+
class TransportRequest < ApplicationRecord
|
4
|
+
DRAFT = 'Draft'.freeze
|
5
|
+
APPROVED = 'Approved'.freeze
|
6
|
+
OPEN = 'Open'.freeze
|
7
|
+
CLOSED = 'Closed'.freeze
|
8
|
+
STATUSES = [DRAFT, APPROVED, OPEN, CLOSED].freeze
|
9
|
+
|
10
|
+
belongs_to :requested_by, class_name: 'Cats::Core::User'
|
11
|
+
belongs_to :approved_by, class_name: 'Cats::Core::User', optional: true
|
12
|
+
has_many :transport_request_items
|
13
|
+
|
14
|
+
validates :reference_no, :request_date, :status, presence: true
|
15
|
+
validates :reference_no, uniqueness: true
|
16
|
+
validates :status, inclusion: { in: STATUSES }
|
17
|
+
|
18
|
+
delegate(:full_name, to: :requested_by, prefix: true, allow_nil: true)
|
19
|
+
delegate(:full_name, to: :approved_by, prefix: true, allow_nil: true)
|
20
|
+
|
21
|
+
def approve(approver)
|
22
|
+
raise(StandardError, 'Request is not open for approval.') unless status == DRAFT
|
23
|
+
|
24
|
+
self.approved_by = approver
|
25
|
+
self.status = APPROVED
|
26
|
+
save!
|
27
|
+
end
|
28
|
+
|
29
|
+
def open
|
30
|
+
raise(StandardError, 'Request is not approved for opening.') unless status == APPROVED
|
31
|
+
|
32
|
+
self.status = OPEN
|
33
|
+
save!
|
34
|
+
end
|
35
|
+
|
36
|
+
def close
|
37
|
+
raise(StandardError, 'Request is not open.') unless status == OPEN
|
38
|
+
|
39
|
+
self.status = CLOSED
|
40
|
+
save!
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Cats
|
2
|
+
module Core
|
3
|
+
class TransportRequestItem < ApplicationRecord
|
4
|
+
belongs_to :transport_request
|
5
|
+
belongs_to :source, class_name: 'Cats::Core::Location'
|
6
|
+
belongs_to :destination, class_name: 'Cats::Core::Location'
|
7
|
+
belongs_to :commodity
|
8
|
+
|
9
|
+
delegate(:name, to: :source, prefix: true)
|
10
|
+
delegate(:name, to: :destination, prefix: true)
|
11
|
+
delegate(:name, to: :commodity, prefix: true)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
class
|
1
|
+
class CreateCatsCoreTransportRequests < ActiveRecord::Migration[6.1]
|
2
2
|
def change
|
3
|
-
create_table :
|
3
|
+
create_table :cats_core_transport_requests do |t|
|
4
4
|
t.string :reference_no, unique: true
|
5
5
|
t.date :request_date, null: false
|
6
6
|
t.string :status, null: false, default: 'Draft'
|
@@ -1,21 +1,21 @@
|
|
1
|
-
class
|
1
|
+
class CreateCatsCoreTransportRequestItems < ActiveRecord::Migration[6.1]
|
2
2
|
def change
|
3
|
-
create_table :
|
4
|
-
t.references :
|
3
|
+
create_table :cats_core_transport_request_items do |t|
|
4
|
+
t.references :transport_request,
|
5
5
|
null: false,
|
6
|
-
index: { name: '
|
7
|
-
foreign_key: { to_table: :
|
6
|
+
index: { name: 'tri_on_tr_indx' },
|
7
|
+
foreign_key: { to_table: :cats_core_transport_requests }
|
8
8
|
t.references :source,
|
9
9
|
null: false,
|
10
|
-
index: { name: '
|
10
|
+
index: { name: 'tri_on_source_indx' },
|
11
11
|
foreign_key: { to_table: :cats_core_locations }
|
12
12
|
t.references :destination,
|
13
13
|
null: false,
|
14
|
-
index: { name: '
|
14
|
+
index: { name: 'tri_on_destination_indx'},
|
15
15
|
foreign_key: { to_table: :cats_core_locations }
|
16
16
|
t.references :commodity,
|
17
17
|
null: false,
|
18
|
-
index: { name: '
|
18
|
+
index: { name: 'tri_on_commodity_indx' },
|
19
19
|
foreign_key: { to_table: :cats_core_commodities }
|
20
20
|
|
21
21
|
t.timestamps
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class CreateCatsCoreTransportOffers < ActiveRecord::Migration[6.1]
|
2
|
+
def change
|
3
|
+
create_table :cats_core_transport_offers do |t|
|
4
|
+
t.references :transport_request_item,
|
5
|
+
null: false,
|
6
|
+
index: { name: 'to_on_tri_indx' },
|
7
|
+
foreign_key: { to_table: :cats_core_transport_request_items }
|
8
|
+
t.references :transporter,
|
9
|
+
null: false,
|
10
|
+
index: { name: 'to_on_transporter_indx' },
|
11
|
+
foreign_key: { to_table: :cats_core_transporters }
|
12
|
+
t.float :price, null: false
|
13
|
+
|
14
|
+
t.timestamps
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/cats/core/version.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
FactoryBot.define do
|
2
|
-
factory :
|
2
|
+
factory :transport_request, class: 'Cats::Core::TransportRequest' do
|
3
3
|
reference_no { FFaker::Name.name }
|
4
4
|
request_date { Date.today }
|
5
5
|
requested_by factory: :user
|
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.12
|
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-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_model_serializers
|
@@ -287,9 +287,9 @@ files:
|
|
287
287
|
- app/models/cats/core/store.rb
|
288
288
|
- app/models/cats/core/supplier.rb
|
289
289
|
- app/models/cats/core/transaction.rb
|
290
|
-
- app/models/cats/core/
|
291
|
-
- app/models/cats/core/
|
292
|
-
- app/models/cats/core/
|
290
|
+
- app/models/cats/core/transport_offer.rb
|
291
|
+
- app/models/cats/core/transport_request.rb
|
292
|
+
- app/models/cats/core/transport_request_item.rb
|
293
293
|
- app/models/cats/core/transporter.rb
|
294
294
|
- app/models/cats/core/unit_of_measure.rb
|
295
295
|
- app/models/cats/core/user.rb
|
@@ -359,9 +359,9 @@ files:
|
|
359
359
|
- db/migrate/20211002050739_create_cats_core_notification_rules.rb
|
360
360
|
- db/migrate/20211024063240_add_status_to_cats_core_rhn_requests.rb
|
361
361
|
- db/migrate/20211030133752_add_status_to_cats_core_commodities.rb
|
362
|
-
- db/migrate/
|
363
|
-
- db/migrate/
|
364
|
-
- db/migrate/
|
362
|
+
- db/migrate/20211209155113_create_cats_core_transport_requests.rb
|
363
|
+
- db/migrate/20211209155915_create_cats_core_transport_request_items.rb
|
364
|
+
- db/migrate/20211209160126_create_cats_core_transport_offers.rb
|
365
365
|
- lib/cats/core.rb
|
366
366
|
- lib/cats/core/engine.rb
|
367
367
|
- lib/cats/core/version.rb
|
@@ -403,9 +403,9 @@ files:
|
|
403
403
|
- spec/factories/cats/core/stacks.rb
|
404
404
|
- spec/factories/cats/core/stores.rb
|
405
405
|
- spec/factories/cats/core/suppliers.rb
|
406
|
-
- spec/factories/cats/core/
|
407
|
-
- spec/factories/cats/core/
|
408
|
-
- spec/factories/cats/core/
|
406
|
+
- spec/factories/cats/core/transport_offers.rb
|
407
|
+
- spec/factories/cats/core/transport_request_items.rb
|
408
|
+
- spec/factories/cats/core/transport_requests.rb
|
409
409
|
- spec/factories/cats/core/transporters.rb
|
410
410
|
- spec/factories/cats/core/unit_of_measures.rb
|
411
411
|
- spec/factories/cats/core/users.rb
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module Cats
|
2
|
-
module Core
|
3
|
-
class TransportServiceRequest < ApplicationRecord
|
4
|
-
DRAFT = 'Draft'.freeze
|
5
|
-
APPROVED = 'Approved'.freeze
|
6
|
-
STATUSES = [DRAFT, APPROVED].freeze
|
7
|
-
|
8
|
-
belongs_to :requested_by, class_name: 'Cats::Core::User'
|
9
|
-
belongs_to :approved_by, class_name: 'Cats::Core::User', optional: true
|
10
|
-
|
11
|
-
validates :reference_no, :request_date, :status, presence: true
|
12
|
-
validates :reference_no, uniqueness: true
|
13
|
-
validates :status, inclusion: { in: STATUSES }
|
14
|
-
|
15
|
-
delegate(:full_name, to: :requested_by, prefix: true, allow_nil: true)
|
16
|
-
delegate(:full_name, to: :approved_by, prefix: true, allow_nil: true)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
module Cats
|
2
|
-
module Core
|
3
|
-
class TransportServiceRequestItem < ApplicationRecord
|
4
|
-
belongs_to :transport_service_request
|
5
|
-
belongs_to :source, class_name: 'Cats::Core::Location'
|
6
|
-
belongs_to :destination, class_name: 'Cats::Core::Location'
|
7
|
-
belongs_to :commodity
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
class CreateCatsCoreTransportServiceOffers < ActiveRecord::Migration[6.1]
|
2
|
-
def change
|
3
|
-
create_table :cats_core_transport_service_offers do |t|
|
4
|
-
t.references :transport_service_request_item,
|
5
|
-
null: false,
|
6
|
-
index: { name: 'tso_on_tsri_indx' },
|
7
|
-
foreign_key: { to_table: :cats_core_transport_service_request_items }
|
8
|
-
t.references :transporter,
|
9
|
-
null: false,
|
10
|
-
index: { name: 'tso_on_transporter_indx' },
|
11
|
-
foreign_key: { to_table: :cats_core_transporters }
|
12
|
-
t.float :price, null: false
|
13
|
-
|
14
|
-
t.timestamps
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|