hand-coded transactions are usually BAD transactions

Kevin HaleBoyes khaleboyes at chartwelltechnology.com
Mon Nov 1 10:50:11 EST 2004


Neil Williams wrote:
> On Saturday 30 October 2004 12:23 am, Kevin HaleBoyes wrote:
> 
>>Just for fun I wrote a small perl program
> 
> 
> Which was inevitably too simple to cope with the requirements of the data.

Agreed, I don't understand the data model that the XML file represents.
Like I said, I did it a bit for fun.

>>to create the 
>><gnc:transaction> entries.  I then took those and merged
>>them into my BoR xml file (after a backup of course).
> 
> 
> By hand? There's no telling the chaos that will result in the QofBook when you 
> arbitrarily insert items. Did you check the GUID? did you create them out of 
> thin air? Did you make any effort to match the GUID of the parent against the 
> GUID of the child?

I should have been more clear in my original posting.  Using gnucash, I
created several transactions similar to what I was trying to generate.
I then copied the <gnc:transaction> entry, changing the date and amount
elements.

>>When I restarted gnucash I got quite a few errors to the
>>console than I don't get in the original BoR file.  Here
> 
> 
> BoR? 

Book of Record

>>is a snippet of the messages:
>>-----------------------------------
>>Transactions: Total: 1144, Loaded: 1160
> 
> 
> You appear to have Transactions that are not linked to an account, linked to 
> an invalid account or corrupt in other ways.

Ya, it seems I've missed something.  Maybe my approach was flawed :-)
I should have at least done a diff on the XML file to see what gets
changed/added when I create a new transaction.

>>First, is it possible to even do this?
> 
> 
> Not by hand, at least, not without a very high probability of errors.
> 
> I'm working on a merge routine that will sort this out but it's not ready yet.

I know.  I regularly follow the devel list and have seen the great
progress you've made lately.  When/if I get more time, this is one
of the projects that I'd like to contribute to.  PostgreSQL is the
other.  From about 1995 to end of 1999, I wrote and maintained a
transaction posting system (TPS) for some brokerage software.  All
C/C++ in a Solaris environment.  The only thing holding me back it
my lack of time.

>>It looks like there is a transaction count somewhere that
>>I also need to update.  Is that true?
> 
> 
> There are lists of transactions and splits within Account objects. There is no 
> way just via the XML to cause those lists to be re-calculated, you have to 
> invoke it via the C code.
> 
> 
>>Maybe there are just too many little things
> 
> 
> Links between objects are not 'little' - they are the crux of the GnuCash 
> system.

No slight intended.  Also, I don't want to waste anyones time with this.
I was just curious to see if I could do it.  When I got the errors I
thought I toss a question to the list.

Here is the transaction element that I generated.  The GUID was taken
from similar entries in the XML file, not invented out of thin air.


<gnc:transaction version="2.0.0">
   <trn:id type="guid">61d56894700f8dfbb16aacc22d453f42</trn:id>
   <trn:currency>
     <cmdty:space>ISO4217</cmdty:space>
     <cmdty:id>CAD</cmdty:id>
   </trn:currency>
   <trn:date-posted>
     <ts:date>2000-08-31 00:00:00 -0700</ts:date>
   </trn:date-posted>
   <trn:date-entered>
     <ts:date>2004-10-28 12:11:20 -0600</ts:date>
   </trn:date-entered>
   <trn:description>SERVICE CHARGE</trn:description>
   <trn:slots>
     <slot>
       <slot:key>notes</slot:key>
       <slot:value type="string">OFX ext. info: |Trans type:Service 
charge</slot:value>
     </slot>
   </trn:slots>
   <trn:splits>
     <trn:split>
       <split:id type="guid">6a228c6b6a409faf3e4abc9a505bb86a</split:id>
       <split:reconciled-state>n</split:reconciled-state>
       <split:value>215/100</split:value>
       <split:quantity>215/100</split:quantity>
       <split:account 
type="guid">394e44bb7cfc235eae38ff75e7107b2c</split:account>
     </trn:split>
     <trn:split>
       <split:id type="guid">8bbf5f0d9768f16afbb03520a5db81c4</split:id>
       <split:memo>SERVICE CHARGE</split:memo>
       <split:reconciled-state>n</split:reconciled-state>
       <split:value>-215/100</split:value>
       <split:quantity>-215/100</split:quantity>
       <split:account 
type="guid">d233312b739d854db67e2c9b36cbd28d</split:account>
     </trn:split>
   </trn:splits>
</gnc:transaction>

>>that need to 
>>be updated manually to accomplish this.  That's fine but
>>I wanted to see if I could merge these hand-coded transactions.
> 
> 
> No, not yet. It's far from simple, despite how it might appear in the XML.
> 
> At least you have the backup.

Yes.  At least I have a backup.



More information about the gnucash-user mailing list