A double-entry accrual accounting system for your Rails application. Currency-agnostic but uses the Money gem. Account holder support and contexts are built-in.
Add this line to your application's Gemfile:
gem 'double_double'
And then execute:
$ bundle
Or install it yourself as:
$ gem install double_double
Generate and migrate the installation database migration
$ rails generate double_double:install
$ rake db:migrate
Double-entry accounting practices have been traced back to the 13th century. double_double strives to make accepted practices accessible and relatively easy to implement within other applications.
As with many off-the-shelf accounting systems, this project supports:
- Accountee: an account holder.
- Context: to track activity on invoices, purchase orders, jobs, campaigns, etc.
- Initiator: who authorized or performed the action.
All accounts created in a double-entry system make up the chart of accounts. This collection of accounts will determine how money is tracked as it moves through the system. It is important to design and create the chart of accounts prior to creating entries. *If we want people to hold "an individual account" in this system, we will configure them as an accountee, not with a new account. See the section on accountees *
In double_double, all accounts created are considered to be the chart of accounts. All accounts are "on the books."
Account Class | Normal Balance | Description | Example Uses |
---|---|---|---|
DoubleDouble::Asset |
Debit | Resources owned or controlled | Cash, Office Computers, Grandma's Jewelry |
DoubleDouble::Liability |
Credit | Obligations | Accounts Payable, Bank Loan |
DoubleDouble::Equity |
Credit | The claim to assets after all liabilities are paid | Paid-In Capital, Dividends, Retained Earnings |
DoubleDouble::Revenue |
Credit | Income | Sales, Interest Earned |
DoubleDouble::Expense |
Debit | Expenditures | Utilities, Salaries, Rent, Taco Tuesday |
Accounts have the following attributes:
- name
- number, for reporting purposes
- contra flag, optional
default: false
An example 'Cash' asset account as account number 20
DoubleDouble::Asset.create! name: 'Cash', number: 20
An example 'Sales' revenue account and a 'Discounts' contra revenue account.
DoubleDouble::Revenue.create! name: 'Sales', number: 40
DoubleDouble::Revenue.create! name: 'Discounts', number: 50, contra: true
Contra accounts are used to offset a related account of the same class. The example above is a common method to track sales. The full sales value of the sale would be assigned to 'Sales' while any discounts given would be assigned to 'Discounts.'
See the double_double wiki
All code is backed by Rspec tests. Clone this repository and rake spec
to execute the tests.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes & tests (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
double_double was influenced by mbulat's plutus project and regularly working with quickbooks.