deb 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/app/models/deb/transaction.rb +5 -1
- data/lib/deb/version.rb +1 -1
- data/lib/generators/deb/templates/migration.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NzE2OWQ0MjVkMTQyNjVlMmMyZjk0OTVlNDk5OWRlZWYyZDkxZjZhYg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YzM2OWExY2MzNDZiNmMwMDZkNDU3YjFiZGUxMjYyYmFlOThjYjMyOQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MzIzMDU3YzU3YWUzOWVhYjdiZTAxYTRlZDQ1NDQ3YTNlMTRkNmMzYjU4ODc0
|
10
|
+
MmFjMmI4ODZmZjM4NGY3OTg1MjIyODE3YmMzZWMxMzM0YzQ2NDM3NTVmZGZh
|
11
|
+
ZDJmMzk4OThjYzI4M2Y2ZTQwN2RjYjU0ZjM5Nzk5MjQ4MGM5NmM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ODlhZWViYzdkOTFkNTYwOWEzYmUzN2MyMTI1NDhiZjdjNDQ4MjY3NzQ2MGE2
|
14
|
+
MTMzMGUyYzg2ZDQ2MzM4YjRmNDVjYjg2YjdlOGExM2NkMzM2NzU4ZGRkYTI2
|
15
|
+
MzFjZDdiMjQzNTEwMzBmNjgyNDZmNDQxYjU3ZjZiYzMyZTJlZDE=
|
@@ -7,6 +7,7 @@ module Deb
|
|
7
7
|
has_many :debit_accounts, through: :debit_items, source: :account
|
8
8
|
has_many :credit_items, class_name: "Deb::Item", conditions: {kind: "credit"}
|
9
9
|
has_many :credit_accounts, through: :credit_items, source: :account
|
10
|
+
belongs_to :rollback_transaction, class_name: "Deb::Transaction"
|
10
11
|
|
11
12
|
validate :debit_items_presence
|
12
13
|
validate :credit_items_presence
|
@@ -20,13 +21,16 @@ module Deb
|
|
20
21
|
|
21
22
|
def rollback!(ref = nil)
|
22
23
|
tran = self
|
23
|
-
self.class.start! do
|
24
|
+
res = self.class.start! do
|
24
25
|
tran.debit_items.each { |di| credit(di.account, di.amount) }
|
25
26
|
tran.credit_items.each { |ci| debit(ci.account, ci.amount) }
|
26
27
|
reference(ref || tran)
|
27
28
|
kind(tran.kind)
|
28
29
|
description("Rollback of #{tran.description}")
|
29
30
|
end
|
31
|
+
self.rollback_transaction_id = res.id
|
32
|
+
save!
|
33
|
+
res
|
30
34
|
end
|
31
35
|
|
32
36
|
def self.start!(&block)
|
data/lib/deb/version.rb
CHANGED
@@ -16,6 +16,7 @@ class CreateDebTables < ActiveRecord::Migration
|
|
16
16
|
t.string :description
|
17
17
|
t.string :kind, limit: 16
|
18
18
|
t.references :transactionable, polymorphic: true
|
19
|
+
t.integer :rollback_transaction_id
|
19
20
|
t.timestamps
|
20
21
|
end
|
21
22
|
add_index :deb_transactions, [:transactionable_type, :transactionable_id, :kind], name: "deb_transactions_default"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Boris Nadion
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|