Knowledgebase: Syntax
[QODBC-Desktop] How to create a Sales Receipt using QODBC
Posted by brad waddell on 12 March 2009 05:21 PM

Example of Creating Sales Receipts for USA QuickBooks Users

Create One Sales Receipt with a Single Line

Note: This creates one SalesReceipt with a single line with all the billing address details.

Query in QODBC

insert into salesreceiptline (CustomerRefListID, TemplateRefListID, TxnDate,
IsPending, DueDate, IsToBePrinted, DepositToAccountRefListID,
BillAddressAddr1, BillAddressAddr2, BillAddressAddr3,
BillAddressCity, BillAddressState, BillAddressPostalCode,
SalesReceiptLineItemRefFullName, SalesReceiptLineDesc,
SalesReceiptLineRate, SalesReceiptLineAmount,
SalesReceiptLineSalesTaxCodeRefListID)
values ('AC0000-1197757899', '90000-933290726', {d'2006-05-25'},
0, {d'2006-05-25'}, 0, '80000-933270541','Joe Mama Inc 2',
'123 Main St.', 'Suite 450', 'Chicago', 'IL', '60602',
'Support Incident', 'Priority Support Incident 10 Pack Subscription',
275.00, 275.00, '20000-999022286')


Note: 
 VB DEMO is to be used for testing of QODBC SQL queries only and is not a development tool.

 

Result in QuickBooks

The query above results in the following Sales Receipt in QuickBooks 2006 Premier:

 

Example of Creating Sales Receipts for NON-USA QuickBooks Users

Create One Sales Receipt with Three Lines

Note: This creates one SalesReceipt with three lines. Note the FQSaveToCache field, set to True except on the last line.

First Line

INSERT INTO "SalesReceiptLine" ("CustomerRefListID", "RefNumber", "SalesReceiptLineItemRefListID", "SalesReceiptLineDesc", "SalesReceiptLineRate", "SalesReceiptLineAmount", "SalesReceiptLineTaxCodeRefListID", "FQSaveToCache") VALUES ('470001-1071525403', '1', '250000-933272656', 'Building permit 1', 1.00000, 1.00, '20000-999022286', 1)

Second Line

INSERT INTO "SalesReceiptLine" ("CustomerRefListID", "RefNumber", "SalesReceiptLineItemRefListID", "SalesReceiptLineDesc", "SalesReceiptLineRate", "SalesReceiptLineAmount", "SalesReceiptLineTaxCodeRefListID", "FQSaveToCache") VALUES ('470001-1071525403', '1', '250000-933272656', 'Building permit 2', 2.00000, 2.00, '20000-999022286', 1)

Third (Last) Line

INSERT INTO "SalesReceiptLine" ("CustomerRefListID", "RefNumber", "SalesReceiptLineItemRefListID", "SalesReceiptLineDesc", "SalesReceiptLineRate", "SalesReceiptLineAmount", "SalesReceiptLineTaxCodeRefListID", "FQSaveToCache") VALUES ('470001-1071525403', '1', '250000-933272656', 'Building permit 3', 3.00000, 3.00, '20000-999022286', 0)

Create Three Sales Receipts with One Line Each

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

First SalesReceipt

INSERT INTO "SalesReceiptLine" ("CustomerRefListID", "RefNumber", "SalesReceiptLineItemRefListID", "SalesReceiptLineDesc", "SalesReceiptLineRate", "SalesReceiptLineAmount", "SalesReceiptLineTaxCodeRefListID") VALUES ('470001-1071525403', '1', '250000-933272656', 'Building permit 1', 1.00000, 1.00, '20000-999022286')

Second SalesReceipt

INSERT INTO "SalesReceiptLine" ("CustomerRefListID", "RefNumber", "SalesReceiptLineItemRefListID", "SalesReceiptLineDesc", "SalesReceiptLineRate", "SalesReceiptLineAmount", "SalesReceiptLineTaxCodeRefListID") VALUES ('470001-1071525403', '1', '250000-933272656', 'Building permit 2', 2.00000, 2.00, '20000-999022286')

Third SalesReceipt

INSERT INTO "SalesReceiptLine" ("CustomerRefListID", "RefNumber", "SalesReceiptLineItemRefListID", "SalesReceiptLineDesc", "SalesReceiptLineRate", "SalesReceiptLineAmount", "SalesReceiptLineTaxCodeRefListID") VALUES ('470001-1071525403', '1', '250000-933272656', 'Building permit 3', 3.00000, 3.00, '20000-999022286')

Create One Sales Receipt with Three Lines with Shared Header Information

Note: This creates one SalesReceipt with three lines with a specified billing address. Note the FQSaveToCache field, set to True. Saving the SalesReceipt saves the lines with it.

First Line

INSERT INTO "SalesReceiptLine" ("SalesReceiptLineItemRefListID", "SalesReceiptLineDesc", "SalesReceiptLineRate", "SalesReceiptLineAmount", "SalesReceiptLineTaxCodeRefListID", "FQSaveToCache") VALUES ('250000-933272656', 'Building permit 1', 1.00000, 1.00, '20000-999022286', 1)

Second Line

