Member Login

Username
Password
Forget Password
New Sign Up
Search Forum

Buy Support
Incidents

If you can't find your answer in the FREE PUBLIC QDeveloper Forum, require URGENT Priority Support, or you need to send us private or confidential information:

Click Here
If you can't login and post questions or you are having trouble viewing forum posts:
Click Here
Callback
Support

If you live in USA, UK, Canada, Australia or New Zealand, you can leave us details on your question and request us to call you back and discuss them with you personally  (charges apply).

Click Here
 
Buy Support
Incidents
If you can't find your answer in the FREE PUBLIC QDeveloper Forum, require URGENT Priority Support, or you need to send us private or confidential information:
Click Here

Forum : How do I create Bills?Search Forum

Forum Home > QODBC - ODBC Driver for QuickBooks > QODBC SQL Sample Scripts Forum

 New Topic 
 
 Post Reply 
[1]  
 How do I create Bills? 
 Author   Message 
  Tom 
  6c3c1_sdk-qodbc.gif
 Group: Administrator 
 Posts: 5510 
 Joined: 2006-02-17 
 Profile
 Posted : 2006-02-26 16:50:26
BillItemLine
This creates one bill with three lines. Note the FQSaveToCache field, set to True except on the last 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)

INSERT INTO "BillItemLine" ("VendorRefListID", "RefNumber", "ItemLineItemRefListID", "ItemLineDesc", "ItemLineCost", "ItemLineAmount", "FQSaveToCache") VALUES ('10000-933272655', '1', '250000-933272656', 'Building permit 2', 2.00000, 2.00, 1)

INSERT INTO "BillItemLine" ("VendorRefListID", "RefNumber", "ItemLineItemRefListID", "ItemLineDesc", "ItemLineCost", "ItemLineAmount", "FQSaveToCache") VALUES ('10000-933272655', '1', '250000-933272656', 'Building permit 3', 3.00000, 3.00, 0)

This creates three bills with one line each. Note the FQSaveToCache field is not specified (or can be set to false)

INSERT INTO "BillItemLine" ("VendorRefListID", "RefNumber", "ItemLineItemRefListID", "ItemLineDesc", "ItemLineCost", "ItemLineAmount") VALUES ('10000-933272655', '1', '250000-933272656', 'Building permit 1', 1.00000, 1.00)

INSERT INTO "BillItemLine" ("VendorRefListID", "RefNumber", "ItemLineItemRefListID", "ItemLineDesc", "ItemLineCost", "ItemLineAmount") VALUES ('10000-933272655', '1', '250000-933272656', 'Building permit 2', 2.00000, 2.00)

INSERT INTO "BillItemLine" ("VendorRefListID", "RefNumber", "ItemLineItemRefListID", "ItemLineDesc", "ItemLineCost", "ItemLineAmount") VALUES ('10000-933272655', '1', '250000-933272656', 'Building permit 3', 3.00000, 3.00)

This creates one bill with three item lines. Note the FQSaveToCache field, set to True. Saving the Bill saves the lines with it.

INSERT INTO "BillItemLine" ("ItemLineItemRefListID", "ItemLineDesc", "ItemLineCost", "ItemLineAmount", "FQSaveToCache") VALUES ('250000-933272656', 'Building permit 1', 1.00000, 1.00, 1)

INSERT INTO "BillItemLine" ("ItemLineItemRefListID", "ItemLineDesc", "ItemLineCost", "ItemLineAmount", "FQSaveToCache") VALUES ('250000-933272656', 'Building permit 2', 2.00000, 2.00, 1)

INSERT INTO "BillItemLine" ("ItemLineItemRefListID", "ItemLineDesc", "ItemLineCost", "ItemLineAmount", "FQSaveToCache") VALUES ('250000-933272656', 'Building permit 3', 3.00000, 3.00, 1)

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')

BillExpenseLine
This creates one bill with two expense lines. Note the FQSaveToCache field, set to True. Saving the Bill saves the lines with it.

INSERT INTO "BillExpenseLine" ("ExpenseLineAccountRefListID", "ExpenseLineAmount", "ExpenseLineMemo", "ExpenseLineCustomerRefListID", "FQSaveToCache") VALUES ('120000-933270541', 436.07, 'Expense Line Memo Test 1', '6E0000-1071509585', 1)

INSERT INTO "BillExpenseLine" ("ExpenseLineAccountRefListID", "ExpenseLineAmount", "ExpenseLineMemo", "ExpenseLineCustomerRefListID", "FQSaveToCache") VALUES ('120000-933270541', 436.06, 'Expense Line Memo Test 2', '6E0000-1071509585', 1)

INSERT INTO "Bill" ("VendorRefListID", "APAccountRefListID", "TxnDate", "RefNumber", "TermsRefListID", "DueDate", "Memo") VALUES ('720000-1071512482', 'C0000-933270541', {d'2002-10-01'}, '1', '20000-933272658', {d'2002-10-31'}, 'Expense Memo Test')

