cats_core 1.0.33 → 1.0.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f642691ce490f46cc23534f368644b7bd6cc2069736cae534994aafb8018d40
|
4
|
+
data.tar.gz: a3967aca1998cf19cbfa55af249e8023c664bb4066bb0c40224a209225584485
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8147dfe37fbe8ad5c1ae9e3945b71936e5c0c135a00633fba2c9e3f1a6aeac4ce482d3f4d81e965c0a3cb00d8ac9bec58033b2d8c418a750f9b68b63c61c4788
|
7
|
+
data.tar.gz: d501edb9668b0372c6c6a91092619d467379083cc7c7ef3201856a43f1a53abcb5dcd0a97411d7e083ba8771f9ea66235213b283f5cdac64d870142bc1635840
|
@@ -22,6 +22,8 @@ module Cats
|
|
22
22
|
validate :validate_coordinates, :validate_dimensions, :validate_distance_from_wall, :validate_overlap,
|
23
23
|
:validate_space_between_stack
|
24
24
|
|
25
|
+
after_save :update_store_space
|
26
|
+
|
25
27
|
def validate_coordinates
|
26
28
|
return unless store.present? && length.present? && width.present? && start_x.present? && start_y.present?
|
27
29
|
|
@@ -99,6 +101,21 @@ module Cats
|
|
99
101
|
|
100
102
|
true
|
101
103
|
end
|
104
|
+
|
105
|
+
def update_store_space
|
106
|
+
return unless length_previously_changed? || width_previously_changed? || stack_status_previously_changed?
|
107
|
+
|
108
|
+
old_area = if length_previously_was.nil? && width_previously_was.nil?
|
109
|
+
0
|
110
|
+
else
|
111
|
+
length_previously_was * width_previously_was
|
112
|
+
end
|
113
|
+
|
114
|
+
store.available_space += old_area
|
115
|
+
store.available_space -= length * width unless stack_status == DESTROYED
|
116
|
+
|
117
|
+
store.save
|
118
|
+
end
|
102
119
|
end
|
103
120
|
end
|
104
121
|
end
|
@@ -15,6 +15,7 @@ module Cats
|
|
15
15
|
allow_nil: true
|
16
16
|
validate :validate_location
|
17
17
|
|
18
|
+
before_create :update_usable_space
|
18
19
|
after_save :update_store_keeper
|
19
20
|
|
20
21
|
def validate_location
|
@@ -27,6 +28,12 @@ module Cats
|
|
27
28
|
"#{store_keeper.first_name} #{store_keeper.last_name}"
|
28
29
|
end
|
29
30
|
|
31
|
+
def update_usable_space
|
32
|
+
self.usable_space = (length - 2) * (width - 2)
|
33
|
+
self.usable_space -= (gangway_length * gangway_width) if has_gangway
|
34
|
+
self.available_space = self.usable_space
|
35
|
+
end
|
36
|
+
|
30
37
|
def update_store_keeper
|
31
38
|
return unless store_keeper_id_previously_changed?
|
32
39
|
|
@@ -5,6 +5,8 @@ class CreateCatsCoreStores < ActiveRecord::Migration[6.1]
|
|
5
5
|
t.float :length, null: false
|
6
6
|
t.float :width, null: false
|
7
7
|
t.float :height, null: false
|
8
|
+
t.float :usable_space, null: false
|
9
|
+
t.float :available_space, null: false
|
8
10
|
t.boolean :temporary, null: false, default: false
|
9
11
|
t.boolean :has_gangway, null: false, default: false
|
10
12
|
t.float :gangway_length
|
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.34
|
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-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_model_serializers
|