plutus 0.11.0 → 0.12.2

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.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/README.markdown +47 -31
  3. data/app/assets/javascripts/plutus/application.js +5 -4
  4. data/app/assets/javascripts/plutus/reports.js.coffee +2 -0
  5. data/app/assets/stylesheets/bootstrap-theme.min.css +5 -0
  6. data/app/assets/stylesheets/bootstrap.min.css +5 -0
  7. data/app/assets/stylesheets/plutus/application.css +11 -5
  8. data/app/controllers/plutus/accounts_controller.rb +1 -16
  9. data/app/controllers/plutus/application_controller.rb +4 -0
  10. data/app/controllers/plutus/entries_controller.rb +2 -17
  11. data/app/controllers/plutus/reports_controller.rb +40 -0
  12. data/app/models/plutus/account.rb +90 -7
  13. data/app/models/plutus/amounts_extension.rb +28 -1
  14. data/app/models/plutus/asset.rb +20 -17
  15. data/app/models/plutus/entry.rb +6 -1
  16. data/app/models/plutus/equity.rb +21 -18
  17. data/app/models/plutus/expense.rb +20 -17
  18. data/app/models/plutus/liability.rb +26 -18
  19. data/app/models/plutus/revenue.rb +21 -18
  20. data/app/views/layouts/plutus/_messages.html.erb +9 -0
  21. data/app/views/layouts/plutus/_navigation.html.erb +19 -0
  22. data/app/views/layouts/plutus/_navigation_links.html.erb +5 -0
  23. data/app/views/layouts/plutus/application.html.erb +19 -0
  24. data/app/views/plutus/accounts/index.html.erb +9 -12
  25. data/app/views/plutus/entries/index.html.erb +14 -12
  26. data/app/views/plutus/reports/_account.html.erb +28 -0
  27. data/app/views/plutus/reports/balance_sheet.html.erb +21 -0
  28. data/app/views/plutus/reports/income_statement.html.erb +24 -0
  29. data/config/routes.rb +6 -3
  30. data/lib/generators/plutus/add_date_upgrade_generator.rb +11 -0
  31. data/lib/generators/plutus/base_generator.rb +19 -0
  32. data/lib/generators/plutus/plutus_generator.rb +8 -22
  33. data/lib/generators/plutus/templates/add_date_migration.rb +6 -0
  34. data/lib/generators/plutus/templates/migration.rb +3 -1
  35. data/lib/generators/plutus/templates/update_migration.rb +2 -2
  36. data/lib/generators/plutus/tenancy_generator.rb +2 -17
  37. data/lib/generators/plutus/upgrade_plutus_generator.rb +6 -22
  38. data/lib/plutus/version.rb +1 -1
  39. data/spec/controllers/accounts_controller_spec.rb +11 -20
  40. data/spec/controllers/entries_controller_spec.rb +11 -20
  41. data/spec/controllers/reports_controller_spec.rb +24 -0
  42. data/spec/models/account_spec.rb +7 -1
  43. data/spec/models/entry_spec.rb +9 -0
  44. data/spec/routing/accounts_routing_spec.rb +6 -25
  45. data/spec/routing/entries_routing_spec.rb +6 -25
  46. data/spec/spec_helper.rb +1 -0
  47. data/spec/support/account_shared_examples.rb +4 -0
  48. metadata +47 -6
  49. data/app/views/plutus/accounts/show.html.erb +0 -59
  50. data/app/views/plutus/entries/show.html.erb +0 -46
  51. data/spec/schema.rb +0 -31
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ module Plutus
4
+ describe ReportsController do
5
+ routes { Plutus::Engine.routes }
6
+
7
+ def mock_entry(stubs={})
8
+ @mock_entry ||= FactoryGirl.create(:entry_with_credit_and_debit)
9
+ end
10
+
11
+ describe "GET balance_sheet" do
12
+ it "renders when one entry exists" do
13
+ Entry.stub_chain(:order).and_return([mock_entry])
14
+ get :balance_sheet
15
+ response.should be_success
16
+ end
17
+ it "renders when no entries exist" do
18
+ Entry.stub_chain(:order).and_return([])
19
+ get :balance_sheet
20
+ response.should be_success
21
+ end
22
+ end
23
+ end
24
+ end
@@ -18,7 +18,13 @@ module Plutus
18
18
  end
19
19
  end
20
20
 
21
- it { should_not respond_to(:balance) }
21
+ it "calling the instance method #balance should raise a NoMethodError" do
22
+ expect { subject.balance }.to raise_error NoMethodError, "undefined method 'balance'"
23
+ end
24
+
25
+ it "calling the class method ::balance should raise a NoMethodError" do
26
+ expect { subject.class.balance }.to raise_error NoMethodError, "undefined method 'balance'"
27
+ end
22
28
 
