|
|
Subscribe / Log in / New account

The accounting quest: Ledger

By Jonathan Corbet
June 13, 2012
Last month, your editor described LWN's need for a non-proprietary accounting system and the difficulty of finding such a thing in the free software community. While there is no shortage of systems that can perform basic double-ledger accounting, it is rather harder to find a system that has everything needed to actually run a business. Since then, a number of people have mentioned a system simply called Ledger. After some experimentation, it is now time to pass on some impressions of how this system works.

Ledger takes an interesting approach to the problem in a couple of ways. One is that it is a purely command-line program; there is no graphical interface of any type. The other is that Ledger does not actually maintain any sort of database of accounting data; instead, it reads that data from a plain-text file that the user manages separately. The result is a system that is quite powerful in some ways while falling short in others.

The file format is relatively simple; entries span multiple lines, with all but the first being indented. An example shipped with the program looks like this:

    2004/05/27 Book Store
      Expenses:Books                 $20.00
      Liabilities:MasterCard

This transaction took place in a book store, where $20 was moved from the Liabilities:MasterCard account to Expenses:Books. The final line lacks a dollar value, so Ledger fills it in to make the transaction balance; more complex split transactions would require explicit values for each account involved. The transaction above has not been reconciled; otherwise there would be an asterisk between the date and the description fields.

Other types of entries are possible. There is a mechanism for adding "period entries," describing transactions that happen at regular intervals. These entries are not really a form of recurring transaction—ledger seems to lack support for those. Instead, period entries are used to describe budgets that can be compared against actual income and expenses. "Automated transactions" are also supported, but those aren't recurring transactions either; they are a mechanism to add splits automatically to other transactions. The syntax for both types is terse and arguably obscure (period entries start with a "~", for example); it can take a little while to understand everything that can appear in the ledger file.

What has been described thus far doesn't involve the Ledger program at all; this file must be created and maintained via some other mechanism. In many cases, that mechanism will be a text editor; inevitably, there is an Emacs mode to make things easier. For those who want a more graphical experience, Ledger can read (uncompressed) GnuCash files, but there are a couple of caveats. One is that the Ledger developer (John Wiegley seems to do almost all the work on Ledger) is somewhat unenthusiastic about this approach; the manual asks: "why would anyone use a Gnome-centric, multi-megabyte behemoth to edit their data, and only a one megabyte binary to query it?" The other is that this support appears to be lacking from the in-development 3.0 release. So, while using GnuCash works for now, it's not clear that it will continue to work in the future.

One could also imagine various automated mechanisms for generating the file from other data sources. Ledger itself never modifies the file; it is simply a consumer of the data contained therein.

As consumers go, it's a powerful one. There is a fairly long list of reports that can be generated. As one might expect, Ledger supports a complex command-line interface that can be used to filter transactions and control the format of the resulting report. The syntax is (once again) terse, but, given time, a suitably motivated user can create almost any sort of text-oriented report one might like. Pie chart aficionados will be disappointed at the outset; there is no graphical output from Ledger. With a bit of work, though, one can get Ledger output into a tool like Gnuplot and produce all kinds of pretty charts.

In summary, Ledger isn't really an accounting system; it's a report-generation utility designed to work with a specific text file format. There are both advantages and disadvantages to its approach. On the up side, Ledger could be an ideal solution for relatively small operations where the people involved are happy to use command-line utilities and do some scripting to make the pieces of a full business hold together. The plain-text ledger file is ideal for anybody wanting to use a tool like Git to track changes over time (or to merge changes done by more than one user). The tool is fast, lightweight, and will never imprison one's accounting data in a black-box binary data file.

On the other hand, it is hard to imagine scaling Ledger even to a business the size of LWN, much less something larger. The tool has clearly been written with speed in mind; it can process a file with many thousands of transactions quickly. But the file itself can only become unwieldy, especially if there are many sources of data feeding into it. Plain-text files lose some of their appeal when they get to be tens or hundreds of thousands of lines in length.

Ledger also lacks features that a typical small-business accounting program would be expected to support. These include:

  • Invoicing. One can certainly enter information about an invoice as an accounts receivable entry, but there is nothing tying it to the actual invoice sent to a customer. Anybody wanting standard invoice formats, summaries of outstanding invoices, or per-customer reports will have to implement them separately.

  • Check printing. Yes, it is still necessary to write checks at times.

  • Integration with bank accounts. That said, LWN has to do its own processing of files from banks before feeding the data into QuickBooks now, so things would not necessarily change a lot in a move to Ledger.

  • Recurring transactions. Again, one can certainly script such things, but it must be done separately.

  • Tracking of contractors and creation of tax data (and, in the US, 1099 forms).

  • Easy execution of routine tasks like account reconciliation. Ledger can certainly provide a register view showing unreconciled items, but the editing of those items must be done elsewhere (in that big text file).

The other problem with a tool like Ledger is that it can complicate dealings with one's accountant, assuming said accountant is not comfortable with command-line tools. Generating the basic reports that an accountant would want to see will not be that hard. But a good accountant will want to dig through the entries to be sure that everything makes sense and, perhaps, add a journal entry or two to straighten them out. Ledger makes that level of interaction impossible for most accountants, and that will complicate life for many businesses trying to use it.

The bottom line, so to speak, is that Ledger is probably not the solution to LWN's accounting problems, though it might work quite well for simpler businesses with fewer customers, transactions, and accounts. For us, there are too many pieces that would have to be added, some of which would be less than straightforward. So the quest continues; stay tuned.


