plutus 0.13 → 0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.markdown +5 -8
- data/app/assets/javascripts/plutus/reports.js +5 -0
- data/app/models/plutus/amount.rb +2 -0
- data/app/models/plutus/asset.rb +1 -1
- data/app/models/plutus/equity.rb +1 -1
- data/app/models/plutus/expense.rb +1 -1
- data/app/models/plutus/liability.rb +1 -1
- data/app/models/plutus/revenue.rb +1 -1
- data/{lib/generators/plutus/templates/migration.rb → db/migrate/20160422010135_create_plutus_tables.rb} +2 -8
- data/lib/plutus.rb +2 -5
- data/lib/plutus/engine.rb +5 -0
- data/lib/plutus/version.rb +1 -1
- data/spec/factories/tenant_factory.rb +12 -0
- data/spec/models/amount_spec.rb +5 -0
- data/spec/models/tenancy_spec.rb +23 -5
- data/spec/spec_helper.rb +2 -2
- data/spec/support/shoulda_matchers.rb +8 -0
- metadata +41 -24
- data/app/assets/javascripts/plutus/reports.js.coffee +0 -2
- data/lib/generators/plutus/templates/add_date_migration.rb +0 -6
- data/lib/generators/plutus/templates/update_migration.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0aaa19cffdd4a91c7dbfefce4263711e8b8731a53510ee4a96963b07f113b0ae
|
4
|
+
data.tar.gz: 9778f6eda822dda5db140b40b50c206dc96e1e9a921a0e64ffd1d660e29d5db3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5171b284aa177e22422da572f29c01c624463c5e609ca010e700a3cf134de999fc29cd7ceafb36df43a5b530a3c3a8821ed0f7dccac75aa1b94461f123d4e668
|
7
|
+
data.tar.gz: ba4f84dc1529509892c61ae4d83dd226b8168fde4e4b73bddfe40e416e35fb56ac302a96b47b373c8fde3b8e2daa557864a27fdc970c5f7b1ee41df8b1809e27
|
data/README.markdown
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Plutus
|
2
2
|
=================
|
3
|
-
[![Build Status](https://
|
3
|
+
[![Build Status](https://travis-ci.org/mbulat/plutus.svg?branch=master)](https://travis-ci.org/mbulat/plutus) [![Coverage Status](https://coveralls.io/repos/github/mbulat/plutus/badge.svg?branch=master)](https://coveralls.io/github/mbulat/plutus?branch=master)
|
4
4
|
|
5
5
|
The Plutus plugin is a Ruby on Rails Engine which provides a double entry accounting system for your application.
|
6
6
|
|
@@ -16,9 +16,7 @@ Installation
|
|
16
16
|
============
|
17
17
|
|
18
18
|
- Add the gem to your Gemfile `gem "plutus"`
|
19
|
-
|
20
|
-
- generate migration files `rails g plutus`
|
21
|
-
|
19
|
+
- generate migration files `rake plutus:install:migrations`
|
22
20
|
- run migrations `rake db:migrate`
|
23
21
|
|
24
22
|
Overview
|
@@ -294,8 +292,8 @@ end
|
|
294
292
|
*NOTE: When building entries, be sure to specify the account directly, rather than use the `account_name` feature. Otherwise you'll probably end up with the wrong account.*
|
295
293
|
|
296
294
|
```ruby
|
297
|
-
debit_account = Plutus::
|
298
|
-
credit_account = Plutus::
|
295
|
+
debit_account = Plutus::Account.where(:name => "Cash", :tenant => my_tenant).last
|
296
|
+
credit_account = Plutus::Account.where(:name => "Unearned Revenue", :tenant => my_tenant).last
|
299
297
|
entry = Plutus::Entry.new(
|
300
298
|
:description => "Order placed for widgets",
|
301
299
|
:date => Date.yesterday,
|
@@ -337,6 +335,7 @@ For the rails 2 version, you can go here:
|
|
337
335
|
* Gems in RubyGems.org >= 0.5.0 support Rails 3
|
338
336
|
* Gems in RubyGems.org >= 0.8.0 support Rails 4
|
339
337
|
* Gems in RubyGems.org >= 0.9.0 support Rails ~> 4.1
|
338
|
+
* Gems in RubyGems.org >= 0.13.0 support Rails ~> 5.0
|
340
339
|
|
341
340
|
Upgrading from older versions
|
342
341
|
-----------------------------
|
@@ -373,8 +372,6 @@ Plutus is free software, but if you'd like to support development, feel free to
|
|
373
372
|
|
374
373
|
`1QFSdJheyFkLcsV8X428J8e3pYqX1nmW39`
|
375
374
|
|
376
|
-
![bitcoin](https://dl.dropboxusercontent.com/u/8428240/plutus_tip.png)
|
377
|
-
|
378
375
|
Also, if anyone is using Plutus for bitcoin related accounting, I'd love to hear about it! Drop me a line.
|
379
376
|
|
380
377
|
ToDo
|
data/app/models/plutus/amount.rb
CHANGED
@@ -12,6 +12,8 @@ module Plutus
|
|
12
12
|
validates_presence_of :type, :amount, :entry, :account
|
13
13
|
# attr_accessible :account, :account_name, :amount, :entry
|
14
14
|
|
15
|
+
delegate :name, to: :account, prefix: true, allow_nil: true
|
16
|
+
|
15
17
|
# Assign an account by name
|
16
18
|
def account_name=(name)
|
17
19
|
self.account = Account.find_by_name!(name)
|
data/app/models/plutus/asset.rb
CHANGED
data/app/models/plutus/equity.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
class CreatePlutusTables < ActiveRecord::Migration[4.2]
|
2
|
-
def
|
2
|
+
def change
|
3
3
|
create_table :plutus_accounts do |t|
|
4
4
|
t.string :name
|
5
5
|
t.string :type
|
6
|
-
t.boolean :contra
|
6
|
+
t.boolean :contra, default: false
|
7
7
|
|
8
8
|
t.timestamps
|
9
9
|
end
|
@@ -30,10 +30,4 @@ class CreatePlutusTables < ActiveRecord::Migration[4.2]
|
|
30
30
|
add_index :plutus_amounts, [:account_id, :entry_id]
|
31
31
|
add_index :plutus_amounts, [:entry_id, :account_id]
|
32
32
|
end
|
33
|
-
|
34
|
-
def self.down
|
35
|
-
drop_table :plutus_accounts
|
36
|
-
drop_table :plutus_entries
|
37
|
-
drop_table :plutus_amounts
|
38
|
-
end
|
39
33
|
end
|
data/lib/plutus.rb
CHANGED
@@ -2,11 +2,6 @@
|
|
2
2
|
require "rails"
|
3
3
|
|
4
4
|
module Plutus
|
5
|
-
class Engine < Rails::Engine
|
6
|
-
isolate_namespace Plutus
|
7
|
-
end
|
8
|
-
|
9
|
-
|
10
5
|
# ------------------------------ tenancy ------------------------------
|
11
6
|
# configuration to enable or disable tenancy
|
12
7
|
mattr_accessor :enable_tenancy
|
@@ -21,3 +16,5 @@ module Plutus
|
|
21
16
|
yield(self)
|
22
17
|
end
|
23
18
|
end
|
19
|
+
|
20
|
+
require "plutus/engine"
|
data/lib/plutus/version.rb
CHANGED
data/spec/models/amount_spec.rb
CHANGED
@@ -2,6 +2,11 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module Plutus
|
4
4
|
describe Amount do
|
5
|
+
|
6
|
+
describe "attributes" do
|
7
|
+
it { is_expected.to delegate_method(:name).to(:account).with_prefix }
|
8
|
+
end
|
9
|
+
|
5
10
|
subject { FactoryGirl.build(:amount) }
|
6
11
|
it { is_expected.not_to be_valid } # construct a child class instead
|
7
12
|
end
|
data/spec/models/tenancy_spec.rb
CHANGED
@@ -3,12 +3,27 @@ require 'spec_helper'
|
|
3
3
|
module Plutus
|
4
4
|
describe Account do
|
5
5
|
describe 'tenancy support' do
|
6
|
+
|
7
|
+
before(:all) do
|
8
|
+
m = ActiveRecord::Migration.new
|
9
|
+
m.verbose = false
|
10
|
+
m.create_table :plutus_tenants do |t|
|
11
|
+
t.string :name
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
after :all do
|
16
|
+
m = ActiveRecord::Migration.new
|
17
|
+
m.verbose = false
|
18
|
+
m.drop_table :plutus_tenants
|
19
|
+
end
|
20
|
+
|
6
21
|
before(:each) do
|
7
22
|
ActiveSupportHelpers.clear_model('Account')
|
8
23
|
ActiveSupportHelpers.clear_model('Asset')
|
9
24
|
|
10
25
|
Plutus.enable_tenancy = true
|
11
|
-
Plutus.tenant_class = 'Plutus::
|
26
|
+
Plutus.tenant_class = 'Plutus::Tenant'
|
12
27
|
|
13
28
|
FactoryGirlHelpers.reload()
|
14
29
|
Plutus::Asset.new
|
@@ -27,17 +42,20 @@ module Plutus
|
|
27
42
|
end
|
28
43
|
|
29
44
|
it 'validate uniqueness of name scoped to tenant' do
|
30
|
-
|
45
|
+
tenant = FactoryGirl.create(:tenant)
|
46
|
+
account = FactoryGirl.create(:asset, tenant: tenant)
|
31
47
|
|
32
|
-
record = FactoryGirl.build(:asset, name: account.name,
|
48
|
+
record = FactoryGirl.build(:asset, name: account.name, tenant: tenant)
|
33
49
|
expect(record).not_to be_valid
|
34
50
|
expect(record.errors[:name]).to eq(['has already been taken'])
|
35
51
|
end
|
36
52
|
|
37
53
|
it 'allows same name scoped under a different tenant' do
|
38
|
-
|
54
|
+
tenant_1 = FactoryGirl.create(:tenant)
|
55
|
+
tenant_2 = FactoryGirl.create(:tenant)
|
56
|
+
account = FactoryGirl.create(:asset, tenant: tenant_1)
|
39
57
|
|
40
|
-
record = FactoryGirl.build(:asset, name: account.name,
|
58
|
+
record = FactoryGirl.build(:asset, name: account.name, tenant: tenant_2)
|
41
59
|
expect(record).to be_valid
|
42
60
|
end
|
43
61
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +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.14'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Bulat
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: shoulda-matchers
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.1'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.1'
|
83
97
|
description: The plutus plugin provides a complete double entry accounting system
|
84
98
|
for use in any Ruby on Rails application. The plugin follows general Double Entry
|
85
99
|
Bookkeeping practices. All calculations are done using BigDecimal in order to prevent
|
@@ -96,7 +110,7 @@ files:
|
|
96
110
|
- README.markdown
|
97
111
|
- Rakefile
|
98
112
|
- app/assets/javascripts/plutus/application.js
|
99
|
-
- app/assets/javascripts/plutus/reports.js
|
113
|
+
- app/assets/javascripts/plutus/reports.js
|
100
114
|
- app/assets/stylesheets/bootstrap-theme.min.css
|
101
115
|
- app/assets/stylesheets/bootstrap.min.css
|
102
116
|
- app/assets/stylesheets/plutus/application.css
|
@@ -133,17 +147,16 @@ files:
|
|
133
147
|
- config/routes.rb
|
134
148
|
- config/secret_token.rb
|
135
149
|
- config/session_store.rb
|
150
|
+
- db/migrate/20160422010135_create_plutus_tables.rb
|
136
151
|
- lib/generators/plutus/USAGE
|
137
152
|
- lib/generators/plutus/add_date_upgrade_generator.rb
|
138
153
|
- lib/generators/plutus/base_generator.rb
|
139
154
|
- lib/generators/plutus/plutus_generator.rb
|
140
|
-
- lib/generators/plutus/templates/add_date_migration.rb
|
141
|
-
- lib/generators/plutus/templates/migration.rb
|
142
155
|
- lib/generators/plutus/templates/tenant_migration.rb
|
143
|
-
- lib/generators/plutus/templates/update_migration.rb
|
144
156
|
- lib/generators/plutus/tenancy_generator.rb
|
145
157
|
- lib/generators/plutus/upgrade_plutus_generator.rb
|
146
158
|
- lib/plutus.rb
|
159
|
+
- lib/plutus/engine.rb
|
147
160
|
- lib/plutus/version.rb
|
148
161
|
- spec/controllers/accounts_controller_spec.rb
|
149
162
|
- spec/controllers/entries_controller_spec.rb
|
@@ -151,6 +164,7 @@ files:
|
|
151
164
|
- spec/factories/account_factory.rb
|
152
165
|
- spec/factories/amount_factory.rb
|
153
166
|
- spec/factories/entry_factory.rb
|
167
|
+
- spec/factories/tenant_factory.rb
|
154
168
|
- spec/lib/plutus_spec.rb
|
155
169
|
- spec/models/account_spec.rb
|
156
170
|
- spec/models/amount_spec.rb
|
@@ -172,6 +186,7 @@ files:
|
|
172
186
|
- spec/support/active_support_helpers.rb
|
173
187
|
- spec/support/amount_shared_examples.rb
|
174
188
|
- spec/support/factory_girl_helpers.rb
|
189
|
+
- spec/support/shoulda_matchers.rb
|
175
190
|
homepage: http://github.com/mbulat/plutus
|
176
191
|
licenses: []
|
177
192
|
metadata: {}
|
@@ -191,35 +206,37 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
191
206
|
version: 1.3.6
|
192
207
|
requirements: []
|
193
208
|
rubyforge_project:
|
194
|
-
rubygems_version: 2.
|
209
|
+
rubygems_version: 2.7.6
|
195
210
|
signing_key:
|
196
211
|
specification_version: 3
|
197
212
|
summary: A Plugin providing a Double Entry Accounting Engine for Rails
|
198
213
|
test_files:
|
214
|
+
- spec/routing/entries_routing_spec.rb
|
215
|
+
- spec/routing/accounts_routing_spec.rb
|
199
216
|
- spec/lib/plutus_spec.rb
|
200
|
-
- spec/
|
201
|
-
- spec/
|
217
|
+
- spec/spec_helper.rb
|
218
|
+
- spec/controllers/entries_controller_spec.rb
|
219
|
+
- spec/controllers/accounts_controller_spec.rb
|
220
|
+
- spec/controllers/reports_controller_spec.rb
|
202
221
|
- spec/factories/entry_factory.rb
|
203
222
|
- spec/factories/account_factory.rb
|
204
|
-
- spec/
|
205
|
-
- spec/
|
206
|
-
- spec/support/amount_shared_examples.rb
|
223
|
+
- spec/factories/amount_factory.rb
|
224
|
+
- spec/factories/tenant_factory.rb
|
207
225
|
- spec/support/active_support_helpers.rb
|
226
|
+
- spec/support/shoulda_matchers.rb
|
208
227
|
- spec/support/account_shared_examples.rb
|
209
|
-
- spec/
|
210
|
-
- spec/
|
228
|
+
- spec/support/factory_girl_helpers.rb
|
229
|
+
- spec/support/amount_shared_examples.rb
|
230
|
+
- spec/spec.opts
|
211
231
|
- spec/rcov.opts
|
212
|
-
- spec/controllers/reports_controller_spec.rb
|
213
|
-
- spec/controllers/entries_controller_spec.rb
|
214
|
-
- spec/controllers/accounts_controller_spec.rb
|
215
|
-
- spec/models/account_spec.rb
|
216
|
-
- spec/models/credit_amount_spec.rb
|
217
|
-
- spec/models/expense_spec.rb
|
218
|
-
- spec/models/tenancy_spec.rb
|
219
232
|
- spec/models/liability_spec.rb
|
220
|
-
- spec/models/
|
221
|
-
- spec/models/
|
233
|
+
- spec/models/credit_amount_spec.rb
|
234
|
+
- spec/models/equity_spec.rb
|
222
235
|
- spec/models/revenue_spec.rb
|
236
|
+
- spec/models/debit_amount_spec.rb
|
237
|
+
- spec/models/account_spec.rb
|
223
238
|
- spec/models/amount_spec.rb
|
224
|
-
- spec/models/
|
239
|
+
- spec/models/tenancy_spec.rb
|
225
240
|
- spec/models/entry_spec.rb
|
241
|
+
- spec/models/asset_spec.rb
|
242
|
+
- spec/models/expense_spec.rb
|
@@ -1,17 +0,0 @@
|
|
1
|
-
class UpdatePlutusTables < ActiveRecord::Migration[4.2]
|
2
|
-
def change
|
3
|
-
# we have to remove these indexes because the temporary
|
4
|
-
# table index name is too long
|
5
|
-
remove_index :plutus_amounts, [:account_id, :transaction_id]
|
6
|
-
remove_index :plutus_amounts, [:transaction_id, :account_id]
|
7
|
-
remove_index :plutus_transactions, column: [:commercial_document_id, :commercial_document_type], :name => "index_transactions_on_commercial_doc"
|
8
|
-
|
9
|
-
rename_table :plutus_transactions, :plutus_entries
|
10
|
-
rename_column :plutus_amounts, :transaction_id, :entry_id
|
11
|
-
|
12
|
-
# adding the indexes back
|
13
|
-
add_index :plutus_amounts, [:account_id, :entry_id]
|
14
|
-
add_index :plutus_amounts, [:entry_id, :account_id]
|
15
|
-
add_index :plutus_entries, [:commercial_document_id, :commercial_document_type], :name => "index_entries_on_commercial_doc"
|
16
|
-
end
|
17
|
-
end
|