cats_core 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bdb1adee3b96e70550ebe13e6e0c8a5fb25003bf9f3e6921547ecc597aa12a53
|
4
|
+
data.tar.gz: c358a310a99dfff0bf57002f81ea5e4dfccbc6937ed064908a5693d234c77568
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: afc8027a1addee047913baa073b8ac5cdac7a5e8d42b7c1a81f303e7d8b28c51948a478f02b240760513787d28a0f583e800e2f65a8abc7a6e0e64103661a1fb
|
7
|
+
data.tar.gz: 0bfb44fbd9f541ea33738cd1a4f5150040cc9d69d2c3afd40ea5b198cc19b3b8361851bcfb5e6ed412cc0afe74e67d372fcf2a914163fdf672dbea96f60b7dfb
|
@@ -6,6 +6,15 @@ module Cats
|
|
6
6
|
|
7
7
|
delegate(:code, to: :source, prefix: true)
|
8
8
|
delegate(:reference_no, to: :destination, prefix: true)
|
9
|
+
|
10
|
+
def commit
|
11
|
+
Transaction.transaction do
|
12
|
+
source.quantity -= quantity
|
13
|
+
source.save!
|
14
|
+
self.status = COMMITTED
|
15
|
+
save!
|
16
|
+
end
|
17
|
+
end
|
9
18
|
end
|
10
19
|
end
|
11
20
|
end
|
@@ -17,23 +17,16 @@ module Cats
|
|
17
17
|
def validate_quantity
|
18
18
|
return unless quantity.present? && source.present?
|
19
19
|
|
20
|
-
|
20
|
+
dispatched = self.class.where(source: source, status: DRAFT).sum(:quantity)
|
21
21
|
|
22
|
-
|
22
|
+
available = source.quantity - dispatched
|
23
|
+
available += quantity_was if quantity_was
|
23
24
|
|
24
|
-
|
25
|
-
errors.add(:quantity, "total is higher than source quantity (Max = #{diff}).") if quantity > diff
|
25
|
+
errors.add(:quantity, "total is higher than source quantity (Max = #{available}).") if quantity > available
|
26
26
|
end
|
27
27
|
|
28
28
|
def commit
|
29
|
-
|
30
|
-
source.quantity -= quantity
|
31
|
-
destination.quantity += quantity
|
32
|
-
source.save
|
33
|
-
destination.save
|
34
|
-
self.status = COMMITTED
|
35
|
-
save!
|
36
|
-
end
|
29
|
+
raise(NotImplementedError, 'Method should be implemented in child classes.')
|
37
30
|
end
|
38
31
|
|
39
32
|
def skip_quantity_validation
|
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.1
|
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-11-
|
11
|
+
date: 2021-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_model_serializers
|