GnuCash Reports

More than 10 years ago I switched from using Quicken for managing personal finances to using an accounting application I developed for the task. I posted my rationale for doing so at the time and see not much has changed in the commercial landscape since then to change my thinking. Intuit is still diligently upsetting customers. Although my needs, demands, and interests have changed. I no longer have time to maintain the code I wrote and a year or two back my accounting needs changed. So I switched from the custom coded solution to GnuCash.

For the most part, I’m quite pleased with the capabilities of GnuCash. Best of all, it’s open source. So I have full access to the code and, more importantly, the data. Where it is weak is in reporting capabilities. I find it rather frustrating to get to the view I want. True to the spirit of open source, users can create their own custom reports. Accomplishing this requires the user to be familiar with the Scheme programming language. When I was younger, this would have been a minor inconvenience. However, graybeard that I am amongst software developers, I’ve learned and forgotten more programming languages than I care to recall. Adding another bone to that yard is less than attractive.

So I turned to my go-to language since version 1.5.2: Python. Even after crafting all manner of solutions in Python over the past 15+ years, it still amazes me what I can do with it. My problems with GnuCash were no exception. Since my data isn’t locked up in some proprietary format, it was a simple enough task to craft a couple of SQL commands that would extract the data I need and wrap them inside an efficient Python script. Simply by setting a date range in a configuration file, I get the (so far) three reports I need in 2-3 seconds.

For those interested, I’m including the current incarnation of the code below. The data captured in the three csv files are:

  • A raw dump of the data, suitable for working within a spreadsheet
  • A subtotal report that includes line item details
  • A subtotal report without line item details

Configuration File

Python Script

Improvements and enhancements are left as an exercise for the reader.