Invoice & payment import script

Geert Janssens janssens-geert at telenet.be
Fri Feb 17 09:54:28 EST 2012


Op vrijdag 17 februari 2012 15:44:00 schreef Reuben Cummings:
> On Feb 17, 2012, at 1:32 PM, Geert Janssens wrote:
> > Op vrijdag 17 februari 2012 12:52:15 schreef Reuben Cummings:
> > 
> > It is for example not clear to me what you are trying to achieve
> > exactly. I read that you want to import invoices and payments. But are
> > you only interested in creating transactions for it, or do you also
> > want these imported invoices to be fully integrated in the business
> > functions of GnuCash ? The latter certainly requires more than only
> > adding transactions.
> 
> I'm looking for full integration
> 
> > How does your script work ? Do you use the gnucash (scheme or python)
> > api to enter invoices and payments into your gnucash database or are
> > you adding those directly ?
> 
> Direct database editing. I studied the existing database to see which tables
> were involved with invoices and payments and then tried to duplicate what I
> saw. So far, I enter rows into the following tables: entries, invoices,
> lots, splits, and transactions. I create my own guids using an md5 hash. I
> have so far successfully imported posted invoices but they display '?'
> instead of 'I' in the register.
> 
> I wasn't aware of an api. Where would I find out how to convert my scripts
> to use the api? I found
> http://svn.gnucash.org/docs/HEAD/python_bindings_page.html is that the best
> source?
There is unfortunately little information on this. Basically most of the non-
gui functions are exported via the api. A good starting point to get an idea 
of the available functions can be found in the doxygen information on the 
engine (which is roughly the name used by the GnuCash developers to refer to 
the API). As a general rule of thumb, most of the functions of the engine 
module will also be available to you in python, but will probably have to be 
called in a more python-like way.
At the bottom of the page you already found are some additional links that can 
be helpful.

One of the most interesting things for you is probably the in-python help of 
the two gnucash python modules
>>> import gnucash.gnucash_core
>>> import gnucash.gnucash_business
>>> help(gnucash.gnucash_core)
>>> help(gnucash.gnucash_business)

The (limited) wiki page on python bindings can be helpful as well:
http://wiki.gnucash.org/wiki/Python
(it's where I found a link to the above import/help statements)

And the python bindings come with a number of example scripts to get you 
started.

And if you learn something on the way that isn't documented, by all means feel 
free to add to the existing documentation so others can benefit from it as 
well. The wiki page is likely the easiest to edit by non-C programmers.

Geert


More information about the gnucash-devel mailing list