cats_core 1.2.13 → 1.2.17
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/dispatch_plans_controller.rb +15 -0
- data/app/controllers/cats/core/routes_controller.rb +13 -0
- data/app/models/cats/core/contract_item.rb +13 -0
- data/app/models/cats/core/dispatch_plan.rb +3 -0
- data/app/models/cats/core/route.rb +18 -0
- data/app/models/cats/core/transport_bid.rb +21 -0
- data/app/models/cats/core/transport_bid_item.rb +15 -0
- data/app/models/cats/core/transport_contract.rb +10 -0
- data/app/models/cats/core/transport_offer.rb +17 -1
- data/app/models/cats/core/transport_request_item.rb +2 -0
- data/app/serializers/cats/core/route_serializer.rb +7 -0
- data/config/routes.rb +2 -0
- data/db/migrate/20210718040129_create_cats_core_routes.rb +19 -0
- data/db/migrate/20210718043328_create_cats_core_dispatch_plans.rb +9 -0
- data/db/migrate/20211215121151_create_cats_core_transport_bids.rb +13 -0
- data/db/migrate/20211215124452_create_cats_core_transport_bid_items.rb +21 -0
- data/db/migrate/{20211209160126_create_cats_core_transport_offers.rb → 20211229160126_create_cats_core_transport_offers.rb} +5 -3
- data/db/migrate/20211229160127_create_cats_core_transport_contracts.rb +19 -0
- data/db/migrate/20211229160128_create_cats_core_contract_items.rb +21 -0
- data/lib/cats/core/version.rb +1 -1
- data/spec/factories/cats/core/contract_items.rb +8 -0
- data/spec/factories/cats/core/dispatch_plans.rb +2 -0
- data/spec/factories/cats/core/routes.rb +6 -0
- data/spec/factories/cats/core/transport_bid_items.rb +8 -0
- data/spec/factories/cats/core/transport_bids.rb +8 -0
- data/spec/factories/cats/core/transport_contracts.rb +9 -0
- data/spec/factories/cats/core/transport_offers.rb +3 -1
- metadata +20 -7
- data/db/migrate/20211209155113_create_cats_core_transport_requests.rb +0 -19
- data/db/migrate/20211209155915_create_cats_core_transport_request_items.rb +0 -24
- data/spec/factories/cats/core/transport_request_items.rb +0 -8
- data/spec/factories/cats/core/transport_requests.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: d7fad29c6363b9f97a6cdf998aa0af3319adb3484d6c12ac363bd17058de3d0e
|
4
|
+
data.tar.gz: 31efe7250a22930a60ad18ee7913530ef5c387b4f743e1f606fa91ab764b620d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff6fa84f59e57e8e7ffe5bfa0e1c6028ecad74a36b98cdff4b189a08fcd367a7c565bd0b7e987a76753df9516d74ba163050ee024cf7659ff0ee98bfc40105bf
|
7
|
+
data.tar.gz: 0672a380f2afef89c0ca904e27415c4286b36b13c844bcc6d7e5ac93cc767cd7fe225824a9c9116613a4601ac6dce1cbf777ac640832565311ff4ac511f34b71
|
@@ -3,11 +3,26 @@ module Cats
|
|
3
3
|
class DispatchPlansController < ApplicationController
|
4
4
|
include Common
|
5
5
|
|
6
|
+
def plans_for_user
|
7
|
+
plans = Cats::Core::DispatchPlan.where(prepared_by: current_user)
|
8
|
+
render json: { success: true, data: serialize(plans) }
|
9
|
+
end
|
10
|
+
|
6
11
|
def filter
|
7
12
|
query = Cats::Core::DispatchPlan.ransack(params[:q])
|
8
13
|
render json: { success: true, data: serialize(query.result) }
|
9
14
|
end
|
10
15
|
|
16
|
+
def create
|
17
|
+
obj = Cats::Core::DispatchPlan.new(model_params)
|
18
|
+
obj.prepared_by = current_user
|
19
|
+
if obj.save
|
20
|
+
render json: { success: true, data: serialize(obj) }, status: :created
|
21
|
+
else
|
22
|
+
render json: { success: false, error: obj.errors.full_messages[0] }, status: :unprocessable_entity
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
11
26
|
def approve
|
12
27
|
plan = Cats::Core::DispatchPlan.find(params[:id])
|
13
28
|
plan.approve
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Cats
|
2
|
+
module Core
|
3
|
+
class ContractItem < ApplicationRecord
|
4
|
+
belongs_to :transport_contract
|
5
|
+
belongs_to :route
|
6
|
+
belongs_to :unit, class_name: 'Cats::Core::UnitOfMeasure'
|
7
|
+
|
8
|
+
validates :price, presence: true, numericality: { greater_than: 0 }
|
9
|
+
|
10
|
+
delegate(:name, to: :route, prefix: true)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -6,6 +6,9 @@ module Cats
|
|
6
6
|
STATUSES = [DRAFT, APPROVED].freeze
|
7
7
|
|
8
8
|
belongs_to :request, polymorphic: true, optional: true
|
9
|
+
belongs_to :prepared_by, class_name: 'Cats::Core::User'
|
10
|
+
belongs_to :approved_by, class_name: 'Cats::Core::User', optional: true
|
11
|
+
|
9
12
|
has_many :dispatch_plan_items
|
10
13
|
|
11
14
|
validates :reference_no, presence: true, uniqueness: true
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Cats
|
2
|
+
module Core
|
3
|
+
class Route < ApplicationRecord
|
4
|
+
before_validation :set_name, on: %i[create update]
|
5
|
+
|
6
|
+
belongs_to :source, class_name: 'Cats::Core::Location'
|
7
|
+
belongs_to :destination, class_name: 'Cats::Core::Location'
|
8
|
+
|
9
|
+
validates :source_id, uniqueness: { scope: :destination_id }
|
10
|
+
|
11
|
+
def set_name
|
12
|
+
return unless source && destination
|
13
|
+
|
14
|
+
self.name = "#{source.name} - #{destination.name}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Cats
|
2
|
+
module Core
|
3
|
+
class TransportBid < ApplicationRecord
|
4
|
+
NEW = 'New'.freeze
|
5
|
+
OPEN = 'Open'.freeze
|
6
|
+
CLOSED = 'Closed'.freeze
|
7
|
+
STATUSES = [NEW, OPEN, CLOSED].freeze
|
8
|
+
|
9
|
+
validates :reference_no, presence: true, uniqueness: true
|
10
|
+
validates :start_date, :end_date, :status, presence: true
|
11
|
+
validates :status, inclusion: { in: STATUSES }
|
12
|
+
validate :validate_start_date_against_end_date
|
13
|
+
|
14
|
+
def validate_start_date_against_end_date
|
15
|
+
return unless start_date && end_date
|
16
|
+
|
17
|
+
errors.add(:start_date, 'should be before end date.') if start_date >= end_date
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Cats
|
2
|
+
module Core
|
3
|
+
class TransportBidItem < ApplicationRecord
|
4
|
+
belongs_to :transport_bid
|
5
|
+
belongs_to :route
|
6
|
+
belongs_to :unit, class_name: 'Cats::Core::UnitOfMeasure', optional: true
|
7
|
+
|
8
|
+
has_many :transport_offers
|
9
|
+
|
10
|
+
validates :quantity, presence: true, numericality: { greater_than: 0 }
|
11
|
+
|
12
|
+
delegate(:name, to: :route, prefix: true)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -1,12 +1,28 @@
|
|
1
1
|
module Cats
|
2
2
|
module Core
|
3
3
|
class TransportOffer < ApplicationRecord
|
4
|
-
belongs_to :
|
4
|
+
belongs_to :transport_bid_item
|
5
5
|
belongs_to :transporter
|
6
6
|
|
7
7
|
validates :price, presence: true, numericality: { greater_than: 0 }
|
8
|
+
validates :rank, numericality: { greater_than: 0 }, allow_nil: true
|
9
|
+
validate :validate_rank_is_set_for_winner
|
8
10
|
|
9
11
|
delegate(:name, to: :transporter, prefix: true)
|
12
|
+
|
13
|
+
def mark_as_winner(rank)
|
14
|
+
raise(StandardError, 'Offer already marked as winner.') if winner
|
15
|
+
|
16
|
+
self.rank = rank
|
17
|
+
self.winner = true
|
18
|
+
save!
|
19
|
+
end
|
20
|
+
|
21
|
+
def validate_rank_is_set_for_winner
|
22
|
+
return if rank
|
23
|
+
|
24
|
+
errors.add(:winner, 'cannot be set for a non-ranked offer.') if winner
|
25
|
+
end
|
10
26
|
end
|
11
27
|
end
|
12
28
|
end
|
@@ -6,6 +6,8 @@ module Cats
|
|
6
6
|
belongs_to :destination, class_name: 'Cats::Core::Location'
|
7
7
|
belongs_to :commodity
|
8
8
|
|
9
|
+
has_many :transport_offers
|
10
|
+
|
9
11
|
delegate(:name, to: :source, prefix: true)
|
10
12
|
delegate(:name, to: :destination, prefix: true)
|
11
13
|
delegate(:name, to: :commodity, prefix: true)
|
data/config/routes.rb
CHANGED
@@ -33,6 +33,7 @@ Cats::Core::Engine.routes.draw do
|
|
33
33
|
get 'stores', controller: :users, action: :stores
|
34
34
|
get 'warehouse', controller: :users, action: :warehouse
|
35
35
|
get 'hub', controller: :users, action: :hub
|
36
|
+
get 'plans', controller: :dispatch_plans, action: :plans_for_user
|
36
37
|
post 'assign_role'
|
37
38
|
post 'revoke_role'
|
38
39
|
end
|
@@ -65,6 +66,7 @@ Cats::Core::Engine.routes.draw do
|
|
65
66
|
end
|
66
67
|
resources :currencies, except: %i[destroy]
|
67
68
|
resources :unit_of_measures, except: %i[destroy]
|
69
|
+
resources :routes, except: %i[destroy]
|
68
70
|
|
69
71
|
post '/dispatch_plans/filter', controller: :dispatch_plans, action: :filter
|
70
72
|
resources :dispatch_plans do
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class CreateCatsCoreRoutes < ActiveRecord::Migration[6.1]
|
2
|
+
def change
|
3
|
+
create_table :cats_core_routes do |t|
|
4
|
+
t.string :name, null: false
|
5
|
+
t.references :source,
|
6
|
+
null: false,
|
7
|
+
index: { name: 'source_on_routes_indx' },
|
8
|
+
foreign_key: { to_table: :cats_core_locations }
|
9
|
+
t.references :destination,
|
10
|
+
null: false,
|
11
|
+
index: { name: 'destination_on_routes_indx' },
|
12
|
+
foreign_key: { to_table: :cats_core_locations }
|
13
|
+
|
14
|
+
t.timestamps
|
15
|
+
|
16
|
+
t.index [:source_id, :destination_id], unique: true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -7,6 +7,15 @@ class CreateCatsCoreDispatchPlans < ActiveRecord::Migration[6.1]
|
|
7
7
|
t.references :request, polymorphic: true
|
8
8
|
t.boolean :upstream, null: false, default: false
|
9
9
|
|
10
|
+
t.references :prepared_by,
|
11
|
+
null: false,
|
12
|
+
index: { name: 'pb_on_dp_indx' },
|
13
|
+
foreign_key: { to_table: :cats_core_users }
|
14
|
+
t.references :approved_by,
|
15
|
+
null: true,
|
16
|
+
index: { name: 'ab_on_dp_indx' },
|
17
|
+
foreign_key: { to_table: :cats_core_users }
|
18
|
+
|
10
19
|
t.timestamps
|
11
20
|
end
|
12
21
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class CreateCatsCoreTransportBids < ActiveRecord::Migration[6.1]
|
2
|
+
def change
|
3
|
+
create_table :cats_core_transport_bids do |t|
|
4
|
+
t.string :reference_no, unique: true
|
5
|
+
t.string :description
|
6
|
+
t.date :start_date, null: false
|
7
|
+
t.date :end_date, null: false
|
8
|
+
t.string :status, null: false, default: 'New'
|
9
|
+
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class CreateCatsCoreTransportBidItems < ActiveRecord::Migration[6.1]
|
2
|
+
def change
|
3
|
+
create_table :cats_core_transport_bid_items do |t|
|
4
|
+
t.references :transport_bid,
|
5
|
+
null: false,
|
6
|
+
index: { name: 'tb_on_tbi_indx' },
|
7
|
+
foreign_key: { to_table: :cats_core_transport_bids }
|
8
|
+
t.references :route,
|
9
|
+
null: false,
|
10
|
+
index: { name: 'route_on_tbi_indx' },
|
11
|
+
foreign_key: { to_table: :cats_core_routes }
|
12
|
+
t.references :unit,
|
13
|
+
null: true,
|
14
|
+
index: { name: 'unit_on_tbi_indx' },
|
15
|
+
foreign_key: { to_table: :cats_core_unit_of_measures }
|
16
|
+
t.float :quantity, null: false
|
17
|
+
|
18
|
+
t.timestamps
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -1,15 +1,17 @@
|
|
1
1
|
class CreateCatsCoreTransportOffers < ActiveRecord::Migration[6.1]
|
2
2
|
def change
|
3
3
|
create_table :cats_core_transport_offers do |t|
|
4
|
-
t.references :
|
4
|
+
t.references :transport_bid_item,
|
5
5
|
null: false,
|
6
|
-
index: { name: '
|
7
|
-
foreign_key: { to_table: :
|
6
|
+
index: { name: 'to_on_tbi_indx' },
|
7
|
+
foreign_key: { to_table: :cats_core_transport_bid_items }
|
8
8
|
t.references :transporter,
|
9
9
|
null: false,
|
10
10
|
index: { name: 'to_on_transporter_indx' },
|
11
11
|
foreign_key: { to_table: :cats_core_transporters }
|
12
12
|
t.float :price, null: false
|
13
|
+
t.boolean :winner, null: false, default: false
|
14
|
+
t.integer :rank
|
13
15
|
|
14
16
|
t.timestamps
|
15
17
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class CreateCatsCoreTransportContracts < ActiveRecord::Migration[6.1]
|
2
|
+
def change
|
3
|
+
create_table :cats_core_transport_contracts do |t|
|
4
|
+
t.references :region,
|
5
|
+
null: false,
|
6
|
+
index: { name: 'region_on_tc_indx' },
|
7
|
+
foreign_key: { to_table: :cats_core_locations }
|
8
|
+
t.references :transporter,
|
9
|
+
null: false,
|
10
|
+
index: { name: 'transporter_on_tc_indx' },
|
11
|
+
foreign_key: { to_table: :cats_core_transporters }
|
12
|
+
t.date :contract_date, null: false
|
13
|
+
t.date :expires_on, null: false
|
14
|
+
t.string :payment_term
|
15
|
+
|
16
|
+
t.timestamps
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class CreateCatsCoreContractItems < ActiveRecord::Migration[6.1]
|
2
|
+
def change
|
3
|
+
create_table :cats_core_contract_items do |t|
|
4
|
+
t.references :transport_contract,
|
5
|
+
null: false,
|
6
|
+
index: { name: 'tc_on_ci_indx' },
|
7
|
+
foreign_key: { to_table: :cats_core_transport_contracts }
|
8
|
+
t.references :route,
|
9
|
+
null: false,
|
10
|
+
index: { name: 'route_on_ci_indx' },
|
11
|
+
foreign_key: { to_table: :cats_core_routes }
|
12
|
+
t.float :price, null: false
|
13
|
+
t.references :unit,
|
14
|
+
null: false,
|
15
|
+
index: { name: 'unit_on_ci_indx' },
|
16
|
+
foreign_key: { to_table: :cats_core_unit_of_measures }
|
17
|
+
|
18
|
+
t.timestamps
|
19
|
+
end
|
20
|
+
end
|
21
|
+
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.17
|
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-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_model_serializers
|
@@ -244,6 +244,7 @@ files:
|
|
244
244
|
- app/controllers/cats/core/receipt_transactions_controller.rb
|
245
245
|
- app/controllers/cats/core/receipts_controller.rb
|
246
246
|
- app/controllers/cats/core/roles_controller.rb
|
247
|
+
- app/controllers/cats/core/routes_controller.rb
|
247
248
|
- app/controllers/cats/core/spaces_controller.rb
|
248
249
|
- app/controllers/cats/core/unit_of_measures_controller.rb
|
249
250
|
- app/controllers/cats/core/users_controller.rb
|
@@ -255,6 +256,7 @@ files:
|
|
255
256
|
- app/models/cats/core/application_record.rb
|
256
257
|
- app/models/cats/core/commodity.rb
|
257
258
|
- app/models/cats/core/commodity_category.rb
|
259
|
+
- app/models/cats/core/contract_item.rb
|
258
260
|
- app/models/cats/core/currency.rb
|
259
261
|
- app/models/cats/core/dispatch.rb
|
260
262
|
- app/models/cats/core/dispatch_plan.rb
|
@@ -281,12 +283,16 @@ files:
|
|
281
283
|
- app/models/cats/core/rhn_request.rb
|
282
284
|
- app/models/cats/core/role.rb
|
283
285
|
- app/models/cats/core/role_menu.rb
|
286
|
+
- app/models/cats/core/route.rb
|
284
287
|
- app/models/cats/core/stack.rb
|
285
288
|
- app/models/cats/core/stack_transaction.rb
|
286
289
|
- app/models/cats/core/stacking_rule.rb
|
287
290
|
- app/models/cats/core/store.rb
|
288
291
|
- app/models/cats/core/supplier.rb
|
289
292
|
- app/models/cats/core/transaction.rb
|
293
|
+
- app/models/cats/core/transport_bid.rb
|
294
|
+
- app/models/cats/core/transport_bid_item.rb
|
295
|
+
- app/models/cats/core/transport_contract.rb
|
290
296
|
- app/models/cats/core/transport_offer.rb
|
291
297
|
- app/models/cats/core/transport_request.rb
|
292
298
|
- app/models/cats/core/transport_request_item.rb
|
@@ -308,6 +314,7 @@ files:
|
|
308
314
|
- app/serializers/cats/core/receipt_transaction_serializer.rb
|
309
315
|
- app/serializers/cats/core/role_menu_serializer.rb
|
310
316
|
- app/serializers/cats/core/role_serializer.rb
|
317
|
+
- app/serializers/cats/core/route_serializer.rb
|
311
318
|
- app/serializers/cats/core/unit_of_measure_serializer.rb
|
312
319
|
- app/serializers/cats/core/user_serializer.rb
|
313
320
|
- app/services/cats/core/dispatch_plan_service.rb
|
@@ -343,6 +350,7 @@ files:
|
|
343
350
|
- db/migrate/20210717033223_create_cats_core_commodities.rb
|
344
351
|
- db/migrate/20210717140855_create_cats_core_stores.rb
|
345
352
|
- db/migrate/20210717171101_create_cats_core_stacks.rb
|
353
|
+
- db/migrate/20210718040129_create_cats_core_routes.rb
|
346
354
|
- db/migrate/20210718042749_create_cats_core_transporters.rb
|
347
355
|
- db/migrate/20210718042755_create_cats_core_rhn_requests.rb
|
348
356
|
- db/migrate/20210718042823_create_cats_core_allocations.rb
|
@@ -359,9 +367,11 @@ files:
|
|
359
367
|
- db/migrate/20211002050739_create_cats_core_notification_rules.rb
|
360
368
|
- db/migrate/20211024063240_add_status_to_cats_core_rhn_requests.rb
|
361
369
|
- db/migrate/20211030133752_add_status_to_cats_core_commodities.rb
|
362
|
-
- db/migrate/
|
363
|
-
- db/migrate/
|
364
|
-
- db/migrate/
|
370
|
+
- db/migrate/20211215121151_create_cats_core_transport_bids.rb
|
371
|
+
- db/migrate/20211215124452_create_cats_core_transport_bid_items.rb
|
372
|
+
- db/migrate/20211229160126_create_cats_core_transport_offers.rb
|
373
|
+
- db/migrate/20211229160127_create_cats_core_transport_contracts.rb
|
374
|
+
- db/migrate/20211229160128_create_cats_core_contract_items.rb
|
365
375
|
- lib/cats/core.rb
|
366
376
|
- lib/cats/core/engine.rb
|
367
377
|
- lib/cats/core/version.rb
|
@@ -372,6 +382,7 @@ files:
|
|
372
382
|
- spec/factories/cats/core/application_modules.rb
|
373
383
|
- spec/factories/cats/core/commodities.rb
|
374
384
|
- spec/factories/cats/core/commodity_categories.rb
|
385
|
+
- spec/factories/cats/core/contract_items.rb
|
375
386
|
- spec/factories/cats/core/currencies.rb
|
376
387
|
- spec/factories/cats/core/dispatch_plan_items.rb
|
377
388
|
- spec/factories/cats/core/dispatch_plans.rb
|
@@ -398,14 +409,16 @@ files:
|
|
398
409
|
- spec/factories/cats/core/rhn_requests.rb
|
399
410
|
- spec/factories/cats/core/role_menus.rb
|
400
411
|
- spec/factories/cats/core/roles.rb
|
412
|
+
- spec/factories/cats/core/routes.rb
|
401
413
|
- spec/factories/cats/core/stack_transactions.rb
|
402
414
|
- spec/factories/cats/core/stacking_rules.rb
|
403
415
|
- spec/factories/cats/core/stacks.rb
|
404
416
|
- spec/factories/cats/core/stores.rb
|
405
417
|
- spec/factories/cats/core/suppliers.rb
|
418
|
+
- spec/factories/cats/core/transport_bid_items.rb
|
419
|
+
- spec/factories/cats/core/transport_bids.rb
|
420
|
+
- spec/factories/cats/core/transport_contracts.rb
|
406
421
|
- 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
422
|
- spec/factories/cats/core/transporters.rb
|
410
423
|
- spec/factories/cats/core/unit_of_measures.rb
|
411
424
|
- spec/factories/cats/core/users.rb
|
@@ -1,19 +0,0 @@
|
|
1
|
-
class CreateCatsCoreTransportRequests < ActiveRecord::Migration[6.1]
|
2
|
-
def change
|
3
|
-
create_table :cats_core_transport_requests do |t|
|
4
|
-
t.string :reference_no, unique: true
|
5
|
-
t.date :request_date, null: false
|
6
|
-
t.string :status, null: false, default: 'Draft'
|
7
|
-
t.references :requested_by,
|
8
|
-
null: false,
|
9
|
-
index: { name: 'tsr_on_rb_indx' },
|
10
|
-
foreign_key: { to_table: :cats_core_users }
|
11
|
-
t.references :approved_by,
|
12
|
-
null: true,
|
13
|
-
index: { name: 'tsr_on_ab_indx' },
|
14
|
-
foreign_key: { to_table: :cats_core_users }
|
15
|
-
|
16
|
-
t.timestamps
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
class CreateCatsCoreTransportRequestItems < ActiveRecord::Migration[6.1]
|
2
|
-
def change
|
3
|
-
create_table :cats_core_transport_request_items do |t|
|
4
|
-
t.references :transport_request,
|
5
|
-
null: false,
|
6
|
-
index: { name: 'tri_on_tr_indx' },
|
7
|
-
foreign_key: { to_table: :cats_core_transport_requests }
|
8
|
-
t.references :source,
|
9
|
-
null: false,
|
10
|
-
index: { name: 'tri_on_source_indx' },
|
11
|
-
foreign_key: { to_table: :cats_core_locations }
|
12
|
-
t.references :destination,
|
13
|
-
null: false,
|
14
|
-
index: { name: 'tri_on_destination_indx'},
|
15
|
-
foreign_key: { to_table: :cats_core_locations }
|
16
|
-
t.references :commodity,
|
17
|
-
null: false,
|
18
|
-
index: { name: 'tri_on_commodity_indx' },
|
19
|
-
foreign_key: { to_table: :cats_core_commodities }
|
20
|
-
|
21
|
-
t.timestamps
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|