acts_as_account 1.2.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.rvmrc +1 -0
- data/.specification +0 -0
- data/Gemfile +7 -13
- data/Gemfile.lock +69 -39
- data/LICENSE +0 -0
- data/README.rdoc +9 -5
- data/Rakefile +0 -0
- data/VERSION +1 -1
- data/acts_as_account.gemspec +95 -0
- data/cucumber.yml +0 -0
- data/db/database.yml +0 -0
- data/db/schema.rb +7 -1
- data/features/account/account_creation.feature +6 -1
- data/features/step_definitions/account_steps.rb +19 -3
- data/features/support/abstract_user.rb +2 -0
- data/features/support/cheque.rb +0 -0
- data/features/support/env.rb +2 -0
- data/features/support/inheriting_user.rb +3 -0
- data/features/support/user.rb +0 -0
- data/features/transfer/journal_creation.feature +0 -0
- data/features/transfer/transfer.feature +0 -0
- data/init.rb +0 -0
- data/lib/acts_as_account.rb +0 -0
- data/lib/acts_as_account/account.rb +6 -5
- data/lib/acts_as_account/active_record_extensions.rb +1 -1
- data/lib/acts_as_account/global_account.rb +2 -2
- data/lib/acts_as_account/journal.rb +15 -15
- data/lib/acts_as_account/manually_created_account.rb +3 -3
- data/lib/acts_as_account/posting.rb +9 -9
- data/lib/acts_as_account/transfer.rb +0 -0
- metadata +145 -162
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm 1.9.3@acts_as_account --create
|
data/.specification
CHANGED
File without changes
|
data/Gemfile
CHANGED
@@ -1,20 +1,14 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
|
-
# Add dependencies required to use your gem here.
|
3
|
-
# Example:
|
4
|
-
# gem "activesupport", ">= 2.3.5"
|
5
2
|
|
6
|
-
# Add dependencies to develop your gem here.
|
7
|
-
# Include everything needed to run rake, tests, features, etc.
|
8
3
|
group :development do
|
9
|
-
gem
|
10
|
-
gem
|
11
|
-
gem
|
12
|
-
gem
|
13
|
-
gem 'mysql', '>= 2.7.0'
|
4
|
+
gem 'rspec'
|
5
|
+
gem 'jeweler'
|
6
|
+
gem 'cucumber'
|
7
|
+
gem 'mysql'
|
14
8
|
end
|
15
9
|
|
16
10
|
group :default do
|
17
|
-
gem
|
18
|
-
gem
|
19
|
-
gem
|
11
|
+
gem 'activerecord', '~> 3.2.8'
|
12
|
+
gem 'actionpack' , '~> 3.2.8'
|
13
|
+
gem 'database_cleaner'
|
20
14
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,52 +1,82 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
actionpack (2.
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
4
|
+
actionpack (3.2.8)
|
5
|
+
activemodel (= 3.2.8)
|
6
|
+
activesupport (= 3.2.8)
|
7
|
+
builder (~> 3.0.0)
|
8
|
+
erubis (~> 2.7.0)
|
9
|
+
journey (~> 1.0.4)
|
10
|
+
rack (~> 1.4.0)
|
11
|
+
rack-cache (~> 1.2)
|
12
|
+
rack-test (~> 0.6.1)
|
13
|
+
sprockets (~> 2.1.3)
|
14
|
+
activemodel (3.2.8)
|
15
|
+
activesupport (= 3.2.8)
|
16
|
+
builder (~> 3.0.0)
|
17
|
+
activerecord (3.2.8)
|
18
|
+
activemodel (= 3.2.8)
|
19
|
+
activesupport (= 3.2.8)
|
20
|
+
arel (~> 3.0.2)
|
21
|
+
tzinfo (~> 0.3.29)
|
22
|
+
activesupport (3.2.8)
|
23
|
+
i18n (~> 0.6)
|
24
|
+
multi_json (~> 1.0)
|
25
|
+
arel (3.0.2)
|
26
|
+
builder (3.0.3)
|
27
|
+
cucumber (1.2.1)
|
28
|
+
builder (>= 2.1.2)
|
29
|
+
diff-lcs (>= 1.1.3)
|
30
|
+
gherkin (~> 2.11.0)
|
31
|
+
json (>= 1.4.6)
|
32
|
+
database_cleaner (0.8.0)
|
33
|
+
diff-lcs (1.1.3)
|
34
|
+
erubis (2.7.0)
|
35
|
+
gherkin (2.11.2)
|
36
|
+
json (>= 1.4.6)
|
22
37
|
git (1.2.5)
|
23
|
-
|
24
|
-
|
38
|
+
hike (1.2.1)
|
39
|
+
i18n (0.6.1)
|
40
|
+
jeweler (1.8.4)
|
41
|
+
bundler (~> 1.0)
|
25
42
|
git (>= 1.2.5)
|
26
43
|
rake
|
27
|
-
|
44
|
+
rdoc
|
45
|
+
journey (1.0.4)
|
46
|
+
json (1.7.5)
|
47
|
+
multi_json (1.3.6)
|
28
48
|
mysql (2.8.1)
|
29
|
-
rack (1.1
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
49
|
+
rack (1.4.1)
|
50
|
+
rack-cache (1.2)
|
51
|
+
rack (>= 0.4)
|
52
|
+
rack-test (0.6.1)
|
53
|
+
rack (>= 1.0)
|
54
|
+
rake (0.9.2.2)
|
55
|
+
rdoc (3.12)
|
56
|
+
json (~> 1.4)
|
57
|
+
rspec (2.11.0)
|
58
|
+
rspec-core (~> 2.11.0)
|
59
|
+
rspec-expectations (~> 2.11.0)
|
60
|
+
rspec-mocks (~> 2.11.0)
|
61
|
+
rspec-core (2.11.1)
|
62
|
+
rspec-expectations (2.11.3)
|
63
|
+
diff-lcs (~> 1.1.3)
|
64
|
+
rspec-mocks (2.11.2)
|
65
|
+
sprockets (2.1.3)
|
66
|
+
hike (~> 1.2)
|
67
|
+
rack (~> 1.0)
|
68
|
+
tilt (~> 1.1, != 1.3.0)
|
69
|
+
tilt (1.3.3)
|
70
|
+
tzinfo (0.3.33)
|
40
71
|
|
41
72
|
PLATFORMS
|
42
73
|
ruby
|
43
74
|
|
44
75
|
DEPENDENCIES
|
45
|
-
actionpack (~> 2.
|
46
|
-
activerecord (~> 2.
|
47
|
-
|
48
|
-
cucumber (~> 0.9.4)
|
76
|
+
actionpack (~> 3.2.8)
|
77
|
+
activerecord (~> 3.2.8)
|
78
|
+
cucumber
|
49
79
|
database_cleaner
|
50
|
-
jeweler
|
51
|
-
mysql
|
52
|
-
rspec
|
80
|
+
jeweler
|
81
|
+
mysql
|
82
|
+
rspec
|
data/LICENSE
CHANGED
File without changes
|
data/README.rdoc
CHANGED
@@ -2,31 +2,35 @@
|
|
2
2
|
|
3
3
|
== Theory
|
4
4
|
|
5
|
-
ActsAsAccount implements a "Double Entry Accounting" system for your
|
5
|
+
ActsAsAccount implements a "Double Entry Accounting" system for your
|
6
6
|
Rails-models.
|
7
7
|
|
8
|
-
It hooks into ActiveRecord and allows to add accounts to any model by
|
8
|
+
It hooks into ActiveRecord and allows to add accounts to any model by
|
9
9
|
simply means of adding "has_account" to your model. Because the accounts
|
10
10
|
are connected via a has_many relation no migration to the account-holder
|
11
11
|
tables is needed.
|
12
12
|
|
13
|
-
We also hook into the ActionController request cycle to warn the developer
|
13
|
+
We also hook into the ActionController request cycle to warn the developer
|
14
14
|
if a request has left the uncommitted changes in the system.
|
15
15
|
|
16
16
|
== How to test
|
17
17
|
|
18
18
|
Run the cucumber features from the acs_as_account gem, just execute
|
19
|
-
* rake features:create_database
|
19
|
+
* rake features:create_database
|
20
20
|
* cucumber
|
21
21
|
|
22
22
|
== Links
|
23
23
|
|
24
24
|
* Double Entry Accounting in a Relational Database: http://homepages.tcp.co.uk/~m-wigley/gc_wp_ded.html
|
25
25
|
|
26
|
+
== Compatibility
|
27
|
+
|
28
|
+
With the release of version 2.0.0 acts_as_account is supposed to work for Rails 3. If you still use Rails 2 please use version 1.2.0.
|
29
|
+
|
26
30
|
== Credits
|
27
31
|
|
28
32
|
This gem was written for the payment backend of betterplace.org by Thies C. Arntzen (http://github.com/thieso2) and Norman Timmler (github.com/unnu).
|
29
33
|
|
30
34
|
== Copyright
|
31
|
-
|
35
|
+
|
32
36
|
Copyright (c) 2010 gut.org gAG
|
data/Rakefile
CHANGED
File without changes
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2.0.1
|
@@ -0,0 +1,95 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "acts_as_account"
|
8
|
+
s.version = "2.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Thies C. Arntzen, Norman Timmler, Matthias Frick, Phillip Oertel"]
|
12
|
+
s.date = "2012-10-04"
|
13
|
+
s.description = "acts_as_account implements double entry accounting for Rails models. Your models get accounts and you can do consistent transactions between them. Since the documentation is sparse, see the transfer.feature for usage examples."
|
14
|
+
s.email = "thieso@gmail.com"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".rvmrc",
|
21
|
+
".specification",
|
22
|
+
"Gemfile",
|
23
|
+
"Gemfile.lock",
|
24
|
+
"LICENSE",
|
25
|
+
"README.rdoc",
|
26
|
+
"Rakefile",
|
27
|
+
"VERSION",
|
28
|
+
"acts_as_account.gemspec",
|
29
|
+
"cucumber.yml",
|
30
|
+
"db/database.yml",
|
31
|
+
"db/schema.rb",
|
32
|
+
"features/account/account_creation.feature",
|
33
|
+
"features/step_definitions/account_steps.rb",
|
34
|
+
"features/support/abstract_user.rb",
|
35
|
+
"features/support/cheque.rb",
|
36
|
+
"features/support/env.rb",
|
37
|
+
"features/support/inheriting_user.rb",
|
38
|
+
"features/support/user.rb",
|
39
|
+
"features/transfer/journal_creation.feature",
|
40
|
+
"features/transfer/transfer.feature",
|
41
|
+
"init.rb",
|
42
|
+
"lib/acts_as_account.rb",
|
43
|
+
"lib/acts_as_account/account.rb",
|
44
|
+
"lib/acts_as_account/active_record_extensions.rb",
|
45
|
+
"lib/acts_as_account/global_account.rb",
|
46
|
+
"lib/acts_as_account/journal.rb",
|
47
|
+
"lib/acts_as_account/manually_created_account.rb",
|
48
|
+
"lib/acts_as_account/posting.rb",
|
49
|
+
"lib/acts_as_account/transfer.rb"
|
50
|
+
]
|
51
|
+
s.homepage = "http://github.com/betterplace/acts_as_account"
|
52
|
+
s.require_paths = ["lib"]
|
53
|
+
s.rubygems_version = "1.8.24"
|
54
|
+
s.summary = "acts_as_account implements double entry accounting for Rails models"
|
55
|
+
|
56
|
+
if s.respond_to? :specification_version then
|
57
|
+
s.specification_version = 3
|
58
|
+
|
59
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
60
|
+
s.add_runtime_dependency(%q<activerecord>, ["~> 3.2.8"])
|
61
|
+
s.add_runtime_dependency(%q<actionpack>, ["~> 3.2.8"])
|
62
|
+
s.add_runtime_dependency(%q<database_cleaner>, [">= 0"])
|
63
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
64
|
+
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
65
|
+
s.add_development_dependency(%q<cucumber>, [">= 0"])
|
66
|
+
s.add_development_dependency(%q<mysql>, [">= 0"])
|
67
|
+
s.add_runtime_dependency(%q<activerecord>, [">= 0"])
|
68
|
+
s.add_runtime_dependency(%q<actionpack>, [">= 0"])
|
69
|
+
s.add_runtime_dependency(%q<database_cleaner>, [">= 0"])
|
70
|
+
else
|
71
|
+
s.add_dependency(%q<activerecord>, ["~> 3.2.8"])
|
72
|
+
s.add_dependency(%q<actionpack>, ["~> 3.2.8"])
|
73
|
+
s.add_dependency(%q<database_cleaner>, [">= 0"])
|
74
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
75
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
76
|
+
s.add_dependency(%q<cucumber>, [">= 0"])
|
77
|
+
s.add_dependency(%q<mysql>, [">= 0"])
|
78
|
+
s.add_dependency(%q<activerecord>, [">= 0"])
|
79
|
+
s.add_dependency(%q<actionpack>, [">= 0"])
|
80
|
+
s.add_dependency(%q<database_cleaner>, [">= 0"])
|
81
|
+
end
|
82
|
+
else
|
83
|
+
s.add_dependency(%q<activerecord>, ["~> 3.2.8"])
|
84
|
+
s.add_dependency(%q<actionpack>, ["~> 3.2.8"])
|
85
|
+
s.add_dependency(%q<database_cleaner>, [">= 0"])
|
86
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
87
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
88
|
+
s.add_dependency(%q<cucumber>, [">= 0"])
|
89
|
+
s.add_dependency(%q<mysql>, [">= 0"])
|
90
|
+
s.add_dependency(%q<activerecord>, [">= 0"])
|
91
|
+
s.add_dependency(%q<actionpack>, [">= 0"])
|
92
|
+
s.add_dependency(%q<database_cleaner>, [">= 0"])
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
data/cucumber.yml
CHANGED
File without changes
|
data/db/database.yml
CHANGED
File without changes
|
data/db/schema.rb
CHANGED
@@ -56,7 +56,13 @@ ActiveRecord::Schema.define(:version => 1) do
|
|
56
56
|
t.datetime "created_at"
|
57
57
|
t.datetime "updated_at"
|
58
58
|
end
|
59
|
-
|
59
|
+
|
60
|
+
create_table "abstract_users", :force => true do |t|
|
61
|
+
t.string "name", :null => false
|
62
|
+
t.string "type", :null => false
|
63
|
+
t.datetime "created_at"
|
64
|
+
t.datetime "updated_at"
|
65
|
+
end
|
60
66
|
create_table "cheques", :force => true do |t|
|
61
67
|
t.string "number"
|
62
68
|
t.datetime "created_at"
|
@@ -13,4 +13,9 @@ Feature: Creating an Account
|
|
13
13
|
Scenario: Race condition while creating account
|
14
14
|
Given I have the same user in memory
|
15
15
|
And I disable the account existence check on those
|
16
|
-
When I call 'account' on both it should be possible
|
16
|
+
When I call 'account' on both it should be possible
|
17
|
+
|
18
|
+
Scenario: Accounts on a sublcass
|
19
|
+
Given I have a user A that inherits from an abstract class
|
20
|
+
And I autocreate an account for inheriting user A
|
21
|
+
Then the account of user A should be there
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
include ActsAsAccount
|
2
4
|
|
3
5
|
def german_date_time_to_local(datestring, timestring)
|
@@ -8,6 +10,20 @@ Given /^I create a user (\w+)$/ do |name|
|
|
8
10
|
User.create!(:name => name)
|
9
11
|
end
|
10
12
|
|
13
|
+
Given /^I have a user (\w+) that inherits from an abstract class$/ do |name|
|
14
|
+
InheritingUser.create!(:name => name)
|
15
|
+
end
|
16
|
+
|
17
|
+
Given /^I autocreate an account for inheriting user (\w+)$/ do |name|
|
18
|
+
@created_account = InheritingUser.find_by_name(name).account
|
19
|
+
assert_not_nil @created_account
|
20
|
+
end
|
21
|
+
|
22
|
+
Then /^the account of user (\w+) should be there$/ do |name|
|
23
|
+
account = InheritingUser.find_by_name(name).account
|
24
|
+
assert_equal @created_account, account
|
25
|
+
end
|
26
|
+
|
11
27
|
Given /^I create a global ([_\w]+) account$/ do |name|
|
12
28
|
Account.for(name)
|
13
29
|
end
|
@@ -97,7 +113,7 @@ end
|
|
97
113
|
|
98
114
|
Given /I transfer (\d+) € from (\w+)'s account to (\w+)'s account referencing a (\w+) with (\w+) (\w+)$/ do |amount, from, to, reference, name, value|
|
99
115
|
@reference = reference.constantize.create!(name => value)
|
100
|
-
|
116
|
+
step "I transfer #{amount} € from #{from}'s account to #{to}'s account"
|
101
117
|
end
|
102
118
|
|
103
119
|
Then /^all postings reference (\w+) with (\w+) (\w+)$/ do |reference_class, name, value|
|
@@ -109,7 +125,7 @@ end
|
|
109
125
|
|
110
126
|
Given /^I transfer (\d+) € from (\w+)'s account to (\w+)'s account and specify (\S+) (\S+) as the booking time$/ do |amount, from, to, booking_date, booking_time|
|
111
127
|
@valuta = german_date_time_to_local(booking_date, booking_time)
|
112
|
-
|
128
|
+
step "I transfer #{amount} € from #{from}'s account to #{to}'s account"
|
113
129
|
end
|
114
130
|
|
115
131
|
Then /^all postings have (\S+) (\S+) as the booking time$/ do |booking_date, booking_time|
|
@@ -139,7 +155,7 @@ end
|
|
139
155
|
|
140
156
|
Given /^I disable the account existence check on those$/ do
|
141
157
|
[@user1, @user2].each do |user|
|
142
|
-
user.instance_eval "def default_account ; end"
|
158
|
+
user.instance_eval "def default_account; true; end"
|
143
159
|
end
|
144
160
|
end
|
145
161
|
|
data/features/support/cheque.rb
CHANGED
File without changes
|
data/features/support/env.rb
CHANGED
@@ -14,6 +14,8 @@ DatabaseCleaner.strategy = :transaction
|
|
14
14
|
Dir[File.dirname(__FILE__) + '/../step_definitions/*.rb'].each { |file| require file }
|
15
15
|
|
16
16
|
require File.dirname(__FILE__) + '/user'
|
17
|
+
require File.dirname(__FILE__) + '/abstract_user'
|
18
|
+
require File.dirname(__FILE__) + '/inheriting_user'
|
17
19
|
require File.dirname(__FILE__) + '/cheque'
|
18
20
|
|
19
21
|
After do
|
data/features/support/user.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
data/init.rb
CHANGED
File without changes
|
data/lib/acts_as_account.rb
CHANGED
File without changes
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module ActsAsAccount
|
2
2
|
class Account < ActiveRecord::Base
|
3
|
-
|
3
|
+
self.table_name = :acts_as_account_accounts
|
4
4
|
|
5
5
|
belongs_to :holder, :polymorphic => true
|
6
6
|
has_many :postings, :class_name => 'ActsAsAccount::Posting'
|
@@ -75,10 +75,11 @@ module ActsAsAccount
|
|
75
75
|
record = if attributes[:holder]
|
76
76
|
attributes[:holder].account(attributes[:name])
|
77
77
|
else
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
78
|
+
where(
|
79
|
+
:holder_type => attributes[:holder_type],
|
80
|
+
:holder_id => attributes[:holder_id],
|
81
|
+
:name => attributes[:name]
|
82
|
+
).first
|
82
83
|
end
|
83
84
|
record || raise("Cannot find or create account with attributes #{attributes.inspect}")
|
84
85
|
end
|
@@ -4,7 +4,7 @@ module ActsAsAccount
|
|
4
4
|
base.extend ClassMethods
|
5
5
|
base.class_eval do
|
6
6
|
def account(name = :default)
|
7
|
-
__send__("#{name}_account") || __send__("create_#{name}_account", :name => name.to_s
|
7
|
+
__send__("#{name}_account") || __send__("create_#{name}_account", :name => name.to_s)
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
module ActsAsAccount
|
2
2
|
class Journal < ActiveRecord::Base
|
3
|
-
|
4
|
-
|
3
|
+
self.table_name = :acts_as_account_journals
|
4
|
+
|
5
5
|
has_many :postings, :class_name => 'ActsAsAccount::Posting'
|
6
6
|
has_many :accounts, :through => :postings
|
7
|
-
|
7
|
+
|
8
8
|
class << self
|
9
9
|
private :new
|
10
10
|
private :create
|
@@ -13,12 +13,12 @@ module ActsAsAccount
|
|
13
13
|
def current
|
14
14
|
Thread.current[:acts_as_account_current] ||= create!
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
def clear_current
|
18
18
|
Thread.current[:acts_as_account_current] = nil
|
19
19
|
end
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
def transfers
|
23
23
|
[].tap do |transfers|
|
24
24
|
postings.in_groups_of(2) { |postings| transfers << Transfer.new(*postings) }
|
@@ -27,28 +27,28 @@ module ActsAsAccount
|
|
27
27
|
|
28
28
|
def transfer(amount, from_account, to_account, reference = nil, valuta = Time.now)
|
29
29
|
transaction do
|
30
|
-
if (amount < 0)
|
30
|
+
if (amount < 0)
|
31
31
|
# change order if amount is negative
|
32
32
|
amount, from_account, to_account = -amount, to_account, from_account
|
33
33
|
end
|
34
34
|
|
35
35
|
logger.debug { "ActsAsAccount::Journal.transfer amount: #{amount} from:#{from_account.id} to:#{to_account.id} reference:#{reference.class.name}(#{reference.id}) valuta:#{valuta}" } if logger
|
36
|
-
|
36
|
+
|
37
37
|
# to avoid possible deadlocks we need to ensure that the locking order is always
|
38
|
-
# the same therfore the sort by id.
|
38
|
+
# the same therfore the sort by id.
|
39
39
|
[from_account, to_account].sort_by(&:id).map(&:lock!)
|
40
|
-
|
40
|
+
|
41
41
|
add_posting(-amount, from_account, to_account, reference, valuta)
|
42
42
|
add_posting( amount, to_account, from_account, reference, valuta)
|
43
43
|
end
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
46
|
private
|
47
|
-
|
47
|
+
|
48
48
|
def add_posting(amount, account, other_account, reference, valuta)
|
49
49
|
posting = postings.build(
|
50
|
-
:amount => amount,
|
51
|
-
:account => account,
|
50
|
+
:amount => amount,
|
51
|
+
:account => account,
|
52
52
|
:other_account => other_account,
|
53
53
|
:reference => reference,
|
54
54
|
:valuta => valuta)
|
@@ -56,8 +56,8 @@ module ActsAsAccount
|
|
56
56
|
account.reload.balance += posting.amount
|
57
57
|
account.postings_count += 1
|
58
58
|
|
59
|
-
posting.
|
60
|
-
account.
|
59
|
+
posting.save(:validate => false)
|
60
|
+
account.save(:validate => false)
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module ActsAsAccount
|
2
2
|
class ManuallyCreatedAccount < ActiveRecord::Base
|
3
|
-
|
4
|
-
|
3
|
+
self.table_name = :acts_as_account_manually_created_accounts
|
4
|
+
|
5
5
|
has_account
|
6
|
-
|
6
|
+
|
7
7
|
validates_length_of :name, :minimum => 1
|
8
8
|
end
|
9
9
|
end
|
@@ -1,15 +1,15 @@
|
|
1
1
|
module ActsAsAccount
|
2
2
|
class Posting < ActiveRecord::Base
|
3
|
-
|
4
|
-
|
5
|
-
belongs_to :account,
|
3
|
+
self.table_name = :acts_as_account_postings
|
4
|
+
|
5
|
+
belongs_to :account, :class_name => 'ActsAsAccount::Account'
|
6
6
|
belongs_to :other_account, :class_name => 'ActsAsAccount::Account'
|
7
|
-
belongs_to :journal,
|
7
|
+
belongs_to :journal, :class_name => 'ActsAsAccount::Journal'
|
8
8
|
belongs_to :reference, :polymorphic => true
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
|
10
|
+
scope :soll, where('amount >= 0')
|
11
|
+
scope :haben, where('amount < 0')
|
12
|
+
scope :start_date, lambda{|date| {:conditions => ['DATE(valuta) >= ?', date]}}
|
13
|
+
scope :end_date, lambda{|date| {:conditions => ['DATE(valuta) <= ?', date]}}
|
14
14
|
end
|
15
15
|
end
|
File without changes
|
metadata
CHANGED
@@ -1,200 +1,187 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_account
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.0.1
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 2
|
9
|
-
- 0
|
10
|
-
version: 1.2.0
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Thies C. Arntzen, Norman Timmler, Matthias Frick, Phillip Oertel
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-10-04 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: activerecord
|
22
|
-
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
23
17
|
none: false
|
24
|
-
requirements:
|
18
|
+
requirements:
|
25
19
|
- - ~>
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
|
28
|
-
segments:
|
29
|
-
- 2
|
30
|
-
- 3
|
31
|
-
- 5
|
32
|
-
version: 2.3.5
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.2.8
|
33
22
|
type: :runtime
|
34
|
-
requirement: *id001
|
35
23
|
prerelease: false
|
36
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.2.8
|
30
|
+
- !ruby/object:Gem::Dependency
|
37
31
|
name: actionpack
|
38
|
-
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
39
33
|
none: false
|
40
|
-
requirements:
|
34
|
+
requirements:
|
41
35
|
- - ~>
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
44
|
-
segments:
|
45
|
-
- 2
|
46
|
-
- 3
|
47
|
-
- 5
|
48
|
-
version: 2.3.5
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 3.2.8
|
49
38
|
type: :runtime
|
50
|
-
requirement: *id002
|
51
39
|
prerelease: false
|
52
|
-
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 3.2.8
|
46
|
+
- !ruby/object:Gem::Dependency
|
53
47
|
name: database_cleaner
|
54
|
-
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
55
49
|
none: false
|
56
|
-
requirements:
|
57
|
-
- -
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
|
60
|
-
segments:
|
61
|
-
- 0
|
62
|
-
version: "0"
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
63
54
|
type: :runtime
|
64
|
-
requirement: *id003
|
65
55
|
prerelease: false
|
66
|
-
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
67
63
|
name: rspec
|
68
|
-
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
69
65
|
none: false
|
70
|
-
requirements:
|
71
|
-
- -
|
72
|
-
- !ruby/object:Gem::Version
|
73
|
-
|
74
|
-
segments:
|
75
|
-
- 2
|
76
|
-
- 3
|
77
|
-
- 0
|
78
|
-
version: 2.3.0
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
79
70
|
type: :development
|
80
|
-
requirement: *id004
|
81
71
|
prerelease: false
|
82
|
-
|
83
|
-
name: bundler
|
84
|
-
version_requirements: &id005 !ruby/object:Gem::Requirement
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
73
|
none: false
|
86
|
-
requirements:
|
87
|
-
- -
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
|
90
|
-
|
91
|
-
- 1
|
92
|
-
- 0
|
93
|
-
- 0
|
94
|
-
version: 1.0.0
|
95
|
-
type: :development
|
96
|
-
requirement: *id005
|
97
|
-
prerelease: false
|
98
|
-
- !ruby/object:Gem::Dependency
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
99
79
|
name: jeweler
|
100
|
-
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
101
81
|
none: false
|
102
|
-
requirements:
|
103
|
-
- -
|
104
|
-
- !ruby/object:Gem::Version
|
105
|
-
|
106
|
-
segments:
|
107
|
-
- 1
|
108
|
-
- 5
|
109
|
-
- 2
|
110
|
-
version: 1.5.2
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
111
86
|
type: :development
|
112
|
-
requirement: *id006
|
113
87
|
prerelease: false
|
114
|
-
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
115
95
|
name: cucumber
|
116
|
-
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
117
97
|
none: false
|
118
|
-
requirements:
|
119
|
-
- -
|
120
|
-
- !ruby/object:Gem::Version
|
121
|
-
|
122
|
-
segments:
|
123
|
-
- 0
|
124
|
-
- 9
|
125
|
-
- 4
|
126
|
-
version: 0.9.4
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
127
102
|
type: :development
|
128
|
-
requirement: *id007
|
129
103
|
prerelease: false
|
130
|
-
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
131
111
|
name: mysql
|
132
|
-
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
133
113
|
none: false
|
134
|
-
requirements:
|
135
|
-
- -
|
136
|
-
- !ruby/object:Gem::Version
|
137
|
-
|
138
|
-
segments:
|
139
|
-
- 2
|
140
|
-
- 7
|
141
|
-
- 0
|
142
|
-
version: 2.7.0
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
143
118
|
type: :development
|
144
|
-
requirement: *id008
|
145
119
|
prerelease: false
|
146
|
-
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
147
127
|
name: activerecord
|
148
|
-
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
149
129
|
none: false
|
150
|
-
requirements:
|
151
|
-
- -
|
152
|
-
- !ruby/object:Gem::Version
|
153
|
-
|
154
|
-
segments:
|
155
|
-
- 0
|
156
|
-
version: "0"
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
157
134
|
type: :runtime
|
158
|
-
requirement: *id009
|
159
135
|
prerelease: false
|
160
|
-
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
- !ruby/object:Gem::Dependency
|
161
143
|
name: actionpack
|
162
|
-
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
163
145
|
none: false
|
164
|
-
requirements:
|
165
|
-
- -
|
166
|
-
- !ruby/object:Gem::Version
|
167
|
-
|
168
|
-
segments:
|
169
|
-
- 0
|
170
|
-
version: "0"
|
146
|
+
requirements:
|
147
|
+
- - ! '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
171
150
|
type: :runtime
|
172
|
-
requirement: *id010
|
173
151
|
prerelease: false
|
174
|
-
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
- !ruby/object:Gem::Dependency
|
175
159
|
name: database_cleaner
|
176
|
-
|
160
|
+
requirement: !ruby/object:Gem::Requirement
|
177
161
|
none: false
|
178
|
-
requirements:
|
179
|
-
- -
|
180
|
-
- !ruby/object:Gem::Version
|
181
|
-
|
182
|
-
segments:
|
183
|
-
- 0
|
184
|
-
version: "0"
|
162
|
+
requirements:
|
163
|
+
- - ! '>='
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
185
166
|
type: :runtime
|
186
|
-
requirement: *id011
|
187
167
|
prerelease: false
|
188
|
-
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
none: false
|
170
|
+
requirements:
|
171
|
+
- - ! '>='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
description: acts_as_account implements double entry accounting for Rails models.
|
175
|
+
Your models get accounts and you can do consistent transactions between them. Since
|
176
|
+
the documentation is sparse, see the transfer.feature for usage examples.
|
189
177
|
email: thieso@gmail.com
|
190
178
|
executables: []
|
191
|
-
|
192
179
|
extensions: []
|
193
|
-
|
194
|
-
extra_rdoc_files:
|
180
|
+
extra_rdoc_files:
|
195
181
|
- LICENSE
|
196
182
|
- README.rdoc
|
197
|
-
files:
|
183
|
+
files:
|
184
|
+
- .rvmrc
|
198
185
|
- .specification
|
199
186
|
- Gemfile
|
200
187
|
- Gemfile.lock
|
@@ -202,13 +189,16 @@ files:
|
|
202
189
|
- README.rdoc
|
203
190
|
- Rakefile
|
204
191
|
- VERSION
|
192
|
+
- acts_as_account.gemspec
|
205
193
|
- cucumber.yml
|
206
194
|
- db/database.yml
|
207
195
|
- db/schema.rb
|
208
196
|
- features/account/account_creation.feature
|
209
197
|
- features/step_definitions/account_steps.rb
|
198
|
+
- features/support/abstract_user.rb
|
210
199
|
- features/support/cheque.rb
|
211
200
|
- features/support/env.rb
|
201
|
+
- features/support/inheriting_user.rb
|
212
202
|
- features/support/user.rb
|
213
203
|
- features/transfer/journal_creation.feature
|
214
204
|
- features/transfer/transfer.feature
|
@@ -223,36 +213,29 @@ files:
|
|
223
213
|
- lib/acts_as_account/transfer.rb
|
224
214
|
homepage: http://github.com/betterplace/acts_as_account
|
225
215
|
licenses: []
|
226
|
-
|
227
216
|
post_install_message:
|
228
217
|
rdoc_options: []
|
229
|
-
|
230
|
-
require_paths:
|
218
|
+
require_paths:
|
231
219
|
- lib
|
232
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
220
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
233
221
|
none: false
|
234
|
-
requirements:
|
235
|
-
- -
|
236
|
-
- !ruby/object:Gem::Version
|
237
|
-
|
238
|
-
segments:
|
222
|
+
requirements:
|
223
|
+
- - ! '>='
|
224
|
+
- !ruby/object:Gem::Version
|
225
|
+
version: '0'
|
226
|
+
segments:
|
239
227
|
- 0
|
240
|
-
|
241
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
228
|
+
hash: -237940272954950514
|
229
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
242
230
|
none: false
|
243
|
-
requirements:
|
244
|
-
- -
|
245
|
-
- !ruby/object:Gem::Version
|
246
|
-
|
247
|
-
segments:
|
248
|
-
- 0
|
249
|
-
version: "0"
|
231
|
+
requirements:
|
232
|
+
- - ! '>='
|
233
|
+
- !ruby/object:Gem::Version
|
234
|
+
version: '0'
|
250
235
|
requirements: []
|
251
|
-
|
252
236
|
rubyforge_project:
|
253
237
|
rubygems_version: 1.8.24
|
254
238
|
signing_key:
|
255
239
|
specification_version: 3
|
256
240
|
summary: acts_as_account implements double entry accounting for Rails models
|
257
241
|
test_files: []
|
258
|
-
|