My Bookkeeping System

One of the things that I like to do in my personal life and in my corporation is control the books. Since I am responsible if the corporation fails, and if mismanaged money is the surest way to failure, then I better control where that money comes and goes. To this, I make myself the bookkeeper (with my wife, who verifies the work). As for accounting, I outsource that stuff to an accountant because it is much too complicated for me to spend so much time on it. That, and he saves me more than what he charges, so it's a good deal.

I first used simple spreadsheets to track assets (income) and expenses, but then I got a bit of a tongue-lashing from my accountant. It turns out that he couldn't make heads or tails of what I was doing, because I was attempting to track my income and expense types in different sheets. I have always been good with numbers, and organized to a fault, but this was one instance where one man's organization is another man's mess.

I then decided to clean up my act and use Quicken instead. Heck, if everyone touts Quicken and other off-the-shelf solutions as good tools I might as well try it out. At first I could almost understand where it was coming from, but then I was not happy with the way that it registered expenses. For instance, if you went to Staples and purchased some pens, paper, and a computer, you would register that in Quicken (as in most bookkeeping tools) as a single expense. Now, what category do you place it in? Office supplies (for the pens and paper) or a depreciating asset (for the computer)? I always had to choose between two bad outcomes so I never felt very organized.

There were other issues present in Quicken that I did not like. The UI, for instance, was something that I couldn't get comfortable with. I didn't like the placement of buttons, how the reports worked, or anything. I also didn't like the backups to a file that – omg, omg I hope it doesn't corrupt – type of opaqueness. Then there was Intuit's incessant need to update the software every year, just to make a quick buck. After 3 years, your original software is no longer able to download the Quicken files, which forces everyone to be on their toes and upgrade frequently. I don't like scammy practices like that, and I like to vote with my wallet.

The last issue with Quicken was that it is not platform independent. I jump between Windows, OSX, and Linux constantly and I would like to be able to update my books whenever I like, but I always found that I needed to keep a VM image of Windows around just to load up Quicken. There exists a Quicken version for OSX, but the controls were so terrible that I stopped using it immediately. It was like someone thought they could take a Windows application and make a direct port of it into OSX. For Linux, I was completely out of luck (other than the VM image). I suffered with the VM image for many years but in January I started the search for something better.

With two options down, I stumbled upon a double-entry accounting system called Ledger. It seemed to be too good to be true: a command-line accounting system that worked on all operating systems, could track multiple categories and verify that everything balanced out. I figured it was some new whiz-bang software that was too new to trust my financials. I was wrong; it was developed 10 years ago and has had numerous updates, with a small cult following.

osx$ sudo brew install ledger

After installing it, the first stumbling block for me was double-entry accounting. It sounded complex, but after reading the Ledger docs it was actually quite simple to understand. Not only that, the system would keep better track of your financials and allow you to organize everything in the same way an accountant does. Wait, I know I hear some accountants scoffing right now. I'm sounding like I just discovered Atlantis when it's something that has been used for decades. I was never taught this in school, and it's never come up in my daily life in the IT industry (lowly peon as I am).

The first thing that Ledger does (and what double-entry accounting teaches you) is not to put some dollar amount into a category. Instead, you want to track the flow of money, because that provides both an audit trail and the ability to balance everything out at the end of the day.

When you receive money from a client, you move it from a revenue (or income) register to your bank account register.

# The money flows from your client to your bank account
revenue of client A -----> company bank account

For an expense that you pay on a credit card, you move money from a credit card (creating a debt on the account) to an expense category. Oh, but now you have a debt on your credit card that must be paid. Once you've paid off the credit card in your online banking, in Ledger you show the movement of money from your bank account to the credit card (creating a credit on the account).

# First, the expense is paid for on your credit card
1. credit card -----> expense
# Then, you pay off your credit card with money from your bank account
2. company bank account -----> create card

How does this happen in Ledger? By using a plaintext file (I love this idea) you structure your ledger entries into a particular format. Once you save the file, you tell Ledger to read the same file. Ledger processes all the data in the file, audits everything and then prints out a result. If you have made a mistake in calculating something, ledger will most likely catch it and let you know that it cannot balance the file (everything should balance to zero in a double-entry accounting system).


Let's say you have three transactions to track in your ledger: 1. You have invoiced a client for services rendered; 2. The client has paid your invoice; 3. You have purchased $500 worth of stuff at Staples on your credit card; 4. You have paid off your credit card balance.

I will show you how each transaction will work in ledger, starting from scratch. For the record, I am using a POSIX environment for this tutorial. If I am inputting text into a file, I will use the cat command and then end the input with a ^D character (or Ctrl-D), which closes the file and then returns me to the command prompt. This is easier than showing you a picture of a text editor.

Create a new plaintext file. The name doesn't matter, but I prefer to lump all transactions by year, and use the .ledger file extension for clarity.

$ touch 2013.ledger

Now create a transaction showing the invoice to your client named Ralph. The invoice was created on July 1, 2013 and is numbered 410 for $4920.33. You will be showing how the invoice is flowing from revenue and into accounts receivable 1. When structuring the ledger entry, note how the bottom line is where the money is coming from, and the top line is where the money is going to.

$ cat >2013.ledger
2013/07/01 (410) Invoice
  assets:accounts receivable:ralph                  $4920.33
  revenue:clients:ralph                            -$4920.33

