tyche 0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +23 -0
- data/README.markdown +392 -0
- data/Rakefile +11 -0
- data/app/assets/javascripts/plutus/application.js +16 -0
- data/app/assets/javascripts/plutus/reports.js +5 -0
- data/app/assets/stylesheets/bootstrap-theme.min.css +5 -0
- data/app/assets/stylesheets/bootstrap.min.css +5 -0
- data/app/assets/stylesheets/plutus/application.css +19 -0
- data/app/controllers/plutus/accounts_controller.rb +30 -0
- data/app/controllers/plutus/application_controller.rb +4 -0
- data/app/controllers/plutus/entries_controller.rb +34 -0
- data/app/controllers/plutus/reports_controller.rb +40 -0
- data/app/models/plutus/account.rb +172 -0
- data/app/models/plutus/amount.rb +24 -0
- data/app/models/plutus/amounts_extension.rb +42 -0
- data/app/models/plutus/asset.rb +56 -0
- data/app/models/plutus/balance_finders/base_balance_finder.rb +13 -0
- data/app/models/plutus/credit_amount.rb +10 -0
- data/app/models/plutus/debit_amount.rb +10 -0
- data/app/models/plutus/entry.rb +77 -0
- data/app/models/plutus/equity.rb +56 -0
- data/app/models/plutus/expense.rb +56 -0
- data/app/models/plutus/liability.rb +56 -0
- data/app/models/plutus/no_tenancy.rb +9 -0
- data/app/models/plutus/revenue.rb +56 -0
- data/app/models/plutus/tenancy.rb +15 -0
- data/app/views/layouts/plutus/_messages.html.erb +9 -0
- data/app/views/layouts/plutus/_navigation.html.erb +19 -0
- data/app/views/layouts/plutus/_navigation_links.html.erb +5 -0
- data/app/views/layouts/plutus/application.html.erb +19 -0
- data/app/views/plutus/accounts/index.html.erb +26 -0
- data/app/views/plutus/entries/index.html.erb +59 -0
- data/app/views/plutus/reports/_account.html.erb +28 -0
- data/app/views/plutus/reports/balance_sheet.html.erb +21 -0
- data/app/views/plutus/reports/income_statement.html.erb +24 -0
- data/config/backtrace_silencers.rb +7 -0
- data/config/database.yml +5 -0
- data/config/inflections.rb +10 -0
- data/config/mime_types.rb +5 -0
- data/config/routes.rb +9 -0
- data/config/secret_token.rb +7 -0
- data/config/session_store.rb +8 -0
- data/db/migrate/20160422010135_create_plutus_tables.rb +35 -0
- data/lib/generators/plutus/USAGE +22 -0
- data/lib/generators/plutus/add_date_upgrade_generator.rb +11 -0
- data/lib/generators/plutus/base_generator.rb +19 -0
- data/lib/generators/plutus/plutus_generator.rb +12 -0
- data/lib/generators/plutus/templates/tenant_migration.rb +6 -0
- data/lib/generators/plutus/tenancy_generator.rb +12 -0
- data/lib/generators/plutus/upgrade_plutus_generator.rb +12 -0
- data/lib/plutus.rb +20 -0
- data/lib/plutus/engine.rb +5 -0
- data/lib/plutus/version.rb +3 -0
- data/spec/controllers/accounts_controller_spec.rb +19 -0
- data/spec/controllers/entries_controller_spec.rb +19 -0
- data/spec/controllers/reports_controller_spec.rb +24 -0
- data/spec/factories/account_factory.rb +35 -0
- data/spec/factories/amount_factory.rb +20 -0
- data/spec/factories/entry_factory.rb +11 -0
- data/spec/lib/plutus_spec.rb +0 -0
- data/spec/models/account_spec.rb +133 -0
- data/spec/models/amount_spec.rb +13 -0
- data/spec/models/asset_spec.rb +7 -0
- data/spec/models/credit_amount_spec.rb +7 -0
- data/spec/models/debit_amount_spec.rb +7 -0
- data/spec/models/entry_spec.rb +182 -0
- data/spec/models/equity_spec.rb +7 -0
- data/spec/models/expense_spec.rb +7 -0
- data/spec/models/liability_spec.rb +7 -0
- data/spec/models/revenue_spec.rb +7 -0
- data/spec/models/tenancy_spec.rb +45 -0
- data/spec/rcov.opts +2 -0
- data/spec/routing/accounts_routing_spec.rb +13 -0
- data/spec/routing/entries_routing_spec.rb +13 -0
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +30 -0
- data/spec/support/account_shared_examples.rb +62 -0
- data/spec/support/active_support_helpers.rb +13 -0
- data/spec/support/amount_shared_examples.rb +21 -0
- data/spec/support/factory_girl_helpers.rb +8 -0
- data/spec/support/shoulda_matchers.rb +8 -0
- metadata +240 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e94ab1abdd00cd8147e32cf960f4ec8b687b1d962bc41418f203080799b655d7
|
4
|
+
data.tar.gz: 72df7d28796962ee163c70532bb0d5d9cb1cf8d3ea3d35637b89976c8ac00852
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 74db273916ba6087c3ee3e521ffde1bf99dc9dbaef7db702933da72fa042671196bca6da883cf6ae1e5e5da87e8601f46b6505a8c3db4b425ee6142494df9cd3
|
7
|
+
data.tar.gz: ec5345cdd946e3cecc02d4d4272a5da0a16acdcdd3a609403ee6b4e3eb89a2391de7c62a7a3948eb0ec1ccce8beefd8a5d06f2c7d484dd585fae0515ea574dae
|
data/LICENSE
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
Copyright (c) 2010 Michael Bulat
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
Except as contained in this notice, the name(s) of the above copyright holders
|
14
|
+
shall not be used in advertising or otherwise to promote the sale, use or
|
15
|
+
other dealings in this Software without prior written authorization.
|
16
|
+
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
23
|
+
THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,392 @@
|
|
1
|
+
Plutus
|
2
|
+
=================
|
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
|
+
|
5
|
+
The Plutus plugin is a Ruby on Rails Engine which provides a double entry accounting system for your application.
|
6
|
+
|
7
|
+
Compatibility
|
8
|
+
=============
|
9
|
+
|
10
|
+
* Ruby versions: MRI 2.2.2+ (should work with earlier versions if using Rails 4)
|
11
|
+
* Rails versions: ~> 5.0, ~> 4.0
|
12
|
+
|
13
|
+
For earlier versions, and upgrading, please see the section titled [Previous Versions](https://github.com/mbulat/plutus#previous-versions)
|
14
|
+
|
15
|
+
Installation
|
16
|
+
============
|
17
|
+
|
18
|
+
- Add the gem to your Gemfile `gem "plutus"`
|
19
|
+
- generate migration files `rake plutus:install:migrations`
|
20
|
+
- run migrations `rake db:migrate`
|
21
|
+
|
22
|
+
Overview
|
23
|
+
========
|
24
|
+
|
25
|
+
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.ruby-doc.org/stdlib-2.1.0/libdoc/bigdecimal/rdoc/BigDecimal.html) in order to prevent floating point rounding errors. The plugin requires a decimal type on your database as well.
|
26
|
+
|
27
|
+
Plutus consists of tables that maintain your accounts, entries and debits and credits. Each entry can have many debits and credits. The entry table, which records your business transactions is, essentially, your accounting [Journal](http://en.wikipedia.org/wiki/Journal_entry).
|
28
|
+
|
29
|
+
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 entries.
|
30
|
+
|
31
|
+
Accounts
|
32
|
+
--------
|
33
|
+
|
34
|
+
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:
|
35
|
+
|
36
|
+
TYPE | NORMAL BALANCE | DESCRIPTION
|
37
|
+
--------------------------------------------------------------------------
|
38
|
+
Asset | Debit | Resources owned by the Business Entity
|
39
|
+
Liability | Credit | Debts owed to outsiders
|
40
|
+
Equity | Credit | Owners rights to the Assets
|
41
|
+
Revenue | Credit | Increases in owners equity
|
42
|
+
Expense | Debit | Assets or services consumed in the generation of revenue
|
43
|
+
|
44
|
+
Your Book of Accounts needs to be created prior to recording any entries. The simplest method is to have a number of `create` methods in your db/seeds.rb file like so:
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
Plutus::Asset.create(:name => "Accounts Receivable")
|
48
|
+
Plutus::Asset.create(:name => "Cash")
|
49
|
+
Plutus::Revenue.create(:name => "Sales Revenue")
|
50
|
+
Plutus::Liability.create(:name => "Unearned Revenue")
|
51
|
+
Plutus::Liability.create(:name => "Sales Tax Payable")
|
52
|
+
```
|
53
|
+
|
54
|
+
Then simply run `rake db:seed`
|
55
|
+
|
56
|
+
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:
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
Plutus::Equity.create(:name => "Drawing", :contra => true)
|
60
|
+
```
|
61
|
+
|
62
|
+
At all times the balance of all accounts should conform to the [Accounting
|
63
|
+
Equation](http://en.wikipedia.org/wiki/Accounting_equation)
|
64
|
+
|
65
|
+
Assets = Liabilities + Owner's Equity
|
66
|
+
|
67
|
+
Every account object has a `has_many` association of credit and debit entries, 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.
|
68
|
+
|
69
|
+
See the `Plutus::Account`, `Plutus::Entry`, and `Plutus::Amount` classes for more information.
|
70
|
+
|
71
|
+
Examples
|
72
|
+
========
|
73
|
+
|
74
|
+
Recording an Entry
|
75
|
+
------------------
|
76
|
+
|
77
|
+
Let's assume we're accounting on an [Accrual basis](http://en.wikipedia.org/wiki/Accounting_methods#Accrual_basis). 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 entry we'd need two accounts:
|
78
|
+
|
79
|
+
```ruby
|
80
|
+
>> Plutus::Asset.create(:name => "Cash")
|
81
|
+
>> Plutus::Liability.create(:name => "Unearned Revenue")
|
82
|
+
```
|
83
|
+
|
84
|
+
Next we'll build the entry we want to record. Plutus uses ActiveRecord conventions to build the transaction and its associated amounts.
|
85
|
+
|
86
|
+
```ruby
|
87
|
+
entry = Plutus::Entry.new(
|
88
|
+
:description => "Order placed for widgets",
|
89
|
+
:date => Date.yesterday,
|
90
|
+
:debits => [
|
91
|
+
{:account_name => "Cash", :amount => 100.00}],
|
92
|
+
:credits => [
|
93
|
+
{:account_name => "Unearned Revenue", :amount => 100.00}])
|
94
|
+
```
|
95
|
+
|
96
|
+
Entries must specify a description, as well as at least one credit and debit amount. Specifying the date is optional; by default, the current date will be assigned to the entry before the record is saved. `debits` and `credits` must specify an array of hashes, with an amount value as well as an account, either by providing a `Plutus::Account` to `account` or by passing in an `account_name` string.
|
97
|
+
|
98
|
+
Finally, save the entry.
|
99
|
+
|
100
|
+
```ruby
|
101
|
+
>> entry.save
|
102
|
+
```
|
103
|
+
|
104
|
+
If there are any issues with your credit and debit amounts, the save will fail and return false. You can inspect the errors via `entry.errors`. Because we are doing double-entry accounting, the sum total of your credit and debit amounts must always cancel out to keep the accounts in balance.
|
105
|
+
|
106
|
+
Recording an Entry with multiple accounts
|
107
|
+
-----------------------------------------
|
108
|
+
|
109
|
+
Often times a single entry requires more than one type of account. A classic example would be a entry 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:
|
110
|
+
|
111
|
+
```ruby
|
112
|
+
>> Plutus::Asset.create(:name => "Accounts Receivable")
|
113
|
+
>> Plutus::Revenue.create(:name => "Sales Revenue")
|
114
|
+
>> Plutus::Liability.create(:name => "Sales Tax Payable")
|
115
|
+
```
|
116
|
+
|
117
|
+
And here's the entry:
|
118
|
+
|
119
|
+
```ruby
|
120
|
+
entry = Plutus::Entry.build(
|
121
|
+
:description => "Sold some widgets",
|
122
|
+
:debits => [
|
123
|
+
{:account_name => "Accounts Receivable", :amount => 50}],
|
124
|
+
:credits => [
|
125
|
+
{:account_name => "Sales Revenue", :amount => 45},
|
126
|
+
{:account_name => "Sales Tax Payable", :amount => 5}])
|
127
|
+
entry.save
|
128
|
+
```
|
129
|
+
|
130
|
+
Associating Documents
|
131
|
+
---------------------
|
132
|
+
|
133
|
+
Although Plutus does not provide a mechanism for generating invoices or orders, it is possible to associate any such commercial document with a given entry.
|
134
|
+
|
135
|
+
Suppose we pull up our latest invoice in order to generate a entry for plutus (we'll assume you already have an Invoice model):
|
136
|
+
|
137
|
+
```ruby
|
138
|
+
>> invoice = Invoice.last
|
139
|
+
```
|
140
|
+
|
141
|
+
Let's assume we're using the same entry from the last example
|
142
|
+
|
143
|
+
```ruby
|
144
|
+
entry = Plutus::Entry.new(
|
145
|
+
:description => "Sold some widgets",
|
146
|
+
:commercial_document => invoice,
|
147
|
+
:debits => [
|
148
|
+
{:account_name => "Accounts Receivable", :amount => invoice.total_amount}],
|
149
|
+
:credits => [
|
150
|
+
{:account_name => "Sales Revenue", :amount => invoice.sales_amount},
|
151
|
+
{:account_name => "Sales Tax Payable", :amount => invoice.tax_amount}])
|
152
|
+
entry.save
|
153
|
+
```
|
154
|
+
|
155
|
+
The commercial document attribute on the entry is a polymorphic association allowing you to associate any record from your models with a entry (i.e. Bills, Invoices, Receipts, Returns, etc.)
|
156
|
+
|
157
|
+
Checking the Balance of an Individual Account
|
158
|
+
----------------------------------------------
|
159
|
+
|
160
|
+
Each account can report on its own balance. This number should normally be positive. If the number is negative, you may have a problem.
|
161
|
+
|
162
|
+
```ruby
|
163
|
+
>> cash = Plutus::Asset.find_by_name("Cash")
|
164
|
+
>> cash.balance
|
165
|
+
=> #<BigDecimal:103259bb8,'0.2E4',4(12)>
|
166
|
+
```
|
167
|
+
|
168
|
+
The balance can also be calculated within a specified date range. Dates can be strings in the format of "yyyy-mm-dd" or Ruby Date objects.
|
169
|
+
|
170
|
+
```ruby
|
171
|
+
>> cash = Plutus::Asset.find_by_name("Cash")
|
172
|
+
>> cash.balance(:from_date => "2014-01-01", :to_date => Date.today)
|
173
|
+
=> #<BigDecimal:103259bb8,'0.2E4',4(12)>
|
174
|
+
```
|
175
|
+
|
176
|
+
Checking the Balance of an Account Type
|
177
|
+
---------------------------------------
|
178
|
+
|
179
|
+
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.
|
180
|
+
|
181
|
+
```ruby
|
182
|
+
>> Plutus::Asset.balance
|
183
|
+
=> #<BigDecimal:103259bb8,'0.2E4',4(12)>
|
184
|
+
```
|
185
|
+
|
186
|
+
Again, a date range can be given
|
187
|
+
|
188
|
+
```ruby
|
189
|
+
>> Plutus::Asset.balance(:from_date => "2014-01-01", :to_date => Date.today)
|
190
|
+
=> #<BigDecimal:103259bb8,'0.2E4',4(12)>
|
191
|
+
```
|
192
|
+
|
193
|
+
Calculating the Trial Balance
|
194
|
+
-----------------------------
|
195
|
+
|
196
|
+
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.
|
197
|
+
|
198
|
+
```ruby
|
199
|
+
>> Plutus::Account.trial_balance
|
200
|
+
=> #<BigDecimal:1031c0d28,'0.0',4(12)>
|
201
|
+
```
|
202
|
+
|
203
|
+
Contra Accounts and Complex Entries
|
204
|
+
-----------------------------------
|
205
|
+
|
206
|
+
For complex entries, you should always ensure that you are balancing your accounts via the [Accounting Equation](http://en.wikipedia.org/wiki/Accounting_equation).
|
207
|
+
|
208
|
+
Assets = Liabilities + Owner's Equity
|
209
|
+
|
210
|
+
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 entry.
|
211
|
+
|
212
|
+
```ruby
|
213
|
+
>> Plutus::Equity.create(:name => "Drawing", :contra => true)
|
214
|
+
>> Plutus::Asset.create(:name => "Cash")
|
215
|
+
```
|
216
|
+
|
217
|
+
We would then create the following entry:
|
218
|
+
|
219
|
+
```ruby
|
220
|
+
entry = Plutus::Entry.new(
|
221
|
+
:description => "Owner withdrawing cash",
|
222
|
+
:debits => [
|
223
|
+
{:account_name => "Drawing", :amount => 1000}],
|
224
|
+
:credits => [
|
225
|
+
{:account_name => "Cash", :amount => 1000}])
|
226
|
+
entry.save
|
227
|
+
```
|
228
|
+
|
229
|
+
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:
|
230
|
+
|
231
|
+
```ruby
|
232
|
+
>> Plutus::Equity.create(:name => "Common Stock")
|
233
|
+
>> Plutus::Asset.create(:name => "Cash")
|
234
|
+
```
|
235
|
+
|
236
|
+
And out entry would be:
|
237
|
+
|
238
|
+
```ruby
|
239
|
+
entry = Plutus::Entry.new(
|
240
|
+
:description => "Owner investing cash",
|
241
|
+
:debits => [
|
242
|
+
{:account_name => "Cash", :amount => 1000}],
|
243
|
+
:credits => [
|
244
|
+
{:account_name => "Common Stock", :amount => 1000}])
|
245
|
+
entry.save
|
246
|
+
```
|
247
|
+
|
248
|
+
In this case, we've increase our cash Asset, and simultaneously increased the other side of our accounting equation in
|
249
|
+
Equity, keeping everything balanced.
|
250
|
+
|
251
|
+
Money & Currency Support
|
252
|
+
========================
|
253
|
+
|
254
|
+
Plutus aims to be agnostic about the values used for amounts. All fields are maintained as BigDecimal values, with `:precision => 20, :scale => 10`, which means that any currency can be safely stored in the tables.
|
255
|
+
|
256
|
+
Plutus is also compatible with the [Money](https://github.com/RubyMoney/money) gem. With Money versions greater than 6.0, the `money.amount` will returns a BigDecimal which you can use with plutus as follows:
|
257
|
+
|
258
|
+
```ruby
|
259
|
+
entry = Plutus::Entry.build(
|
260
|
+
:description => "Order placed for widgets",
|
261
|
+
:debits => [
|
262
|
+
{:account_name => "Cash", :amount => money.amount}],
|
263
|
+
:credits => [
|
264
|
+
{:account_name => "Unearned Revenue", :amount => money.amount}])
|
265
|
+
```
|
266
|
+
|
267
|
+
Multitenancy Support
|
268
|
+
=====================
|
269
|
+
|
270
|
+
Plutus supports multitenant applications. Multitenancy is acheived by associating all Accounts under `Plutus::Account` with a "Tenant" object (typically some model in your Rails application). To add multi-tenancy support to Plutus, you must do the following:
|
271
|
+
|
272
|
+
- Generate the migration which will add `tenant_id` to the plutus accounts table
|
273
|
+
|
274
|
+
```sh
|
275
|
+
bundle exec rails g plutus:tenancy
|
276
|
+
```
|
277
|
+
|
278
|
+
- Run the migration
|
279
|
+
|
280
|
+
```sh
|
281
|
+
rake db:migrate
|
282
|
+
```
|
283
|
+
|
284
|
+
- Add an initializer to your Rails application, i.e. `config/initializers/plutus.rb`
|
285
|
+
|
286
|
+
```ruby
|
287
|
+
Plutus.config do |config|
|
288
|
+
config.enable_tenancy = true
|
289
|
+
config.tenant_class = 'Tenant'
|
290
|
+
end
|
291
|
+
```
|
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.*
|
293
|
+
|
294
|
+
```ruby
|
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
|
297
|
+
entry = Plutus::Entry.new(
|
298
|
+
:description => "Order placed for widgets",
|
299
|
+
:date => Date.yesterday,
|
300
|
+
:debits => [
|
301
|
+
{:account => debit_account, :amount => 100.00}],
|
302
|
+
:credits => [
|
303
|
+
{:account => credit_account, :amount => 100.00}])
|
304
|
+
```
|
305
|
+
|
306
|
+
Reporting Views
|
307
|
+
===============
|
308
|
+
|
309
|
+
The Engine provides controllers and views for rendering basic reports, including a Balance Sheet and Income Statement.
|
310
|
+
|
311
|
+
These views and controllers are read-only for reporting purposes. It is assumed entry creation will occur within your applications code.
|
312
|
+
|
313
|
+
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:
|
314
|
+
|
315
|
+
```ruby
|
316
|
+
mount Plutus::Engine => "/plutus", :as => "plutus"
|
317
|
+
```
|
318
|
+
|
319
|
+
*NOTE: The `Plutus::ApplicationController` does not currently support authentication. If you enable routing, the views will be publicly available on your mount point. Authentication can be added by overriding the controller.*
|
320
|
+
|
321
|
+
*Future versions of plutus will allow for customization of authentication.*
|
322
|
+
|
323
|
+
|
324
|
+
Previous Versions
|
325
|
+
=================
|
326
|
+
|
327
|
+
For the rails 3 version, you can go here:
|
328
|
+
|
329
|
+
[https://github.com/mbulat/plutus/tree/rails3](https://github.com/mbulat/plutus/tree/rails3)
|
330
|
+
|
331
|
+
For the rails 2 version, you can go here:
|
332
|
+
|
333
|
+
[https://github.com/mbulat/plutus/tree/rails2](https://github.com/mbulat/plutus/tree/rails2)
|
334
|
+
|
335
|
+
* Gems in RubyGems.org >= 0.5.0 support Rails 3
|
336
|
+
* Gems in RubyGems.org >= 0.8.0 support Rails 4
|
337
|
+
* Gems in RubyGems.org >= 0.9.0 support Rails ~> 4.1
|
338
|
+
* Gems in RubyGems.org >= 0.13.0 support Rails ~> 5.0
|
339
|
+
|
340
|
+
Upgrading from older versions
|
341
|
+
-----------------------------
|
342
|
+
|
343
|
+
As Plutus is still in alpha, there have been some breaking changes with previous versions.
|
344
|
+
|
345
|
+
If you are upgrading, please check the Wiki for guides on how to properly upgrade plutus to deal with the changes:
|
346
|
+
|
347
|
+
[Upgrade Notes](https://github.com/mbulat/plutus/wiki/Updrade-Notes)
|
348
|
+
|
349
|
+
Testing
|
350
|
+
=======
|
351
|
+
|
352
|
+
[Rspec](http://rspec.info/) tests are provided. Run `bundle install` then `rake`.
|
353
|
+
|
354
|
+
Contributing and Contributors
|
355
|
+
=============================
|
356
|
+
|
357
|
+
There's a guide to contributing to Plutus (both code and general help) over in [CONTRIBUTING](https://github.com/mbulat/plutus/blob/master/CONTRIBUTING.md)
|
358
|
+
|
359
|
+
Many thanks to all our contributors! Check them all at:
|
360
|
+
|
361
|
+
https://github.com/mbulat/plutus/graphs/contributors
|
362
|
+
|
363
|
+
Community and where to get help
|
364
|
+
===============================
|
365
|
+
|
366
|
+
* Join the [mailing list](https://groups.google.com/d/forum/plutus-gem) (Google Group)
|
367
|
+
|
368
|
+
Bitcoins
|
369
|
+
========
|
370
|
+
|
371
|
+
Plutus is free software, but if you'd like to support development, feel free to send some bitcoins:
|
372
|
+
|
373
|
+
`1QFSdJheyFkLcsV8X428J8e3pYqX1nmW39`
|
374
|
+
|
375
|
+
Also, if anyone is using Plutus for bitcoin related accounting, I'd love to hear about it! Drop me a line.
|
376
|
+
|
377
|
+
ToDo
|
378
|
+
====
|
379
|
+
|
380
|
+
* Better views, including paging
|
381
|
+
* Reference for common accounting entries
|
382
|
+
|
383
|
+
Reference
|
384
|
+
=========
|
385
|
+
|
386
|
+
For a complete reference on Accounting principles, we recommend the following textbook
|
387
|
+
|
388
|
+
[http://amzn.com/0324662963](http://amzn.com/0324662963)
|
389
|
+
|
390
|
+
* * *
|
391
|
+
|
392
|
+
Copyright (c) 2010-2016 Michael Bulat
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
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 any plugin's vendor/assets/javascripts directory 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
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require jquery
|
14
|
+
//= require jquery_ujs
|
15
|
+
//= require jquery-ui/widgets/datepicker
|
16
|
+
//= require_tree .
|