blawzoo-plutus 0.5.3

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 (62) hide show
  1. data/.yardopts +2 -0
  2. data/LICENSE +23 -0
  3. data/README.markdown +197 -0
  4. data/Rakefile +11 -0
  5. data/VERSION.yml +5 -0
  6. data/app/controllers/accounts_controller.rb +43 -0
  7. data/app/controllers/transactions_controller.rb +42 -0
  8. data/app/models/account.rb +57 -0
  9. data/app/models/asset.rb +81 -0
  10. data/app/models/equity.rb +82 -0
  11. data/app/models/expense.rb +81 -0
  12. data/app/models/liability.rb +76 -0
  13. data/app/models/revenue.rb +81 -0
  14. data/app/models/transaction.rb +27 -0
  15. data/app/views/accounts/index.html.erb +27 -0
  16. data/app/views/accounts/show.html.erb +69 -0
  17. data/app/views/layouts/accounts.html.erb +68 -0
  18. data/app/views/layouts/transactions.html.erb +68 -0
  19. data/app/views/transactions/index.html.erb +27 -0
  20. data/app/views/transactions/show.html.erb +24 -0
  21. data/doc/Account.html +300 -0
  22. data/doc/AccountsController.html +317 -0
  23. data/doc/Asset.html +610 -0
  24. data/doc/Equity.html +610 -0
  25. data/doc/Expense.html +610 -0
  26. data/doc/Liability.html +588 -0
  27. data/doc/Revenue.html +610 -0
  28. data/doc/Transaction.html +156 -0
  29. data/doc/TransactionsController.html +317 -0
  30. data/doc/_index.html +204 -0
  31. data/doc/class_list.html +36 -0
  32. data/doc/file.README.html +250 -0
  33. data/doc/file_list.html +38 -0
  34. data/doc/frames.html +13 -0
  35. data/doc/index.html +250 -0
  36. data/doc/js/app.js +202 -0
  37. data/doc/js/full_list.js +149 -0
  38. data/doc/js/jquery.js +154 -0
  39. data/doc/method_list.html +275 -0
  40. data/doc/top-level-namespace.html +90 -0
  41. data/lib/plutus.rb +6 -0
  42. data/plutus.gemspec +116 -0
  43. data/spec/controllers/accounts_controller_spec.rb +26 -0
  44. data/spec/controllers/transactions_controller_spec.rb +26 -0
  45. data/spec/factories/account_factory.rb +31 -0
  46. data/spec/factories/transaction_factory.rb +6 -0
  47. data/spec/lib/plutus_spec.rb +0 -0
  48. data/spec/models/account_spec.rb +43 -0
  49. data/spec/models/asset_spec.rb +46 -0
  50. data/spec/models/equity_spec.rb +46 -0
  51. data/spec/models/expense_spec.rb +46 -0
  52. data/spec/models/liability_spec.rb +46 -0
  53. data/spec/models/revenue_spec.rb +46 -0
  54. data/spec/models/transaction_spec.rb +48 -0
  55. data/spec/rcov.opts +2 -0
  56. data/spec/routing/accounts_routing_spec.rb +30 -0
  57. data/spec/routing/transactions_routing_spec.rb +30 -0
  58. data/spec/schema.rb +31 -0
  59. data/spec/spec.opts +4 -0
  60. data/spec/spec_helper.rb +14 -0
  61. data/tasks/plutus_tasks.rake +4 -0
  62. metadata +204 -0