23
29
  describe ".trial_balance" do
24
30
  subject { Account.trial_balance }
@@ -45,6 +45,15 @@ module Plutus
45
45
  end
46
46
  end
47
47
 
48
+ context "without a date" do
49
+ let(:entry) { FactoryGirl.build(:entry_with_credit_and_debit, date: nil) }
50
+
51
+ context "should assign a default date before being saved" do
52
+ before { entry.save! }
53
+ its(:date) { should == Date.today }
54
+ end
55
+ end
56
+
48
57
  it "should require the debit and credit amounts to cancel" do
49
58
  entry.credit_amounts << FactoryGirl.build(:credit_amount, :amount => 100, :entry => entry)
50
59
  entry.debit_amounts << FactoryGirl.build(:debit_amount, :amount => 200, :entry => entry)
@@ -2,31 +2,12 @@ require 'spec_helper'
2
2
 
3
3
  module Plutus
4
4
  describe AccountsController do
5
- # Run these tests if you enable routing in your rails app. See README
6
- #describe "routing" do
7
- #it "recognizes and generates #index" do
8
- #{ :get => "/accounts" }.should route_to(:controller => "accounts", :action => "index")
9
- #end
5
+ routes { Plutus::Engine.routes }
10
6
 
11
- #it "recognizes and generates #show" do
12
- #{ :get => "/accounts/1" }.should route_to(:controller => "accounts", :action => "show", :id => "1")
13
- #end
14
-
15
- #it "recognizes and generates #edit" do
16
- #{ :get => "/accounts/1/edit" }.should_not be_routable
17
- #end
18
-
19
- #it "recognizes and generates #create" do
20
- #{ :post => "/accounts" }.should_not be_routable
21
- #end
22
-
23
- #it "recognizes and generates #update" do
24
- #{ :put => "/accounts/1" }.should_not be_routable
25
- #end
26
-
27
- #it "recognizes and generates #destroy" do
28
- #{ :delete => "/accounts/1" }.should_not be_routable
29
- #end
30
- #end
7
+ describe "routing" do
8
+ it "recognizes and generates #index" do
9
+ { :get => "/accounts" }.should route_to(:controller => "plutus/accounts", :action => "index")
10
+ end
11
+ end
31
12
  end
32
13
  end
@@ -2,31 +2,12 @@ require 'spec_helper'
2
2
 
3
3
  module Plutus
4
4
  describe EntriesController do
5
- # Run these tests if you enable routing in your rails app. See README
6
- #describe "routing" do
7
- #it "recognizes and generates #index" do
8
- #{ :get => "/entries" }.should route_to(:controller => "entries", :action => "index")
9
- #end
5
+ routes { Plutus::Engine.routes }
10
6
 
11
- #it "recognizes and generates #show" do
12
- #{ :get => "/entries/1" }.should route_to(:controller => "entries", :action => "show", :id => "1")
13
- #end
14
-
15
- #it "recognizes and generates #edit" do
16
- #{ :get => "/entries/1/edit" }.should_not be_routable
17
- #end
18
-
19
- #it "recognizes and generates #create" do
20
- #{ :post => "/entries" }.should_not be_routable
21
- #end
22
-
23
- #it "recognizes and generates #update" do
24
- #{ :put => "/entries/1" }.should_not be_routable
25
- #end
26
-
27
- #it "recognizes and generates #destroy" do
28
- #{ :delete => "/entries/1" }.should_not be_routable
29
- #end
30
- #end
7
+ describe "routing" do
8
+ it "recognizes and generates #index" do
9
+ { :get => "/entries" }.should route_to(:controller => "plutus/entries", :action => "index")
10
+ end
11
+ end
31
12
  end
32
13
  end
@@ -19,6 +19,7 @@ FactoryGirl.definition_file_paths << plutus_definitions
19
19
 
20
20
  RSpec.configure do |config|
21
21
  config.use_transactional_fixtures = true
22
+ config.infer_spec_type_from_file_location!
22
23
  end
23
24
 
24
25
  FactoryGirlHelpers.reload()
@@ -16,6 +16,10 @@ shared_examples_for 'a Plutus::Account subtype' do |elements|
16
16
  describe "instance methods" do
17
17
  its(:balance) { should be_kind_of(BigDecimal) }
18
18
 
19
+ it "reports a balance with date range" do
20
+ account.balance(:from_date => "2014-01-01", :to_date => Date.today).should be_kind_of(BigDecimal)
21
+ end
22
+
19
23
  it { should respond_to(:credit_entries) }
20
24
  it { should respond_to(:debit_entries) }
