[QODBC-Desktop] How to create Bills using QODBC
Posted by brad waddell on 12 March 2009 05:21 PM
|
|
Example of Creating Bills using BillItemLine TableCreate One Bill with Three LinesNote: This creates one Bill with three lines. Note the FQSaveToCache field, set to True except on the last line. Note: The primary rule is first to save the data to the child record. The child record for each parent/child pair has all the data required by the parent record. First Line INSERT INTO "BillItemLine" ("VendorRefListID", "RefNumber", "ItemLineItemRefListID", "ItemLineDesc", "ItemLineCost", "ItemLineAmount", "FQSaveToCache") VALUES ('10000-933272655', '1', '250000-933272656', 'Building permit 1', 1.00000, 1.00, 1) Second Line INSERT INTO "BillItemLine" ("VendorRefListID", "RefNumber", "ItemLineItemRefListID", "ItemLineDesc", "ItemLineCost", "ItemLineAmount", "FQSaveToCache") VALUES ('10000-933272655', '1', '250000-933272656', 'Building permit 2', 2.00000, 2.00, 1) Third (Last) Line INSERT INTO "BillItemLine" ("VendorRefListID", "RefNumber", "ItemLineItemRefListID", "ItemLineDesc", "ItemLineCost", "ItemLineAmount", "FQSaveToCache") VALUES ('10000-933272655', '1', '250000-933272656', 'Building permit 3', 3.00000, 3.00, 0) Create Three Bills with One Line EachNote: This creates three bills with one line each. Note the FQSaveToCache field is not specified (or can be set to false) First Bill INSERT INTO "BillItemLine" ("VendorRefListID", "RefNumber", "ItemLineItemRefListID", "ItemLineDesc", "ItemLineCost", "ItemLineAmount") VALUES ('10000-933272655', '1', '250000-933272656', 'Building permit 1', 1.00000, 1.00) Second Bill INSERT INTO "BillItemLine" ("VendorRefListID", "RefNumber", "ItemLineItemRefListID", "ItemLineDesc", "ItemLineCost", "ItemLineAmount") VALUES ('10000-933272655', '1', '250000-933272656', 'Building permit 2', 2.00000, 2.00) Third Bill INSERT INTO "BillItemLine" ("VendorRefListID", "RefNumber", "ItemLineItemRefListID", "ItemLineDesc", "ItemLineCost", "ItemLineAmount") VALUES ('10000-933272655', '1', '250000-933272656', 'Building permit 3', 3.00000, 3.00) Create One Bill with Three Item Lines with Shared Header InformationNote: This creates one Bill with three-item lines. Note the FQSaveToCache field, set to True. Saving the Bill saves the lines with it. First Line INSERT INTO "BillItemLine" ("ItemLineItemRefListID", "ItemLineDesc", "ItemLineCost", "ItemLineAmount", "FQSaveToCache") VALUES ('250000-933272656', 'Building permit 1', 1.00000, 1.00, 1) Second Line INSERT INTO "BillItemLine" ("ItemLineItemRefListID", "ItemLineDesc", "ItemLineCost", "ItemLineAmount", "FQSaveToCache") VALUES ('250000-933272656', 'Building permit 2', 2.00000, 2.00, 1) Third Line INSERT INTO "BillItemLine" ("ItemLineItemRefListID", "ItemLineDesc", "ItemLineCost", "ItemLineAmount", "FQSaveToCache") VALUES ('250000-933272656', 'Building permit 3', 3.00000, 3.00, 1) Shared Header Information INSERT INTO "Bill" ("VendorRefListID", "APAccountRefListID", "TxnDate", "RefNumber", "TermsRefListID", "DueDate", "Memo") VALUES ('10000-933272655', 'C0000-933270541', {d'2002-10-01'}, '1', '10000-933272658', {d'2002-10-31'}, 'Memo Test')
Example of Creating Bills using BillExpenseLine TableCreate One Bill with Two Expense Lines with Shared Header InformationNote: This creates one Bill with two expense lines. Note the FQSaveToCache field, set to True. Saving the Bill saves the lines with it. First Line
Second Line INSERT INTO "BillExpenseLine" ("ExpenseLineAccountRefListID", "ExpenseLineAmount", "ExpenseLineMemo", "ExpenseLineCustomerRefListID", "FQSaveToCache") VALUES ('370001-909762877', 436.06, 'Expense Line Memo Test 2', '4C0000-1040154668', 1)
Shared Header Information INSERT INTO "Bill" ("VendorRefListID", "APAccountRefListID", "TxnDate", "RefNumber", "TermsRefListID", "DueDate", "Memo") VALUES ('390000-1039739488', 'C0000-896817249', {d'2021-12-15'}, '1', '50000-898307888', {d'2021-12-31'}, 'Expense Memo Test')
Result in QuickBooks
Special Instructions and Examples for Australian UsersNote: For Australian users, use the following SQL Statements using ExpenseLineTaxCodeRefListID (for GST) and these modified values to create a single line expense bill for "Optical Phone Networks" in the sample Stadium Construction company file supplied with QuickBooks in Australia located at : Single Expense Line INSERT INTO "BillExpenseLine" ("ExpenseLineAccountRefListID", "ExpenseLineAmount", "ExpenseLineMemo", "ExpenseLineTaxCodeRefListID", "FQSaveToCache") VALUES ('270000-1045536344', 500.00, 'QODBC Expense Line Memo Test 1', 'C0000-1045536338', 1) Header Information INSERT INTO "Bill" ("VendorRefListID", "APAccountRefListID", "TxnDate", "RefNumber", "TermsRefListID", "DueDate", "Memo") VALUES ('200000-1045537156', '3D0000-1045609540', {d'2004-11-17'}, '1', '20000-1045536343', {d'2004-12-31'}, 'QODBC Bill Expense Memo Test') Related Data Location Note: Never enter a tax value, as QuickBooks generates the tax amount based on the ExpenseLineTaxCodeRefListID being used. ExpenseLineTaxCodeRefListID is the ListID for GST found in the TaxCode Table. Use the following SQL Statement in VB Demo to locate the ListID: SELECT * FROM TaxCode Also Note: The ExpenseLineCustomerRefListID or ExpenseLineAccountRefFullName is found by doing something like: select ListID, Fullname from customer where FullName like 'D%.'
Example of Creating Bills using ExpenseLine without ExpenseLineCustomerRefListIDNote: You can leave out ExpenseLineCustomerRefListID altogether; you can't say you will use it and then try to insert a null. Create a Single Line Expense Bill without ExpenseLineCustomerRefListIDThe following example also works: Single Expense Line INSERT INTO "BillExpenseLine" ("ExpenseLineAccountRefListID", "ExpenseLineAmount", "ExpenseLineMemo", "FQSaveToCache") VALUES ('370001-909762877', 436.07, 'Expense Line Memo Test 100', 1)
Header Information INSERT INTO "Bill" ("VendorRefListID", "APAccountRefListID", "TxnDate", "RefNumber", "TermsRefListID", "DueDate", "Memo") VALUES ('390000-1039739488', 'C0000-896817249', {d'2021-12-15'}, '100', '50000-898307888',{d'2021-12-31'}, 'Expense Memo Test')
Result in QuickBooks
ListID and FullName ReferencesNote: When doing INSERTs, you need to use either the ListID or FullName reference, so if you know the Vendor's name and the account name you can select to use the FullName like this: INSERT INTO "Bill" ("VendorRefFullName", "APAccountRefFullName", "TxnDate", "RefNumber", "DueDate", "Memo") instead of the ListIDs like this: INSERT INTO "Bill" ("VendorRefListID", "APAccountRefListID", "TxnDate", "RefNumber", "DueDate", "Memo")
| |
|