cats_core 1.0.48 → 1.0.49
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/cats/core/transaction.rb +9 -0
- data/lib/cats/core/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88f88c106a10c160703ee6898947a371aef510da88eea9aa514ff93e20c4e806
|
4
|
+
data.tar.gz: 2baa107b490e7372ed823c6d8fec83e91a19de41f77a48cd187e99eb2dc934bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f12a36ca3a10c537f09e6fd12b07e66d70b0bc69692badb2f9a0de6642d1b91f308ba53754456ecf35da935c7a380af3e7237bdda35690177ae0823acab8ef60
|
7
|
+
data.tar.gz: fdb2ed8c53e2d0c2e554017dce091be7056004b28a9dc3b0cbc6c4e343855957afcb64de644ccefc7649372c5c29584f98f9fc78ba9f0b0e6bb24bb96c434458
|
@@ -2,6 +2,7 @@ module Cats
|
|
2
2
|
module Core
|
3
3
|
class Transaction < ApplicationRecord
|
4
4
|
self.abstract_class = true
|
5
|
+
after_initialize :set_status
|
5
6
|
|
6
7
|
# Transaction statuses
|
7
8
|
DRAFT = 'Draft'.freeze
|
@@ -25,8 +26,16 @@ module Cats
|
|
25
26
|
destination.quantity += quantity
|
26
27
|
source.save
|
27
28
|
destination.save
|
29
|
+
self.status = COMMITTED
|
30
|
+
save
|
28
31
|
end
|
29
32
|
end
|
33
|
+
|
34
|
+
def set_status
|
35
|
+
return unless new_record?
|
36
|
+
|
37
|
+
self.status = DRAFT
|
38
|
+
end
|
30
39
|
end
|
31
40
|
end
|
32
41
|
end
|
data/lib/cats/core/version.rb
CHANGED