0

I am using consolibyte Keith Palmer's PHP SDK for QuickBooks Desktop with web connector. below is the code for sales recipt mod request.what must be going wrong in this code? i printed the xml. it is getting printed correctly.then what could be the cause of that error-"QuickBooks found an error when parsing the provided XML" text stream please help me out.......................... .

 $xml = '<?xml version="1.0" encoding="utf-8"?>
            <?qbxml version="2.0"?>
            <QBXML>
                <QBXMLMsgsRq onError="stopOnError">
                    <SalesReceiptModRq requestID = "'.$requestID.'">             
          <SalesReceiptMod>
            <TxnID>'.$row_invoice['quickbooks_txnID'].'</TxnID>                             
            <EditSequence>'.$row_invoice['edit_sequence'].'</EditSequence>                
            <CustomerRef>                                      
              <ListID>'.$row_customer['quickbooks_listid'].'</ListID>                         
            </CustomerRef>
            <TxnDate>'.$row_invoice['invoice_date'].'</TxnDate>                        
            <RefNumber>601</RefNumber>                     
            <BillAddress>                                       
            <Addr1>'.$row_customer['address_1'].'</Addr1>
            </BillAddress>';
             while($row_invoice_details = mysqli_fetch_array($sql_sale_invoice_details))
        {
        $row_item = mysqli_fetch_array(mysqli_query($con,"SELECT quickbooks_listid FROM item WHERE item_id =".$row_invoice_details['item_id']));

            $xml .= '
            <SalesReceiptLineMod>
              <TxnLineID>'.$row_invoice_details['quickbooks_txnLineId'].'</TxnLineID>                   
              <ItemRef>                                         
                <ListID>'.$row_item['quickbooks_listid'].'</ListID>                        
              </ItemRef>
              <Desc>'.$row_invoice_details['description'].'</Desc>                             
              <Quantity>'.$row_invoice_details['quantity'].'</Quantity>                   
              <Rate>'.$row_invoice_details['price'].'</Rate>';
                                /////////check if tax is applied or not////////////////
                                if($row_invoice['sales_tax_percent']!=0)
                                {
                               $xml .= ' <SalesTaxCodeRef>
                                    <FullName>tax</FullName>
                                </SalesTaxCodeRef>';
                                }
                                else
                                {
                               $xml .= '<SalesTaxCodeRef>
                                    <FullName>non</FullName>
                                </SalesTaxCodeRef>';
                                }
                                ///////////////////////////////////////
            $xml.='</SalesReceiptLineMod>';
            }
          $xml .= '</SalesReceiptMod>
        </SalesReceiptModRq>
                </QBXMLMsgsRq>
            </QBXML>';

        return $xml;

below is printed xml

<?xml version="1.0" encoding="utf-8"?>
        <?qbxml version="2.0"?>
        <QBXML>
            <QBXMLMsgsRq onError="stopOnError">
                <SalesReceiptModRq requestID = "1">             
      <SalesReceiptMod>
        <TxnID>279-1574097843</TxnID>                             
        <EditSequence>1574097843</EditSequence>                
        <CustomerRef>                                      
          <ListID>80000030-1573831750</ListID>                         
        </CustomerRef>
        <TxnDate>2019-11-18</TxnDate>                        
        <RefNumber>601</RefNumber>                     
        <BillAddress>                                       
        <Addr1>kothrud1234564789</Addr1>
        </BillAddress>
        <SalesReceiptLineMod>
          <TxnLineID>27B-1574097843</TxnLineID>                   
          <ItemRef>                                         
            <ListID>8000004A-1574094120</ListID>                        
          </ItemRef>
          <Desc>100 meter pipe</Desc>                             
          <Quantity>1</Quantity>                   
          <Rate>300</Rate> <SalesTaxCodeRef>
                                <FullName>tax</FullName>
                            </SalesTaxCodeRef></SalesReceiptLineMod>
        <SalesReceiptLineMod>
          <TxnLineID>27C-1574097843</TxnLineID>                   
          <ItemRef>                                         
            <ListID>8000004B-1574094123</ListID>                        
          </ItemRef>
          <Desc>200 meters pipe</Desc>                             
          <Quantity>1</Quantity>                   
          <Rate>400</Rate> <SalesTaxCodeRef>
                                <FullName>tax</FullName>
                            </SalesTaxCodeRef></SalesReceiptLineMod>
        <SalesReceiptLineMod>
          <TxnLineID>27D-1574097843</TxnLineID>                   
          <ItemRef>                                         
            <ListID>8000004C-1574094242</ListID>                        
          </ItemRef>
          <Desc>test desc</Desc>                             
          <Quantity>1</Quantity>                   
          <Rate>200</Rate> <SalesTaxCodeRef>
                                <FullName>tax</FullName>
                            </SalesTaxCodeRef></SalesReceiptLineMod></SalesReceiptMod>
    </SalesReceiptModRq>
            </QBXMLMsgsRq>
        </QBXML>
  • You need to tell us what your problem actually is. – delboy1978uk Nov 19 '19 at 11:25
  • @delboy1978uk i am integrating my software with quickbook desktop. i have added sales receipt into qb desktop using qbxml. but got this error while sending sales receipt modification request – GAURAV DESHPANDE Nov 19 '19 at 11:29
  • 1
    @delboy1978uk error - 0x80040400: QuickBooks found an error when parsing the provided XML text stream – GAURAV DESHPANDE Nov 19 '19 at 11:34
  • @GAURAVDESHPANDE if you search that error message, you'll find many, many answers that explain how to troubleshoot that specific error message. Use the XML Validator tool included with the QuickBooks SDK and it'll tell you exactly what is wrong. – Keith Palmer Jr. Nov 20 '19 at 03:47

1 Answers1

0

Your problem will be caused by characters that XML doesn't accept.

At first I looked for symbols such as &, which need to be HTML encoded to &amp; etc.

It looks like your dashes are causing you issue.

PHP quickbooks appears to have a "cast" feature, for handling characters outwith the acceptable range.

Here's an example from the repo. Hope this helps! As a first test, try removing non ASCII characters (try the dashes! -) from your generated XML and see if it processes successfully.

https://github.com/consolibyte/quickbooks-php/blob/master/docs/qbxml/example_qbxml_cast.php

delboy1978uk
  • 12,118
  • 2
  • 21
  • 39