cats_core 1.0.28 → 1.0.32
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 +5 -0
- data/app/models/cats/core/allocation_item.rb +3 -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: b481d401018e6fdfdf93be24ee465d117e45b4a888e4e4a0e079f3aa4654009a
|
4
|
+
data.tar.gz: dae45a28258a5125762192e4bd2579ed2b5c486ea74271dac1437ee4bea5c2b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2404e609083ccfe957927a8a7fbc9355eaa564f2aa2620af2eac779a10457b11661d1db34a8b6bdb27ad3b60ff2ba717dce8e35627688f2590bd2c292d17079f
|
7
|
+
data.tar.gz: d2748d191c6ac70a5977acf13b3647a0387dcd80dfeaa4dfb03c88244a845b353aeffd25cd6856ba5d1a3c2934ed5a8a85b71ab82e2cdde2f1ddc56afd14ae66
|
@@ -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,8 +6,13 @@ 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 }
|
12
|
+
|
13
|
+
delegate(:reference_no, to: :rhn_request, prefix: :rhn, allow_nil: true)
|
14
|
+
delegate(:batch_no, to: :commodity, prefix: true)
|
15
|
+
delegate(:name, to: :source, prefix: true)
|
11
16
|
end
|
12
17
|
end
|
13
18
|
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.32
|
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
|