I'm writting a function to take an invoice file in a defined format and import it into QuickBooks via qbXML. One of the requrements is that it be possible to reimport the same invoice number than that the existing invoice be modified rather than create a new one with the same number.
The problem I have is with how QuickBooks handles addresses. The addresses I'm getting can be in any format (In 6 different contenents), without any guarantee of adherence to a proper address format for that locale.
So creating the invoice is simple enough, I specify in the xml tag the billing address addr1 through addr5, and QuickBooks takes it no problem. HOWEVER it doesn't store the address as raw text, it attempts to parse out the city, state postal code and country.
Invoice modify, given the same address information, will not parse out the city state and zip, but rather leave the address line intact, and leave the city state and zip untouched, creating a duplicate line on the invoice, one of free form text, the other of the composite of city, state and postal code. The workaround for that was to explicity set city state zip country and note to blank on invoice modify. However, that hasn't fully solved the problem.
Sometimes QuickBooks will correctly parse the address and add a random number on the next line (internally represented on the note tab).
And sometimes QuickBooks will reject the address, even thought it accepted it on create. I assume because it is trying to parse a 5 line address and on modify since the city state and postal code have no where to go, it has no place to store them.
Right now my only solution is to simply leave the address untouched, and tell the user that due to QuickBooks limitations there is no way to modify the address on reimport of the invoice, only invoice lines.
Has anyone run into this before, and if so, do you have a better work around? Do you know of an address parser that can reasonably approximate what quickbooks does so I can send it city state and postal code on create in a consistent manner?
Now, to some degree (except for that last one) QuickBooks is giving me a response that tells me what it parsed on create, so I could theoretically store that to know what I am dealing with, but short of writing some time consuming address parsing routines is there any solution to get quickbooks to re parse the address from new.
Here is the request and the response. Note that the invoice create was identical, and that I removed some identifying information, but kept the field lengths the same.
Request:
<?xml version="1.0" encoding="UTF-8"?> <?qbxml version="7.0"?>
<QBXML>
<QBXMLMsgsRq newMessageSetID="243f42acf4011139b7a" onError="stopOnError">
<InvoiceModRq>
<InvoiceMod>
<TxnID>4E64-1242411202</TxnID>
<EditSequence>1242411202</EditSequence>
<CustomerRef>
<ListID>80000012-1242156814</ListID>
</CustomerRef>
<ARAccountRef>
<FullName>Accounts Receivable</FullName>
</ARAccountRef>
<TxnDate>2009-04-01</TxnDate>
<RefNumber>M-053491</RefNumber>
<BillAddress>
<Addr1>S & S ACME CO., INC.</Addr1>
<Addr2>MR. ABC ABCDEF</Addr2>
<Addr3>981 ABCD 761 ST</Addr3>
<Addr4>ABABC, AA 99999-3584</Addr4>
<Addr5>USA</Addr5>
<City/>
<State/>
<PostalCode/>
<Country/>
<Note/>
</BillAddress>
<TermsRef>
<FullName>NET 30</FullName>
</TermsRef>
<DueDate>2009-05-01</DueDate>
<InvoiceLineMod>
<TxnLineID>-1</TxnLineID>
<Desc/>
</InvoiceLineMod>
<InvoiceLineMod>
<TxnLineID>-1</TxnLineID>
<Desc>ABCDEFG ABC $3,000.00 *</Desc>
</InvoiceLineMod>
<InvoiceLineMod>
<TxnLineID>-1</TxnLineID>
<Desc/>
</InvoiceLineMod>
<InvoiceLineMod>
<TxnLineID>-1</TxnLineID>
<Desc>FOR:</Desc>
</InvoiceLineMod>
<InvoiceLineMod>
<TxnLineID>-1</TxnLineID>
<ItemRef>
<FullName>ANFEE</FullName>
</ItemRef>
<Desc>1 . #9999 S & S ABCD CO., INC., ABCDE, AA *</Desc>
<Amount>123456.72</Amount>
</InvoiceLineMod>
<InvoiceLineMod>
<TxnLineID>-1</TxnLineID>
<Desc/>
</InvoiceLineMod>
<InvoiceLineMod>
<TxnLineID>-1</TxnLineID>
<Desc>PLEASE NOTE: Blahh Someone sellificant repeats on July 31st, 2009.</Desc>
</InvoiceLineMod>
<InvoiceLineMod>
<TxnLineID>-1</TxnLineID>
<Desc>Sellifcan of your Someone Ssellificant to Jan. 31st, 2011 is contingent upon</Desc>
</InvoiceLineMod>
<InvoiceLineMod>
<TxnLineID>-1</TxnLineID>
<Desc>your satisfying all open invoices and all other/different issues.</Desc>
</InvoiceLineMod>
<InvoiceLineMod>
<TxnLineID>-1</TxnLineID>
<Desc/>
</InvoiceLineMod>
<InvoiceLineMod>
<TxnLineID>-1</TxnLineID>
<Desc/>
</InvoiceLineMod>
<InvoiceLineMod>
<TxnLineID>-1</TxnLineID>
<Desc>* PLUS expenses for some amount of service described here.</Desc>
</InvoiceLineMod>
</InvoiceMod>
</InvoiceModRq>
</QBXMLMsgsRq>
</QBXML>
Response:
<?xml version="1.0" ?> <QBXML>
<QBXMLMsgsRs newMessageSetID="243f42acf4011139b7a">
<InvoiceModRs statusCode="3210" statusSeverity="Error"
statusMessage="The "address" field has an invalid value "". QuickBooks error message: The parameter is incorrect. "/>
</QBXMLMsgsRs>
</QBXML>