plutus 0.17 → 0.18
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/README.markdown +12 -3
- data/app/assets/config/plutus/manifest.js +1 -0
- data/app/controllers/plutus/accounts_controller.rb +1 -1
- data/app/controllers/plutus/entries_controller.rb +1 -1
- data/app/controllers/plutus/reports_controller.rb +1 -1
- data/app/models/plutus/entry.rb +26 -27
- data/lib/plutus/engine.rb +2 -0
- data/lib/plutus/version.rb +1 -1
- data/spec/factories/entry_factory.rb +5 -4
- data/spec/factories/tenant_factory.rb +2 -2
- data/spec/models/entry_spec.rb +2 -1
- data/spec/models/tenancy_spec.rb +26 -26
- data/spec/support/active_support_helpers.rb +3 -10
- metadata +45 -48
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 527073217d3b110f92779b2a83fba46bd0b1b6e97dfc05bd30eaf4b42aca4b21
|
4
|
+
data.tar.gz: 96b50d4b7a669ff08a94ac473fc82b614210e98df5bf555378df6294e8a2c8c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5e0efef2af327b812c8073ccbeddc83c1e86907d597190b8c52a513b6d7c0c5933fad05bd750ea30c5594072a09c690cd3c4aef33b6575260b7bf30cc158eff
|
7
|
+
data.tar.gz: e777f29f0d83e3eafffe6f5ef71a01d44e18beb70807977358c5d5ac6a97025e329a3690b7dcd30f9eaf231206d759bb5a8a1b203e62ed4578a039d29d8c4bf2
|
data/README.markdown
CHANGED
@@ -7,8 +7,8 @@ The Plutus plugin is a Ruby on Rails Engine which provides a double entry accoun
|
|
7
7
|
Compatibility
|
8
8
|
=============
|
9
9
|
|
10
|
-
* Ruby versions: MRI 2.
|
11
|
-
* Rails versions: ~>
|
10
|
+
* Ruby versions: MRI 2.7+
|
11
|
+
* Rails versions: ~> 7.0
|
12
12
|
|
13
13
|
For earlier versions, and upgrading, please see the section titled [Previous Versions](https://github.com/mbulat/plutus#previous-versions)
|
14
14
|
|
@@ -310,7 +310,7 @@ The Engine provides controllers and views for rendering basic reports, including
|
|
310
310
|
|
311
311
|
These views and controllers are read-only for reporting purposes. It is assumed entry creation will occur within your applications code.
|
312
312
|
|
313
|
-
Routing is supplied via an engine mount point. Plutus can be mounted on a subpath in your existing Rails
|
313
|
+
Routing is supplied via an engine mount point. Plutus can be mounted on a subpath in your existing Rails app by adding the following to your routes.rb:
|
314
314
|
|
315
315
|
```ruby
|
316
316
|
mount Plutus::Engine => "/plutus", :as => "plutus"
|
@@ -320,6 +320,15 @@ mount Plutus::Engine => "/plutus", :as => "plutus"
|
|
320
320
|
|
321
321
|
*Future versions of plutus will allow for customization of authentication.*
|
322
322
|
|
323
|
+
Sprockets 4+
|
324
|
+
------------
|
325
|
+
|
326
|
+
You must require Plutus' manifest.js in your app manifest.js:
|
327
|
+
|
328
|
+
```
|
329
|
+
//= link plutus/manifest.js
|
330
|
+
```
|
331
|
+
|
323
332
|
|
324
333
|
Previous Versions
|
325
334
|
=================
|
@@ -0,0 +1 @@
|
|
1
|
+
//= link plutus/application.css
|
data/app/models/plutus/entry.rb
CHANGED
@@ -25,53 +25,52 @@ module Plutus
|
|
25
25
|
before_save :default_date
|
26
26
|
|
27
27
|
if ActiveRecord::VERSION::MAJOR > 4
|
28
|
-
belongs_to :commercial_document, :
|
28
|
+
belongs_to :commercial_document, polymorphic: true, optional: true
|
29
29
|
else
|
30
|
-
belongs_to :commercial_document, :
|
30
|
+
belongs_to :commercial_document, polymorphic: true
|
31
31
|
end
|
32
32
|
|
33
|
-
has_many :credit_amounts, :
|
34
|
-
has_many :debit_amounts, :
|
35
|
-
has_many :credit_accounts, :
|
36
|
-
has_many :debit_accounts, :
|
33
|
+
has_many :credit_amounts, extend: AmountsExtension, class_name: 'Plutus::CreditAmount', inverse_of: :entry
|
34
|
+
has_many :debit_amounts, extend: AmountsExtension, class_name: 'Plutus::DebitAmount', inverse_of: :entry
|
35
|
+
has_many :credit_accounts, through: :credit_amounts, source: :account, class_name: 'Plutus::Account'
|
36
|
+
has_many :debit_accounts, through: :debit_amounts, source: :account, class_name: 'Plutus::Account'
|
37
37
|
|
38
38
|
validates_presence_of :description
|
39
|
-
validate :
|
40
|
-
validate :
|
39
|
+
validate :credit_amounts?
|
40
|
+
validate :debit_amounts?
|
41
41
|
validate :amounts_cancel?
|
42
42
|
|
43
43
|
# Support construction using 'credits' and 'debits' keys
|
44
44
|
accepts_nested_attributes_for :credit_amounts, :debit_amounts, allow_destroy: true
|
45
|
-
|
46
|
-
|
45
|
+
alias credits= credit_amounts_attributes=
|
46
|
+
alias debits= debit_amounts_attributes=
|
47
47
|
# attr_accessible :credits, :debits
|
48
48
|
|
49
|
+
def default_date
|
50
|
+
todays_date = ActiveRecord.default_timezone == :utc ? Time.now.utc : Time.now
|
51
|
+
self.date ||= todays_date
|
52
|
+
end
|
53
|
+
|
49
54
|
# Support the deprecated .build method
|
50
55
|
def self.build(hash)
|
51
56
|
ActiveSupport::Deprecation.warn('Plutus::Transaction.build() is deprecated (use new instead)', caller)
|
52
57
|
new(hash)
|
53
58
|
end
|
54
59
|
|
55
|
-
|
56
|
-
super
|
57
|
-
end
|
60
|
+
private
|
58
61
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
self.date ||= todays_date
|
63
|
-
end
|
64
|
-
|
65
|
-
def has_credit_amounts?
|
66
|
-
errors[:base] << "Entry must have at least one credit amount" if self.credit_amounts.blank?
|
67
|
-
end
|
62
|
+
def credit_amounts?
|
63
|
+
errors.add(:base, 'Entry must have at least one credit amount') if credit_amounts.blank?
|
64
|
+
end
|
68
65
|
|
69
|
-
|
70
|
-
|
71
|
-
|
66
|
+
def debit_amounts?
|
67
|
+
errors.add(:base, 'Entry must have at least one debit amount') if debit_amounts.blank?
|
68
|
+
end
|
72
69
|
|
73
|
-
|
74
|
-
|
70
|
+
def amounts_cancel?
|
71
|
+
if credit_amounts.balance_for_new_record != debit_amounts.balance_for_new_record
|
72
|
+
errors.add(:base, 'The credit and debit amounts are not equal')
|
75
73
|
end
|
74
|
+
end
|
76
75
|
end
|
77
76
|
end
|
data/lib/plutus/engine.rb
CHANGED
data/lib/plutus/version.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
FactoryGirl.define do
|
2
|
-
factory :entry, :
|
2
|
+
factory :entry, class: Plutus::Entry do |entry|
|
3
3
|
entry.description { 'factory description' }
|
4
|
-
|
4
|
+
|
5
|
+
factory :entry_with_credit_and_debit, class: Plutus::Entry do |entry_cd|
|
5
6
|
entry_cd.after_build do |t|
|
6
|
-
t.credit_amounts << FactoryGirl.build(:credit_amount, :
|
7
|
-
t.debit_amounts << FactoryGirl.build(:debit_amount, :
|
7
|
+
t.credit_amounts << FactoryGirl.build(:credit_amount, entry: t)
|
8
|
+
t.debit_amounts << FactoryGirl.build(:debit_amount, entry: t)
|
8
9
|
end
|
9
10
|
end
|
10
11
|
end
|
data/spec/models/entry_spec.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'debug'
|
2
3
|
|
3
4
|
module Plutus
|
4
5
|
describe Entry do
|
5
6
|
let(:entry) { FactoryGirl.build(:entry) }
|
6
7
|
subject { entry }
|
7
8
|
|
8
|
-
it { is_expected.not_to be_valid }
|
9
|
+
it { is_expected.not_to be_valid }
|
9
10
|
|
10
11
|
context "with credit and debit" do
|
11
12
|
let(:entry) { FactoryGirl.build(:entry_with_credit_and_debit) }
|
data/spec/models/tenancy_spec.rb
CHANGED
@@ -3,58 +3,58 @@ require 'spec_helper'
|
|
3
3
|
module Plutus
|
4
4
|
describe Account do
|
5
5
|
describe 'tenancy support' do
|
6
|
-
|
6
|
+
|
7
7
|
before(:all) do
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
m = ActiveRecord::Migration.new
|
9
|
+
m.verbose = false
|
10
|
+
m.create_table :plutus_tenants do |t|
|
11
|
+
t.string :name
|
12
|
+
end
|
13
13
|
end
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
14
|
+
|
15
|
+
after :all do
|
16
|
+
m = ActiveRecord::Migration.new
|
17
|
+
m.verbose = false
|
18
|
+
m.drop_table :plutus_tenants
|
19
|
+
end
|
20
|
+
|
21
21
|
before(:each) do
|
22
|
-
ActiveSupportHelpers.clear_model('Account')
|
23
|
-
ActiveSupportHelpers.clear_model('Asset')
|
24
|
-
|
25
22
|
Plutus.enable_tenancy = true
|
26
23
|
Plutus.tenant_class = 'Plutus::Tenant'
|
27
|
-
|
24
|
+
|
25
|
+
ActiveSupportHelpers.reload_model('Account')
|
26
|
+
ActiveSupportHelpers.reload_model('Asset')
|
27
|
+
|
28
28
|
FactoryGirlHelpers.reload()
|
29
29
|
Plutus::Asset.new
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
after(:each) do
|
33
33
|
if Plutus.const_defined?(:Asset)
|
34
|
-
ActiveSupportHelpers.
|
35
|
-
ActiveSupportHelpers.
|
34
|
+
ActiveSupportHelpers.reload_model('Account')
|
35
|
+
ActiveSupportHelpers.reload_model('Asset')
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
Plutus.enable_tenancy = false
|
39
39
|
Plutus.tenant_class = nil
|
40
|
-
|
40
|
+
|
41
41
|
FactoryGirlHelpers.reload()
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
it 'validate uniqueness of name scoped to tenant' do
|
45
45
|
tenant = FactoryGirl.create(:tenant)
|
46
46
|
account = FactoryGirl.create(:asset, tenant: tenant)
|
47
|
-
|
47
|
+
|
48
48
|
record = FactoryGirl.build(:asset, name: account.name, tenant: tenant)
|
49
49
|
expect(record).not_to be_valid
|
50
50
|
expect(record.errors[:name]).to eq(['has already been taken'])
|
51
51
|
end
|
52
|
-
|
52
|
+
|
53
53
|
it 'allows same name scoped under a different tenant' do
|
54
54
|
tenant_1 = FactoryGirl.create(:tenant)
|
55
55
|
tenant_2 = FactoryGirl.create(:tenant)
|
56
56
|
account = FactoryGirl.create(:asset, tenant: tenant_1)
|
57
|
-
|
57
|
+
|
58
58
|
record = FactoryGirl.build(:asset, name: account.name, tenant: tenant_2)
|
59
59
|
expect(record).to be_valid
|
60
60
|
end
|
@@ -1,13 +1,6 @@
|
|
1
1
|
module ActiveSupportHelpers
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
# * remove the constant from active support dependencies
|
6
|
-
def self.clear_model(model_name)
|
7
|
-
ActiveSupport::Dependencies.remove_constant('Plutus::' + model_name)
|
8
|
-
|
9
|
-
models_dir = File.dirname(__FILE__) + '/../../app/models/plutus/'
|
10
|
-
path = File.expand_path(models_dir + model_name.downcase + '.rb')
|
11
|
-
$LOADED_FEATURES.delete(path)
|
2
|
+
def self.reload_model(model_name)
|
3
|
+
Plutus.send(:remove_const, "#{model_name}")
|
4
|
+
load("app/models/plutus/#{model_name.downcase}.rb")
|
12
5
|
end
|
13
6
|
end
|
metadata
CHANGED
@@ -1,29 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: plutus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.18'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Bulat
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-03-23 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: rails
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '6.0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '6.0'
|
27
12
|
- !ruby/object:Gem::Dependency
|
28
13
|
name: kaminari
|
29
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,19 +24,19 @@ dependencies:
|
|
39
24
|
- !ruby/object:Gem::Version
|
40
25
|
version: '1.2'
|
41
26
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
27
|
+
name: rails
|
43
28
|
requirement: !ruby/object:Gem::Requirement
|
44
29
|
requirements:
|
45
|
-
- - "
|
30
|
+
- - ">"
|
46
31
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :
|
32
|
+
version: '7.0'
|
33
|
+
type: :runtime
|
49
34
|
prerelease: false
|
50
35
|
version_requirements: !ruby/object:Gem::Requirement
|
51
36
|
requirements:
|
52
|
-
- - "
|
37
|
+
- - ">"
|
53
38
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
39
|
+
version: '7.0'
|
55
40
|
- !ruby/object:Gem::Dependency
|
56
41
|
name: shoulda-matchers
|
57
42
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,6 +51,20 @@ dependencies:
|
|
66
51
|
- - "~>"
|
67
52
|
- !ruby/object:Gem::Version
|
68
53
|
version: '3.1'
|
54
|
+
- !ruby/object:Gem::Dependency
|
55
|
+
name: yard
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
type: :development
|
62
|
+
prerelease: false
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
69
68
|
description: The plutus plugin provides a complete double entry accounting system
|
70
69
|
for use in any Ruby on Rails application. The plugin follows general Double Entry
|
71
70
|
Bookkeeping practices. All calculations are done using BigDecimal in order to prevent
|
@@ -81,6 +80,7 @@ files:
|
|
81
80
|
- LICENSE
|
82
81
|
- README.markdown
|
83
82
|
- Rakefile
|
83
|
+
- app/assets/config/plutus/manifest.js
|
84
84
|
- app/assets/javascripts/plutus/application.js
|
85
85
|
- app/assets/stylesheets/bootstrap-theme.min.css
|
86
86
|
- app/assets/stylesheets/bootstrap.min.css
|
@@ -161,7 +161,6 @@ files:
|
|
161
161
|
homepage: http://github.com/mbulat/plutus
|
162
162
|
licenses: []
|
163
163
|
metadata: {}
|
164
|
-
post_install_message:
|
165
164
|
rdoc_options: []
|
166
165
|
require_paths:
|
167
166
|
- lib
|
@@ -174,40 +173,38 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
174
173
|
requirements:
|
175
174
|
- - ">="
|
176
175
|
- !ruby/object:Gem::Version
|
177
|
-
version:
|
176
|
+
version: '0'
|
178
177
|
requirements: []
|
179
|
-
|
180
|
-
rubygems_version: 2.7.6.2
|
181
|
-
signing_key:
|
178
|
+
rubygems_version: 3.6.6
|
182
179
|
specification_version: 3
|
183
180
|
summary: A Plugin providing a Double Entry Accounting Engine for Rails
|
184
181
|
test_files:
|
185
|
-
- spec/routing/entries_routing_spec.rb
|
186
|
-
- spec/routing/accounts_routing_spec.rb
|
187
|
-
- spec/lib/plutus_spec.rb
|
188
|
-
- spec/spec_helper.rb
|
189
|
-
- spec/controllers/entries_controller_spec.rb
|
190
182
|
- spec/controllers/accounts_controller_spec.rb
|
183
|
+
- spec/controllers/entries_controller_spec.rb
|
191
184
|
- spec/controllers/reports_controller_spec.rb
|
192
|
-
- spec/factories/entry_factory.rb
|
193
185
|
- spec/factories/account_factory.rb
|
194
186
|
- spec/factories/amount_factory.rb
|
187
|
+
- spec/factories/entry_factory.rb
|
195
188
|
- spec/factories/tenant_factory.rb
|
196
|
-
- spec/
|
197
|
-
- spec/support/shoulda_matchers.rb
|
198
|
-
- spec/support/account_shared_examples.rb
|
199
|
-
- spec/support/factory_girl_helpers.rb
|
200
|
-
- spec/support/amount_shared_examples.rb
|
201
|
-
- spec/spec.opts
|
202
|
-
- spec/rcov.opts
|
203
|
-
- spec/models/liability_spec.rb
|
204
|
-
- spec/models/credit_amount_spec.rb
|
205
|
-
- spec/models/equity_spec.rb
|
206
|
-
- spec/models/revenue_spec.rb
|
207
|
-
- spec/models/debit_amount_spec.rb
|
189
|
+
- spec/lib/plutus_spec.rb
|
208
190
|
- spec/models/account_spec.rb
|
209
191
|
- spec/models/amount_spec.rb
|
210
|
-
- spec/models/tenancy_spec.rb
|
211
|
-
- spec/models/entry_spec.rb
|
212
192
|
- spec/models/asset_spec.rb
|
193
|
+
- spec/models/credit_amount_spec.rb
|
194
|
+
- spec/models/debit_amount_spec.rb
|
195
|
+
- spec/models/entry_spec.rb
|
196
|
+
- spec/models/equity_spec.rb
|
213
197
|
- spec/models/expense_spec.rb
|
198
|
+
- spec/models/liability_spec.rb
|
199
|
+
- spec/models/revenue_spec.rb
|
200
|
+
- spec/models/tenancy_spec.rb
|
201
|
+
- spec/rcov.opts
|
202
|
+
- spec/routing/accounts_routing_spec.rb
|
203
|
+
- spec/routing/entries_routing_spec.rb
|
204
|
+
- spec/spec.opts
|
205
|
+
- spec/spec_helper.rb
|
206
|
+
- spec/support/account_shared_examples.rb
|
207
|
+
- spec/support/active_support_helpers.rb
|
208
|
+
- spec/support/amount_shared_examples.rb
|
209
|
+
- spec/support/factory_girl_helpers.rb
|
210
|
+
- spec/support/shoulda_matchers.rb
|