21
25
  end
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.11.0
4
+ version: 0.12.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Bulat
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-10 00:00:00.000000000 Z
11
+ date: 2015-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -24,6 +24,34 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '4.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: jquery-rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '3.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '3.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: jquery-ui-rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '4.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '4.0'
27
55
  - !ruby/object:Gem::Dependency
28
56
  name: yard
29
57
  requirement: !ruby/object:Gem::Requirement
@@ -54,9 +82,14 @@ files:
54
82
  - README.markdown
55
83
  - Rakefile
56
84
  - app/assets/javascripts/plutus/application.js
85
+ - app/assets/javascripts/plutus/reports.js.coffee
86
+ - app/assets/stylesheets/bootstrap-theme.min.css
87
+ - app/assets/stylesheets/bootstrap.min.css
57
88
  - app/assets/stylesheets/plutus/application.css
58
89
  - app/controllers/plutus/accounts_controller.rb
90
+ - app/controllers/plutus/application_controller.rb
59
91
  - app/controllers/plutus/entries_controller.rb
92
+ - app/controllers/plutus/reports_controller.rb
60
93
  - app/models/plutus/account.rb
61
94
  - app/models/plutus/amount.rb
62
95
  - app/models/plutus/amounts_extension.rb
@@ -70,10 +103,15 @@ files:
70
103
  - app/models/plutus/no_tenancy.rb
71
104
  - app/models/plutus/revenue.rb
72
105
  - app/models/plutus/tenancy.rb
106
+ - app/views/layouts/plutus/_messages.html.erb
107
+ - app/views/layouts/plutus/_navigation.html.erb
108
+ - app/views/layouts/plutus/_navigation_links.html.erb
109
+ - app/views/layouts/plutus/application.html.erb
73
110
  - app/views/plutus/accounts/index.html.erb
74
- - app/views/plutus/accounts/show.html.erb
75
111
  - app/views/plutus/entries/index.html.erb
76
- - app/views/plutus/entries/show.html.erb
112
+ - app/views/plutus/reports/_account.html.erb
113
+ - app/views/plutus/reports/balance_sheet.html.erb
114
+ - app/views/plutus/reports/income_statement.html.erb
77
115
  - config/backtrace_silencers.rb
78
116
  - config/database.yml
79
117
  - config/inflections.rb
@@ -82,7 +120,10 @@ files:
82
120
  - config/secret_token.rb
83
121
  - config/session_store.rb
84
122
  - lib/generators/plutus/USAGE
123
+ - lib/generators/plutus/add_date_upgrade_generator.rb
124
+ - lib/generators/plutus/base_generator.rb
85
125
  - lib/generators/plutus/plutus_generator.rb
126
+ - lib/generators/plutus/templates/add_date_migration.rb
86
127
  - lib/generators/plutus/templates/migration.rb
87
128
  - lib/generators/plutus/templates/tenant_migration.rb
88
129
  - lib/generators/plutus/templates/update_migration.rb
@@ -92,6 +133,7 @@ files:
92
133
  - lib/plutus/version.rb
93
134
  - spec/controllers/accounts_controller_spec.rb
94
135
  - spec/controllers/entries_controller_spec.rb
136
+ - spec/controllers/reports_controller_spec.rb
95
137
  - spec/factories/account_factory.rb
96
138
  - spec/factories/amount_factory.rb
97
139
  - spec/factories/entry_factory.rb
@@ -110,7 +152,6 @@ files:
110
152
  - spec/rcov.opts
111
153
  - spec/routing/accounts_routing_spec.rb
112
154
  - spec/routing/entries_routing_spec.rb
113
- - spec/schema.rb
114
155
  - spec/spec.opts
115
156
  - spec/spec_helper.rb
116
157
  - spec/support/account_shared_examples.rb
@@ -142,7 +183,6 @@ specification_version: 3
142
183
  summary: A Plugin providing a Double Entry Accounting Engine for Rails
143
184
  test_files:
144
185
  - spec/lib/plutus_spec.rb
145
- - spec/schema.rb
146
186
  - spec/spec.opts
147
187
  - spec/factories/amount_factory.rb
148
188
  - spec/factories/entry_factory.rb
@@ -155,6 +195,7 @@ test_files:
155
195
  - spec/routing/accounts_routing_spec.rb
156
196
  - spec/routing/entries_routing_spec.rb
157
197
  - spec/rcov.opts
198
+ - spec/controllers/reports_controller_spec.rb
158
199
  - spec/controllers/entries_controller_spec.rb
159
200
  - spec/controllers/accounts_controller_spec.rb
160
201
  - spec/models/account_spec.rb
