Reputation: 3416
Is it possible to create an invoice with one-off items or to generate the missing items on-demand, without parsing the QBXMLMsgsRs
return value?
I am trying to transmit invoices to QuickBooks through the QuickBooks Web Connector, I cannot ensure that the items already exist. I knew that QuickBooks itself is able to create items on-demand.
I’ll get following return message:
QBXMLMsgsRs:
There is an invalid reference to QuickBooks Item "1000000000" in the Invoice line. QuickBooks error message: Invalid argument. The specified record does not exist in the list.
As fallback, I would parse the return value, create the item and submit the invoice again, but I am looking for an existing implementation. I already checked the Onscreen Reference (InvoiceAdd), without any helpful information.
Here is an example of my QBXML
:
<?xml version="1.0" encoding="us-ascii"?>
<?qbxml version="13.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<InvoiceAddRq requestID="bd4a0a4d-81ea-4f95-ae09-150f15a12423">
<InvoiceAdd>
<CustomerRef>
<ListID>80000004-1434444973</ListID>
<FullName>University of North Carolina</FullName>
</CustomerRef>
<TxnDate>1999-01-21</TxnDate>
<RefNumber>9668</RefNumber>
<BillAddress>
<Addr1>University of North Carolina</Addr1>
<Addr2>University City Blvd</Addr2>
<Addr3 />
<City>Charlotte</City>
<State>NC</State>
<PostalCode>9201</PostalCode>
<Country>United States</Country>
</BillAddress>
<InvoiceLineAdd>
<ItemRef>
<FullName>1000000000</FullName>
</ItemRef>
<Desc>Item 1 Description Goes Here</Desc>
<Quantity>1</Quantity>
<Rate>295</Rate>
</InvoiceLineAdd>
<InvoiceLineAdd>
<ItemRef>
<FullName>1000000001</FullName>
</ItemRef>
<Desc>Item 2 Description Goes Here</Desc>
<Quantity>5</Quantity>
<Rate>25</Rate>
</InvoiceLineAdd>
</InvoiceAdd>
</InvoiceAddRq>
</QBXMLMsgsRq>
</QBXML>
Upvotes: 2
Views: 606
Reputation: 27952
Is it possible to create an invoice with one-off items or to generate the missing items on-demand,
No.
I cannot ensure that the items already exist.
Why not? Everyone else does...
I knew that QuickBooks itself is able to create items on-demand.
This is incorrect, QuickBooks is not capable of creating items on demand. The GUI prompts you to create it manually if the item does not exist and you try to type it into the list.
As fallback, I would parse the return value, create the item and submit the invoice again, but I am looking for an existing implementation.
Another option is to batch your requests and always attempt to create the items in order to ensure they exist.
For example:
<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="7.0"?>
<QBXML>
<QBXMLMsgsRq onError="continueOnError">
<ItemNonInventoryAdd>
... your item data here ...
</ItemNonInventoryAdd>
<InvoiceAdd>
... your invoice data here ...
</InvoiceAdd>
</QBXMLMsgsRq>
</QBXML>
More examples:
By doing this, the item will be created prior to the invoice if it doesn't already exist. If the item does exist, QuickBooks will skip that part of the request and continue with the next.
Upvotes: 3