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
@@ -1,10 +1,10 @@
1
1
  Plutus
2
2
  =================
3
+ [![Build Status](https://secure.travis-ci.org/mbulat/plutus.png?branch=master)](http://travis-ci.org/mbulat/plutus)
3
4
 
4
- This plutus plugin is a Ruby on Rails Engine which provides a double entry accounting system for your application.
5
+ The Plutus plugin is a Ruby on Rails Engine which provides a double entry accounting system for your application.
5
6
 
6
- NOTE: This version of Plutus is compatable with RAILS 3
7
- =======================================================
7
+ ### NOTE: This version of Plutus is compatible with RAILS 3.1
8
8
 
9
9
  For the rails 2 version, you can go here:
10
10
 
@@ -26,37 +26,46 @@ Overview
26
26
 
27
27
  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](http://en.wikipedia.org/wiki/Double-entry_bookkeeping_system) practices. All calculations are done using [BigDecimal](http://www.ensta.fr/~diam/ruby/online/ruby-doc-stdlib/libdoc/bigdecimal/rdoc/classes/BigDecimal.html) in order to prevent floating point rounding errors. The plugin requires a decimal type on your database as well.
28
28
 
29
- The system consists of a table that maintains your accounts and a table for recording transactions. Transactions are the recording of debits and credits to various accounts. The transaction table, which records your business transactions is, essentially, your accounting [Journal](http://en.wikipedia.org/wiki/Journal_entry)
29
+ The system consists of tables that maintains your accounts, transactions and debits and credits. Each transaction can have many debits and credits. The transaction table, which records your business transactions is, essentially, your accounting [Journal](http://en.wikipedia.org/wiki/Journal_entry).
30
30
 
31
- Posting to a [Ledger](http://en.wikipedia.org/wiki/General_ledger) can be considered to happen automatically, since Accounts have the reverse `has_many` relationship to either its credit or debit transactions
31
+ Posting to a [Ledger](http://en.wikipedia.org/wiki/General_ledger) can be considered to happen automatically, since Accounts have the reverse `has_many` relationship to either its credit or debit transactions.
32
32
 
33
33
  Accounts
34
34
  --------
35
35
 
36
- The Account class represents accounts in the system. The Account table uses single table inheritance to store information on each type of account (Asset, Liability, Equity, Revenue, Expense). Each account must be subclassed as one of the following types:
36
+ The Account class represents accounts in the system. The Account table uses single table inheritance to store information on each type of account (Asset, Liability, Equity, Revenue, Expense). Each account must be sub-classed as one of the following types:
37
37
 
38
- TYPE | NORMAL BALANCE | DESCRIPTION
39
- --------------------------------------------------------------------------
40
- Asset | Debit | Resources owned by the Business Entity
41
- Liability | Credit | Debts owed to outsiders
42
- Equity | Credit | Owners rights to the Assets
43
- Revenue | Credit | Increases in owners equity
44
- Expense | Debit | Assets or services consumed in the generation of revenue
38
+ TYPE | NORMAL BALANCE | DESCRIPTION
39
+ --------------------------------------------------------------------------
40
+ Asset | Debit | Resources owned by the Business Entity
41
+ Liability | Credit | Debts owed to outsiders
42
+ Equity | Credit | Owners rights to the Assets
43
+ Revenue | Credit | Increases in owners equity
44
+ Expense | Debit | Assets or services consumed in the generation of revenue
45
+
46
+ Your Book of Accounts needs to be created prior to recording any transactions. The simplest method is to have a number of create methods in your db/seeds.rb file like so:
47
+
48
+ Plutus::Asset.create(:name => "Accounts Receivable")
49
+ Plutus::Asset.create(:name => "Cash")
50
+ Plutus::Revenue.create(:name => "Sales Revenue")
51
+ Plutus::Liability.create(:name => "Unearned Revenue")
52
+ Plutus::Liability.create(:name => "Sales Tax Payable")
53
+ etc...
54
+
55
+ Then simply run `rake db:seed`
45
56
 
46
57
  Each account can also be marked as a "Contra Account". A contra account will have its normal balance swapped. For example, to remove equity, a "Drawing" account may be created as a contra equity account as follows:
47
58
 
48
- Equity.create(:name => "Drawing", contra => true)
59
+ Plutus::Equity.create(:name => "Drawing", contra => true)
49
60
 
50
61
  At all times the balance of all accounts should conform to the [Accounting
51
62
  Equation](http://en.wikipedia.org/wiki/Accounting_equation)
52
63
 
53
- Assets = Liabilties + Owner's Equity
64
+ Assets = Liabilities + Owner's Equity
54
65
 
55
66
  Every account object has a `has_many` association of credit and debit transactions, which means that each account object also acts as its own [Ledger](http://en.wikipedia.org/wiki/General_ledger), and exposes a method to calculate the balance of the account.
56
67
 
57
- See the {Account} and {Transaction} classes for more information.
58
-
59
-
68
+ See the {Plutus::Account}, {Plutus::Transaction}, and {Plutus::Amount} classes for more information.
60
69
 
61
70
  Examples
62
71
  ========
@@ -64,17 +73,47 @@ Examples
64
73
  Recording a Transaction
65
74
  -----------------------
66
75
 
67
- Let's assume we're accounting on an [Accrual basis](http://en.wikipedia.org/wiki/Accounting_methods). We've just taken a customer's order for some widgets, which we've also billed him for. At this point we've actually added a liability to the company until we deliver the goods. To record this transaction we'd need two accounts.
76
+ Let's assume we're accounting on an [Accrual basis](http://en.wikipedia.org/wiki/Accounting_methods). We've just taken a customer's order for some widgets, which we've also billed him for. At this point we've actually added a liability to the company until we deliver the goods. To record this transaction we'd need two accounts:
77
+
78
+ >> Plutus::Asset.create(:name => "Cash")
79
+ >> Plutus::Liability.create(:name => "Unearned Revenue")
68
80
 
69
- >> Liability.create(:name => "Unearned Revenue")
70
- >> Asset.create(:name => "Cash")
81
+ Next we'll build the transaction we want to record. Plutus provides a simple interface to build the transaction.
71
82
 
72
- We'd then record the following transaction.
83
+ transaction = Plutus::Transaction.build(
84
+ :description => "Order placed for widgets",
85
+ :debits => [
86
+ {:account => "Cash", :amount => 100.00}],
87
+ :credits => [
88
+ {:account => "Unearned Revenue", :amount => 100.00}])
89
+
90
+ The build method takes a hash consisting of a description, and an array of debits and credits. Each debit and credit item is a hash that specifies the amount, and the account to be debited or credited. Simply pass in the string name you used when you created the account.
91
+
92
+ Finally, save the transaction.
93
+
94
+ >> transaction.save
95
+
96
+ If there are any issues with your credit and debit amounts, the save will fail and return false. You can inspect the errors via `transaction.errors`. Because we are doing double-entry accounting, your credit and debit amounts must always cancel out to keep the accounts in balance.
97
+
98
+ Recording a Transaction with multiple accounts
99
+ ----------------------------------------------
73
100
 
74
- >> Transaction.create(:description => "Order placed for widgets",
75
- :credit_account => Liability.find_by_name("Unearned Revenue"),
76
- :debit_account => Asset.find_by_name("Cash"),
77
- :amount => 1000)
101
+ Often times a single transaction requires more than one type of account. A classic example would be a transaction in which a tax is charged. We'll assume that we have not yet received payment for the order, so we'll need an "Accounts Receivable" Asset:
102
+
103
+ >> Plutus::Asset.create(:name => "Accounts Receivable")
104
+ >> Plutus::Revenue.create(:name => "Sales Revenue")
105
+ >> Plutus::Liability.create(:name => "Sales Tax Payable")
106
+
107
+ And here's the transaction:
108
+
109
+ transaction = Plutus::Transaction.build(
110
+ :description => "Sold some widgets",
111
+ :debits => [
112
+ {:account => "Accounts Receivable", :amount => 50}],
113
+ :credits => [
114
+ {:account => "Sales Revenue", :amount => 45},
115
+ {:account => "Sales Tax Payable", :amount => 5}])
116
+ transaction.save
78
117
 
79
118
  Associating Documents
80
119
  ---------------------
@@ -83,19 +122,19 @@ Although Plutus does not provide a mechanism for generating invoices or orders,
83
122
 
84
123
  Suppose we pull up our latest invoice in order to generate a transaction for plutus (we'll assume you already have an Invoice model):
85
124
 
86
- >> invoice = Invoice.last
125
+ >> invoice = Invoice.last
87
126
 
88
- We'll also assume that we have not yet received payment for the order, so we'll need an "Accounts Receivable" Asset:
127
+ Let's assume we're using the same transaction from the last example
89
128
 
90
- >> Asset.create(:name => "Accounts Receivable")
91
-
92
- Next, we'll go ahead and create a transaction for this invoice:
93
-
94
- >> Transaction.create(:description => "Order placed for widgets",
95
- :credit_account => Liability.find_by_name("Unearned Revenue"),
96
- :debit_account => Asset.find_by_name("Accounts Receivable"),
97
- :amount => invoice.amount,
98
- :commercial_document => invoice)
129
+ transaction = Plutus::Transaction.build(
130
+ :description => "Sold some widgets",
131
+ :commercial_document => invoice,
132
+ :debits => [
133
+ {:account => "Accounts Receivable", :amount => invoice.total_amount}],
134
+ :credits => [
135
+ {:account => "Sales Revenue", :amount => invoice.sales_amount},
136
+ {:account => "Sales Tax Payable", :amount => invoice.tax_amount}])
137
+ transaction.save
99
138
 
100
139
  The commercial document attribute on the transaction is a polymorphic association allowing you to associate any record from your models with a transaction (i.e. Bills, Invoices, Receipts, Returns, etc.)
101
140
 
@@ -104,9 +143,9 @@ Checking the Balance of an Individual Account
104
143
 
105
144
  Each account can report on its own balance. This number should normally be positive. If the number is negative, you may have a problem.
106
145
 
107
- >> cash = Asset.find_by_name("Cash")
108
- >> cash.balance
109
- => #<BigDecimal:103259bb8,'0.2E4',4(12)>
146
+ >> cash = Plutus::Asset.find_by_name("Cash")
147
+ >> cash.balance
148
+ => #<BigDecimal:103259bb8,'0.2E4',4(12)>
110
149
 
111
150
 
112
151
  Checking the Balance of an Account Type
@@ -114,48 +153,53 @@ Checking the Balance of an Account Type
114
153
 
115
154
  Each subclass of accounts can report on the total balance of all the accounts of that type. This number should normally be positive. If the number is negative, you may have a problem.
116
155
 
117
- >> Asset.balance
118
- => #<BigDecimal:103259bb8,'0.2E4',4(12)>
156
+ >> Plutus::Asset.balance
157
+ => #<BigDecimal:103259bb8,'0.2E4',4(12)>
119
158
 
120
159
  Calculating the Trial Balance
121
160
  -----------------------------
122
161
 
123
162
  The [Trial Balance](http://en.wikipedia.org/wiki/Trial_balance) for all accounts on the system can be found through the abstract Account class. This value should be 0 unless there is an error in the system.
124
163
 
125
- >> Account.trial_balance
126
- => #<BigDecimal:1031c0d28,'0.0',4(12)>
164
+ >> Plutus::Account.trial_balance
165
+ => #<BigDecimal:1031c0d28,'0.0',4(12)>
127
166
 
128
167
  Contra Accounts and Complex Transactions
129
168
  ----------------------------------------
130
169
 
131
170
  For complex transaction, you should always ensure that you are balancing your accounts via the [Accounting Equation](http://en.wikipedia.org/wiki/Accounting_equation).
132
171
 
133
- Assets = Liabilties + Owner's Equity
172
+ Assets = Liabilities + Owner's Equity
134
173
 
135
- For example, let's assume the owner of a business wants to withdraw cash. First we'll assume that we have an asset account for "Cash" which the funds will be drawn from. We'll then need an Equity account to record where the funds are going, however, in this case, we can't simply create a regular Equity account. The "Cash" account must be credited for the decrease in its balance since it's an Asset. Likewise, Equity accounts are typically credited when there is an increase in their balance. Equity is considered an owner's rights to Assets in the business. In this case however, we are not simply increasing the owners right's to assets within the business; we are actually removing capital from the business altogether. Hence both sides of our accounting equation will see a decrease. In order to accomplish this, we need to create a Contra-Equity account we'll call "Drawings". Since Equity accounts normally have credit balances, a Contra-Equity account will have a debit balance, which is what we need for our transaction.
174
+ For example, let's assume the owner of a business wants to withdraw cash. First we'll assume that we have an asset account for "Cash" which the funds will be drawn from. We'll then need an Equity account to record where the funds are going, however, in this case, we can't simply create a regular Equity account. The "Cash" account must be credited for the decrease in its balance since it's an Asset. Likewise, Equity accounts are typically credited when there is an increase in their balance. Equity is considered an owner's rights to Assets in the business. In this case however, we are not simply increasing the owner's rights to assets within the business; we are actually removing capital from the business altogether. Hence both sides of our accounting equation will see a decrease. In order to accomplish this, we need to create a Contra-Equity account we'll call "Drawings". Since Equity accounts normally have credit balances, a Contra-Equity account will have a debit balance, which is what we need for our transaction.
175
+
176
+ >> Plutus::Equity.create(:name => "Drawing", :contra => true)
177
+ >> Plutus::Asset.create(:name => "Cash")
136
178
 
137
- >> Equity.create(:name => "Drawing", :contra => true)
138
- >> Asset.create(:name => "Cash")
139
-
140
179
  We would then create the following transaction:
141
180
 
142
- >> Transaction.create(:description => "Owner withdrawing cash",
143
- :credit_account => Asset.find_by_name("Cash"),
144
- :debit_account => Equity.find_by_name("Drawing"),
145
- :amount => 1000.00)
181
+ transaction = Plutus::Transaction.build(
182
+ :description => "Owner withdrawing cash",
183
+ :debits => [
184
+ {:account => "Drawing", :amount => 1000}],
185
+ :credits => [
186
+ {:account => "Cash", :amount => 1000}])
187
+ transaction.save
146
188
 
147
189
  To make the example clearer, imagine instead that the owner decides to invest his money into the business in exchange for some type of equity security. In this case we might have the following accounts:
148
190
 
149
-
150
- >> Equity.create(:name => "Common Stock")
151
- >> Asset.create(:name => "Cash")
191
+ >> Plutus::Equity.create(:name => "Common Stock")
192
+ >> Plutus::Asset.create(:name => "Cash")
152
193
 
153
194
  And out transaction would be:
154
195
 
155
- >> Transaction.create(:description => "Owner investing cash",
156
- :credit_account => Equity.find_by_name("Common Stock"),
157
- :debit_account => Asset.find_by_name("Cash"),
158
- :amount => 1000.00)
196
+ transaction = Plutus::Transaction.build(
197
+ :description => "Owner investing cash",
198
+ :debits => [
199
+ {:account => "Cash", :amount => 1000}],
200
+ :credits => [
201
+ {:account => "Common Stock", :amount => 1000}])
202
+ transaction.save
159
203
 
160
204
  In this case, we've increase our cash Asset, and simultaneously increased the other side of our accounting equation in
161
205
  Equity, keeping everything balanced.
@@ -163,26 +207,29 @@ Equity, keeping everything balanced.
163
207
  Access & Security
164
208
  =================
165
209
 
166
- The Engine provides controllers and views for viewing Accounts and Transactions via the {AccountsController} and {TransactionsController} classes. The controllers will render HTML, XML and JSON, and are compatible with [ActiveResource](http://api.rubyonrails.org/classes/ActiveResource/Base.html)
210
+ The Engine provides controllers and views for viewing Accounts and Transactions via the {Plutus::AccountsController} and {Plutus::TransactionsController} classes. The controllers will render HTML, XML and JSON, and are compatible with [ActiveResource](http://api.rubyonrails.org/classes/ActiveResource/Base.html)
211
+
212
+ These controllers are read-only for reporting purposes. It is assumed transaction creation will occur within your applications code.
213
+
214
+ Routing is supplied via an engine mount point. Plutus can be mounted on a subpath in your existing Rails 3 app by adding the following to your routes.rb:
215
+
216
+ mount Plutus::Engine => "/plutus", :as => "plutus"
167
217
 
168
- Routing is NOT supplied by the engine. You can add routes to your application in your config/routes.rb with something like the following
218
+ *NOTE: If you enable routing, you should ensure that your ApplicationController enforces its own authentication and authorization, which this controller will inherit.*
169
219
 
170
- map.resources :transactions, :only => [:index, :show], :conditions => { :method => :get }
171
- map.resources :accounts, :only => [:index, :show], :conditions => { :method => :get }
220
+ Sample stylesheets can also be applied by adding the following to your application layout:
172
221
 
173
- *NOTE: If you enable routing, you should ensure that your ApplicationController enforces its own authentication and authorization, which this controller will inherit.*
222
+ <%= stylesheet_link_tag "plutus/application" %>
174
223
 
175
224
  Testing
176
225
  =======
177
226
 
178
- [Rspec](http://rspec.info/) tests are provided. Install both the rpsec and rspec-rails gems, and install this plugin
179
- into a working rails application to run the tests.
227
+ [Rspec](http://rspec.info/) tests are provided. Run `bundle install` then `rake`.
180
228
 
181
229
  ToDo
182
230
  ====
183
231
 
184
232
  * Better views, including paging and ledgers
185
- * Namespacing to allow overriding engine classes
186
233
  * Reference for common accounting transactions
187
234
 
188
235
  Reference
@@ -194,4 +241,4 @@ For a complete reference on Accounting principles, we recommend the following te
194
241
 
195
242
  * * *
196
243
 
197
- Copyright (c) 2010 Michael Bulat
244
+ Copyright (c) 2010-2012 Michael Bulat
data/Rakefile CHANGED
@@ -1,24 +1,11 @@
1
- require 'rake'
2
- require 'yard'
1
+ require 'bundler/setup'
3
2
 
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "plutus"
8
- gem.summary = "A Plugin providing a Double Entry Accounting Engine for Rails"
9
- gem.description = "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
- gem.email = "mbulat@crazydogsoftware.com"
11
- gem.homepage = "http://github.com/mbulat/Plutus"
12
- gem.authors = ["Michael Bulat"]
13
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
14
- end
3
+ require 'rspec/core/rake_task'
15
4
 
16
- rescue LoadError
17
- puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
5
+ desc "run specs"
6
+ RSpec::Core::RakeTask.new do |t|
7
+ t.rspec_opts = ["-c", "-f d", "-r ./spec/spec_helper.rb"]
8
+ t.pattern = 'spec/**/*_spec.rb'
18
9
  end
19
10
 
20
- desc 'Generate documentation for the plutus plugin.'
21
- YARD::Rake::YardocTask.new do |t|
22
- t.files = ['lib/**/*.rb', 'app/**/*.rb'] # optional
23
- t.options = [] # optional
24
- end
11
+ task :default => :spec
@@ -0,0 +1,15 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // the compiled file.
9
+ //
10
+ // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
+ // GO AFTER THE REQUIRES BELOW.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require_tree .
@@ -0,0 +1,13 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -0,0 +1,86 @@
1
+ .plutus_container {
2
+
3
+ /* CSS from http://wptheming.com/2011/01/simple-table-css3/ */
4
+
5
+ margin:0;
6
+ padding:0;
7
+ border:0;
8
+ font-family: "Helvetica Neue",Arial, Helvetica, sans-serif;
9
+
10
+ /*
11
+ Pretty Table Styling
12
+ CSS Tricks also has a nice writeup: http://css-tricks.com/feature-table-design/
13
+ */
14
+
15
+ table {
16
+ overflow:hidden;
17
+ border:1px solid #d3d3d3;
18
+ background:#fefefe;
19
+ width:70%;
20
+ margin:5% auto 0;
21
+ -moz-border-radius:5px; /* FF1+ */
22
+ -webkit-border-radius:5px; /* Saf3-4 */
23
+ border-radius:5px;
24
+ -moz-box-shadow: 0 0 4px rgba(0, 0, 0, 0.2);
25
+ -webkit-box-shadow: 0 0 4px rgba(0, 0, 0, 0.2);
26
+ }
27
+
28
+ th, td {padding:10px 18px 10px; }
29
+
30
+ th {padding-top:22px; text-shadow: 1px 1px 1px #fff; background:#e8eaeb;}
31
+
32
+ td {border-top:1px solid #e0e0e0; border-right:1px solid #e0e0e0;}
33
+
34
+ tr.even td {background:#f6f6f6;}
35
+
36
+ td.first, th.first {text-align:left}
37
+
38
+ td.last {border-right:none;}
39
+
40
+ /*
41
+ Background gradients are completely unnessary but a neat effect.
42
+ */
43
+
44
+ td {
45
+ background: -moz-linear-gradient(100% 25% 90deg, #fefefe, #f9f9f9);
46
+ background: -webkit-gradient(linear, 0% 0%, 0% 25%, from(#f9f9f9), to(#fefefe));
47
+ }
48
+
49
+ tr.even td {
50
+ background: -moz-linear-gradient(100% 25% 90deg, #f6f6f6, #f1f1f1);
51
+ background: -webkit-gradient(linear, 0% 0%, 0% 25%, from(#f1f1f1), to(#f6f6f6));
52
+ }
53
+
54
+ th {
55
+ background: -moz-linear-gradient(100% 20% 90deg, #e8eaeb, #ededed);
56
+ background: -webkit-gradient(linear, 0% 0%, 0% 20%, from(#ededed), to(#e8eaeb));
57
+ }
58
+
59
+ /*
60
+ I know this is annoying, but we need dditional styling so webkit will recognize rounded corners on background elements.
61
+ Nice write up of this issue: http://www.onenaught.com/posts/266/css-inner-elements-breaking-border-radius
62
+
63
+ And, since we've applied the background colors to td/th element because of IE, Gecko browsers also need it.
64
+ */
65
+
66
+ tr:first-child th.first {
67
+ -moz-border-radius-topleft:5px;
68
+ -webkit-border-top-left-radius:5px; /* Saf3-4 */
69
+ }
70
+
71
+ tr:first-child th.last {
72
+ -moz-border-radius-topright:5px;
73
+ -webkit-border-top-right-radius:5px; /* Saf3-4 */
74
+ }
75
+
76
+ tr:last-child td.first {
77
+ -moz-border-radius-bottomleft:5px;
78
+ -webkit-border-bottom-left-radius:5px; /* Saf3-4 */
79
+ }
80
+
81
+ tr:last-child td.last {
82
+ -moz-border-radius-bottomright:5px;
83
+ -webkit-border-bottom-right-radius:5px; /* Saf3-4 */
84
+ }
85
+
86
+ }
@@ -0,0 +1,45 @@
1
+ module Plutus
2
+ # This controller provides restful route handling for Accounts.
3
+ #
4
+ # The controller supports ActiveResource, and provides for
5
+ # HMTL, XML, and JSON presentation.
6
+ #
7
+ # == Security:
8
+ # Only GET requests are supported. You should ensure that your application
9
+ # controller enforces its own authentication and authorization, which this
10
+ # controller will inherit.
11
+ #
12
+ # @author Michael Bulat
13
+ class AccountsController < ApplicationController
14
+ unloadable
15
+
16
+ # @example
17
+ # GET /accounts
18
+ # GET /accounts.xml
19
+ # GET /accounts.json
20
+ def index
21
+ @accounts = Account.all
22
+
23
+ respond_to do |format|
24
+ format.html # index.html.erb
25
+ format.xml { render :xml => @accounts }
26
+ format.json { render :json => @accounts }
27
+ end
28
+ end
29
+
30
+ # @example
31
+ # GET /accounts/1
32
+ # GET /accounts/1.xml
33
+ # GET /accounts/1.json
34
+ def show
35
+ @account = Account.find(params[:id])
36
+
37
+ respond_to do |format|
38
+ format.html # show.html.erb
39
+ format.xml { render :xml => @account }
40
+ format.json { render :json => @account }
41
+ end
42
+ end
43
+
44
+ end
45
+ end