cats_core 1.2.3 → 1.2.7
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_plan_items_controller.rb +18 -0
- data/app/controllers/cats/core/dispatch_plans_controller.rb +26 -0
- data/app/controllers/cats/core/dispatches_controller.rb +6 -6
- data/app/models/cats/core/dispatch.rb +9 -9
- data/app/models/cats/core/dispatch_plan.rb +24 -0
- data/app/models/cats/core/dispatch_plan_item.rb +20 -0
- data/app/models/cats/core/transport_service_offer.rb +10 -0
- data/app/models/cats/core/transport_service_request.rb +19 -0
- data/app/models/cats/core/transport_service_request_item.rb +10 -0
- data/app/models/cats/core/user.rb +4 -0
- data/app/notifications/cats/core/dispatch_notification.rb +5 -5
- data/app/serializers/cats/core/dispatch_plan_item_serializer.rb +8 -0
- data/app/serializers/cats/core/dispatch_plan_serializer.rb +7 -0
- data/app/serializers/cats/core/dispatch_serializer.rb +4 -3
- data/app/services/cats/core/dispatch_plan_service.rb +7 -0
- data/app/services/cats/core/dispatch_service.rb +16 -14
- data/config/routes.rb +13 -3
- data/db/migrate/20210718043328_create_cats_core_dispatch_plans.rb +13 -0
- data/db/migrate/20210718043401_create_cats_core_dispatch_plan_items.rb +25 -0
- data/db/migrate/20210718045516_create_cats_core_dispatches.rb +3 -3
- data/db/migrate/20211209155113_create_cats_core_transport_service_requests.rb +19 -0
- data/db/migrate/20211209155915_create_cats_core_transport_service_request_items.rb +24 -0
- data/db/migrate/20211209160126_create_cats_core_transport_service_offers.rb +17 -0
- data/lib/cats/core/version.rb +1 -1
- data/spec/factories/cats/core/dispatch_plan_items.rb +9 -0
- data/spec/factories/cats/core/dispatch_plans.rb +8 -0
- data/spec/factories/cats/core/dispatches.rb +4 -5
- data/spec/factories/cats/core/transport_service_offers.rb +7 -0
- data/spec/factories/cats/core/transport_service_request_items.rb +8 -0
- data/spec/factories/cats/core/transport_service_requests.rb +8 -0
- metadata +22 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca3e2b07298417bdd0c747df150ae9a58934408502bb9f7f4725a5c80a823c7f
|
4
|
+
data.tar.gz: 3e95c45ac93a996b21bc66488679af6fe02e6867a4443ac585f94c69eea0c79a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27816ccd1f35816d5fc931e8e4e8fd192189a67f2d92697914cf64826cafeff778a52a305891ab6e8d06f3b71df12cd620907813539188b8dfa53b08aaba35fe
|
7
|
+
data.tar.gz: e09c67befdb2122d236d1cbf2bdcb354fedaf48a098b533af46be85e0119b13c582bffe48497a44f20830455d2668ea42e63b95e83aad977a8393e8f6c17da21
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Cats
|
2
|
+
module Core
|
3
|
+
class DispatchPlanItemsController < ApplicationController
|
4
|
+
include Common
|
5
|
+
|
6
|
+
def index
|
7
|
+
items = Cats::Core::DispatchPlanItem.where(dispatch_plan_id: params[:id])
|
8
|
+
render json: { success: true, data: serialize(items) }
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def model_params
|
14
|
+
params.require(:payload).permit(:dispatch_plan_id, :source_id, :destination_id, :quantity, :commodity_id)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Cats
|
2
|
+
module Core
|
3
|
+
class DispatchPlansController < ApplicationController
|
4
|
+
include Common
|
5
|
+
|
6
|
+
def filter
|
7
|
+
query = Cats::Core::DispatchPlan.ransack(params[:q])
|
8
|
+
render json: { success: true, data: serialize(query.result) }
|
9
|
+
end
|
10
|
+
|
11
|
+
def approve
|
12
|
+
plan = Cats::Core::DispatchPlan.find(params[:id])
|
13
|
+
plan.approve
|
14
|
+
render json: { success: true, data: serialize(plan) }
|
15
|
+
rescue StandardError => e
|
16
|
+
render json: { success: false, error: e.message }
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def model_params
|
22
|
+
params.require(:payload).permit(:reference_no, :request_id)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -7,7 +7,7 @@ module Cats
|
|
7
7
|
before_action :set_dispatch, only: %i[approve start confirm commodity]
|
8
8
|
|
9
9
|
def index
|
10
|
-
dispatches = Cats::Core::Dispatch.where(
|
10
|
+
dispatches = Cats::Core::Dispatch.where(dispatch_plan_item_id: params[:id])
|
11
11
|
render json: { success: true, data: serialize(dispatches) }
|
12
12
|
end
|
13
13
|
|
@@ -23,9 +23,9 @@ module Cats
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def create_receipt_authorization
|
26
|
-
|
26
|
+
item = Cats::Core::DispatchPlanItem.find(params[:id])
|
27
27
|
dispatch = @service.create_receipt_authorization(
|
28
|
-
params[:reference_no],
|
28
|
+
params[:reference_no], item, params[:quantity], params[:remark], current_user
|
29
29
|
)
|
30
30
|
render json: { success: true, data: serialize(dispatch) }
|
31
31
|
end
|
@@ -57,7 +57,7 @@ module Cats
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def commodity
|
60
|
-
data = @dispatch.
|
60
|
+
data = @dispatch.dispatch_plan_item.commodity
|
61
61
|
render json: { success: true, data: serialize(data) }
|
62
62
|
end
|
63
63
|
|
@@ -72,8 +72,8 @@ module Cats
|
|
72
72
|
end
|
73
73
|
|
74
74
|
def model_params
|
75
|
-
params.require(:payload).permit(:reference_no, :
|
76
|
-
:driver_phone, :quantity, :remark)
|
75
|
+
params.require(:payload).permit(:reference_no, :dispatch_plan_item_id, :transporter_id, :plate_no,
|
76
|
+
:driver_name, :driver_phone, :quantity, :remark)
|
77
77
|
end
|
78
78
|
end
|
79
79
|
end
|
@@ -12,7 +12,7 @@ module Cats
|
|
12
12
|
|
13
13
|
belongs_to :prepared_by, class_name: 'Cats::Core::User'
|
14
14
|
belongs_to :transporter
|
15
|
-
belongs_to :
|
15
|
+
belongs_to :dispatch_plan_item
|
16
16
|
has_many :receipts
|
17
17
|
|
18
18
|
validates :reference_no, :plate_no, :driver_name, :driver_phone, :quantity, :commodity_status, presence: true
|
@@ -20,27 +20,27 @@ module Cats
|
|
20
20
|
validates :reference_no, uniqueness: true
|
21
21
|
validates :quantity, numericality: { greater_than: 0 }
|
22
22
|
validates :commodity_status, inclusion: { in: Cats::Core::Commodity::COMMODITY_STATUSES }
|
23
|
-
validate :validate_quantity, :
|
23
|
+
validate :validate_quantity, :validate_dispatch_plan_status
|
24
24
|
|
25
25
|
delegate(:name, to: :transporter, prefix: true)
|
26
26
|
delegate(:email, to: :prepared_by, prefix: true)
|
27
27
|
|
28
28
|
def validate_quantity
|
29
|
-
return unless quantity &&
|
29
|
+
return unless quantity && dispatch_plan_item
|
30
30
|
|
31
31
|
return unless quantity_changed?
|
32
32
|
|
33
|
-
dispatched =
|
34
|
-
remaining =
|
33
|
+
dispatched = dispatch_plan_item.dispatches.sum(:quantity)
|
34
|
+
remaining = dispatch_plan_item.quantity - dispatched
|
35
35
|
remaining += quantity_was if quantity_was
|
36
36
|
errors.add(:quantity, "exceeds allocated quantity. Maximum allowed is #{remaining}") if quantity > remaining
|
37
37
|
end
|
38
38
|
|
39
|
-
def
|
40
|
-
return unless
|
39
|
+
def validate_dispatch_plan_status
|
40
|
+
return unless dispatch_plan_item
|
41
41
|
|
42
|
-
status =
|
43
|
-
errors.add(:
|
42
|
+
status = dispatch_plan_item.dispatch_plan.status
|
43
|
+
errors.add(:dispatch_plan, 'should be approved first.') unless status == DispatchPlan::APPROVED
|
44
44
|
end
|
45
45
|
|
46
46
|
def approve
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Cats
|
2
|
+
module Core
|
3
|
+
class DispatchPlan < ApplicationRecord
|
4
|
+
DRAFT = 'Draft'.freeze
|
5
|
+
APPROVED = 'Approved'.freeze
|
6
|
+
STATUSES = [DRAFT, APPROVED].freeze
|
7
|
+
|
8
|
+
belongs_to :request, polymorphic: true, optional: true
|
9
|
+
has_many :dispatch_plan_items
|
10
|
+
|
11
|
+
validates :reference_no, presence: true, uniqueness: true
|
12
|
+
validates :status, inclusion: { in: STATUSES }
|
13
|
+
|
14
|
+
def approve
|
15
|
+
raise(StandardError, 'Dispatch plan already approved.') if status == APPROVED
|
16
|
+
|
17
|
+
raise(StandardError, 'Dispatch plan is empty.') if dispatch_plan_items.count.zero?
|
18
|
+
|
19
|
+
self.status = APPROVED
|
20
|
+
save!
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Cats
|
2
|
+
module Core
|
3
|
+
class DispatchPlanItem < ApplicationRecord
|
4
|
+
belongs_to :commodity
|
5
|
+
belongs_to :source, class_name: 'Cats::Core::Location'
|
6
|
+
belongs_to :destination, class_name: 'Cats::Core::Location'
|
7
|
+
belongs_to :dispatch_plan
|
8
|
+
has_many :dispatches
|
9
|
+
|
10
|
+
validates :quantity, presence: true, numericality: { greater_than: 0 }
|
11
|
+
|
12
|
+
delegate(:reference_no, to: :dispatch_plan, prefix: :plan, allow_nil: true)
|
13
|
+
delegate(:batch_no, to: :commodity, prefix: true)
|
14
|
+
delegate(:name, to: :source, prefix: true)
|
15
|
+
delegate(:name, to: :destination, prefix: true)
|
16
|
+
delegate(:location_type, to: :source, prefix: true)
|
17
|
+
delegate(:location_type, to: :destination, prefix: true)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,19 @@
|
|
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)
|
16
|
+
delegate(:full_name, to: :approved_by, prefix: true)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,10 @@
|
|
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
|
@@ -7,15 +7,15 @@ module Cats
|
|
7
7
|
|
8
8
|
def message
|
9
9
|
dispatch = params[:dispatch]
|
10
|
-
commodity = dispatch.
|
11
|
-
title = "Dispatch Notification - #{commodity}"
|
10
|
+
commodity = dispatch.dispatch_plan_item.commodity
|
11
|
+
title = "Dispatch Notification - #{commodity.name}"
|
12
12
|
date = Date.today
|
13
13
|
body = <<~BODY
|
14
14
|
Commodity with the following details has been dispatched to you:
|
15
15
|
Dispatch Ref. = #{dispatch.reference_no}
|
16
|
-
Batch No. = #{
|
17
|
-
Commodity = #{commodity}
|
18
|
-
Allocated Quantity = #{dispatch.
|
16
|
+
Batch No. = #{commodity.batch_no}
|
17
|
+
Commodity = #{commodity.name}
|
18
|
+
Allocated Quantity = #{dispatch.dispatch_plan_item.quantity}
|
19
19
|
Quantity = #{dispatch.quantity}
|
20
20
|
Truck Plate No. = #{dispatch.plate_no}
|
21
21
|
Driver Name = #{dispatch.driver_name}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
module Cats
|
2
|
+
module Core
|
3
|
+
class DispatchPlanItemSerializer < ActiveModel::Serializer
|
4
|
+
attributes :id, :dispatch_plan_id, :plan_reference_no, :source_id, :source_name, :destination_id,
|
5
|
+
:destination_name, :quantity, :source_location_type, :destination_location_type
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
@@ -1,11 +1,12 @@
|
|
1
1
|
module Cats
|
2
2
|
module Core
|
3
3
|
class DispatchSerializer < ActiveModel::Serializer
|
4
|
-
attributes :id, :reference_no, :
|
5
|
-
:driver_phone, :quantity, :remark, :prepared_by_id, :prepared_by_email,
|
4
|
+
attributes :id, :reference_no, :dispatch_plan_item_id, :transporter_id, :transporter_name, :plate_no,
|
5
|
+
:driver_name, :driver_phone, :quantity, :remark, :prepared_by_id, :prepared_by_email,
|
6
|
+
:dispatch_status, :destination
|
6
7
|
|
7
8
|
def destination
|
8
|
-
object.
|
9
|
+
object.dispatch_plan_item.destination.name
|
9
10
|
end
|
10
11
|
end
|
11
12
|
end
|
@@ -1,14 +1,16 @@
|
|
1
1
|
module Cats
|
2
2
|
module Core
|
3
3
|
class DispatchService
|
4
|
-
def create_receipt_authorization(reference_no,
|
4
|
+
def create_receipt_authorization(reference_no, plan_item, quantity, remark, user)
|
5
|
+
raise(StandardError, 'Dispatch plan is not an upstream plan.') unless plan_item.dispatch_plan.upstream?
|
6
|
+
|
5
7
|
transporter = Cats::Core::Transporter.find_by(code: 'SUP-TRANS')
|
6
8
|
raise(StandardError, 'Supplier transporter does not exist.') unless transporter
|
7
9
|
|
8
10
|
store = Cats::Core::Store.find_by(code: 'SUP-STORE')
|
9
11
|
raise(StandardError, 'Supplier store does not exist.') unless store
|
10
12
|
|
11
|
-
commodity =
|
13
|
+
commodity = plan_item.commodity
|
12
14
|
stack = store.stacks.find_by(commodity: commodity)
|
13
15
|
|
14
16
|
raise(StandardError, 'Commodity not found in supplier store.') unless stack
|
@@ -17,7 +19,7 @@ module Cats
|
|
17
19
|
ApplicationRecord.transaction do
|
18
20
|
dispatch = Cats::Core::Dispatch.create!(
|
19
21
|
reference_no: reference_no,
|
20
|
-
|
22
|
+
dispatch_plan_item: plan_item,
|
21
23
|
transporter: transporter,
|
22
24
|
plate_no: 'Supplier plate no',
|
23
25
|
driver_name: 'Supplier driver',
|
@@ -51,36 +53,36 @@ module Cats
|
|
51
53
|
warehouse = Cats::Core::Store.find(details['stores'][0]).warehouse
|
52
54
|
hub = warehouse.parent
|
53
55
|
|
54
|
-
dispatches = Cats::Core::Dispatch.joins(:
|
56
|
+
dispatches = Cats::Core::Dispatch.joins(:dispatch_plan_item)
|
55
57
|
.where(
|
56
|
-
|
58
|
+
dispatch_plan_item: { destination: hub },
|
57
59
|
dispatch_status: status
|
58
60
|
).or(
|
59
|
-
Cats::Core::Dispatch.joins(:
|
61
|
+
Cats::Core::Dispatch.joins(:dispatch_plan_item)
|
60
62
|
.where(
|
61
|
-
|
63
|
+
dispatch_plan_item: { destination: warehouse },
|
62
64
|
dispatch_status: status
|
63
65
|
)
|
64
66
|
)
|
65
67
|
elsif details['warehouse']
|
66
68
|
warehouse = Cats::Core::Location.find(details['warehouse'])
|
67
69
|
hub = warehouse.parent
|
68
|
-
dispatches = Cats::Core::Dispatch.joins(:
|
70
|
+
dispatches = Cats::Core::Dispatch.joins(:dispatch_plan_item)
|
69
71
|
.where(
|
70
|
-
|
72
|
+
dispatch_plan_item: { destination: hub },
|
71
73
|
dispatch_status: status
|
72
74
|
).or(
|
73
|
-
Cats::Core::Dispatch.joins(:
|
75
|
+
Cats::Core::Dispatch.joins(:dispatch_plan_item)
|
74
76
|
.where(
|
75
|
-
|
77
|
+
dispatch_plan_item: { destination: warehouse },
|
76
78
|
dispatch_status: status
|
77
79
|
)
|
78
80
|
)
|
79
81
|
elsif details['hub']
|
80
82
|
hub = Cats::Core::Location.find(details['hub'])
|
81
|
-
dispatches = Cats::Core::Dispatch.joins(:
|
83
|
+
dispatches = Cats::Core::Dispatch.joins(:dispatch_plan_item)
|
82
84
|
.where(
|
83
|
-
|
85
|
+
dispatch_plan_item: { destination: hub },
|
84
86
|
dispatch_status: status
|
85
87
|
)
|
86
88
|
end
|
@@ -98,7 +100,7 @@ module Cats
|
|
98
100
|
raise(StandardError, 'Notification rule not found for dispatch notification.') unless notification_rule
|
99
101
|
|
100
102
|
users = Cats::Core::User.joins(:roles).where(cats_core_roles: { name: notification_rule.roles })
|
101
|
-
location_id = dispatch.
|
103
|
+
location_id = dispatch.dispatch_plan_item.destination_id
|
102
104
|
recipients = users.map do |user|
|
103
105
|
details = user.details
|
104
106
|
if (details.key?('warehouse') && details['warehouse'] == location_id) ||
|
data/config/routes.rb
CHANGED
@@ -66,11 +66,21 @@ Cats::Core::Engine.routes.draw do
|
|
66
66
|
resources :currencies, except: %i[destroy]
|
67
67
|
resources :unit_of_measures, except: %i[destroy]
|
68
68
|
|
69
|
-
|
70
|
-
|
69
|
+
post '/dispatch_plans/filter', controller: :dispatch_plans, action: :filter
|
70
|
+
resources :dispatch_plans do
|
71
|
+
member do
|
72
|
+
get 'items', controller: :dispatch_plan_items, action: :index
|
73
|
+
post 'approve'
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
resources :dispatch_plan_items, except: %i[index destroy]
|
78
|
+
|
79
|
+
get '/dispatch_plan_items/:id/dispatches', controller: :dispatches, action: :index, as: :dispatches_plan_item
|
80
|
+
post '/dispatch_plan_items/:id/receipt_authorizaton',
|
71
81
|
controller: :dispatches,
|
72
82
|
action: :create_receipt_authorization,
|
73
|
-
as: :
|
83
|
+
as: :receipt_authorization_plan_item
|
74
84
|
|
75
85
|
get '/dispatches/search', controller: :dispatches, action: :search, as: :search_dispatches
|
76
86
|
resources :dispatches, except: %i[index destroy] do
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class CreateCatsCoreDispatchPlans < ActiveRecord::Migration[6.1]
|
2
|
+
def change
|
3
|
+
create_table :cats_core_dispatch_plans do |t|
|
4
|
+
t.string :reference_no, unique: true
|
5
|
+
t.string :description
|
6
|
+
t.string :status, null: false, default: 'Draft'
|
7
|
+
t.references :request, polymorphic: true
|
8
|
+
t.boolean :upstream, null: false, default: false
|
9
|
+
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class CreateCatsCoreDispatchPlanItems < ActiveRecord::Migration[6.1]
|
2
|
+
def change
|
3
|
+
create_table :cats_core_dispatch_plan_items do |t|
|
4
|
+
t.references :dispatch_plan,
|
5
|
+
null: false,
|
6
|
+
index: { name: 'dpi_on_dp_indx' },
|
7
|
+
foreign_key: { to_table: :cats_core_dispatch_plans }
|
8
|
+
t.references :commodity,
|
9
|
+
null: false,
|
10
|
+
index: { name: 'dpi_on_commodity_indx' },
|
11
|
+
foreign_key: { to_table: :cats_core_commodities }
|
12
|
+
t.references :source,
|
13
|
+
null: false,
|
14
|
+
index: { name: 'dpi_on_source_indx' },
|
15
|
+
foreign_key: { to_table: :cats_core_locations }
|
16
|
+
t.references :destination,
|
17
|
+
null: false,
|
18
|
+
index: { name: 'dpi_on_destination_indx'},
|
19
|
+
foreign_key: { to_table: :cats_core_locations }
|
20
|
+
t.float :quantity, null: false
|
21
|
+
|
22
|
+
t.timestamps
|
23
|
+
end
|
24
|
+
end
|
25
|
+
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 :dispatch_plan_item,
|
6
6
|
null: false,
|
7
|
-
index: { name: '
|
8
|
-
foreign_key: { to_table: :
|
7
|
+
index: { name: 'dpi_on_dispatches_indx' },
|
8
|
+
foreign_key: { to_table: :cats_core_dispatch_plan_items }
|
9
9
|
t.references :transporter,
|
10
10
|
null: false,
|
11
11
|
index: { name: 'transporter_on_dispatches_indx' },
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class CreateCatsCoreTransportServiceRequests < ActiveRecord::Migration[6.1]
|
2
|
+
def change
|
3
|
+
create_table :cats_core_transport_service_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
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class CreateCatsCoreTransportServiceRequestItems < ActiveRecord::Migration[6.1]
|
2
|
+
def change
|
3
|
+
create_table :cats_core_transport_service_request_items do |t|
|
4
|
+
t.references :transport_service_request,
|
5
|
+
null: false,
|
6
|
+
index: { name: 'tsri_on_tsr_indx' },
|
7
|
+
foreign_key: { to_table: :cats_core_transport_service_requests }
|
8
|
+
t.references :source,
|
9
|
+
null: false,
|
10
|
+
index: { name: 'tsri_on_source_indx' },
|
11
|
+
foreign_key: { to_table: :cats_core_locations }
|
12
|
+
t.references :destination,
|
13
|
+
null: false,
|
14
|
+
index: { name: 'tsri_on_destination_indx'},
|
15
|
+
foreign_key: { to_table: :cats_core_locations }
|
16
|
+
t.references :commodity,
|
17
|
+
null: false,
|
18
|
+
index: { name: 'tsri_on_commodity_indx' },
|
19
|
+
foreign_key: { to_table: :cats_core_commodities }
|
20
|
+
|
21
|
+
t.timestamps
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,17 @@
|
|
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
|
data/lib/cats/core/version.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
FactoryBot.define do
|
2
2
|
factory :dispatch, class: 'Cats::Core::Dispatch' do
|
3
3
|
reference_no { FFaker::Name.name }
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
allocation_item
|
4
|
+
dispatch_plan_item do
|
5
|
+
plan_item = create(:dispatch_plan_item, quantity: 100)
|
6
|
+
plan_item.dispatch_plan.approve
|
7
|
+
plan_item
|
9
8
|
end
|
10
9
|
transporter
|
11
10
|
plate_no { FFaker::Name.name }
|
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.7
|
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-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_model_serializers
|
@@ -234,6 +234,8 @@ files:
|
|
234
234
|
- app/controllers/cats/core/application_controller.rb
|
235
235
|
- app/controllers/cats/core/commodity_categories_controller.rb
|
236
236
|
- app/controllers/cats/core/currencies_controller.rb
|
237
|
+
- app/controllers/cats/core/dispatch_plan_items_controller.rb
|
238
|
+
- app/controllers/cats/core/dispatch_plans_controller.rb
|
237
239
|
- app/controllers/cats/core/dispatch_transactions_controller.rb
|
238
240
|
- app/controllers/cats/core/dispatches_controller.rb
|
239
241
|
- app/controllers/cats/core/locations_controller.rb
|
@@ -255,6 +257,8 @@ files:
|
|
255
257
|
- app/models/cats/core/commodity_category.rb
|
256
258
|
- app/models/cats/core/currency.rb
|
257
259
|
- app/models/cats/core/dispatch.rb
|
260
|
+
- app/models/cats/core/dispatch_plan.rb
|
261
|
+
- app/models/cats/core/dispatch_plan_item.rb
|
258
262
|
- app/models/cats/core/dispatch_transaction.rb
|
259
263
|
- app/models/cats/core/donation.rb
|
260
264
|
- app/models/cats/core/donor.rb
|
@@ -283,6 +287,9 @@ files:
|
|
283
287
|
- app/models/cats/core/store.rb
|
284
288
|
- app/models/cats/core/supplier.rb
|
285
289
|
- app/models/cats/core/transaction.rb
|
290
|
+
- app/models/cats/core/transport_service_offer.rb
|
291
|
+
- app/models/cats/core/transport_service_request.rb
|
292
|
+
- app/models/cats/core/transport_service_request_item.rb
|
286
293
|
- app/models/cats/core/transporter.rb
|
287
294
|
- app/models/cats/core/unit_of_measure.rb
|
288
295
|
- app/models/cats/core/user.rb
|
@@ -292,6 +299,8 @@ files:
|
|
292
299
|
- app/serializers/cats/core/commodity_category_serializer.rb
|
293
300
|
- app/serializers/cats/core/commodity_serializer.rb
|
294
301
|
- app/serializers/cats/core/currency_serializer.rb
|
302
|
+
- app/serializers/cats/core/dispatch_plan_item_serializer.rb
|
303
|
+
- app/serializers/cats/core/dispatch_plan_serializer.rb
|
295
304
|
- app/serializers/cats/core/dispatch_serializer.rb
|
296
305
|
- app/serializers/cats/core/dispatch_transaction_serializer.rb
|
297
306
|
- app/serializers/cats/core/location_serializer.rb
|
@@ -301,6 +310,7 @@ files:
|
|
301
310
|
- app/serializers/cats/core/role_serializer.rb
|
302
311
|
- app/serializers/cats/core/unit_of_measure_serializer.rb
|
303
312
|
- app/serializers/cats/core/user_serializer.rb
|
313
|
+
- app/services/cats/core/dispatch_plan_service.rb
|
304
314
|
- app/services/cats/core/dispatch_service.rb
|
305
315
|
- app/services/cats/core/menu_service.rb
|
306
316
|
- app/services/cats/core/notification_service.rb
|
@@ -337,6 +347,8 @@ files:
|
|
337
347
|
- db/migrate/20210718042755_create_cats_core_rhn_requests.rb
|
338
348
|
- db/migrate/20210718042823_create_cats_core_allocations.rb
|
339
349
|
- db/migrate/20210718043204_create_cats_core_allocation_items.rb
|
350
|
+
- db/migrate/20210718043328_create_cats_core_dispatch_plans.rb
|
351
|
+
- db/migrate/20210718043401_create_cats_core_dispatch_plan_items.rb
|
340
352
|
- db/migrate/20210718045516_create_cats_core_dispatches.rb
|
341
353
|
- db/migrate/20210718202957_create_cats_core_dispatch_transactions.rb
|
342
354
|
- db/migrate/20210719133710_create_cats_core_stacking_rules.rb
|
@@ -347,6 +359,9 @@ files:
|
|
347
359
|
- db/migrate/20211002050739_create_cats_core_notification_rules.rb
|
348
360
|
- db/migrate/20211024063240_add_status_to_cats_core_rhn_requests.rb
|
349
361
|
- db/migrate/20211030133752_add_status_to_cats_core_commodities.rb
|
362
|
+
- db/migrate/20211209155113_create_cats_core_transport_service_requests.rb
|
363
|
+
- db/migrate/20211209155915_create_cats_core_transport_service_request_items.rb
|
364
|
+
- db/migrate/20211209160126_create_cats_core_transport_service_offers.rb
|
350
365
|
- lib/cats/core.rb
|
351
366
|
- lib/cats/core/engine.rb
|
352
367
|
- lib/cats/core/version.rb
|
@@ -358,6 +373,8 @@ files:
|
|
358
373
|
- spec/factories/cats/core/commodities.rb
|
359
374
|
- spec/factories/cats/core/commodity_categories.rb
|
360
375
|
- spec/factories/cats/core/currencies.rb
|
376
|
+
- spec/factories/cats/core/dispatch_plan_items.rb
|
377
|
+
- spec/factories/cats/core/dispatch_plans.rb
|
361
378
|
- spec/factories/cats/core/dispatch_transactions.rb
|
362
379
|
- spec/factories/cats/core/dispatches.rb
|
363
380
|
- spec/factories/cats/core/donations.rb
|
@@ -386,6 +403,9 @@ files:
|
|
386
403
|
- spec/factories/cats/core/stacks.rb
|
387
404
|
- spec/factories/cats/core/stores.rb
|
388
405
|
- spec/factories/cats/core/suppliers.rb
|
406
|
+
- spec/factories/cats/core/transport_service_offers.rb
|
407
|
+
- spec/factories/cats/core/transport_service_request_items.rb
|
408
|
+
- spec/factories/cats/core/transport_service_requests.rb
|
389
409
|
- spec/factories/cats/core/transporters.rb
|
390
410
|
- spec/factories/cats/core/unit_of_measures.rb
|
391
411
|
- spec/factories/cats/core/users.rb
|