How To Do My Own Transaction Matching

John Ralls jralls at ceridwen.us
Mon Dec 9 17:25:44 EST 2013


On Dec 9, 2013, at 12:04 PM, Michael Iles <michael.iles at gmail.com> wrote:

> I would like to be able to do my own transaction matching and I'm
> looking for advice on the easiest way to do it.
> 
> (I find that with the built-in Bayesian matching I still have to
> inspect every match, many matches aren't automatically made, sometimes
> the matching history gets lost and I have to start over, etc.)
> 
> My goal is to automate all of the regular transactions that happen in
> my account, using heuristics like: (1) if a transaction labeled
> 'insurance' is in one range then it's my car insurance, if it's in a
> different range then it's home insurance; (2) utility bills usually
> have extra numbers so I would look for substrings to match them; etc.
> 
> (Aside: in my opinion, the perfect system for GnuCash would be the
> ability to provide a list of regular expressions, along with the
> destination account to use if the regex matches.)
> 
> I'm using GnuCash 2.4.13 on OS X, with the XML data store. My
> transactions are coming into GnuCash via QFX files.
> 
> My first thought was to use script bindings. I prefer Ruby so I found
> the 'gnucash' gem [1] but quickly realized that it was read-only.
> 
> I then looked at the Python bindings [2] but it's not clear to me how
> to set them up. (Do I need to build GnuCash from source? Do they work
> on the 2.4 stream?)
> 
> I then thought that I could parse the QFX and generate QIF files that
> have both source and destination accounts... I haven't tried this yet,
> but at first glance I'm not sure that QIF files support both source
> and destination accounts.
> 
> (Another aside: it would be wonderful if GnuCash implemented a custom
> "GnuCash Import" file format that allowed all aspects of a transaction
> to be specified, including source and destination account.)
> 
> So now I'm not sure what the best approach is:
> 
> 1. Would the QIF approach work?
> 2. Are the Python bindings easy to get working?
> 3. Should I move to 2.5?
> 4. Should I move to a SQL data store? I understand that I couldn't
> write directly to the DB, but is there a DB client library that would
> allow me to script against the DB?
> 5. Other bindings I should look at? (Scheme? Guile?)
> 

You will need to build Gnucash from source in order to enable the Python bindings. They have to link against libpython, and the many versions of that provided in various versions of OSX mean that we’d have to include Python in the app bundle to make it work.

There are no changes to the Gnucash file format or database schema between 2.4 and 2.6 (to be released in less than 3 weeks), so it doesn’t really matter which you use for this. Similarly you won’t find any benefit to using the SQL data store for this purpose, since your intent is to write to it. You should use the Gnucash API either in the native C or the Guile/Scheme or Python bindings. The advantage of the first two is that you don’t have to rebuild Gnucash to use them.

Guile is the implementation of Scheme that we use for our API bindings. It’s not an either-or.

I don’t know if the QIF approach would work. Maybe Derek knows…

Regards,
John Ralls




More information about the gnucash-user mailing list