plutus 0.5.2 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. data/README.markdown +116 -69
  2. data/Rakefile +7 -20
  3. data/app/assets/javascripts/plutus/application.js +15 -0
  4. data/app/assets/stylesheets/plutus/application.css +13 -0
  5. data/app/assets/stylesheets/plutus/main.css.scss +86 -0
  6. data/app/controllers/plutus/accounts_controller.rb +45 -0
  7. data/app/controllers/plutus/transactions_controller.rb +44 -0
  8. data/app/models/plutus/account.rb +60 -0
  9. data/app/models/plutus/amount.rb +16 -0
  10. data/app/models/plutus/asset.rb +83 -0
  11. data/app/models/plutus/credit_amount.rb +10 -0
  12. data/app/models/plutus/debit_amount.rb +10 -0
  13. data/app/models/plutus/equity.rb +84 -0
  14. data/app/models/plutus/expense.rb +83 -0
  15. data/app/models/plutus/liability.rb +78 -0
  16. data/app/models/plutus/revenue.rb +83 -0
  17. data/app/models/plutus/transaction.rb +83 -0
  18. data/app/views/{accounts → plutus/accounts}/index.html.erb +4 -2
  19. data/app/views/{accounts → plutus/accounts}/show.html.erb +8 -18
  20. data/app/views/plutus/transactions/index.html.erb +48 -0
  21. data/app/views/plutus/transactions/show.html.erb +46 -0
  22. data/config/database.yml +5 -0
  23. data/config/routes.rb +6 -0
  24. data/lib/generators/plutus/templates/migration.rb +17 -13
  25. data/lib/plutus.rb +3 -2
  26. data/lib/plutus/version.rb +3 -0
  27. data/spec/controllers/accounts_controller_spec.rb +22 -19
  28. data/spec/controllers/transactions_controller_spec.rb +23 -20
  29. data/spec/factories/account_factory.rb +30 -24
  30. data/spec/factories/amount_factory.rb +19 -0
  31. data/spec/factories/transaction_factory.rb +11 -6
  32. data/spec/models/account_spec.rb +61 -40
  33. data/spec/models/amount_spec.rb +12 -0
  34. data/spec/models/asset_spec.rb +46 -39
  35. data/spec/models/credit_amount_spec.rb +22 -0
  36. data/spec/models/debit_amount_spec.rb +22 -0
  37. data/spec/models/equity_spec.rb +51 -43
  38. data/spec/models/expense_spec.rb +49 -41
  39. data/spec/models/liability_spec.rb +48 -40
  40. data/spec/models/revenue_spec.rb +48 -41
  41. data/spec/models/transaction_spec.rb +77 -42
  42. data/spec/routing/accounts_routing_spec.rb +23 -20
  43. data/spec/routing/transactions_routing_spec.rb +23 -20
  44. data/spec/spec_helper.rb +3 -1
  45. metadata +208 -139
  46. data/.yardopts +0 -2
  47. data/VERSION.yml +0 -5
  48. data/app/controllers/accounts_controller.rb +0 -43
  49. data/app/controllers/transactions_controller.rb +0 -42
  50. data/app/models/account.rb +0 -57
  51. data/app/models/asset.rb +0 -81
  52. data/app/models/equity.rb +0 -82
  53. data/app/models/expense.rb +0 -81
  54. data/app/models/liability.rb +0 -76
  55. data/app/models/revenue.rb +0 -81
  56. data/app/models/transaction.rb +0 -27
  57. data/app/views/layouts/accounts.html.erb +0 -68
  58. data/app/views/layouts/transactions.html.erb +0 -68
  59. data/app/views/transactions/index.html.erb +0 -27
  60. data/app/views/transactions/show.html.erb +0 -24
  61. data/doc/Account.html +0 -300
  62. data/doc/AccountsController.html +0 -317
  63. data/doc/Asset.html +0 -610
  64. data/doc/CreatePlutusTables.html +0 -265
  65. data/doc/Equity.html +0 -610
  66. data/doc/Expense.html +0 -610
  67. data/doc/Liability.html +0 -588
  68. data/doc/Plutus.html +0 -91
  69. data/doc/Plutus/Engine.html +0 -100
  70. data/doc/PlutusGenerator.html +0 -312
  71. data/doc/Revenue.html +0 -610
  72. data/doc/Transaction.html +0 -156
  73. data/doc/TransactionsController.html +0 -317
  74. data/doc/_index.html +0 -204
  75. data/doc/class_list.html +0 -36
  76. data/doc/css/common.css +0 -1
  77. data/doc/css/full_list.css +0 -53
  78. data/doc/css/style.css +0 -310
  79. data/doc/file.README.html +0 -250
  80. data/doc/file_list.html +0 -38
  81. data/doc/frames.html +0 -13
  82. data/doc/index.html +0 -250
  83. data/doc/js/app.js +0 -202
  84. data/doc/js/full_list.js +0 -149
  85. data/doc/js/jquery.js +0 -154
  86. data/doc/method_list.html +0 -275
  87. data/doc/top-level-namespace.html +0 -90
  88. data/fixture_rails_root/.gitignore +0 -4
  89. data/fixture_rails_root/Gemfile +0 -38
  90. data/fixture_rails_root/Gemfile.lock +0 -98
  91. data/fixture_rails_root/README +0 -256
  92. data/fixture_rails_root/Rakefile +0 -7
  93. data/fixture_rails_root/app/controllers/application_controller.rb +0 -3
  94. data/fixture_rails_root/app/helpers/application_helper.rb +0 -2
  95. data/fixture_rails_root/app/views/layouts/application.html.erb +0 -14
  96. data/fixture_rails_root/config.ru +0 -4
  97. data/fixture_rails_root/config/application.rb +0 -42
  98. data/fixture_rails_root/config/boot.rb +0 -13
  99. data/fixture_rails_root/config/database.yml +0 -22
  100. data/fixture_rails_root/config/environment.rb +0 -5
  101. data/fixture_rails_root/config/environments/development.rb +0 -26
  102. data/fixture_rails_root/config/environments/production.rb +0 -49
  103. data/fixture_rails_root/config/environments/test.rb +0 -35
  104. data/fixture_rails_root/config/initializers/backtrace_silencers.rb +0 -7
  105. data/fixture_rails_root/config/initializers/inflections.rb +0 -10
  106. data/fixture_rails_root/config/initializers/mime_types.rb +0 -5
  107. data/fixture_rails_root/config/initializers/secret_token.rb +0 -7
  108. data/fixture_rails_root/config/initializers/session_store.rb +0 -8
  109. data/fixture_rails_root/config/locales/en.yml +0 -5
  110. data/fixture_rails_root/config/routes.rb +0 -58
  111. data/fixture_rails_root/db/migrate/20101203193439_create_plutus_tables.rb +0 -33
  112. data/fixture_rails_root/db/schema.rb +0 -40
  113. data/fixture_rails_root/db/seeds.rb +0 -7
  114. data/fixture_rails_root/doc/README_FOR_APP +0 -2
  115. data/fixture_rails_root/lib/tasks/.gitkeep +0 -0
  116. data/fixture_rails_root/public/404.html +0 -26
  117. data/fixture_rails_root/public/422.html +0 -26
  118. data/fixture_rails_root/public/500.html +0 -26
  119. data/fixture_rails_root/public/favicon.ico +0 -0
  120. data/fixture_rails_root/public/images/rails.png +0 -0
  121. data/fixture_rails_root/public/index.html +0 -239
  122. data/fixture_rails_root/public/javascripts/application.js +0 -2
  123. data/fixture_rails_root/public/javascripts/controls.js +0 -965
  124. data/fixture_rails_root/public/javascripts/dragdrop.js +0 -974
  125. data/fixture_rails_root/public/javascripts/effects.js +0 -1123
  126. data/fixture_rails_root/public/javascripts/prototype.js +0 -6001
  127. data/fixture_rails_root/public/javascripts/rails.js +0 -175
  128. data/fixture_rails_root/public/robots.txt +0 -5
  129. data/fixture_rails_root/public/stylesheets/.gitkeep +0 -0
  130. data/fixture_rails_root/script/rails +0 -6
  131. data/fixture_rails_root/test/performance/browsing_test.rb +0 -9
  132. data/fixture_rails_root/test/test_helper.rb +0 -13
  133. data/fixture_rails_root/vendor/plugins/.gitkeep +0 -0
  134. data/plutus.gemspec +0 -176
  135. data/tasks/plutus_tasks.rake +0 -4
