Member Login

Username
Password
Forget Password
New Sign Up
  Search Forums

  FREE Support
  Forums

  QODBC v10
  QODBC v9
  QODBC v8
  QODBC v7
  QODBC v6

  QODBC FAQs

The QDeveloper Forum is the property of Data Access Worldwide, Australia. The contents of this forum have been taken by FLEXquarters.com Limited, Hong Kong at: http://support.flexquarters
.com/esupport/
without our permission.

 


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

Forum : Reading Reference Documentation about REQ fieldsSearch Forum

Forum Home > QODBC - ODBC Driver for QuickBooks > QODBC v9 Independent Self Help Forum

 New Topic 
 
 Post Reply 
[1]  
 Reading Reference Documentation about REQ fields 
 Author   Message 
  TexasGuy 
  
 Group: Members 
 Posts: 35 
 Joined: 2009-08-19 
 Profile
 Posted : 2009-09-11 08:04:58

Hmm, thought that the reference was easy enough but I cannot get what should be a simple thing...

In the following table: InvoiceLine

It is said (what I think is being said) that fields CustomerRefListID & CustomerRefFullName are required to be explicitly filled when doing insert operation. However, going through a little tutorial on how to add new invoices from: How do I create Invoices? 

... it is evident from the examples that fields CustomerRefListID & CustomerRefFullName are not given any value when InvoiceLine table gets new inserts.

Therefore, am I reading the documentation incorrectly? Going from their table of fields, how do I decide what is the most minimum fields should be given explicit value when inserting, say into InvoiceLine.

Thanks.

PS: Going back to the new invoice insert example, should one call SP_BATCHUPDATE after the queries in the example? Is it for fields with FQSaveToCache value or it plays a different role?

 

  Top 
  Tom Aczel 
  dd4bf_dawworld.jpg
 Group: Administrator 
 Posts: 6281 
 Joined: 2006-02-17 
 Profile
 Posted : 2009-09-11 21:13:09

As per: How can I create multiple lines in the Invoice, Purchase, Journal and other tables? 

The answer really is that either the CustomerRefListID or CustomerRefFullName must be supplied to complete the Invoice (not both). Below are some examples of creating a Invoice. The primary rule is to save the data to the child record first. The child record for each parent/child pair has all of the data required by the parent record included in it.

If you need to create a one line item invoice for example, you can use a format similar to this:

INSERT INTO "InvoiceLine" ("CustomerRefListID", "RefNumber",
"InvoiceLineItemRefListID", "InvoiceLineDesc", "InvoiceLineRate",
"InvoiceLineAmount", "InvoiceLineSalesTaxCodeRefListID") VALUES
('470001-1071525403', '1', '250000-933272656', 'Building permit 1',
1.00000, 1.00, '20000-999022286')

The above transaction inserts all required data in the InvoiceLine table to create a complete record in the InvoiceLine table, as well as the Invoice header table, and saves the completed invoice record immediately. This is the simplest form of invoice creation.

Multi-line invoices require a series of SQL statements to complete a single invoice. In the example below we are creating a 3 line invoice using 3 SQL INSERT commands in sequence. The key to this process is the field named "FQSaveToCache". This field is not part of the table, but is used as a flag to the QODBC driver. In the sequence below, you should note that the value of "FQSaveToCache" is set to 1 or TRUE for the first two line item insert statements, and then it is set to 0 or FALSE for the final statement.

A TRUE setting of "FQSaveToCache" instructs QODBC to take the values from your INSERT statement and hold them for later processing, but not to save them to QuickBooks yet. When QODBC receives the final transaction where the cache is set to 0 or FALSE, the contents of the current INSERT statement will be combined with all of the previous INSERT statements held in the cache for this connection, and saved as a batch into QuickBooks.

QODBC maintains a connection for each application using the driver, and this cache is specific for each connection, so multiple applications or users of QODBC will not interfere with the cached transactions of other users. There is no set limit to the number of lines that can be cached for a single transaction, other than what QuickBooks would limit you to.

Since the data on the INSERT statement is being cached and not written to QuickBooks, some application tools (most notably Microsoft Access) will re-check that the data was saved properly to the target database by running a SELECT statement following a successful INSERT statement. In this example, this re-check will fail.

To get around this, use a pass-thru query (Append Query) and ignore any errors in the processing of the transaction, except for the last one. After the final line has been saved and the record is inserted into QuickBooks, then you can do your own validation by SELECTing the results of the Invoice number you just created in the Invoice and InvoiceLines tables to see that it was inserted correctly.

