cats_core 1.0.29 → 1.0.33
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/unit_of_measures_controller.rb +49 -0
- data/app/models/cats/core/allocation.rb +3 -1
- data/app/models/cats/core/allocation_item.rb +4 -0
- data/app/models/cats/core/rhn_request.rb +2 -0
- data/app/serializers/cats/core/unit_of_measure_serializer.rb +3 -0
- data/config/routes.rb +1 -0
- data/db/migrate/20210718042823_create_cats_core_allocations.rb +1 -0
- data/lib/cats/core/version.rb +1 -1
- data/spec/factories/cats/core/allocations.rb +1 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7e8bd73f8569d1c144fed8b4b5676ee0c163333156d501b21a2516bd2fd535f
|
4
|
+
data.tar.gz: ea06d76acd38e5c9cf96067dbfb84730abc4ade1ceb741910a75a0c56dd1d2fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22114a9def60bcae317450fa5a4fb9fbac9f938dfb314cefcd888c1a4a9f1dbfd4a345bd254810245efe8a6e638267dfc4a8e2a76520310164f460042535c640
|
7
|
+
data.tar.gz: 057d3981b8b746a3d19b83c4dd5b20357dc38d8f909973f6e7e82c1bf3f951c6fb14dd7bd8bd544524f1d4333ceb0eeaca25486a40a49d4feb0e7a75c59d0c1c
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Cats
|
2
|
+
module Core
|
3
|
+
class UnitOfMeasuresController < ApplicationController
|
4
|
+
before_action :set_unit_of_measure, only: %i[show update]
|
5
|
+
|
6
|
+
def index
|
7
|
+
data = ActiveModelSerializers::SerializableResource.new(Cats::Core::UnitOfMeasure.all)
|
8
|
+
render json: { success: true, data: data }
|
9
|
+
end
|
10
|
+
|
11
|
+
def show
|
12
|
+
data = ActiveModelSerializers::SerializableResource.new(@unit_of_measure)
|
13
|
+
render json: { success: true, data: data }
|
14
|
+
end
|
15
|
+
|
16
|
+
def create
|
17
|
+
obj = Cats::Core::UnitOfMeasure.new(model_params)
|
18
|
+
if obj.save
|
19
|
+
data = ActiveModelSerializers::SerializableResource.new(obj)
|
20
|
+
render json: { success: true, data: data }, status: :created
|
21
|
+
else
|
22
|
+
render json: { success: false, error: obj.errors.full_messages[0] }, status: :unprocessable_entity
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def update
|
27
|
+
if @unit_of_measure.update(model_params)
|
28
|
+
data = ActiveModelSerializers::SerializableResource.new(@unit_of_measure)
|
29
|
+
render json: { success: true, data: data }
|
30
|
+
else
|
31
|
+
render json: {
|
32
|
+
success: false,
|
33
|
+
error: @unit_of_measure.errors.full_messages[0]
|
34
|
+
}, status: :unprocessable_entity
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def set_unit_of_measure
|
41
|
+
@unit_of_measure = Cats::Core::UnitOfMeasure.find(params[:id])
|
42
|
+
end
|
43
|
+
|
44
|
+
def model_params
|
45
|
+
params.require(:payload).permit(:abbreviation, :name, :unit_type)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -6,12 +6,14 @@ module Cats
|
|
6
6
|
belongs_to :source, class_name: 'Cats::Core::Location'
|
7
7
|
|
8
8
|
validates :commodity_status, presence: true
|
9
|
+
validates :reference_no, presence: true, uniqueness: true
|
9
10
|
validates :quantity, presence: true, numericality: { greater_than: 0 }
|
10
11
|
validates :commodity_status, inclusion: { in: Cats::Core::Commodity::COMMODITY_STATUSES }
|
11
12
|
|
12
|
-
delegate(:reference_no, to: :rhn_request, prefix: :rhn)
|
13
|
+
delegate(:reference_no, to: :rhn_request, prefix: :rhn, allow_nil: true)
|
13
14
|
delegate(:batch_no, to: :commodity, prefix: true)
|
14
15
|
delegate(:name, to: :source, prefix: true)
|
16
|
+
delegate(:location_type, to: :source, prefix: true)
|
15
17
|
end
|
16
18
|
end
|
17
19
|
end
|
@@ -13,6 +13,10 @@ module Cats
|
|
13
13
|
|
14
14
|
errors.add(:base, 'source and destination cannot be the same') if allocation.source == destination
|
15
15
|
end
|
16
|
+
|
17
|
+
delegate(:name, to: :destination, prefix: true)
|
18
|
+
delegate(:reference_no, to: :allocation, prefix: true)
|
19
|
+
delegate(:location_type, to: :destination, prefix: true)
|
16
20
|
end
|
17
21
|
end
|
18
22
|
end
|
data/config/routes.rb
CHANGED
data/lib/cats/core/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cats_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.33
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henock L.
|
@@ -224,6 +224,7 @@ files:
|
|
224
224
|
- app/controllers/cats/core/menus_controller.rb
|
225
225
|
- app/controllers/cats/core/notifications_controller.rb
|
226
226
|
- app/controllers/cats/core/roles_controller.rb
|
227
|
+
- app/controllers/cats/core/unit_of_measures_controller.rb
|
227
228
|
- app/controllers/cats/core/users_controller.rb
|
228
229
|
- app/jobs/cats/core/application_job.rb
|
229
230
|
- app/models/cats/core/allocation.rb
|
@@ -267,6 +268,7 @@ files:
|
|
267
268
|
- app/serializers/cats/core/currency_serializer.rb
|
268
269
|
- app/serializers/cats/core/location_serializer.rb
|
269
270
|
- app/serializers/cats/core/role_menu_serializer.rb
|
271
|
+
- app/serializers/cats/core/unit_of_measure_serializer.rb
|
270
272
|
- app/services/cats/core/menu_service.rb
|
271
273
|
- app/services/cats/core/notification_service.rb
|
272
274
|
- app/services/cats/core/token_auth_service.rb
|