data/.yardopts DELETED
@@ -1,2 +0,0 @@
1
- app/**/*.rb
2
- LICENSE
@@ -1,5 +0,0 @@
1
- ---
2
- :major: 0
3
- :minor: 5
4
- :build:
5
- :patch: 2
@@ -1,43 +0,0 @@
1
- # This controller provides restful route handling for Accounts.
2
- #
3
- # The controller supports ActiveResource, and provides for
4
- # HMTL, XML, and JSON presentation.
5
- #
6
- # == Security:
7
- # Only GET requests are supported. You should ensure that your application
8
- # controller enforces its own authentication and authorization, which this
9
- # controller will inherit.
10
- #
11
- # @author Michael Bulat
12
- class AccountsController < ApplicationController
13
- unloadable
14
-
15
- # @example
16
- # GET /accounts
17
- # GET /accounts.xml
18
- # GET /accounts.json
19
- def index
20
- @accounts = Account.all
21
-
22
- respond_to do |format|
23
- format.html # index.html.erb
24
- format.xml { render :xml => @accounts }
25
- format.json { render :json => @accounts }
26
- end
27
- end
28
-
29
- # @example
30
- # GET /accounts/1
31
- # GET /accounts/1.xml
32
- # GET /accounts/1.json
33
- def show
34
- @account = Account.find(params[:id])
35
-
36
- respond_to do |format|
37
- format.html # show.html.erb
38
- format.xml { render :xml => @account }
39
- format.json { render :json => @account }
40
- end
41
- end
42
-
43
- end
@@ -1,42 +0,0 @@
1
- # This controller provides restful route handling for Transactions.
2
- #
3
- # The controller supports ActiveResource, and provides for
4
- # HMTL, XML, and JSON presentation.
5
- #
6
- # == Security:
7
- # Only GET requests are supported. You should ensure that your application
8
- # controller enforces its own authentication and authorization, which this
9
- # controller will inherit.
10
- #
11
- # @author Michael Bulat
12
- class TransactionsController < ApplicationController
13
- unloadable
14
- # @example
15
- # GET /transactions
16
- # GET /transactions.xml
17
- # GET /transactions.json
18
- def index
19
- @transactions = Transaction.all
20
-
21
- respond_to do |format|
22
- format.html # index.html.erb
23
- format.xml { render :xml => @transactions }
24
- format.json { render :json => @transactions }
25
- end
26
- end
27
-
28
- # @example
29
- # GET /transactions/1
30
- # GET /transactions/1.xml
31
- # GET /transactions/1.json
32
- def show
33
- @transaction = Transaction.find(params[:id])
34
-
35
- respond_to do |format|
36
- format.html # show.html.erb
37
- format.xml { render :xml => @transaction }
38
- format.json { render :json => @transaction }
39
- end
40
- end
41
-
42
- end
@@ -1,57 +0,0 @@
1
- #
2
- # == Overview:
3
- #
4
- # The Account class represents accounts in the system. Each account must be subclassed as one of the following types:
5
- #
6
- # TYPE | NORMAL BALANCE | DESCRIPTION
7
- # --------------------------------------------------------------------------
8
- # Asset | Debit | Resources owned by the Business Entity
9
- # Liability | Credit | Debts owed to outsiders
10
- # Equity | Credit | Owners rights to the Assets
11
- # Revenue | Credit | Increases in owners equity
12
- # Expense | Debit | Assets or services consumed in the generation of revenue
13
- #
14
- # Each account can also be marked as a "Contra Account". A contra account will have it's
15
- # normal balance swapped. For example, to remove equity, a "Drawing" account may be created
16
- # as a contra equity account as follows:
17
- #
18
- # Equity.create(:name => "Drawing", contra => true)
19
- #
20
- # At all times the balance of all accounts should conform to the "accounting equation"
21
- # Assets = Liabilties + Owner's Equity
22
- #
23
- # Each sublclass account acts as it's own ledger. See the individual subclasses for a
24
- # description.
25
- #
26
- # @abstract
27
- # An account must be a subclass to be saved to the database. The Account class
28
- # has a singleton method {trial_balance} to calculate the balance on all Accounts.
29
- #
30
- # @see http://en.wikipedia.org/wiki/Accounting_equation Accounting Equation
31
- # @see http://en.wikipedia.org/wiki/Debits_and_credits Debits, Credits, and Contra Accounts
32
- #
33
- # @author Michael Bulat
34
- class Account < ActiveRecord::Base
35
-
36
- validates_presence_of :type, :name
37
-
38
- has_many :credit_transactions, :class_name => "Transaction", :foreign_key => "credit_account_id"
39
- has_many :debit_transactions, :class_name => "Transaction", :foreign_key => "debit_account_id"
40
-
41
- # The trial balance of all accounts in the system. This should always equal zero,
42
- # otherwise there is an error in the system.
43
- #
44
- # @example
45
- # >> Account.trial_balance.to_i
46
- # => 0
47
- #
48
- # @return [BigDecimal] The decimal value balance of all accounts
49
- def self.trial_balance
50
- unless self.new.class == Account
51
- raise(NoMethodError, "undefined method 'trial_balance'")
52
- else
53
- Asset.balance - (Liability.balance + Equity.balance + Revenue.balance - Expense.balance)
54
- end
55
- end
56
-
57
- end
@@ -1,81 +0,0 @@
1
- # The Asset class is an account type used to represents resources owned by the business entity.
2
- #
3
- # === Normal Balance
4
- # The normal balance on Asset accounts is a *Debit*.
5
- #
6
- # @see http://en.wikipedia.org/wiki/Asset Assets
7
- #
8
- # @author Michael Bulat
9
- class Asset < Account
10
-
11
- # The credit balance for the account.
12
- #
13
- # @example
14
- # >> asset.credits_balance
15
- # => #<BigDecimal:103259bb8,'0.1E4',4(12)>
16
- #
17
- # @return [BigDecimal] The decimal value credit balance
18
- def credits_balance
19
- credits_balance = BigDecimal.new('0')
20
- credit_transactions.each do |credit_transaction|
21
- credits_balance += credit_transaction.amount
22
- end
23
- return credits_balance
24
- end
25
-
26
- # The debit balance for the account.
27
- #
28
- # @example
29
- # >> asset.debits_balance
30
- # => #<BigDecimal:103259bb8,'0.3E4',4(12)>
31
- #
32
- # @return [BigDecimal] The decimal value credit balance
33
- def debits_balance
34
- debits_balance = BigDecimal.new('0')
35
- debit_transactions.each do |debit_transaction|
36
- debits_balance += debit_transaction.amount
37
- end
38
- return debits_balance
39
- end
40
-
41
- # The balance of the account.
42
- #
43
- # Assets have normal debit balances, so the credits are subtracted from the debits
44
- # unless this is a contra account, in which debits are subtracted from credits
45
- #
46
- # @example
47
- # >> asset.balance
48
- # => #<BigDecimal:103259bb8,'0.2E4',4(12)>
49
- #
50
- # @return [BigDecimal] The decimal value balance
51
- def balance
52
- unless contra
53
- debits_balance - credits_balance
54
- else
55
- credits_balance - debits_balance
56
- end
57
- end
58
-
59
- # This class method is used to return
60
- # the balance of all Asset accounts.
61
- #
62
- # Contra accounts are automatically subtracted from the balance.
63
- #
64
- # @example
65
- # >> Asset.balance
66
- # => #<BigDecimal:1030fcc98,'0.82875E5',8(20)>
67
- #
68
- # @return [BigDecimal] The decimal value balance
69
- def self.balance
70
- accounts_balance = BigDecimal.new('0')
71
- accounts = self.find(:all)
72
- accounts.each do |asset|
73
- unless asset.contra
74
- accounts_balance += asset.balance
75
- else
76
- accounts_balance -= asset.balance
77
- end
78
- end
79
- accounts_balance
80
- end
81
- end
@@ -1,82 +0,0 @@
1
- # The Equity class is an account type used to represents owners rights to the assets.
2
- #
3
- # === Normal Balance
4
- # The normal balance on Equity accounts is a *Credit*.
5
- #
6
- # @see http://en.wikipedia.org/wiki/Equity_(finance) Equity
7
- #
8
- # @author Michael Bulat
9
- class Equity < Account
10
-
11
- # The credit balance for the account.
12
- #
13
- # @example
14
- # >> equity.credits_balance
15
- # => #<BigDecimal:103259bb8,'0.3E4',4(12)>
16
- #
17
- # @return [BigDecimal] The decimal value credit balance
18
- def credits_balance
19
- credits_balance = BigDecimal.new('0')
20
- credit_transactions.each do |credit_transaction|
21
- credits_balance = credits_balance + credit_transaction.amount
22
- end
23
- return credits_balance
24
- end
25
-
26
- # The debit balance for the account.
27
- #
28
- # @example
29
- # >> equity.debits_balance
30
- # => #<BigDecimal:103259bb8,'0.1E4',4(12)>
31
- #
32
- # @return [BigDecimal] The decimal value credit balance
33
- def debits_balance
34
- debits_balance = BigDecimal.new('0')
35
- debit_transactions.each do |debit_transaction|
36
- debits_balance = debits_balance + debit_transaction.amount
37
- end
38
- return debits_balance
39
- end
40
-
41
-
42
- # The balance of the account.
43
- #
44
- # Equity accounts have normal credit balances, so the debits are subtracted from the credits
45
- # unless this is a contra account, in which credits are subtracted from debits
46
- #
47
- # @example
48
- # >> asset.balance
49
- # => #<BigDecimal:103259bb8,'0.2E4',4(12)>
50
- #
51
- # @return [BigDecimal] The decimal value balance
52
- def balance
53
- unless contra
54
- credits_balance - debits_balance
55
- else
56
- debits_balance - credits_balance
57
- end
58
- end
59
-
60
- # This class method is used to return
61
- # the balance of all Equity accounts.
62
- #
63
- # Contra accounts are automatically subtracted from the balance.
64
- #
65
- # @example
66
- # >> Equity.balance
67
- # => #<BigDecimal:1030fcc98,'0.82875E5',8(20)>
68
- #
69
- # @return [BigDecimal] The decimal value balance
70
- def self.balance
71
- accounts_balance = BigDecimal.new('0')
72
- accounts = self.find(:all)
73
- accounts.each do |equity|
74
- unless equity.contra
75
- accounts_balance += equity.balance
76
- else
77
- accounts_balance -= equity.balance
78
- end
79
- end
80
- accounts_balance
81
- end
82
- end
@@ -1,81 +0,0 @@
1
- # The Expense class is an account type used to represents assets or services consumed in the generation of revenue.
2
- #
3
- # === Normal Balance
4
- # The normal balance on Expense accounts is a *Debit*.
5
- #
6
- # @see http://en.wikipedia.org/wiki/Expense Expenses
7
- #
8
- # @author Michael Bulat
9
- class Expense < Account
10
-
11
- # The credit balance for the account.
12
- #
13
- # @example
14
- # >> expense.credits_balance
15
- # => #<BigDecimal:103259bb8,'0.1E4',4(12)>
16
- #
17
- # @return [BigDecimal] The decimal value credit balance
18
- def credits_balance
19
- credits_balance = BigDecimal.new('0')
20
- credit_transactions.each do |credit_transaction|
21
- credits_balance = credits_balance + credit_transaction.amount
22
- end
23
- return credits_balance
24
- end
25
-
26
- # The debit balance for the account.
27
- #
28
- # @example
29
- # >> expense.debits_balance
30
- # => #<BigDecimal:103259bb8,'0.3E4',4(12)>
31
- #
32
- # @return [BigDecimal] The decimal value credit balance
33
- def debits_balance
34
- debits_balance = BigDecimal.new('0')
35
- debit_transactions.each do |debit_transaction|
36
- debits_balance = debits_balance + debit_transaction.amount
37
- end
38
- return debits_balance
39
- end
40
-
41
- # The balance of the account.
42
- #
43
- # Expenses have normal debit balances, so the credits are subtracted from the debits
44
- # unless this is a contra account, in which debits are subtracted from credits
45
- #
46
- # @example
47
- # >> expense.balance
48
- # => #<BigDecimal:103259bb8,'0.2E4',4(12)>
49
- #
50
- # @return [BigDecimal] The decimal value balance
51
- def balance
52
- unless contra
53
- debits_balance - credits_balance
54
- else
55
- credits_balance - debits_balance
56
- end
57
- end
58
-
59
- # This class method is used to return
60
- # the balance of all Expense accounts.
61
- #
62
- # Contra accounts are automatically subtracted from the balance.
63
- #
64
- # @example
65
- # >> Expense.balance
66
- # => #<BigDecimal:1030fcc98,'0.82875E5',8(20)>
67
- #
68
- # @return [BigDecimal] The decimal value balance
69
- def self.balance
70
- accounts_balance = BigDecimal.new('0')
71
- accounts = self.find(:all)
72
- accounts.each do |expense|
73
- unless expense.contra
74
- accounts_balance += expense.balance
75
- else
76
- accounts_balance -= expense.balance
77
- end
78
- end
79
- accounts_balance
80
- end
81
- end
@@ -1,76 +0,0 @@
1
- # The Liability class is an account type used to represents debts owed to outsiders.
2
- #
3
- # === Normal Balance
4
- # The normal balance on Liability accounts is a *Credit*.
5
- #
6
- # @see http://en.wikipedia.org/wiki/Liability_(financial_accounting) Liability
7
- #
8
- # @author Michael Bulat
9
- class Liability < Account
10
-
11
- # The credit balance for the account.
12
- #
13
- # @example
14
- # >> liability.credits_balance
15
- # => #<BigDecimal:103259bb8,'0.3E4',4(12)>
16
- #
17
- # @return [BigDecimal] The decimal value credit balance
18
- def credits_balance
19
- credits_balance = BigDecimal.new('0')
20
- credit_transactions.each do |credit_transaction|
21
- credits_balance = credits_balance + credit_transaction.amount
22
- end
23
- return credits_balance
24
- end
25
-
26
- # The debit balance for the account.
27
- #
28
- # @example
29
- # >> liability.debits_balance
30
- # => #<BigDecimal:103259bb8,'0.1E4',4(12)>
31
- #
32
- # @return [BigDecimal] The decimal value credit balance
33
- def debits_balance
34
- debits_balance = BigDecimal.new('0')
35
- debit_transactions.each do |debit_transaction|
36
- debits_balance = debits_balance + debit_transaction.amount
37
- end
38
- return debits_balance
39
- end
40
-
41
- # The balance of the account.
42
- #
43
- # Liability accounts have normal credit balances, so the debits are subtracted from the credits
44
- # unless this is a contra account, in which credits are subtracted from debits
45
- #
46
- # @example
47
- # >> liability.balance
48
- # => #<BigDecimal:103259bb8,'0.2E4',4(12)>
49
- #
50
- # @return [BigDecimal] The decimal value balance
51
- def balance
52
- unless contra
53
- credits_balance - debits_balance
54
- else
55
- debits_balance - credits_balance
56
- end
57
- end
58
-
59
- # Balance of all Liability accounts
60
- #
61
- # @example
62
- # >> Liability.balance
63
- # => #<BigDecimal:1030fcc98,'0.82875E5',8(20)>
64
- def self.balance
65
- accounts_balance = BigDecimal.new('0')
66
- accounts = self.find(:all)
67
- accounts.each do |liability|
68
- unless liability.contra
69
- accounts_balance += liability.balance
70
- else
71
- accounts_balance -= liability.balance
72
- end
73
- end
74
- accounts_balance
75
- end
76
- end