INSERT INTO "InvoiceLine" ("CustomerRefListID", "RefNumber",
"InvoiceLineItemRefListID", "InvoiceLineDesc", "InvoiceLineRate",
"InvoiceLineAmount", "InvoiceLineSalesTaxCodeRefListID", "FQSaveToCache")
VALUES ('470001-1071525403', '1', '250000-933272656', 'Building permit 1',
1.00000, 1.00, '20000-999022286', 1)

INSERT INTO "InvoiceLine" ("CustomerRefListID", "RefNumber",
"InvoiceLineItemRefListID", "InvoiceLineDesc", "InvoiceLineRate",
"InvoiceLineAmount", "InvoiceLineSalesTaxCodeRefListID", "FQSaveToCache")
VALUES ('470001-1071525403', '1', '250000-933272656', 'Building permit 2',
2.00000, 2.00, '20000-999022286', 1)

INSERT INTO "InvoiceLine" ("CustomerRefListID", "RefNumber",
"InvoiceLineItemRefListID", "InvoiceLineDesc", "InvoiceLineRate",
"InvoiceLineAmount", "InvoiceLineSalesTaxCodeRefListID", "FQSaveToCache")
VALUES ('470001-1071525403', '1', '250000-933272656', 'Building permit 3',
3.00000, 3.00, '20000-999022286', 0)

For multi-line invoices, some may find it easier to not include the header information with each line item, but rather to have seperate smaller commands for the Invoice Lines and a final INSERT for the Invoice header. This will also work as in the example below.

Here we create an invoice with 3 lines by using 3 InvoiceLine INSERT commands (with the caching flag set true) followed by the Invoice table (header) insert, which is automatically designed to pull in all cached InvoiceLine records and save immediately.

INSERT INTO "InvoiceLine" ("InvoiceLineItemRefListID", "InvoiceLineDesc",
"InvoiceLineRate", "InvoiceLineAmount", "InvoiceLineSalesTaxCodeRefListID",
"FQSaveToCache") VALUES ('250000-933272656', 'Building permit 1', 1.00000,
1.00, '20000-999022286', 1)

INSERT INTO "InvoiceLine" ("InvoiceLineItemRefListID", "InvoiceLineDesc",
"InvoiceLineRate", "InvoiceLineAmount", "InvoiceLineSalesTaxCodeRefListID",
"FQSaveToCache") VALUES ('250000-933272656', 'Building permit 2', 2.00000,
2.00, '20000-999022286', 1)

INSERT INTO "InvoiceLine" ("InvoiceLineItemRefListID", "InvoiceLineDesc",
"InvoiceLineRate", "InvoiceLineAmount", "InvoiceLineSalesTaxCodeRefListID",
"FQSaveToCache") VALUES ('250000-933272656', 'Building permit 3', 3.00000,
3.00, '20000-999022286', 1)

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

SP_BATCHUPDATE is only used if we have hundreds of invoices to create as it saves waiting on QuickBooks for each Invoice to be created.

QODBC Batch Stored Procedures

These allow you to start a batch for a given table and all insert/updates will be queued until the sp_batchupdate command is issued. This allows for fewer round trips to QuickBooks which increases performance when doing large transfers of records from external systems to QuickBooks.

The sp_lastinsertid stored procedure will return the ListID/TxnID plus an error message column for every row added to the batch.

Note: Each batch is limited to 500 transactions.

  • sp_batchclear tablename – clears the current batch started with sp_batchstart.
  • sp_batchstart tablename – starts a new batch. All inserts/update issued on this table will be batched until sp_batchupdate is issued.
  • sp_batchupdate tablename – sends the batched transactions to QuickBooks. ListID/TxnIDs and error messages are available through sp_lastinsertid tablename.

BatchStart
sp_batchstart InvoiceLine

BatchInsert1
INSERT INTO "InvoiceLine" ("CustomerRefListID", "RefNumber",
"InvoiceLineItemRefListID", "InvoiceLineDesc", "InvoiceLineRate",
"InvoiceLineAmount", "InvoiceLineSalesTaxCodeRefListID", "FQSaveToCache")
VALUES ('AC0000-1197757899', 'Batch1', '250000-933272656', 'Bin Permit Renovations',
200.00000, 200.00, '20000-999022286', 0) 

..................................................................

BatchInsert499
INSERT INTO "InvoiceLine" ("CustomerRefListID", "RefNumber",
"InvoiceLineItemRefListID", "InvoiceLineDesc", "InvoiceLineRate",
"InvoiceLineAmount", "InvoiceLineSalesTaxCodeRefListID", "FQSaveToCache")
VALUES ('AC0000-1197757899', 'Batch2', '250000-933272656', 'Bin Permit Renovations',
200.00000, 200.00, '20000-999022286', 0) 

