reubano at gmail.com
Wed Mar 28 02:48:58 EDT 2012
On Mar 27, 2012, at 12:01 PM, Derek Atkins wrote:
> 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
> 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.
Yes, I wasn't questioning John's response, just letting you know what I'm not using the API.
>>>> This refers to the invoice field of the entries database table, i.e.,
>>> 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.
Agreed, and as soon as I can get python bindings working I plan to.
>>>> 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.
>>>> 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?
Because entries.invoices isn't null. Even the orphan entries have an invoice guid. It just that these guids are not present in the invoices table.
> Of course you would still need to manually update each entry to apply it
> to the right Invoice GUID.
More information about the gnucash-devel