to post comments

The accounting quest: Ledger

Posted Jun 14, 2012 15:48 UTC (Thu) by joey (guest, #328) [Link]

Have you seen hledger? Same file format, has a web interface that can be used to add transactions. http://demo.hledger.org/register (Also written in haskell if that turns you on ;)

The accounting quest: Ledger

Posted Jun 14, 2012 15:51 UTC (Thu) by bronson (subscriber, #4806) [Link]

I must say, assuming performance is acceptable, text file storage sounds ideal. Little chance of being stranded with a bunch of unreadable, outdated .gnucash (or whatever) files. I'd rather have a bunch of 100,000 line text files than a similar amount of opaque database files.

I'd guess the problem is not so much the storage format, but the interface onto it? If someone were to write an accountant-friendly front-end, would that take care of your file format concerns?

(of course this doesn't affect the other missing bits like invoicing, bank accounts, recurring transactions, etc..)

Jon, we should be in touch about this as Conservancy wants to improve ledger in ways LWN needs.

Posted Jun 14, 2012 16:39 UTC (Thu) by bkuhn (subscriber, #58642) [Link] (1 responses)

Jon, I've been meaning to get in touch with you about this, but hadn't had a chance. Conservancy is using Ledger for all its accounting and we have some of the same needs that LWN has. Since we're already invested in Ledger, we're going to build up systems with it and around it to do some of things that you need. I know you probably need to pursue a more immediate solution for LWN, but I'd love to be in touch if you're willing to think about Ledger as a solution going forward. Conservancy is committed to finding a way to improve Ledger in the directions you suggest.

Conservancy and ledger

Posted Jun 14, 2012 19:27 UTC (Thu) by tbm (subscriber, #7049) [Link]

Those interested should check out Bradley's (bkuhn) recent posting to the ledger mailing list about this.

The accounting quest: Ledger

Posted Jun 14, 2012 19:21 UTC (Thu) by tbm (subscriber, #7049) [Link] (1 responses)

As a user of ledger, I wanted to add some comments:

  • If you want to try out ledger, make sure to get the 3.0 development version from git. While 3.0 has not been released yet, the ledger 2 series is considered as obsolete since the upcoming 3.0 has tons of new features and has changed some of the syntax.
  • John Wiegley, the author of ledger, has always said that ledger will stay a simple accounting "calculator"; but he has always encouraged other people to build full accounting applications/GUIs on top. At the moment, this doesn't exist (but see bkuhn's comment). In order to use ledger for a business, a lot of accounting and business logic needs to be built on top and this is definitely an area lacking today. ledger works pretty well to keep track of your personal finance, though.
  • Related to the above: I think the current situation is that getting data into ledger is easy but doing something useful with the data is hard at the moment... some people have written some scripts on top of ledger (for example to create PDF invoices and nice charts) but this needs more work (and cooperation among ledger users). ledger 3.0 has a Python interface that can be used to write scripts that do interesting things with your data.
  • In addition to the Emacs mode, there's also a vim mode offering syntax highlighting and other features.
  • GnuCash support won't be in 3.0 but is planned for 3.1 afaik.
  • I don't see ledger files with "hundreds of thousands of lines" as a problem: a ledger file can include other ledger files, so you can neatly put data from different bank accounts into separate files.
  • I'm not sure what you mean by lack of support for "recurring transactions": if you mean that there'll be e.g. a phone payment on your bank statement every month, then this would be handled by whatever way you're getting your bank data into ledger. I have some Perl scripts that convert my bank data to ledger and they will recognize payments to specific vendors as such and fill in the details correctly. Furthermore, ledger has an xact command that will add a new transaction based on information from previous transactions.

The accounting quest: Ledger

Posted Jun 19, 2012 22:39 UTC (Tue) by eternaleye (guest, #67051) [Link]

To elaborate further on the ability to include other files, I use a system where my ledger is kept in a git repository with the following layout:

main.dat
global
global/00-defaults.dat
global/01-accounts.dat
by-date
by-date/2012
by-date/2012/2012-01.dat
by-date/2012/2012-02.dat
by-date/2012/2012-03.dat
by-date/2012/2012-04.dat
by-date/2012/2012-05.dat
by-date/2012/2012-06.dat
by-date/2012.dat

main.dat includes global/*.dat, and then by-date/*.dat.

by-date contains 2012/ and 2012.dat (and another such pair for each year, when I've finished entering older years), which includes by-date/2012/*.dat (which are monthly).

accounts.dat is all of the accounts I deal with, and defaults.dat is for stuff like setting the default currency.

That puts a nice limit on the size of each file, and I find it superior to dividing things up based on accounts because that can be icky when entries involve multiple accounts. In order to classify entries, I just use tags. It also makes importing from a monthly CSV even easier, since it can just go in its own file.

The accounting quest: Ledger

Posted Jun 14, 2012 21:59 UTC (Thu) by bronson (subscriber, #4806) [Link] (1 responses)

What license is Ledger covered by? Judging by source file comments, maybe 3 clause BSD?

The accounting quest: Ledger

Posted Jun 17, 2012 20:51 UTC (Sun) by bronson (subscriber, #4806) [Link]


Copyright © 2012, Eklektix, Inc.
This article may be redistributed under the terms of the Creative Commons CC BY-SA 4.0 license
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds