Invoice Importer

Derek Atkins warlord at MIT.EDU
Tue Mar 27 05:01:26 EDT 2012


Hi,

Reuben Cummings <reubano at gmail.com> writes:

>> Umm, let's ignore the database and talk about the GnuCash objects,
>> please?  You shouldn't be modifying the database, you should be using
>> the GnuCash APIs to enter your data.
>
> I would like to use the API but I haven't gotten the python module to work. See my post at
> http://gnucash.1415818.n4.nabble.com/python-binding-error-on-macports-td4441220.html

As I believe was pointed out by John, this is a MacPorts issue.
Still, for terminology it would still help to use Object terminology
instead of database tables.

>>> This refers to the invoice field of the entries database table, i.e.,
>>> entries.invoice.
>> 
>> So you mean the gncEntryGetInvoice() result?
>
> I'll have to assume we are talking about the same thing since I'm not
> familiar with the objects.

I highly recommend you become familiar with them.

>>> I guess 'record' is more appropriate. The invoice field of each record
>>> in the entries table should have a corresponding record in the
>>> invoices table (joined at the guid field).
>> 
>> Again, please consider using the object model instead of table.  So you
>> are saying that the gncEntryGetInvoice() is NULL?
>
> Yes, that sounds right.
>
>> Is this a customer Invoice or a Vendor Bill? 
>
> Customer invoice. 
>
>> What API did the Importer use to add the entry to the Invoice (or Bill)?
>
> I have no idea, I guess Mike Evans would know the answer though.
>
>>> SELECT
>>> 	entries.invoice
>>> 
>>> 	FROM entries
>>> 	LEFT OUTER JOIN invoices ON entries.invoice = invoices.guid
>>> 	WHERE invoices.guid IS NULL
>>> 	GROUP BY entries.invoice
>> 
>> Do you really need the join here?
>
> Yes. Since the orphan entries are identical to the non-orphan entries,
> the only way to filter them out is to join on the invoices table and
> exclude all the entries that match. That leaves entries with
> non-matching invoices... the orphan entries.

Really?  Why can't you just do:

  SELECT ... FROM entries where entries.invoice IS NULL?

Of course you would still need to manually update each entry to apply it
to the right Invoice GUID.

-derek
-- 
       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
       Member, MIT Student Information Processing Board  (SIPB)
       URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
       warlord at MIT.EDU                        PGP key available


More information about the gnucash-devel mailing list