*** Regarding My Understanding Of The Engine; [EMAIL PROTECTED] adds:

cbbrowne> Am I way off here?  Or does this sound like the right
cbbrowne> direction?

I can comment on the best method to use in Scheme/Guile but I can at
least give you an idea of how I approached essentially the same
problem using the perl interface to the engine.

I had to convert 3000+ Pocket Quicken transactions.  I approached the
conversion in two steps: first I converted all the accounts and
categories into Gnucash accounts.  After this step I had a Gnucash
file with all the accounts but no transactions (except the opening
balances).

I then wrote a Perl script to parse the text file of transactions into
an internal data structure of transactions.  This internal data
structure was then handed to the function that did the actual
conversion to Gnucash.  Due to the simplicity of Pocket Quicken each
transaction would always have exactly two splits: either the
transaction would be a transfer from one account to another or it
would be an expense or an income transaction.  So the function that
converts a transaction first acquires (C) pointers to the two Gnucash
accounts in question, then it creates the two splits using
xaccMallocSplit().  It also creates the transaction object using
xaccMallocTransaction() and attaches the two splits to the
transaction.  It fills in all the requires fields and finally commits
the edit.

So to summarize the sequence is:

1) Create the accounts.
2) For each transaction
   a) Create the splits.
   b) Create the transaction.
   c) Attach the splits.
   d) Commit the transaction.

I ran the perl script outside Gnucash so I didn't have to worry about
somebody modifying the database underneath the script the way Rob was
talking about.  I guess in that case the hole is the timing of
xaccAccountInsertSplit() and the fact that you can't insert all splits
simultaneously in an atomic operation (I think.  Can you?).

Is there any way to lock the transaction database while you're
modifying it?

-- 
Per Bojsen                                        <[EMAIL PROTECTED]>
6132 Lexington Ridge Drive
Lexington, MA 02421-8317
USA
----- %< -------------------------------------------- >% ------
The GnuCash / X-Accountant Mailing List
To unsubscribe, send mail to [EMAIL PROTECTED] and
put "unsubscribe gnucash-devel [EMAIL PROTECTED]" in the body

Reply via email to