Generic Import API

Olaf Faaland ofaaland at alamedanet.net
Mon Apr 21 23:47:51 CDT 2003


d'OH!  Thanks for pointing that out.

I did find the docs helpful, but since this is my first foray into coding with 
the engine, I spent most if my time trying to understand how to create a 
proper transaction.

With the engine documentation in particular, I found it difficult to see the 
forest for the trees.  There are so many public functions, and nothing that I 
found in the doxygen-generated files gives a typical sequence of calls - 
creating objects to store your book, account(s), transaction, splits, filling 
up some of the common fields, and then committing/adding.  I got much of that 
from the "Engine Introduction" node of the gnucash-design.info, but I did not 
see anything covering how to associate a split with an account and a 
transaction, or indicating that those were separate function calls.  So a 
reference in the doxygen-generated stuff would have helped, but not answered 
all of my questions.

It's the sort of thing where a very brief overview or example would have sped 
up my process considerably; but that might qualify as something that is more 
likely to get out of date than it is to be useful; and in the end, if someone 
can't figure it out from the documentation that is available, it may be that 
they aren't capable of getting anything useful done.  I don't really know.  

Having said all that, I'd be happy to make an annotated code snippet that uses 
your importer and shows these things, if you like.  I have 2 kids competing 
with gnucash for my time, so it would take a little while.

In any case, thanks for writing the API.  I found it quite easy to use once I 
got the context down.

-Olaf

On Monday 21 April 2003 08:44 pm, Benoit Grégoire wrote:
> On April 21, 2003 12:10 am, Olaf Faaland wrote:
> > Hi,
> >
> > I'm playing with the import API written by Benoit.  Using the OFX and
> > HBCI imports as a model, I've written a quickie test import, but I have
> > two questions:
>
> Wow, I am glad someone besides me and cstim is playing with it!  Are the
> docs helpfull?
>
> > 1. From what I can see of the OFX and HBCI code, the transactions
> > initially created are never balanced; that is, they have only one split,
> > and the GUI always prompts the user to select the 2nd account for the 2nd
> > split.  Is that what really happens?  I have access to neither type of
> > service to test my understanding.
>
> This is what USUALLY happens, but not always. Some transactions are added
> already balanced.  The GUI will only ask the user for a destination split
> if the transaction isn't balanced when it is passed to the importer.
>
> > 2. My test import creates what appears to me to be a single valid
> > transaction. Specifically, there is only one TX shown in the register,
> > and diffing the before and after data files shows only one
> > <gnc:transaction> object, containing 2 splits.  It shows in the importer,
> > however, with two rows.  I've attached the pertinent part of a screen
> > shot, and my code.  Am I doing something obviously wrong?
>
> LOL, you are adding it twice:
>
>   	DEBUG("OPF: gnc_file_olaf_import(): Adding the transaction...\n");
>         gnc_gen_trans_list_add_trans(gnc_olaf_importer_gui, olaf_trans);
>
> 	/* Instead of xaccTransCommitEdit(gnc_trans)  */
> 	gnc_gen_trans_list_add_trans(gnc_olaf_importer_gui, olaf_trans);



More information about the gnucash-devel mailing list