BatchUpdate
sp_batchupdate  InvoiceLine

 

  Top 
  TexasGuy 
  
 Group: Members 
 Posts: 35 
 Joined: 2009-08-19 
 Profile
 Posted : 2009-09-12 01:09:24
I appreciate you taking time for this detailed explanation, I found it to be very helpful.

Thank you. 

  Top 
  TexasGuy 
  
 Group: Members 
 Posts: 35 
 Joined: 2009-08-19 
 Profile
 Posted : 2009-09-12 08:06:20
Could you give an example how to insert group items into an invoice. This time I don't have to do deletions, just creating invoices.

In a sense, I have to add items and groups, in each group I have to modify quantity of the items inside a group.

How would groups be different from inserting items?

Thanks. 

  Top 
  TexasGuy 
  
 Group: Members 
 Posts: 35 
 Joined: 2009-08-19 
 Profile
 Posted : 2009-09-12 08:52:46
A little clarification.... myself I learn Quickbooks as I go along...

Most of our items are groups which represent a collection of items that go with the main product, lets call it a kit. Some items from that kit can be upgraded on our website. Therefore, when we receive an order, manually on invoice our employee adds at first a group with the default options to the main product. Then, if there are upgrades, they modify items of group on the invoice, meaning, they delete a line representing an item in that group and add in its place another item (the upgrade). In Quickbooks it seems to become a part of that (kind of) local group because when you delete the main item of the group (I guess the reference of the group) on the invoice, all items including updated, modified and replaced are removed at once.

Thus, how can one modify the group so it would contain some other items on the invoice that the group original items? 

  Top 
  Tom Aczel 
  dd4bf_dawworld.jpg
 Group: Administrator 
 Posts: 6281 
 Joined: 2006-02-17 
 Profile
 Posted : 2009-09-12 08:55:26

See: How do I invoice item groups? 
         Can I Change the pricing and quantity of Items in a groupitems 
         How do I create Item Groups(ItemGroup)? 

To answer your question, you cannot currently change the price or quantity of individual item group lines (or add new items within the group) within an invoice using QODBC. If you want to do that, you should read the itemgroup lines as a template only and write each item seperately on seperate invoice lines within the invoice. Doing it that way lets you make any changes to the invoice lines you want later on as per:
        Can't add new InvoiceLine to existing Invoice 
         Invoice Table Updates 

 

  Top 
  TexasGuy 
  
 Group: Members 
 Posts: 35 
 Joined: 2009-08-19 
 Profile
 Posted : 2009-09-15 05:17:57
Well, my goal is not to modify invoices but to create them. Maybe it is a world of difference.

I don't know if you my description was clear enough to understand my goal, in short, I need to apply to a new invoice contents of a modified group (from its original state).

In QuickBook one would take an existing group, apply it to the invoice and then modify the lines. The default group "template" (not sure if 'template' would be a correct term here) is untouched at this point.

Through QODBC it seems one cannot do it since one can only apply (from my understanding) the group as it appears as a "template."

Thus, is it possible to modify the group "template" before applying it to the invoice with the modifications I need (setting different items, removing old ones, changing quantity and price of the items), applying that changed group to the invoice, then modifying the group to its original "template."

Would such a trick work? 

  Top 
  TexasGuy 
  
 Group: Members 
 Posts: 35 
 Joined: 2009-08-19 
 Profile
 Posted : 2009-09-15 05:33:05
Also, forgot to say, I don't have to modify these invoices through code later on. Creating them is enough. 

  Top 
  TexasGuy 
  
 Group: Members 
 Posts: 35 
 Joined: 2009-08-19 
 Profile
 Posted : 2009-09-15 07:02:08
Do you think this will work?

This would modify the group template with a different set of populated items at different prices, then it will insert the modified group template into the invoice (no need to modify the invoice later since the group is modified to my needs when being inserted) and then change the modified group template back to its original state (so human operators could continue to use the group template they are used to).

Steps:

0) Pick a group to insert into invoice (to modify)

//--- Save current state
1) Save current prices of standalone products currently appearing in the group
2) Save the current Group items to array
3) Save current prices of standalone products that will be inserted into the group
//--- Modify the group
4) Empty Group of all items
5) Adjust to custom price the standalone products which will be inserted into the group
6) Add standalone products to the group, adjust quantities to a custom number
7) Insert to invoice modified Group
//--- Put everything back
8) Empty the group of all items
9) Set standalone products to original prices saved in step #3
10) Adjust to prices the standalone products from step #2
11) Insert original items into the group
12) Set standalone products to original prices saved in step #1