INSERT INTO "SalesReceiptLine" ("SalesReceiptLineItemRefListID", "SalesReceiptLineDesc", "SalesReceiptLineRate", "SalesReceiptLineAmount", "SalesReceiptLineTaxCodeRefListID", "FQSaveToCache") VALUES ('250000-933272656', 'Building permit 2', 2.00000, 2.00, '20000-999022286', 1)

Third Line

INSERT INTO "SalesReceiptLine" ("SalesReceiptLineItemRefListID", "SalesReceiptLineDesc", "SalesReceiptLineRate", "SalesReceiptLineAmount", "SalesReceiptLineTaxCodeRefListID", "FQSaveToCache") VALUES ('250000-933272656', 'Building permit 3', 3.00000, 3.00, '20000-999022286', 1)

Shared Header Information

INSERT INTO "SalesReceipt" ("CustomerRefListID", "TxnDate", "RefNumber", "BillAddressAddr1", "BillAddressAddr2", "BillAddressCity", "BillAddressCounty", "BillAddressPostalCode", "BillAddressCountry", "IsPending", "DueDate", "ShipDate", "ItemSalesTaxRefListID", "Memo", "IsToBePrinted", "CustomerTaxCodeRefListID") VALUES ('470001-1071525403', {d'2002-10-01'}, '1', 'Brad Lamb', '1921 Appleseed Lane', 'Bayshore', 'CA', '94326', 'USA', 0, {d'2002-10-31'}, {d'2002-10-01'}, '2E0000-933272656', 'Memo Test', 0, '10000-999022286')

 

Special Instructions about Add Lines to a Single Line Sales Receipt

      FileMaker Pro and some other products connect to and disconnect from QODBC after running every SQL statement, so it's not possible to do multiple Sales Receipt lines using our standard FQSaveToCache method. Where this is the case you will have to use Plan B, which is to create a single line Sales Receipt and add additional lines to it afterwards as per the following example.

Create a New One Line SalesReceipt

INSERT INTO "SalesReceiptLine" ("CustomerRefListID", "RefNumber", "SalesReceiptLineItemRefListID", "SalesReceiptLineDesc", "SalesReceiptLineRate", "SalesReceiptLineAmount", "SalesReceiptLineSalesTaxCodeRefListID", "FQSaveToCache") VALUES ('470001-1071525403', '1', '250000-933272656', 'Building permit 1', 1.00000, 1.00, '20000-999022286', 0)

Locate the TxnID of the Sales Receipt

      We can then add two new lines to the SalesReceipt by using the TxnID of the SalesReceipt we just created. The TxnID is found by searching the SalesReceiptLine table for the SalesReceipt by doing:

      select TxnID, TxnDate, RefNumber, CustomerRefFullName from SalesReceiptLine
      where CustomerRefFullName='Lamb, Brad:Room Addition' and RefNumber = '1'

Where 1 is the RefNumber for the Sales Receipt we just created.

Add Two New Lines to the Existing SalesReceipt

First Line

INSERT INTO "SalesReceiptLine" ("TxnID", "SalesReceiptLineItemRefListID", "SalesReceiptLineDesc", "SalesReceiptLineRate", "SalesReceiptLineAmount", "SalesReceiptLineSalesTaxCodeRefListID")
VALUES ('5C60-1197756901', '250000-933272656', 'Building permit 2', 2.00000, 2.00, '20000-999022286')

Second Line

INSERT INTO "SalesReceiptLine" ("TxnID", "SalesReceiptLineItemRefListID", "SalesReceiptLineDesc", "SalesReceiptLineRate", "SalesReceiptLineAmount", "SalesReceiptLineSalesTaxCodeRefListID")
VALUES ('5C60-1197756901', '250000-933272656', 'Building permit 3', 3.00000, 3.00, '20000-999022286')

Result in QuickBooks

      We now have the following Sales Receipt with three lines in QuickBooks:

 

An Example of Sum all Sales Receipts for a Selected Date Fange

Query in QODBC

SELECT SalesReceiptLine.CustomerRefFullName, Sum(SalesReceiptLine.TotalAmount) AS SumOfTotalAmount
FROM SalesReceiptLine unoptimized
WHERE (((SalesReceiptLine.TxnDate)>={d'2004-01-01'})) and (((SalesReceiptLine.TxnDate)<{d'2005-01-01'}))
GROUP BY SalesReceiptLine.CustomerRefFullName

and change the greater than or equal (>=) and the less than (<) dates to the date range you wish to use.

(173 vote(s))
Helpful
Not helpful

Comments (2)
Barb Gustin
11 September 2012 07:39 PM
I cliked on "Create Sales Invoice" but it went to "Create Sales Receipt"! Weird. I need to know how to create not one but multiple invoives from a database table.
Jack
08 July 2014 11:14 AM
Hi Barb,

Please refer below mentioned article for creating Invoices:

http://support.flexquarters.com/esupport/index.php?/Default/Knowledgebase/Article/View/2389/0/how-to-create-invoices-using-qodbc

http://support.flexquarters.com/esupport/index.php?/Knowledgebase/Article/View/1007/61/how-to-create-multiple-invoices-with-multiple-line-items-using-access-2003-and-qodbc
Post a new comment
 
 
Full Name:
Email:
Comments:
CAPTCHA Verification 
 
Please enter the text you see in the image into the textbox below (we use this to prevent automated submissions).