Build Status

Signup:

gem install subledger

subledger

Welcome to Subledger, the world's first in-app accounting API!

To stop this script at any time simply press control-C.

We require your email address for verification.

Please enter your email address:
> [email protected]

  creating key...created!

  Your key: Gid1vE0lStRnPNCx9GFmL5

  You *must* keep it 100% secure, or your data may be accessed by others.

Would you like your key written into ~/.subledger for you?
This prevents the need for you to enter it or put it in source code.
> n

  OK, please store your key and secret securely.

> y

  Your key has been written to ~/.subledger

Your key is not yet ready to use, it must be verified via email.

Please enter the verification code we sent you via email:
> V6XxRwP5j9ldaeDjOpbkv7

  Verifying key...verified!

  Sorry, that verification code does not match your key. Please try again.

Next, we'll create an organization.

The organization name will be present in URLs, and must be unique.

What organization name would you like to use?
> subledger

  creating organization "subledger"...created!

  Your key has been granted access to your new organization.

Next we'll create a book in the subledger organization to create accounts in.

A book tracks the state of one dimension of your business.

The most common book tracks the state of currency in your business.

What would you like to name your book? We'd suggest Dollars, Euros, Yen, etc.
> USD

  creating book "USD"...created!

Would you like to create a very basic set of accounting accounts?
> n

> y

creating account "1000 Assets"...created!
creating account "2000 Liabilities"...created!
creating account "3000 Equity"...created!
creating account "4000 Income"...created!
creating account "5000 Cost of goods sold"...created!
creating account "6000 Expenses"...created!

Would you like to become virtually wealthy?
> n

  Ok, just remember: early to bed, early to rise, makes a man healthy, wealthy and wise! :-)

> y

  posting opening balances...posted!

Congratulations, you've successfully setup Subledger!

Your private and secure API explorer now exists at:

  https://api.subledger.com/

You'll need to enter your key_id and secret where indicated.

Post Signup:

Gemfile:

  gem install subledger

Client setup:

  subledger = Subledger.new :key_id  => '',
                            :secret  => '',
                            :org_id  => '',
                            :book_id => ''

Basic accounting objects:

  debit  = subledger.debit  '1'
  credit = subledger.credit '1'
  zero   = subledger.zero   '0'

  debit + credit          == zero
  debit + debit  + credit == debit
  debit + credit + credit == credit

  book = subject.books.create :description => 'description of book', # required
                              :reference   => 'http://url.of.choice' # optional, must be a URL if present

  book = subledger.books.read :id => book.id

  book.update :description => '',
              :reference   => ''

  book.archive
  book.activate

  subledger.books.collect :state       => :active|:archived,
                          :action      => :before|:ending|:starting|:after,
                          :description => 'description',
                          :limit       => 25

  subledger.books.collect :state  => :active|:archived,
                          :action => :preceding|:following,
                          :id     => another_book_in_this_org.id,
                          :limit  => 25