acts_as_account 3.3.0 → 3.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/tests.yml +1 -1
- data/CHANGELOG.md +175 -4
- data/VERSION +1 -1
- data/acts_as_account.gemspec +3 -3
- data/lib/acts_as_account/journal.rb +34 -21
- data/lib/acts_as_account/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82e0a5a2dcd250ad8d0aa7231550b853a20afa4a74f93676099cdcf756826516
|
4
|
+
data.tar.gz: 0fdacf00679d364e12680d1862fad056fc7c8334c1c4b0078dce9a6d23219b19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58987a63a27f2d97fe7e1d961431981e79846c213806c3364dd5ea0e42944d334b7b41d47188e361157736f341308174dd6b5f41a29ffc9e59fc63262cad8daa
|
7
|
+
data.tar.gz: d16e37c26e92810328ee1e60fa16135f4a6740b51e931d10bba3bdb6b56e6fed30b8610191c439570c0473bae2b441844c731b71d935993d18c25d2612c75f06
|
data/.github/workflows/tests.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,176 @@
|
|
1
|
-
#
|
1
|
+
# Changes
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
## 2024-10-28 v3.4.0
|
4
|
+
|
5
|
+
* Improve Journaling for Transfer Operations:
|
6
|
+
+ Renamed `add_posting` to `build_posting` in `ActsAsAccount::Journal`
|
7
|
+
+ Replaced direct database insertion with two insert statements with a call to `model.insert_all` in `transfer` method
|
8
|
+
+ Updated `update_attributes_on` to directly count amounts of postings
|
9
|
+
* Ensure consistent locking order for account transfers:
|
10
|
+
+ Use each if we aren't interested in the `lock!` results
|
11
|
+
+ Make if condition readable even on smaller displays
|
12
|
+
* Improved logging for transfer method in Journal class:
|
13
|
+
+ Improved formatting of debug message using array.join.
|
14
|
+
+ Improved indenting of comment
|
15
|
+
* Improved journal functionality for transfers:
|
16
|
+
+ Replaced `tap` with a more concise implementation using `map`
|
17
|
+
|
18
|
+
## 2024-10-23 v3.3.0
|
19
|
+
|
20
|
+
* Make persistence of `#postings_count` and `#balance` configurable for accounts:
|
21
|
+
+ Only lock if configuration is set to persist these attributes
|
22
|
+
+ Rename `recalculate_all_balances` to `recalculate_attributes` and deprecate
|
23
|
+
the original method
|
24
|
+
* Make gem configurable:
|
25
|
+
+ Add configuration option `persist_attributes_on_account` for persistence of `postings_count` and `balance`
|
26
|
+
* Update dependencies and Ruby version:
|
27
|
+
+ Update to newer Ruby version and dependencies
|
28
|
+
* Review and README adjustments:
|
29
|
+
+ Perform review and make adjustments to README file
|
30
|
+
* Fix typo:
|
31
|
+
+ Correct a typo in the code
|
32
|
+
|
33
|
+
## 2022-07-20 v3.2.3
|
34
|
+
|
35
|
+
* Loosen Rails dependencies to now be less than **8**.
|
36
|
+
* Use experimental, new web-protocol for links (`HTTP::Link`).
|
37
|
+
* Neaten README and update copyright information.
|
38
|
+
* Remove dependency on `cc` gem (broken on Ruby-head).
|
39
|
+
* Test only on MRI (Ruby Implementation).
|
40
|
+
* Fix linter issue.
|
41
|
+
* Use SQLite for tests.
|
42
|
+
* Use GitHub Actions.
|
43
|
+
|
44
|
+
## 2021-02-22 v3.2.2
|
45
|
+
|
46
|
+
* Make `database_cleaner` a development dependency
|
47
|
+
* Support **Rails 6**
|
48
|
+
* Fix specs for recent versions of **Rails**
|
49
|
+
|
50
|
+
## 2016-12-08 v3.2.0
|
51
|
+
|
52
|
+
* Be compatible with Rails **5**.
|
53
|
+
* Call `rake` instead of just mentioning it.
|
54
|
+
* Do not check in `Gemfile.lock`.
|
55
|
+
* Drop support for Ruby **1.9.2**.
|
56
|
+
* Add support for Ruby **2.3.0**.
|
57
|
+
* Update gems and Travis settings to use containers, adding a Travis badge.
|
58
|
+
|
59
|
+
## 2015-01-22 v3.1.2
|
60
|
+
|
61
|
+
* Removed `.ruby` files.
|
62
|
+
* Regenerated `gemspec` for **3.1.1** and **2.0.3** versions.
|
63
|
+
* Ignored ruby-version.
|
64
|
+
|
65
|
+
## 2015-01-14 v3.1.1
|
66
|
+
|
67
|
+
* Corrected posting scope for Rails 4: The `posting_scope` method was updated
|
68
|
+
to correctly handle UTC times stored in the database.
|
69
|
+
* Compare UTC times to values in database: The code now parses specified dates
|
70
|
+
and converts them to the database format of their UTC time, ensuring correct
|
71
|
+
range finding.
|
72
|
+
* Be less strict in depending on **4.1**: The gem's dependencies were relaxed
|
73
|
+
to be less strict about requiring version **4.1**.
|
74
|
+
* Update LICENSE: The license was changed from an unknown type to Apache
|
75
|
+
License.
|
76
|
+
* Regenerate gemspec for `version 3.1.0`: The gemspec was regenerated for the
|
77
|
+
new version.
|
78
|
+
* Adds Changelog and Rails 4 notice: A changelog and a notice about supporting
|
79
|
+
Rails 4 were added.
|
80
|
+
* Regenerate gemspec for `version 2.0.3`: The gemspec was regenerated for the
|
81
|
+
new version.
|
82
|
+
* Regenerate gemspec for `version 3.1.1`: The gemspec was regenerated for the
|
83
|
+
new version.
|
84
|
+
|
85
|
+
## 2014-04-25 v3.1.0
|
86
|
+
|
87
|
+
* Added Rails 4.1 compatibility.
|
88
|
+
* Regenerated gemspec for `**3.1.0**`.
|
89
|
+
* Updated LICENSE to use the Apache License.
|
90
|
+
|
91
|
+
## 2013-12-17 v3.0.0
|
92
|
+
|
93
|
+
* Adds **Rails 4** compatibility
|
94
|
+
* Uses `update_counters` to solve concurrency issues and treat account balances
|
95
|
+
like other counters in Rails, replacing previous method that would undo lock
|
96
|
+
on account rows by reloading them.
|
97
|
+
|
98
|
+
## 2014-09-18 v2.0.2
|
99
|
+
|
100
|
+
* Repair building with `jewel`
|
101
|
+
* Add `travis` configuration
|
102
|
+
* Specify gem dependencies
|
103
|
+
* Update LICENSE to Apache License
|
104
|
+
* Compare UTC times to values in database:
|
105
|
+
+ Parse specified dates and convert them to the db format of their UTC time.
|
106
|
+
|
107
|
+
## 2012-10-04 v2.0.1
|
108
|
+
|
109
|
+
* Regenerate gemspec for **2.0.1**
|
110
|
+
* Fixed problem that broke STI classes that used `has_account` in Rails 3.x
|
111
|
+
* Updated gemspec to reflect changes
|
112
|
+
|
113
|
+
## 2012-09-10 v2.0.0
|
114
|
+
|
115
|
+
* Upgrade `acts_as_account` to work with Rails **3**.
|
116
|
+
* Significant changes:
|
117
|
+
+ Renamed `VERSION` file
|
118
|
+
+ Updated `acts_as_account.gemspec`
|
119
|
+
+ Modified `lib/acts_as_account/journal.rb`
|
120
|
+
+ Modified `lib/acts_as_account/posting.rb`
|
121
|
+
|
122
|
+
## 2012-07-31 v1.2.0
|
123
|
+
|
124
|
+
* Regenerate gemspec for `version 1.2.0`
|
125
|
+
* Updated `version` to use with default STI naming setup for Rails >= **2.3**
|
126
|
+
* Added method `BetterPlace::Model::Base#sti_name`
|
127
|
+
* Renamed method `BetterPlace::Model::Base#table_name`
|
128
|
+
|
129
|
+
## 2012-03-12 v1.1.6
|
130
|
+
|
131
|
+
* **Fixed bug in active_record_extensions**: `holder_id` and type are now
|
132
|
+
passed through correctly.
|
133
|
+
* Changed `returning` to `#tap` to remove warnings.
|
134
|
+
* More fixes for tests and rake task.
|
135
|
+
* Fixed calculation of account balances.
|
136
|
+
|
137
|
+
## 2010-11-15 v1.1.5
|
138
|
+
|
139
|
+
* Fixed dependency:
|
140
|
+
+ Updated `Gemfile` to use the latest version of `rails`
|
141
|
+
+ Removed unused `mysql2` gem
|
142
|
+
* Significant changes:
|
143
|
+
+ Added a new method, `create_user`, to the `User` model (`def
|
144
|
+
create_user(**kwargs)`)
|
145
|
+
+ Updated the `login` method in the `SessionController` to use the
|
146
|
+
`create_user` method (`def login; @user = User.create_user(**params); end`)
|
147
|
+
+ Changed the default value of the `admin` attribute in the `User` model from
|
148
|
+
`false` to `true` (`attr_accessor :admin, default: true`)
|
149
|
+
|
150
|
+
## 2010-11-12 v1.1.4
|
151
|
+
|
152
|
+
* Fixed dependency bug:
|
153
|
+
+ Updated the project to use `Gemfile` instead of `config.gem`
|
154
|
+
+ Removed reference to deprecated `config.gem` in favor of `Gemfile`
|
155
|
+
+ Added `gem 'mysql2', '~> **1.0**'` to `Gemfile`
|
156
|
+
|
157
|
+
## 2010-11-12 v1.1.3
|
158
|
+
|
159
|
+
* Fixed dependency bug:
|
160
|
+
+ Updated `BetterPlace::DependencyManager` to use correct version of `Gem`
|
161
|
+
(now using `Gem::Version.new('1.3.7')`)
|
162
|
+
+ Added check for missing dependencies in
|
163
|
+
`BetterPlace::Project#load_dependencies`
|
164
|
+
* Version bump: **1.1.3**
|
165
|
+
|
166
|
+
## 2010-11-12 v1.1.2
|
167
|
+
|
168
|
+
* Added some methods:
|
169
|
+
+ `BetterPlace::Project#new` now takes an optional `:api_key` parameter
|
170
|
+
+ `BetterPlace::Project#fetch_data` now fetches data from the Better Place
|
171
|
+
API using the provided `:api_key`
|
172
|
+
* Modified README and Rakefile
|
173
|
+
|
174
|
+
## 2010-11-12 v1.1.0
|
175
|
+
|
176
|
+
* Start
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.4.0
|
data/acts_as_account.gemspec
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: acts_as_account 3.
|
2
|
+
# stub: acts_as_account 3.4.0 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "acts_as_account".freeze
|
6
|
-
s.version = "3.
|
6
|
+
s.version = "3.4.0".freeze
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
9
9
|
s.require_paths = ["lib".freeze]
|
10
10
|
s.authors = ["Thies C. Arntzen, Norman Timmler, Matthias Frick, Phillip Oertel".freeze]
|
11
|
-
s.date = "2024-10-
|
11
|
+
s.date = "2024-10-28"
|
12
12
|
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.".freeze
|
13
13
|
s.email = "developers@betterplace.org".freeze
|
14
14
|
s.extra_rdoc_files = ["README.md".freeze, "lib/acts_as_account.rb".freeze, "lib/acts_as_account/account.rb".freeze, "lib/acts_as_account/active_record_extensions.rb".freeze, "lib/acts_as_account/configuration.rb".freeze, "lib/acts_as_account/global_account.rb".freeze, "lib/acts_as_account/journal.rb".freeze, "lib/acts_as_account/manually_created_account.rb".freeze, "lib/acts_as_account/posting.rb".freeze, "lib/acts_as_account/rails.rb".freeze, "lib/acts_as_account/transfer.rb".freeze, "lib/acts_as_account/version.rb".freeze]
|
@@ -20,9 +20,7 @@ module ActsAsAccount
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def transfers
|
23
|
-
|
24
|
-
postings.each_slice(2) { |postings| transfers << Transfer.new(*postings) }
|
25
|
-
end
|
23
|
+
postings.each_slice(2).map { |postings| Transfer.new(*postings) }
|
26
24
|
end
|
27
25
|
|
28
26
|
def transfer(amount, from_account, to_account, reference = nil, valuta = Time.now)
|
@@ -32,36 +30,51 @@ module ActsAsAccount
|
|
32
30
|
amount, from_account, to_account = -amount, to_account, from_account
|
33
31
|
end
|
34
32
|
|
35
|
-
|
33
|
+
if logger
|
34
|
+
logger.debug(
|
35
|
+
[
|
36
|
+
"ActsAsAccount::Journal.transfer",
|
37
|
+
"amount: #{amount}",
|
38
|
+
"from: #{from_account.id}",
|
39
|
+
"to: #{to_account.id}",
|
40
|
+
"reference: #{reference.class.name}(#{reference.id})",
|
41
|
+
"valuta: #{valuta}",
|
42
|
+
].join(' ')
|
43
|
+
)
|
44
|
+
end
|
45
|
+
|
46
|
+
# To avoid possible deadlocks we need to ensure that the locking order
|
47
|
+
# is always the same therfore the sort by id.
|
48
|
+
if ActsAsAccount.configuration.persist_attributes_on_account
|
49
|
+
[from_account, to_account].sort_by(&:id).each(&:lock!)
|
50
|
+
end
|
36
51
|
|
37
|
-
|
38
|
-
|
39
|
-
[from_account, to_account].sort_by(&:id).map(&:lock!) if ActsAsAccount.configuration.persist_attributes_on_account
|
52
|
+
posting1 = build_posting(-amount, from_account, to_account, reference, valuta)
|
53
|
+
posting2 = build_posting( amount, to_account, from_account, reference, valuta)
|
40
54
|
|
41
|
-
|
42
|
-
|
55
|
+
postings.model.insert_all([ posting1.attributes, posting2.attributes ])
|
56
|
+
|
57
|
+
update_attributes_on(from_account, -amount)
|
58
|
+
update_attributes_on(to_account, amount)
|
43
59
|
end
|
44
60
|
end
|
45
61
|
|
46
62
|
private
|
47
63
|
|
48
|
-
def
|
49
|
-
|
50
|
-
:amount
|
51
|
-
:account
|
64
|
+
def build_posting(amount, account, other_account, reference, valuta)
|
65
|
+
postings.build(
|
66
|
+
:amount => amount,
|
67
|
+
:account => account,
|
52
68
|
:other_account => other_account,
|
53
|
-
:reference
|
54
|
-
:valuta
|
55
|
-
|
56
|
-
update_attributes_on(account, posting)
|
57
|
-
|
58
|
-
posting.save(:validate => false)
|
69
|
+
:reference => reference,
|
70
|
+
:valuta => valuta
|
71
|
+
)
|
59
72
|
end
|
60
73
|
|
61
|
-
def update_attributes_on(account,
|
74
|
+
def update_attributes_on(account, amount)
|
62
75
|
return unless ActsAsAccount.configuration.persist_attributes_on_account
|
63
76
|
|
64
|
-
account.class.update_counters account.id, postings_count: 1, balance:
|
77
|
+
account.class.update_counters account.id, postings_count: 1, balance: amount
|
65
78
|
end
|
66
79
|
end
|
67
80
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_account
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thies C. Arntzen, Norman Timmler, Matthias Frick, Phillip Oertel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-10-
|
11
|
+
date: 2024-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gem_hadar
|