and results in the following Bill in QuickBooks:

or 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 :-
 
C:\Program Files\Intuit\QuickBooks Premier\Stadium Construction and Hardware Pty Ltd QB Premier.qbw

INSERT INTO "BillExpenseLine" ("ExpenseLineAccountRefListID", "ExpenseLineAmount", "ExpenseLineMemo", "ExpenseLineTaxCodeRefListID", "FQSaveToCache") VALUES ('270000-1045536344', 500.00, 'QODBC Expense Line Memo Test 1', 'C0000-1045536338', 1)

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')

Never enter a tax value as QuickBooks generates the tax amount based upon 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

Please Note: The ExpenseLineCustomerRefListID or ExpenseLineAccountRefFullName is found by doing something like:

select ListID, Fullname from customer where FullName like 'V%'

 

 

 

  Top 
  Tom 
  6c3c1_sdk-qodbc.gif
 Group: Administrator 
 Posts: 5510 
 Joined: 2006-02-17 
 Profile
 Posted : 2006-04-21 09:02:50

UPDATE: You can actually leave out ExpenseLineCustomerRefListID all together, you just can't say you are going to use it, and then try to insert a null. 

The following example also works:

INSERT INTO "BillExpenseLine" ("ExpenseLineAccountRefListID", "ExpenseLineAmount", "ExpenseLineMemo", "FQSaveToCache") VALUES ('120000-933270541', 436.07, 'Expense Line Memo Test 100', 1)

INSERT INTO "Bill" ("VendorRefListID", "APAccountRefListID", "TxnDate", "RefNumber", "TermsRefListID", "DueDate", "Memo") VALUES ('720000-1071512482', 'C0000-933270541', {d'2002-10-01'}, '100', '20000-933272658', {d'2002-10-31'}, 'Expense Memo Test')

 

  Top 
  Tom 
  6c3c1_sdk-qodbc.gif
 Group: Administrator 
 Posts: 5510 
 Joined: 2006-02-17 
 Profile
 Posted : 2006-06-27 11:25:44

Note: When doing INSERTs you need to use either the ListID or FullName reference, so if you know the Vendor's name and Account Name you can elect to use the FullName like this:

INSERT INTO "Bill" ("VendorRefFullName", "APAccountRefFullName", "TxnDate", "RefNumber", "DueDate", "Memo")
VALUES ('ABC', 'Accounts Payable',  {d'2006-06-26'}, '100',  {d'2006-06-30'}, 'Expense Memo Test 5' )

instead of the ListIDs like this:

INSERT INTO "Bill" ("VendorRefListID", "APAccountRefListID", "TxnDate", "RefNumber", "DueDate", "Memo")
VALUES ('10000-933272655', 'C0000-933270541', {d'2002-10-01'}, '100', {d'2002-10-31'}, 'Memo Test')

 

  Top 
  germanky 
  
 Group: Members 
 Posts: 4 
 Joined: 2007-04-26 
 Profile
 Posted : 2007-04-26 23:08:21

hi, this code works, with this vbscrip code you may be able to put a Billexpenseline and a bill at the same time, works great i hope save some time with this code, i got more applications running at this momment if you need anithing else let me know at german@natureflowers.com

"code in vbscript"

Option Explicit
Const vbNormal = 1

const adOpenStatic = 3
Const adLockOptimistic = 3
Const AdUseClient = 3

Dim oRecordset3, oConnection3, sSQL, ssSQL

Set oConnection3 = CreateObject("ADODB.Connection")
oConnection3.Open "DSN=Quickbooks Data;OLE DB Services=-2"
sSQL = "SELECT * FROM BillExpenseLine WHERE TxnId = 'X'"

Set oRecordset3 = CreateObject("ADODB.Recordset")
oRecordset3.Open sSQL, oConnection3, adOpenStatic, adLockOptimistic

  oRecordset3.Addnew()
  oRecordset3.Fields("ExpenseLineAccountRefListID").Value = "8C0001-1197740053"
  oRecordset3.Fields("ExpenseLineAmount").Value = 150000
  oRecordset3.Fields("ExpenseLineMemo").Value = "TESTMEMO0000"
  oRecordset3.Fields("ExpenseLineCustomerRefListID").Value = "890000-1047591941"
  oRecordset3.Fields("FQSaveToCache").Value = 1
  oRecordset3.Update()

ssSQL = "SELECT * FROM Bill WHERE TxnId = 'X'"

Set oRecordset3 = CreateObject("ADODB.Recordset")
oRecordset3.Open ssSQL, oConnection3, adOpenStatic, adLockOptimistic

  oRecordset3.Addnew()
  oRecordset3.Fields("VendorRefListID").Value = "2F0004-1197735443"
  oRecordset3.Fields("APAccountRefListID").Value = "C0000-896817249"
  oRecordset3.Fields("TxnDate").Value = "2/16/2007"
  oRecordset3.Fields("RefNumber").Value = "TEST123NUMB"
  oRecordset3.Fields("TermsRefListID").Value = "20000-898307885"
  oRecordset3.Fields("DueDate").Value = "3/16/2007"
  oRecordset3.Fields("Memo").Value = "TESTMEMO2"
  oRecordset3.Update()