@@ -0,0 +1,90 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta name="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>Top Level Namespace</title>
7
+ <link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />
8
+ <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
9
+
10
+ <script type="text/javascript" charset="utf-8">
11
+ relpath = '';
12
+ if (relpath != '') relpath += '/';
13
+ </script>
14
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
15
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
16
+
17
+ </head>
18
+ <body>
19
+ <script type="text/javascript" charset="utf-8">
20
+ if (window.top.frames.main) document.body.className = 'frames';
21
+ </script>
22
+
23
+ <div id="header">
24
+ <div id="menu">
25
+
26
+ <a href="_index.html">Index</a> &raquo;
27
+
28
+
29
+ <span class="title">Top Level Namespace</span>
30
+
31
+
32
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
33
+ </div>
34
+
35
+ <div id="search">
36
+ <a id="class_list_link" href="#">Class List</a>
37
+ <a id="method_list_link" href="#">Method List</a>
38
+ <a id ="file_list_link" href="#">File List</a>
39
+ </div>
40
+
41
+ <div class="clear"></div>
42
+ </div>
43
+
44
+ <iframe id="search_frame"></iframe>
45
+
46
+ <div id="content"><h1>Top Level Namespace
47
+
48
+
49
+
50
+ </h1>
51
+
52
+ <dl class="box">
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+
61
+ </dl>
62
+ <div class="clear"></div>
63
+
64
+ <h2>Defined Under Namespace</h2>
65
+ <p class="children">
66
+
67
+
68
+ <strong class="modules">Modules:</strong> <span class='object_link'><a href="Plutus.html" title="Plutus (module)">Plutus</a></span>
69
+
70
+
71
+
72
+ <strong class="classes">Classes:</strong> <span class='object_link'><a href="Account.html" title="Account (class)">Account</a></span>, <span class='object_link'><a href="AccountsController.html" title="AccountsController (class)">AccountsController</a></span>, <span class='object_link'><a href="Asset.html" title="Asset (class)">Asset</a></span>, <span class='object_link'><a href="CreatePlutusTables.html" title="CreatePlutusTables (class)">CreatePlutusTables</a></span>, <span class='object_link'><a href="Equity.html" title="Equity (class)">Equity</a></span>, <span class='object_link'><a href="Expense.html" title="Expense (class)">Expense</a></span>, <span class='object_link'><a href="Liability.html" title="Liability (class)">Liability</a></span>, <span class='object_link'><a href="PlutusGenerator.html" title="PlutusGenerator (class)">PlutusGenerator</a></span>, <span class='object_link'><a href="Revenue.html" title="Revenue (class)">Revenue</a></span>, <span class='object_link'><a href="Transaction.html" title="Transaction (class)">Transaction</a></span>, <span class='object_link'><a href="TransactionsController.html" title="TransactionsController (class)">TransactionsController</a></span>
73
+
74
+
75
+ </p>
76
+
77
+
78
+
79
+
80
+
81
+ </div>
82
+
83
+ <div id="footer">
84
+ Generated on Fri Dec 3 14:35:09 2010 by
85
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
86
+ 0.6.2 (ruby-1.8.7).
87
+ </div>
88
+
89
+ </body>
90
+ </html>
@@ -0,0 +1,6 @@
1
+ # Plutus
2
+ require "rails"
3
+ module Plutus
4
+ class Engine < Rails::Engine
5
+ end
6
+ end
@@ -0,0 +1,116 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{blawzoo-plutus}
5
+ s.version = "0.5.3"
6
+
7
+ s.authors = ["Michael Bulat"]
8
+ s.date = %q{2011-03-31}
9
+ s.description = %q{The plutus plugin provides a complete double entry accounting system for use in any Ruby on Rails application. The plugin follows general Double Entry Bookkeeping practices. All calculations are done using BigDecimal in order to prevent floating point rounding errors. The plugin requires a decimal type on your database as well.}
10
+ s.email = %q{mbulat@crazydogsoftware.com}
11
+ s.extra_rdoc_files = [
12
+ "LICENSE",
13
+ "README.markdown"
14
+ ]
15
+ s.add_dependency("rails", ">= 3.0")
16
+ s.add_development_dependency("sqlite3")
17
+ s.add_development_dependency("rspec", "~> 2.6")
18
+ s.add_development_dependency("rspec-rails", "~> 2.6")
19
+ s.add_development_dependency("rspec-rails", "~> 2.6")
20
+ s.add_development_dependency("factory_girl")
21
+ s.add_development_dependency("factory_girl_rails", "~> 1.1")
22
+ s.files = [
23
+ ".yardopts",
24
+ "LICENSE",
25
+ "README.markdown",
26
+ "Rakefile",
27
+ "VERSION.yml",
28
+ "app/controllers/accounts_controller.rb",
29
+ "app/controllers/transactions_controller.rb",
30
+ "app/models/account.rb",
31
+ "app/models/asset.rb",
32
+ "app/models/equity.rb",
33
+ "app/models/expense.rb",
34
+ "app/models/liability.rb",
35
+ "app/models/revenue.rb",
36
+ "app/models/transaction.rb",
37
+ "app/views/accounts/index.html.erb",
38
+ "app/views/accounts/show.html.erb",
39
+ "app/views/layouts/accounts.html.erb",
40
+ "app/views/layouts/transactions.html.erb",
41
+ "app/views/transactions/index.html.erb",
42
+ "app/views/transactions/show.html.erb",
43
+ "doc/Account.html",
44
+ "doc/AccountsController.html",
45
+ "doc/Asset.html",
46
+ "doc/Equity.html",
47
+ "doc/Expense.html",
48
+ "doc/Liability.html",
49
+ "doc/Revenue.html",
50
+ "doc/Transaction.html",
51
+ "doc/TransactionsController.html",
52
+ "doc/_index.html",
53
+ "doc/class_list.html",
54
+ "doc/file.README.html",
55
+ "doc/file_list.html",
56
+ "doc/frames.html",
57
+ "doc/index.html",
58
+ "doc/js/app.js",
59
+ "doc/js/full_list.js",
60
+ "doc/js/jquery.js",
61
+ "doc/method_list.html",
62
+ "doc/top-level-namespace.html",
63
+ "lib/plutus.rb",
64
+ "plutus.gemspec",
65
+ "spec/controllers/accounts_controller_spec.rb",
66
+ "spec/controllers/transactions_controller_spec.rb",
67
+ "spec/factories/account_factory.rb",
68
+ "spec/factories/transaction_factory.rb",
69
+ "spec/lib/plutus_spec.rb",
70
+ "spec/models/account_spec.rb",
71
+ "spec/models/asset_spec.rb",
72
+ "spec/models/equity_spec.rb",
73
+ "spec/models/expense_spec.rb",
74
+ "spec/models/liability_spec.rb",
75
+ "spec/models/revenue_spec.rb",
76
+ "spec/models/transaction_spec.rb",
77
+ "spec/rcov.opts",
78
+ "spec/routing/accounts_routing_spec.rb",
79
+ "spec/routing/transactions_routing_spec.rb",
80
+ "spec/schema.rb",
81
+ "spec/spec.opts",
82
+ "spec/spec_helper.rb",
83
+ "tasks/plutus_tasks.rake"
84
+ ]
85
+ s.require_paths = ["lib"]
86
+ s.required_rubygems_version = ">= 1.3.6"
87
+ s.summary = %q{A Plugin providing a Double Entry Accounting Engine for Rails}
88
+ s.test_files = [
89
+ "spec/controllers/accounts_controller_spec.rb",
90
+ "spec/controllers/transactions_controller_spec.rb",
91
+ "spec/factories/account_factory.rb",
92
+ "spec/factories/transaction_factory.rb",
93
+ "spec/lib/plutus_spec.rb",
94
+ "spec/models/account_spec.rb",
95
+ "spec/models/asset_spec.rb",
96
+ "spec/models/equity_spec.rb",
97
+ "spec/models/expense_spec.rb",
98
+ "spec/models/liability_spec.rb",
99
+ "spec/models/revenue_spec.rb",
100
+ "spec/models/transaction_spec.rb",
101
+ "spec/routing/accounts_routing_spec.rb",
102
+ "spec/routing/transactions_routing_spec.rb",
103
+ "spec/schema.rb",
104
+ "spec/spec_helper.rb"
105
+ ]
106
+
107
+ if s.respond_to? :specification_version then
108
+ s.specification_version = 3
109
+
110
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
111
+ else
112
+ end
113
+ else
114
+ end
115
+ end
116
+
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe AccountsController do
4
+ # Run these tests if you enable routing in your rails app. See README
5
+
6
+ #def mock_account(stubs={})
7
+ #@mock_account ||= mock_model(Account, stubs)
8
+ #end
9
+
10
+ #describe "GET index" do
11
+ #it "assigns all accounts as @accounts" do
12
+ #Account.stub(:find).with(:all).and_return([mock_account])
13
+ #get :index
14
+ #assigns[:accounts].should == [mock_account]
15
+ #end
16
+ #end
17
+
18
+ #describe "GET show" do
19
+ #it "assigns the requested account as @account" do
20
+ #Account.stub(:find).with("37").and_return(mock_account)
21
+ #get :show, :id => "37"
22
+ #assigns[:account].should equal(mock_account)
23
+ #end
24
+ #end
25
+
26
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe TransactionsController do
4
+ # Run these tests if you enable routing in your rails app. See README
5
+
6
+ #def mock_transaction(stubs={})
7
+ #@mock_transaction ||= mock_model(Transaction, stubs)
8
+ #end
9
+
10
+ #describe "GET index" do
11
+ #it "assigns all transactions as @transactions" do
12
+ #Transaction.stub(:find).with(:all).and_return([mock_transaction])
13
+ #get :index
14
+ #assigns[:transactions].should == [mock_transaction]
15
+ #end
16
+ #end
17
+
18
+ #describe "GET show" do
19
+ #it "assigns the requested transaction as @transaction" do
20
+ #Transaction.stub(:find).with("37").and_return(mock_transaction)
21
+ #get :show, :id => "37"
22
+ #assigns[:transaction].should equal(mock_transaction)
23
+ #end
24
+ #end
25
+
26
+ end
@@ -0,0 +1,31 @@
1
+ FactoryGirl.define do
2
+ factory :account do |account|
3
+ account.name 'factory name'
4
+ account.contra false
5
+ end
6
+
7
+ factory :asset do |account|
8
+ account.name 'factory name'
9
+ account.contra false
10
+ end
11
+
12
+ factory :equity do |account|
13
+ account.name 'factory name'
14
+ account.contra false
15
+ end
16
+
17
+ factory :expense do |account|
18
+ account.name 'factory name'
19
+ account.contra false
20
+ end
21
+
22
+ factory :liability do |account|
23
+ account.name 'factory name'
24
+ account.contra false
25
+ end
26
+
27
+ factory :revenue do |account|
28
+ account.name 'factory name'
29
+ account.contra false
30
+ end
31
+ end
@@ -0,0 +1,6 @@
1
+ Factory.define :transaction do |transaction|
2
+ transaction.description 'factory description'
3
+ transaction.credit_account {|credit_account| credit_account.association(:asset)}
4
+ transaction.debit_account {|debit_account| debit_account.association(:revenue)}
5
+ transaction.amount BigDecimal.new('100')
6
+ end
File without changes
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+
3
+ describe Account do
4
+
5
+ it "should not allow creating an account without a subtype" do
6
+ account = Factory.build(:account)
7
+ account.should_not be_valid
8
+ end
9
+
10
+ it "should not have a balance method" do
11
+ lambda{Account.balance}.should raise_error(NoMethodError)
12
+ end
13
+
14
+ it "should have a trial balance" do
15
+ Account.should respond_to(:trial_balance)
16
+ Account.trial_balance.should be_kind_of(BigDecimal)
17
+ end
18
+
19
+ it "should report a trial balance of 0 with correct transactions" do
20
+ # credit accounts
21
+ liability = Factory(:liability)
22
+ equity = Factory(:equity)
23
+ revenue = Factory(:revenue)
24
+ contra_asset = Factory(:asset, :contra => true)
25
+ contra_expense = Factory(:expense, :contra => true)
26
+
27
+ # debit accounts
28
+ asset = Factory(:asset)
29
+ expense = Factory(:expense)
30
+ contra_liability = Factory(:liability, :contra => true)
31
+ contra_equity = Factory(:equity, :contra => true)
32
+ contra_revenue = Factory(:revenue, :contra => true)
33
+
34
+ Factory(:transaction, :credit_account => liability, :debit_account => asset, :amount => 100000)
35
+ Factory(:transaction, :credit_account => equity, :debit_account => expense, :amount => 1000)
36
+ Factory(:transaction, :credit_account => revenue, :debit_account => contra_liability, :amount => 40404)
37
+ Factory(:transaction, :credit_account => contra_asset, :debit_account => contra_equity, :amount => 2)
38
+ Factory(:transaction, :credit_account => contra_expense, :debit_account => contra_revenue, :amount => 333)
39
+
40
+ Account.trial_balance.should == 0
41
+ end
42
+
43
+ end
@@ -0,0 +1,46 @@
1
+ require 'spec_helper'
2
+
3
+ describe Asset do
4
+
5
+ it "should allow creating an asset account" do
6
+ asset = Factory(:asset)
7
+ end
8
+
9
+ it "should report a balance for the asset account" do
10
+ asset = Factory(:asset)
11
+ asset.balance.should be_kind_of(BigDecimal)
12
+ end
13
+
14
+ it "should report a balance for the class of accounts" do
15
+ Asset.should respond_to(:balance)
16
+ Asset.balance.should be_kind_of(BigDecimal)
17
+ end
18
+
19
+ it "should not report a trial balance" do
20
+ lambda{Asset.trial_balance}.should raise_error(NoMethodError)
21
+ end
22
+
23
+ it "should not be valid without a name" do
24
+ asset = Factory.build(:asset, :name => nil)
25
+ asset.should_not be_valid
26
+ end
27
+
28
+ it "should have many credit transactions" do
29
+ asset = Factory(:asset)
30
+ asset.should respond_to(:credit_transactions)
31
+ end
32
+
33
+ it "should have many debit transactions" do
34
+ asset = Factory(:asset)
35
+ asset.should respond_to(:debit_transactions)
36
+ end
37
+
38
+ it "a contra account should reverse the normal balance" do
39
+ asset = Factory(:asset)
40
+ contra_asset = Factory(:asset, :contra => true)
41
+ transaction = Factory(:transaction, :credit_account => contra_asset, :debit_account => asset, :amount => 1000)
42
+ contra_asset.balance.should > 0
43
+ Asset.balance.should == 0
44
+ end
45
+
46
+ end
@@ -0,0 +1,46 @@
1
+ require 'spec_helper'
2
+
3
+ describe Equity do
4
+
5
+ it "should allow creating a equity account" do
6
+ equity = Factory(:equity)
7
+ end
8
+
9
+ it "should report a balance for the equity account" do
10
+ equity = Factory(:equity)
11
+ equity.balance.should be_kind_of(BigDecimal)
12
+ end
13
+
14
+ it "should report a balance for the class of accounts" do
15
+ Equity.should respond_to(:balance)
16
+ Equity.balance.should be_kind_of(BigDecimal)
17
+ end
18
+
19
+ it "should not report a trial balance" do
20
+ lambda{Equity.trial_balance}.should raise_error(NoMethodError)
21
+ end
22
+
23
+ it "should not be valid without a name" do
24
+ equity = Factory.build(:equity, :name => nil)
25
+ equity.should_not be_valid
26
+ end
27
+
28
+ it "should have many credit transactions" do
29
+ equity = Factory(:equity)
30
+ equity.should respond_to(:credit_transactions)
31
+ end
32
+
33
+ it "should have many debit transactions" do
34
+ equity = Factory(:equity)
35
+ equity.should respond_to(:debit_transactions)
36
+ end
37
+
38
+ it "a contra account should reverse the normal balance" do
39
+ equity = Factory(:equity)
40
+ contra_equity = Factory(:equity, :contra => true)
41
+ transaction = Factory(:transaction, :credit_account => equity, :debit_account => contra_equity, :amount => 1000)
42
+ contra_equity.balance.should > 0
43
+ Equity.balance.should == 0
44
+ end
45
+
46
+ end