Run ledger over the file and see what happens. It will tell you that you have money in two registers (categories, in ledger's parlance). Note how the revenue area is negative; this is intended as it shows that money was taken from something. In this instance, it shows that you have made $4,920.33 from Ralph (or, in other words, Ralph has lost $4.920.33 to you, making it a negative amount for him). Although this seems weird, it becomes useful later when the invoice is paid by the client because we will no longer see the accounts receiveable section and the money will become comingled into our bank account. By simply glancing at the revenue section you will be able to determine how much money you have made from each client within this year 2.

$ ledger -f 2013.ledger equity

2013/07/01 Opening Balances
    assets:accounts receivable:ralph        $4920.33
    revenue:clients:ralph                  $-4920.33

The number at the end of the report, the 0, is ledger telling us that everthing balances out to 0. This is a good thing.

A few days later the client has paid you with a cheque. You go to the bank and deposit the cheque into the account, and receive a receipt. This receipt tells you that you can now add this money into your bank account register in the ledger.

$ cat >>2013.ledger

2013/07/04 (410) Invoice Payment from Ralph
  assets:chequing                          $4920.33
  assets:accounts receivable:ralph


In the bank deposit, I show that the invoice has been paid off by moving the money from accounts receivable to my company's chequing account.

Notice how I omitted the negative dollar amount on the accounts receivable line. You can do this because ledger will automatically assume that the amount is the same (but negative) as the first line.

When you run the ledger command again, you'll notice that the accounts receivable section is gone, and is replaced by a chequing account register.

$ ledger -f 2013.ledger

2013/07/04 Opening Balances
    assets:chequing                         $4920.33
    revenue:clients:ralph                  $-4920.33

The reason the accounts receivable was removed is because the register has a $0 amount in it and is no longer needed in the display. In a way, accounts receivable and accounts payable registers are simply a holding place for money that has not been transferred into or out of your bank account. It's as simple as that.

Now that you have some money in your company coffers, you go to Staples and purchase some items (pens, paper, computer) of varying expense types. This is where ledger starts to shine and makes my organizational mind do a little jig.

$ cat >>2013.ledger

2013/07/06 Staples
  expenses:computer hardware          $323.58
  expenses:taxes                     ($323.58 * 0.05)
  expenses:office supplies             $60.00
  expenses:office supplies            $100.24
  liabilities:credit card            -$500.00


Notice how I have itemized the Staples receipt right into Ledger. I took the computer hardware purchase and put it into the computer hardware register, because that type of expense is a depreciating asset and must be written-off in piecemeal over 3 years. Then, I had to pay a 5% tax on the price due to some mythical taxation law that only affects computers. Then I paid for $60 worth of pens and $100.24 worth of paper.

The 5% tax shows how you can tell Ledger to perform simple calculations for you if you aren't sure what the exact value should be. I use this all the time for denoting provincial and federal taxes on purchases.

Rather than omitting the dollar amount in the last line of the entry, I enter it because I want ledger to automatically verify that I have input each number correctly. This has helped me numerous times. Note: if you are using calculations in your line items you may not balance correctly due to rounding errors. You can always add or subtract $0.01 from the entry by adding a new line to the entry.

Like before, process the file through Ledger and see what happens to your financials.

$ ledger -f 2013.ledger equity

2013/07/06 Opening Balances
    assets:chequing                   $4920.33
    expenses:computer hardware         $323.58
    expenses:office supplies           $160.24
    expenses:taxes                      $16.18
    liabilities:credit card           -$500.00
    revenue:clients:ralph            -$4920.33

All debts are known as liabilities, and they are the opposite of assets. Since the items were paid for on a credit card, the money from the credit card was used to create expenses on the ledger, thereby resulting in a negative amount on the credit card. Now let's complete the tutorial and pay off the credit card with a payment from our bank.

Using the online banking software, a payment of $500 was made on July 6th to the credit card company and a confirmation number of 948204 was issued to verify the transfer.

$ cat >>2013.ledger
2013/07/06 (948204) Credit Card Payment
  liabilities:credit card             $500.00


The last step is to process the file and see what happened. Note that the chequing account has decreased by $500.00 and the liability has now disappeared off the ledger (again, because it has a $0 balance).

$ ledger -f 2013.ledger equity
    assets:chequing                   $4420.33
    expenses:computer hardware         $323.58
    expenses:office supplies           $160.24
    expenses:taxes                      $16.18
    revenue:clients:ralph            -$4920.33

The final step of the tutorial is to look at our balance, which sums everything up to the top-level registers and gives a balance. I prefer using the equity command more often as it shows a detailed account of all the non-zero registers, but the balance is useful if you only want to glance at your financials.

$ ledger -f 2013.ledger balance
            $4420.33  assets
            $ 500.00  expenses
           -$4920.33  revenue

Saving, Backups and More

All off-the-shelf bookkeeping software provides the functionality to backup the data file to an external file, network location, or removable device. The same can be said with ledger, as you only have a simple text file to copy, with the added benefit that it can be printed out to paper for safe-keeping or viewed on any operating system (even if ledger is not installed). If you need to password protect your ledger, you can use any third-party program or OS built-in encryption program you like.

My preferred method of storing and keeping track of my ledger is to store it in a Git repository, which is a command-line version control system that can track changes to a file over time. Using this software I can send my repository to a server for safe-keeping, or even go back in time to when I made an erroneous change and see what I did wrong.

There are many other ways to configure and use Ledger for financial transactions (even non-financial ones). My suggestion is to peruse the documentation, it is very well written.

  1. Since you have invoiced the client but not managed to touch the money owed to you by the client (i.e. he hasn't paid you), then you need to put it into accounts receivable. This counts the money as an asset on your books (meaning you have a right to it, and pay taxes for it), but you do not yet hold it in your bank account. 

  2. With more options provided on the command line, you can see even more detail for a register than simply year-to-date amounts. You can also retrieve a line-by-line itemized account of the transactions and many other things. 

« Previous: Skills
Next: So Over SSO »