I hope my intentions are clear... ;) 

  Top 
  Tom Aczel 
  dd4bf_dawworld.jpg
 Group: Administrator 
 Posts: 6281 
 Joined: 2006-02-17 
 Profile
 Posted : 2009-09-15 10:05:34
Geee, wouldn't reading the group lines and writing each group line seperately on a invoice line with all the changes you want in the first place be more simple? If you change the itemgroup other human users can get your temporarily modified version by mistake. 

  Top 
  TexasGuy 
  
 Group: Members 
 Posts: 35 
 Joined: 2009-08-19 
 Profile
 Posted : 2009-09-15 10:09:53
I don't know.

Not if it is executed quickly enough, I don't think there should be trouble.

However, there is a potential for problem, yes.

On the other hand, I don't see a way to do it with a nice elegant solution.

Any advice? 

  Top 
  Tom Aczel 
  dd4bf_dawworld.jpg
 Group: Administrator 
 Posts: 6281 
 Joined: 2006-02-17 
 Profile
 Posted : 2009-09-15 10:27:05

You should read the itemgroup lines as a template only and write each item seperately on seperate invoice lines within the invoice. Doing it that way lets you make any changes to the invoice lines you want later using QODBC because you can't change invoices with ItemGroups using QODBC.

Another way would be to create your own QODBC use only itemgroup that you would only use and change for every invoice. 

 

  Top 
  TexasGuy 
  
 Group: Members 
 Posts: 35 
 Joined: 2009-08-19 
 Profile
 Posted : 2009-10-02 07:30:23
What if I need to "delete" an invoice line from the invoice? Do I insert to that invoiceline some junk RefNumber to break the link?

What is the correct strategy to accomplish this? 

  Top 
  TexasGuy 
  
 Group: Members 
 Posts: 35 
 Joined: 2009-08-19 
 Profile
 Posted : 2009-10-02 07:39:02
Also, some of my test records were written to the Invoice table twice (the loop ran once more than needed by accident), the QODBC did not give me an error and my test company then had 2 of every invoice with the same RefNumber. I guess it is not a unique table field then. I don't know much about accounting as a profession, thus, does it sound normal to have multiple  invoices with the same invoice numbers? I was surprised with the result. 

  Top 
  Tom Aczel 
  dd4bf_dawworld.jpg
 Group: Administrator 
 Posts: 6281 
 Joined: 2006-02-17 
 Profile
 Posted : 2009-10-02 13:05:54

Yes, QuickBooks (not QODBC) allows the same RefNumber to be used!!

To delete a invoice you would do:

DELETE FROM Invoice WHERE TxnID = 'xxxxxxxxxxx'

You can also use SP_VOID just like you would use DELETE. It will void the invoice instead of deleting it.

Example:
SP_VOID FROM Invoice WHERE TxnID = 'xxxxxxxxxxxx'

To delete just a InvoiceLine see: How do I delete a Invoice Line in the InvoiceLine table? 

 

  Top 
  TexasGuy 
  
 Group: Members 
 Posts: 35 
 Joined: 2009-08-19 
 Profile
 Posted : 2009-10-03 02:21:46
If I delete the invoice, is deleting from 'Invoice' table enough, that is, will it delete all linked 'InvoiceLine'(s) automatically, or *I* have to delete from 'InvoiceLine' everything with a specific RefNumber, and then delete from  'Invoice' table? 

  Top 
  Tom Aczel 
  dd4bf_dawworld.jpg
 Group: Administrator 
 Posts: 6281 
 Joined: 2006-02-17 
 Profile
 Posted : 2009-10-03 02:38:37
When you delete a Invoice from the Invoice table, QuickBooks automatically deletes all the InvoiceLines for the Invoice. 

  Top 
 New Topic 
 
 Post Reply 
[1]  

Jump to    

Copyright (c) 2006-2009
Data Access Worldwide, Australia. This FREE self help forum website was copied by FLEXquarters.com Limited, Hong Kong to: http://archive.qodbc.com
/forum50f5.html
without our permission.

The QDeveloper Forum is dedicated to the FREE professional exchange of information. QODBC and FlexODBC users can post support queries, report product bugs, or simply search topics for help. Data Access Worldwide - Asia Pacific normal office business hours are 9am to 5pm week days Australian EST with the exception of Public Holidays.
       
ABN: 86 544 223 459
PO Box 873, Boronia VIC 3155 Australia  Tel: 03 9761 3644  Intl: +613 9761 3644