cats_core 1.2.15 → 1.2.16
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/models/cats/core/dispatch_plan.rb +3 -0
- data/app/models/cats/core/transport_offer.rb +4 -4
- data/config/routes.rb +1 -0
- data/db/migrate/20210718043328_create_cats_core_dispatch_plans.rb +9 -0
- data/lib/cats/core/version.rb +1 -1
- data/spec/factories/cats/core/dispatch_plans.rb +2 -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: 83ed27840275615cce0b4a2fdee9d147a61407eef87df375e9db5e0424d4e923
|
4
|
+
data.tar.gz: 06a77ee55dec5a1d292afeaa225b35629867d85eac43640d5073aab84b657634
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f57ac8ebc0d69cb0abc5e0b19a28ae3afd4b3549a72b2fe34469bf63e15bc05067fa101bc378b97f073b5650b66d21516d9ea7998d165e8e5b133d971e08dbfe
|
7
|
+
data.tar.gz: 41f293dd59320cafef958b1d1dcf6b2342e2af1d696e31fb761ff50cf749966e5a993062d23f3e859c32bbb0431cba93c333b7410977be67a33c1bb8575e829a
|
@@ -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
|
@@ -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
|
@@ -6,7 +6,7 @@ module Cats
|
|
6
6
|
|
7
7
|
validates :price, presence: true, numericality: { greater_than: 0 }
|
8
8
|
validates :rank, numericality: { greater_than: 0 }, allow_nil: true
|
9
|
-
validate :
|
9
|
+
validate :validate_rank_is_set_for_winner
|
10
10
|
|
11
11
|
delegate(:name, to: :transporter, prefix: true)
|
12
12
|
|
@@ -18,10 +18,10 @@ module Cats
|
|
18
18
|
save!
|
19
19
|
end
|
20
20
|
|
21
|
-
def
|
22
|
-
return if
|
21
|
+
def validate_rank_is_set_for_winner
|
22
|
+
return if rank
|
23
23
|
|
24
|
-
errors.add(:
|
24
|
+
errors.add(:winner, 'cannot be set for a non-ranked offer.') if winner
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
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
|
@@ -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
|
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.16
|
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-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_model_serializers
|