@@ -1,59 +0,0 @@
1
- <div class="plutus_container">
2
- <h1><%=h @account.name %> Account</h1>
3
-
4
- <table>
5
- <tr>
6
- <th class="nobg">ID</th>
7
- <th>Name</th>
8
- <th>Type</th>
9
- <th>Credit Balance</th>
10
- <th>Debit Balance</th>
11
- <th>Balance</td>
12
- </tr>
13
-
14
- <tr class="odd">
15
- <td><%=h @account.id %></td>
16
- <td><%=h @account.name %></td>
17
- <td><%=h @account.type.sub('Plutus::','') %></td>
18
- <td><%=h @account.credits_balance %></td>
19
- <td><%=h @account.debits_balance %></td>
20
- <td><%=h @account.balance %></td>
21
- </tr>
22
- </table>
23
-
24
- <h1>Credit Entries</h1>
25
-
26
- <table>
27
- <tr>
28
- <th class="nobg">ID</th>
29
- <th>Description</th>
30
- <th>Date</th>
31
- </tr>
32
-
33
- <% @account.credit_entries.each do |entry| %>
34
- <tr class="<%= cycle("even", "odd") -%>">
35
- <td><%=h entry.id %></td>
36
- <td><%=h entry.description %></td>
37
- <td><%=h entry.created_at %></td>
38
- </tr>
39
- <% end %>
40
- </table>
41
-
42
- <h1>Debit Entries</h1>
43
-
44
- <table>
45
- <tr>
46
- <th class="nobg">ID</th>
47
- <th>Description</th>
48
- <th>Date</th>
49
- </tr>
50
-
51
- <% @account.debit_entries.each do |tr| %>
52
- <tr class="<%= cycle("even", "odd") -%>">
53
- <td><%=h tr.id %></td>
54
- <td><%=h tr.description %></td>
55
- <td><%=h tr.created_at %></td>
56
- </tr>
57
- <% end %>
58
- </table>
59
- </div>
@@ -1,46 +0,0 @@
1
- <div class="plutus_container">
2
- <h1><%=h @entry.description %> Entry</h1>
3
-
4
- <table cellspacing="0">
5
- <thead>
6
- <tr>
7
- <th class="nobg">ID</th>
8
- <th>Description</th>
9
- <th>Debits</th>
10
- <th>Credits</th>
11
- <th>Date</th>
12
- </tr>
13
- </thead>
14
- <tbody>
15
- <tr class="<%= cycle("even", "odd") -%>">
16
- <td><%=link_to(@entry.id, entry_path(@entry)) %></td>
17
- <td><%=h @entry.description %></td>
18
- <td></td>
19
- <td></td>
20
- <td><%=h @entry.created_at %></td>
21
- </tr>
22
- <% @entry.debit_amounts.each do |debit_amount| %>
23
- <tr class="<%= cycle("odd", "odd") -%>">
24
- <td></td>
25
- <td>&nbsp;&nbsp;&nbsp;&nbsp;<%=h "#{debit_amount.account.name}" %></td>
26
- <td><%=h debit_amount.amount %></td>
27
- <td></td>
28
- <td></td>
29
- </tr>
30
- <% end %>
31
- <% @entry.credit_amounts.each do |credit_amount| %>
32
- <tr class="<%= cycle("odd", "odd") -%>">
33
- <td></td>
34
- <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<%=h "#{credit_amount.account.name}" %></td>
35
- <td></td>
36
- <td><%=h credit_amount.amount %></td>
37
- <td></td>
38
- </tr>
39
- <% end %>
40
- </tbody>
41
- </table>
42
-
43
- <br />
44
-
45
- <h3>Go to <%= link_to 'Accounts', accounts_path %></h3>
46
- </div>
@@ -1,31 +0,0 @@
1
- # This file is auto-generated from the current state of the database. Instead of editing this file,
2
- # please use the migrations feature of Active Record to incrementally modify your database, and
3
- # then regenerate this schema definition.
4
- #
5
- # Note that this schema.rb definition is the authoritative source for your database schema. If you need
6
- # to create the application database on another system, you should be using db:schema:load, not running
7
- # all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
8
- # you'll amass, the slower it'll run and the greater likelihood for issues).
9
- #
10
- # It's strongly recommended to check this file into your version control system.
11
-
12
- ActiveRecord::Schema.define(:version => 20100419190249) do
13
-
14
- create_table "accounts", :force => true do |t|
15
- t.string "name"
16
- t.string "type"
17
- t.datetime "created_at"
18
- t.datetime "updated_at"
19
- end
20
-
21
- create_table "transactions", :force => true do |t|
22
- t.string "description"
23
- t.integer "credit_account_id"
24
- t.decimal "credit_amount"
25
- t.integer "debit_account_id"
26
- t.decimal "debit_amount"
27
- t.datetime "created_at"
28
- t.datetime "updated_at"
29
- end
30
-
31
- end