oRecordset3.Close
oConnection3.Close

msgbox "end of process"
WScript.Quit

'********************************//****************************************
'*TABLE DETAIL REFERENCE:   BillExpenseLine 
'*
'*FIELD RELATIONSHIPS:   (BillExpenseLine ) . ExpenseLineAccountRefListID 
'*TABLE   FIELD  CATEGORY
'*Account ListID  List
'*("ExpenseLineAccountRefListID").Value = "8C0001-1197740053"
'*
'*FIELD RELATIONSHIPS:   (BillExpenseLine ) . ExpenseLineCustomerRefListID 
'*TABLE    FIELD  CATEGORY
'*Customer ListID  List
'*("ExpenseLineCustomerRefListID").Value = "890000-1047591941" stern
'*
'*TABLE DETAIL REFERENCE:   Bill
'*FIELD RELATIONSHIPS:   (Bill ) . VendorRefListID 
'*TABLE  FIELD  CATEGORY
'*Vendor ListID  List
'*("VendorRefListID").Value = "2F0004-1197735443" german
'*
'*FIELD RELATIONSHIPS:   (Bill ) . APAccountRefListID 
'*TABLE   FIELD  CATEGORY
'*Account ListID  List
'*("APAccountRefListID").Value = "C0000-896817249" german
'*
'*FIELD RELATIONSHIPS:   (Bill ) . TermsRefListID 
'*TABLE  FIELD  CATEGORY
'*Terms  ListID  List
'*("TermsRefListID").Value = "20000-898307885" net 30
'********************************//****************************************

 

 
German Rodriguez 
 
  Top 
  KofK 
  
 Group: Members 
 Posts: 43 
 Joined: 2006-04-04 
 Profile
 Posted : 2007-08-22 02:11:49
Can I insert both BillItems and BillExpenses into one bill? 

  Top 
  Tom 
  6c3c1_sdk-qodbc.gif
 Group: Administrator 
 Posts: 5510 
 Joined: 2006-02-17 
 Profile
 Posted : 2007-08-22 10:18:00

Yes, but you need to first create either the Expense or Item lines first and then add the Item or Expense lines afterwards like this:

Step 1 - Create the Expense Lines
INSERT INTO "BillExpenseLine" ("ExpenseLineAccountRefListID", "ExpenseLineAmount", 
"ExpenseLineMemo", "FQSaveToCache")
VALUES ('120000-933270541', 436.07,
'Expense Line Memo Test', 1)

Step 2 - Write the Bill Header
INSERT INTO "Bill" ("VendorRefListID", "APAccountRefListID", "TxnDate", "RefNumber",
"TermsRefListID", "DueDate", "Memo")
VALUES ('10000-933272655', 'C0000-933270541', {d'2007-10-01'}, '905',
'10000-933272658', {d'2007-10-31'}, 'Test Expense and Item Lines')

Step 3 - Determine the TxnID of the new Bill
sp_lastinsertID Bill

Step 4 - Use the TxnID to append Item lines to the existing Bill
The LastInsertID returned was: 5CAD-1197762987

INSERT INTO "BillItemLine" ("TxnID", "ItemLineItemRefListID",
"ItemLineDesc", "ItemLineCost",  "ItemLineAmount")
VALUES ('5CAD-1197762987', '250000-933272656',
'Building permit 1', 1.00000, 1.00)

This results in the following Bill in QuickBooks with both a Expense and Item line:

 

 

 

  Top 
  Snap Communications 
  
 Group: Members 
 Posts: 9 
 Joined: 2007-11-22 
 Profile
 Posted : 2007-11-22 07:19:35
Do you have any examples of Creating a bill with one item that works on Quickbooks Online.  I would love to do it with one insert statement.. 

  Top 
  Tom 
  6c3c1_sdk-qodbc.gif
 Group: Administrator 
 Posts: 5510 
 Joined: 2006-02-17 
 Profile
 Posted : 2007-11-22 08:20:19

That would look something like:

INSERT INTO "BillExpenseLine" ("VendorRefListID", "TxnDate", "RefNumber",
"ExpenseLineAccountRefListID", "ExpenseLineAmount", "ExpenseLineMemo", "FQSaveToCache")
VALUES ('2', {d'2007-11-22'}, 'TestRefNum_1',
'22', 436.07, 'QBOE Expense Line Memo Test', 0)


Where "VendorRefListID" is found from the Vendor table
and   "ExpenseLineAccountRefListID" is found from the Account table

 

  Top 
  Snap Communications 
  
 Group: Members 
 Posts: 9 
 Joined: 2007-11-22 
 Profile
 Posted : 2007-11-22 14:04:48
thanks this was exactly what I needed.. 

  Top 
 New Topic 
 
 Post Reply 
[1]  

Jump to