cats_core 1.0.49 → 1.0.50
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/services/cats/core/space_service.rb +38 -7
- data/config/routes.rb +2 -2
- data/lib/cats/core/version.rb +1 -1
- 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: b13a3549ac212c8e869ce5aff6b3508787e75af7afaeadba4b0e99f5476b101e
|
4
|
+
data.tar.gz: d4993f0e36936fc4ed18ae9accca173189056c3cddae7fc2f16704f6509bac80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91d4ba5e59ef7da90cf36d6073d20819496bae612eff73cdeccada481293a956311732201b049da61e84ba1c12b1a7464d636202b101f66a49bcf22146211440
|
7
|
+
data.tar.gz: afdceef95b3321eaea7ebad43bd622b814ef268f97b20c5815af07376fc710b338b74a25bc3e81d6c4b366f00e30e6553c2f2dcc38e84685bc670201ce4e4e13
|
@@ -8,7 +8,9 @@ module Cats
|
|
8
8
|
def available_space(id, level)
|
9
9
|
case level
|
10
10
|
when HUB
|
11
|
-
|
11
|
+
hub = Cats::Core::Location.find(id)
|
12
|
+
warehouses = hub.children
|
13
|
+
warehouse_ids = warehouses.map(&:id)
|
12
14
|
stores = Cats::Core::Store.joins(:warehouse)
|
13
15
|
.where(
|
14
16
|
cats_core_locations: {
|
@@ -19,19 +21,48 @@ module Cats
|
|
19
21
|
wh_details = []
|
20
22
|
stores.each do |key, value|
|
21
23
|
total_space = value.inject(0) { |sum, val| sum + val.available_space }
|
22
|
-
details = value.map
|
23
|
-
|
24
|
+
details = value.map do |val|
|
25
|
+
{ store_id: val.id, code: val.code, name: val.name, total_space: val.available_space }
|
26
|
+
end
|
27
|
+
warehouse = warehouses.find(key)
|
28
|
+
wh_details << {
|
29
|
+
warehouse_id: key,
|
30
|
+
code: warehouse.code,
|
31
|
+
name: warehouse.name,
|
32
|
+
total_space: total_space,
|
33
|
+
details: details
|
34
|
+
}
|
24
35
|
end
|
25
36
|
hub_space = wh_details.inject(0) { |sum, val| sum + val[:total_space] }
|
26
|
-
space = {
|
37
|
+
space = {
|
38
|
+
hub_id: id,
|
39
|
+
code: hub.code,
|
40
|
+
name: hub.name,
|
41
|
+
total_space: hub_space,
|
42
|
+
details: wh_details
|
43
|
+
}
|
27
44
|
when WAREHOUSE
|
45
|
+
warehouse = Cats::Core::Location.find(id)
|
28
46
|
stores = Cats::Core::Store.where(warehouse_id: id)
|
29
|
-
details = stores.map
|
47
|
+
details = stores.map do |store|
|
48
|
+
{ store_id: store.id, code: store.code, name: store.name, total_space: store.available_space }
|
49
|
+
end
|
30
50
|
total_space = stores.inject(0) { |sum, val| sum + val.available_space }
|
31
|
-
space = {
|
51
|
+
space = {
|
52
|
+
warehouse_id: id,
|
53
|
+
code: warehouse.code,
|
54
|
+
name: warehouse.name,
|
55
|
+
total_space: total_space,
|
56
|
+
details: details
|
57
|
+
}
|
32
58
|
when STORE
|
33
59
|
store = Cats::Core::Store.find(id)
|
34
|
-
space = {
|
60
|
+
space = {
|
61
|
+
store_id: store.id,
|
62
|
+
code: store.code,
|
63
|
+
name: store.name,
|
64
|
+
total_space: store.available_space
|
65
|
+
}
|
35
66
|
end
|
36
67
|
space
|
37
68
|
end
|
data/config/routes.rb
CHANGED
@@ -33,11 +33,11 @@ Cats::Core::Engine.routes.draw do
|
|
33
33
|
to: 'spaces#available_space',
|
34
34
|
as: :hub_space,
|
35
35
|
defaults: { level: Cats::Core::SpaceService::HUB }
|
36
|
-
get '/
|
36
|
+
get '/warehouses/:id/space',
|
37
37
|
to: 'spaces#available_space',
|
38
38
|
as: :warehouse_space,
|
39
39
|
defaults: { level: Cats::Core::SpaceService::WAREHOUSE }
|
40
|
-
get '/
|
40
|
+
get '/stores/:id/space',
|
41
41
|
to: 'spaces#available_space',
|
42
42
|
as: :store_space,
|
43
43
|
defaults: { level: Cats::Core::SpaceService::STORE }
|
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.0.
|
4
|
+
version: 1.0.50
|
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-09-
|
11
|
+
date: 2021-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_model_serializers
|