Reuben Cummings <reub...@gmail.com> writes: >>> I figured it out. The invoices from the entries table were never entered >>> into the invoices table. I wrote a script to match the invoices with the >>> transaction guids and insert them into the invoices table. >> >> I don't think I understand this issue. What do you mean by "The >> invoices from the entries table were never entered into the invoices >> table"? > > I'm referring to tables in the backend database. There are two tables > that relate to invoices, i.e., entries and invoices. The two tables > are related by the fields entries.invoice = invoice.guid.
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. >> In particular I don't understand what you mean by "invoices >> from the entries table", > > This refers to the invoice field of the entries database table, i.e., > entries.invoice. So you mean the gncEntryGetInvoice() result? >> and I don't understand what you mean by >> "[entries] were never entered into the invoices table." > > 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? Is this a customer Invoice or a Vendor Bill? What about gncEntryGetBill()? >> Are you saying that the Entries on an invoice were never added to the >> Invoice? > > So, I am saying that the importer created records in the entries table > that had no corresponding record in the invoices table. You can view > them with the following sql statement. What API did the Importer use to add the entry to the Invoice (or Bill)? > 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? What about the entry bill? > What I did was match these orphan invoices with the appropriate > transactions in the transactions table (the invoices and transaction > tables are related by the transaction guid) to create the records that > needed to be inserted into the invoices table. I still don't understand what you mean by "Orphan Invoices" here. I think it's a terminology issue here. It sounds to me like you have "Orphan Entries", not "Orphan Invoices", and I'm trying to understand how these could be orphaned unless there is a bug in the importer. -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 warl...@mit.edu PGP key available _______________________________________________ gnucash-devel mailing list gnucash-devel@gnucash.org https://lists.gnucash.org/mailman/listinfo/gnucash-devel