double_entry 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +13 -16
- data/README.md +6 -6
- data/Rakefile +0 -6
- data/double_entry.gemspec +11 -11
- data/lib/double_entry/line.rb +4 -4
- data/lib/double_entry/reporting/line_aggregate_filter.rb +4 -6
- data/lib/double_entry/transfer.rb +1 -1
- data/lib/double_entry/version.rb +1 -1
- data/script/jack_hammer +2 -4
- data/spec/generators/double_entry/install/install_generator_spec.rb +2 -2
- data/spec/spec_helper.rb +5 -0
- data/spec/support/gemfiles/Gemfile.rails-3.2.x +2 -1
- data/spec/support/gemfiles/Gemfile.rails-4.1.x +1 -0
- data/spec/support/gemfiles/Gemfile.rails-5.0.x +5 -0
- metadata +12 -10
- data/.rubocop.yml +0 -65
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d879d4baf12d4479b4533fb5032c27c0ef4968f
|
4
|
+
data.tar.gz: dfeda86d6a9147c2cb99313c3136f1fe2bbe3ca3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4415c2eae26420297541d515cabf79eb2eb7833c10c4984724e391d9f3ebad20f86178837fad21ee91baebf9ee57332554c617a2ab3cb856375b21df9a92dc07
|
7
|
+
data.tar.gz: 45c892f2e32784e8aefcbadb014372729e59ce9089c7ab5ebd075679b50be04a87bc5b81f9c00638dca4d79466cd18a6390f8b970a24ed9377d3eaabf89d83b3
|
data/.travis.yml
CHANGED
@@ -1,32 +1,29 @@
|
|
1
1
|
language: ruby
|
2
|
+
sudo: false
|
2
3
|
before_script:
|
3
4
|
- cp spec/support/database.travis.yml spec/support/database.yml
|
4
5
|
- mysql -e 'create database double_entry_test;'
|
5
6
|
- psql -c 'create database double_entry_test;' -U postgres
|
6
7
|
script:
|
7
|
-
- rake spec
|
8
|
+
- bundle exec rake spec
|
8
9
|
- ruby script/jack_hammer -t 2000
|
9
|
-
- rake rubocop
|
10
10
|
matrix:
|
11
11
|
include:
|
12
|
-
- rvm: 1
|
13
|
-
gemfile: spec/support/gemfiles/Gemfile.rails-
|
14
|
-
env: DB=mysql
|
15
|
-
- rvm: 2.0.0
|
16
|
-
gemfile: spec/support/gemfiles/Gemfile.rails-4.2.x
|
12
|
+
- rvm: 2.1
|
13
|
+
gemfile: spec/support/gemfiles/Gemfile.rails-3.2.x
|
17
14
|
env: DB=mysql
|
18
|
-
- rvm: 2.2
|
15
|
+
- rvm: 2.2
|
19
16
|
gemfile: spec/support/gemfiles/Gemfile.rails-4.1.x
|
20
17
|
env: DB=mysql
|
21
|
-
- rvm: 2.2
|
18
|
+
- rvm: 2.2
|
22
19
|
gemfile: spec/support/gemfiles/Gemfile.rails-4.2.x
|
23
20
|
env: DB=mysql
|
24
|
-
- rvm: 2.
|
25
|
-
gemfile: spec/support/gemfiles/Gemfile.rails-
|
21
|
+
- rvm: 2.3
|
22
|
+
gemfile: spec/support/gemfiles/Gemfile.rails-5.0.x
|
23
|
+
env: DB=mysql
|
24
|
+
- rvm: 2.3
|
25
|
+
gemfile: spec/support/gemfiles/Gemfile.rails-5.0.x
|
26
26
|
env: DB=sqlite
|
27
|
-
- rvm: 2.
|
28
|
-
gemfile: spec/support/gemfiles/Gemfile.rails-
|
27
|
+
- rvm: 2.3
|
28
|
+
gemfile: spec/support/gemfiles/Gemfile.rails-5.0.x
|
29
29
|
env: DB=postgres
|
30
|
-
- rvm: 2.1.6
|
31
|
-
gemfile: spec/support/gemfiles/Gemfile.rails-3.2.x
|
32
|
-
env: DB=mysql
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
[](https://github.com/envato/double_entry/blob/master/LICENSE.md)
|
5
5
|
[](http://badge.fury.io/rb/double_entry)
|
6
|
-
[](https://travis-ci.org/envato/double_entry)
|
7
7
|
[](https://codeclimate.com/github/envato/double_entry)
|
8
8
|
|
9
9
|

|
@@ -22,15 +22,15 @@ DoubleEntry uses the [Money gem](https://github.com/RubyMoney/money) to encapsul
|
|
22
22
|
DoubleEntry is tested against:
|
23
23
|
|
24
24
|
Ruby
|
25
|
-
* 1.
|
26
|
-
* 2.
|
27
|
-
* 2.
|
28
|
-
* 2.2.0
|
25
|
+
* 2.1.x
|
26
|
+
* 2.2.x
|
27
|
+
* 2.3.x
|
29
28
|
|
30
29
|
Rails
|
31
30
|
* 3.2.x
|
32
31
|
* 4.1.x
|
33
32
|
* 4.2.x
|
33
|
+
* 5.0.x
|
34
34
|
|
35
35
|
Databases
|
36
36
|
* MySQL
|
@@ -227,7 +227,7 @@ Run a concurrency test on the code.
|
|
227
227
|
This spawns a bunch of processes, and does random transactions between a set
|
228
228
|
of accounts, then validates that all the numbers add up at the end.
|
229
229
|
|
230
|
-
You can also tell
|
230
|
+
You can also tell it to flush out the account balances table at regular
|
231
231
|
intervals, to validate that new account balances records get created with the
|
232
232
|
correct balances from the lines table.
|
233
233
|
|
data/Rakefile
CHANGED
@@ -1,21 +1,15 @@
|
|
1
1
|
require 'rspec/core/rake_task'
|
2
2
|
require 'bundler/gem_tasks'
|
3
|
-
require 'rubocop/rake_task'
|
4
3
|
|
5
4
|
RSpec::Core::RakeTask.new(:spec) do |t|
|
6
5
|
t.verbose = false
|
7
6
|
t.ruby_opts = '-w'
|
8
7
|
end
|
9
8
|
|
10
|
-
RuboCop::RakeTask.new(:rubocop) do |t|
|
11
|
-
t.fail_on_error = true
|
12
|
-
end
|
13
|
-
|
14
9
|
task :default do
|
15
10
|
%w(mysql postgres sqlite).each do |db|
|
16
11
|
puts "Running tests with `DB=#{db}`"
|
17
12
|
ENV['DB'] = db
|
18
13
|
Rake::Task['spec'].execute
|
19
14
|
end
|
20
|
-
Rake::Task['rubocop'].execute
|
21
15
|
end
|
data/double_entry.gemspec
CHANGED
@@ -5,17 +5,17 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
5
|
require 'double_entry/version'
|
6
6
|
|
7
7
|
Gem::Specification.new do |gem|
|
8
|
-
gem.name
|
9
|
-
gem.version
|
10
|
-
gem.authors
|
11
|
-
gem.email
|
12
|
-
gem.summary
|
13
|
-
gem.homepage
|
8
|
+
gem.name = 'double_entry'
|
9
|
+
gem.version = DoubleEntry::VERSION
|
10
|
+
gem.authors = ['Anthony Sellitti', 'Keith Pitt', 'Martin Jagusch', 'Martin Spickermann', 'Mark Turnley', 'Orien Madgwick', 'Pete Yandall', 'Stephanie Staub', 'Giancarlo Salamanca']
|
11
|
+
gem.email = ['anthony.sellitti@envato.com', 'me@keithpitt.com', '_@mj.io', 'spickemann@gmail.com', 'mark@envato.com', '_@orien.io', 'pete@envato.com', 'staub.steph@gmail.com', 'giancarlo@salamanca.net.au']
|
12
|
+
gem.summary = 'Tools to build your double entry financial ledger'
|
13
|
+
gem.homepage = 'https://github.com/envato/double_entry'
|
14
14
|
|
15
|
-
gem.files
|
16
|
-
gem.executables
|
17
|
-
gem.test_files
|
18
|
-
gem.require_paths
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{bin/}).map { |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ['lib']
|
19
19
|
|
20
20
|
gem.post_install_message = <<-'POSTINSTALLMESSAGE'
|
21
21
|
Please note the following changes in DoubleEntry:
|
@@ -62,7 +62,7 @@ POSTINSTALLMESSAGE
|
|
62
62
|
gem.add_development_dependency 'generator_spec'
|
63
63
|
gem.add_development_dependency 'machinist'
|
64
64
|
gem.add_development_dependency 'timecop'
|
65
|
-
gem.add_development_dependency '
|
65
|
+
gem.add_development_dependency 'test-unit'
|
66
66
|
|
67
67
|
gem.add_development_dependency 'pry'
|
68
68
|
gem.add_development_dependency 'pry-doc'
|
data/lib/double_entry/line.rb
CHANGED
@@ -132,11 +132,11 @@ module DoubleEntry
|
|
132
132
|
end
|
133
133
|
|
134
134
|
def decrease?
|
135
|
-
amount
|
135
|
+
amount.negative?
|
136
136
|
end
|
137
137
|
|
138
138
|
def increase?
|
139
|
-
amount
|
139
|
+
amount.positive?
|
140
140
|
end
|
141
141
|
|
142
142
|
# Query out just the id and created_at fields for lines, without
|
@@ -151,10 +151,10 @@ module DoubleEntry
|
|
151
151
|
private
|
152
152
|
|
153
153
|
def check_balance_will_remain_valid
|
154
|
-
if account.positive_only && balance
|
154
|
+
if account.positive_only && balance.negative?
|
155
155
|
fail AccountWouldBeSentNegative, account
|
156
156
|
end
|
157
|
-
if account.negative_only && balance
|
157
|
+
if account.negative_only && balance.positive?
|
158
158
|
fail AccountWouldBeSentPositiveError, account
|
159
159
|
end
|
160
160
|
end
|
@@ -15,13 +15,11 @@ module DoubleEntry
|
|
15
15
|
|
16
16
|
private
|
17
17
|
|
18
|
-
attr_reader :account, :code, :range, :filter_criteria
|
19
|
-
|
20
18
|
def apply_filters
|
21
19
|
collection = apply_filter_criteria.
|
22
|
-
where(:account => account).
|
23
|
-
where(:created_at => range.start
|
24
|
-
collection = collection.where(:code => code) if code
|
20
|
+
where(:account => @account).
|
21
|
+
where(:created_at => @range.start..@range.finish)
|
22
|
+
collection = collection.where(:code => @code) if @code
|
25
23
|
|
26
24
|
collection
|
27
25
|
end
|
@@ -52,7 +50,7 @@ module DoubleEntry
|
|
52
50
|
# }
|
53
51
|
# ]
|
54
52
|
def apply_filter_criteria
|
55
|
-
filter_criteria.reduce(DoubleEntry::Line) do |collection, filter|
|
53
|
+
@filter_criteria.reduce(DoubleEntry::Line) do |collection, filter|
|
56
54
|
if filter[:scope].present?
|
57
55
|
filter_by_scope(collection, filter[:scope])
|
58
56
|
elsif filter[:metadata].present?
|
@@ -16,7 +16,7 @@ module DoubleEntry
|
|
16
16
|
|
17
17
|
# @api private
|
18
18
|
def transfer(amount, options = {})
|
19
|
-
fail TransferIsNegative if amount
|
19
|
+
fail TransferIsNegative if amount.negative?
|
20
20
|
from_account = options[:from]
|
21
21
|
to_account = options[:to]
|
22
22
|
code = options[:code]
|
data/lib/double_entry/version.rb
CHANGED
data/script/jack_hammer
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
# This spawns a bunch of processes, and does random transactions between a set
|
6
6
|
# of accounts, then validates that all the numbers add up at the end.
|
7
7
|
#
|
8
|
-
# You can also tell
|
8
|
+
# You can also tell it to flush our the account balances table at regular
|
9
9
|
# intervals, to validate that new account balances records get created with the
|
10
10
|
# correct balances from the lines table.
|
11
11
|
#
|
@@ -109,6 +109,7 @@ def run_tests
|
|
109
109
|
$balance_flush_count.times do
|
110
110
|
puts "Flushing balances"
|
111
111
|
DoubleEntry::AccountBalance.delete_all
|
112
|
+
ActiveRecord::Base.connection_pool.disconnect!
|
112
113
|
|
113
114
|
if $use_threads
|
114
115
|
puts "Using threads as workers"
|
@@ -127,14 +128,11 @@ def run_tests
|
|
127
128
|
|
128
129
|
pids.each {|pid| Process.wait2(pid) }
|
129
130
|
end
|
130
|
-
|
131
|
-
ActiveRecord::Base.connection_pool.disconnect!
|
132
131
|
end
|
133
132
|
end
|
134
133
|
|
135
134
|
|
136
135
|
def run_process(iterations, process_num)
|
137
|
-
ActiveRecord::Base.connection_pool.disconnect! # Get a unique DB connection for this process.
|
138
136
|
srand # Seed the random number generator separately for each process.
|
139
137
|
|
140
138
|
puts "Process #{process_num} running #{iterations} transfers..."
|
@@ -13,7 +13,7 @@ RSpec.describe DoubleEntry::Generators::InstallGenerator do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
specify do
|
16
|
-
expect(destination_root).to have_structure
|
16
|
+
expect(destination_root).to have_structure {
|
17
17
|
directory 'db' do
|
18
18
|
directory 'migrate' do
|
19
19
|
migration 'create_double_entry_tables' do
|
@@ -25,6 +25,6 @@ RSpec.describe DoubleEntry::Generators::InstallGenerator do
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
28
|
-
|
28
|
+
}
|
29
29
|
end
|
30
30
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: double_entry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anthony Sellitti
|
@@ -12,10 +12,11 @@ authors:
|
|
12
12
|
- Orien Madgwick
|
13
13
|
- Pete Yandall
|
14
14
|
- Stephanie Staub
|
15
|
+
- Giancarlo Salamanca
|
15
16
|
autorequire:
|
16
17
|
bindir: bin
|
17
18
|
cert_chain: []
|
18
|
-
date:
|
19
|
+
date: 2018-01-06 00:00:00.000000000 Z
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
22
|
name: money
|
@@ -228,19 +229,19 @@ dependencies:
|
|
228
229
|
- !ruby/object:Gem::Version
|
229
230
|
version: '0'
|
230
231
|
- !ruby/object:Gem::Dependency
|
231
|
-
name:
|
232
|
+
name: test-unit
|
232
233
|
requirement: !ruby/object:Gem::Requirement
|
233
234
|
requirements:
|
234
|
-
- - "
|
235
|
+
- - ">="
|
235
236
|
- !ruby/object:Gem::Version
|
236
|
-
version: 0
|
237
|
+
version: '0'
|
237
238
|
type: :development
|
238
239
|
prerelease: false
|
239
240
|
version_requirements: !ruby/object:Gem::Requirement
|
240
241
|
requirements:
|
241
|
-
- - "
|
242
|
+
- - ">="
|
242
243
|
- !ruby/object:Gem::Version
|
243
|
-
version: 0
|
244
|
+
version: '0'
|
244
245
|
- !ruby/object:Gem::Dependency
|
245
246
|
name: pry
|
246
247
|
requirement: !ruby/object:Gem::Requirement
|
@@ -335,13 +336,13 @@ email:
|
|
335
336
|
- _@orien.io
|
336
337
|
- pete@envato.com
|
337
338
|
- staub.steph@gmail.com
|
339
|
+
- giancarlo@salamanca.net.au
|
338
340
|
executables: []
|
339
341
|
extensions: []
|
340
342
|
extra_rdoc_files: []
|
341
343
|
files:
|
342
344
|
- ".gitignore"
|
343
345
|
- ".rspec"
|
344
|
-
- ".rubocop.yml"
|
345
346
|
- ".travis.yml"
|
346
347
|
- ".yardopts"
|
347
348
|
- Gemfile
|
@@ -412,6 +413,7 @@ files:
|
|
412
413
|
- spec/support/gemfiles/Gemfile.rails-3.2.x
|
413
414
|
- spec/support/gemfiles/Gemfile.rails-4.1.x
|
414
415
|
- spec/support/gemfiles/Gemfile.rails-4.2.x
|
416
|
+
- spec/support/gemfiles/Gemfile.rails-5.0.x
|
415
417
|
- spec/support/performance_helper.rb
|
416
418
|
- spec/support/reporting_configuration.rb
|
417
419
|
- spec/support/schema.rb
|
@@ -459,7 +461,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
459
461
|
version: '0'
|
460
462
|
requirements: []
|
461
463
|
rubyforge_project:
|
462
|
-
rubygems_version: 2.
|
464
|
+
rubygems_version: 2.5.2
|
463
465
|
signing_key:
|
464
466
|
specification_version: 4
|
465
467
|
summary: Tools to build your double entry financial ledger
|
@@ -495,7 +497,7 @@ test_files:
|
|
495
497
|
- spec/support/gemfiles/Gemfile.rails-3.2.x
|
496
498
|
- spec/support/gemfiles/Gemfile.rails-4.1.x
|
497
499
|
- spec/support/gemfiles/Gemfile.rails-4.2.x
|
500
|
+
- spec/support/gemfiles/Gemfile.rails-5.0.x
|
498
501
|
- spec/support/performance_helper.rb
|
499
502
|
- spec/support/reporting_configuration.rb
|
500
503
|
- spec/support/schema.rb
|
501
|
-
has_rdoc:
|
data/.rubocop.yml
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
AllCops:
|
2
|
-
Exclude:
|
3
|
-
- .bundle/**/*
|
4
|
-
- bin/**/*
|
5
|
-
- tmp/**/*
|
6
|
-
- script/jack_hammer
|
7
|
-
- spec/support/schema.rb
|
8
|
-
- lib/generators/double_entry/install/templates/**/*
|
9
|
-
|
10
|
-
Style/AccessModifierIndentation:
|
11
|
-
EnforcedStyle: outdent
|
12
|
-
|
13
|
-
Style/DotPosition:
|
14
|
-
EnforcedStyle: trailing
|
15
|
-
|
16
|
-
Style/GuardClause:
|
17
|
-
Enabled: false
|
18
|
-
|
19
|
-
Style/HashSyntax:
|
20
|
-
EnforcedStyle: hash_rockets
|
21
|
-
|
22
|
-
Style/SpecialGlobalVars:
|
23
|
-
Enabled: false
|
24
|
-
|
25
|
-
Style/TrailingComma:
|
26
|
-
EnforcedStyleForMultiline: comma
|
27
|
-
|
28
|
-
# TODO Enable these checks and fix codes
|
29
|
-
|
30
|
-
Style/ClassVars:
|
31
|
-
Enabled: false
|
32
|
-
|
33
|
-
Style/Documentation:
|
34
|
-
Enabled: false
|
35
|
-
|
36
|
-
Style/DoubleNegation:
|
37
|
-
Enabled: false
|
38
|
-
|
39
|
-
Style/ModuleFunction:
|
40
|
-
Enabled: false
|
41
|
-
|
42
|
-
Style/ParallelAssignment:
|
43
|
-
Enabled: false
|
44
|
-
|
45
|
-
Style/SingleLineBlockParams:
|
46
|
-
Enabled: false
|
47
|
-
|
48
|
-
Metrics/AbcSize:
|
49
|
-
Max: 47 #15
|
50
|
-
|
51
|
-
Metrics/CyclomaticComplexity:
|
52
|
-
Max: 13 #6
|
53
|
-
|
54
|
-
Metrics/LineLength:
|
55
|
-
Max: 185
|
56
|
-
|
57
|
-
Metrics/MethodLength:
|
58
|
-
Max: 30 # 10
|
59
|
-
|
60
|
-
Metrics/ModuleLength:
|
61
|
-
Exclude:
|
62
|
-
- spec/**/*
|
63
|
-
|
64
|
-
Metrics/PerceivedComplexity:
|
65
|
-
Max: 13 #7
|