0

I am trying to debug an issue.

TLDR: Quickbooks is returning an error saying the Invoice does not exist. But checking in QB or searching via sync, it exists.

Everything was working fine, until 1 day, it stopped.

Background Details

  • No Code changes whatsoever.

  • I believe no Quickbooks changes that would cause any issue. Client says they didn't make any changes to their quickbooks either.

  • There was a QB software update a week before. But the Sync worked fine after that.

  • Everything else still works.

  • PHP Version: 5.4.45

  • Quickbooks PHP Integrator Version: 1.5.2 (https://github.com/consolibyte/quickbooks-php)

  • Quickbooks Version: Quickbooks 2018 Premier

It is a very basic system. It just adds new Customers, adds new Invoices/Charges, and adds Payments to those Invoices/Charges into their quickbooks. It has worked for 10+ years. Yes, the PHP Quickbooks Sync is quite old. I don't believe the issue is with that though?

The Issue

As of a few days ago, ANY payment trying to be sent to quickbooks to apply to an invoice, gets rejected and returns the following error message in the php quickbooks queue table:

3120: Object "6741D-1666222191" specified in the request cannot be found.

This happens with ANY and EVERY payment being sent. Same error, everytime (with the invoice TxnID accordingly). It is still able to sync over new customers, add new invoices. But payments return this error. This all happened pretty suddenly. On a Wednesday, it worked fine. The next day Thursday, error.

Debugging

I have checked quickbooks itself to verify if the charge/invoice is there. It shows under the customer. I have run a Invoice Query () to search for the invoice, and the invoice exists and is returned in the results. I have verified that the customer exists. I have verified that the ListIDs are correct. The Quickbooks user should have permissions as it is being tested under their Admin user.

The Transaction ListID that it is trying to apply the payment is correct. The Customer it is trying to apply it to, is correct (as you can see below in the XML of what is being sent)

Code

Here is the XML being sent for the invoice being sent over. I have made changes such as removing sensitive info.

<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="4.0"?>
<QBXML>
    <QBXMLMsgsRq onError="stopOnError">
        <InvoiceAddRq requestID="SW52b2ljZUFkZHwyNTk0Ng==">
            <InvoiceAdd>
                <CustomerRef>
                    <ListID>80000717-1371847043</ListID>
                </CustomerRef>
                
                <TemplateRef>
                    <ListID>80000001-1214875504</ListID>
                </TemplateRef>
                
                <TxnDate>2022-10-18</TxnDate>
                
                <InvoiceLineAdd>
                    <ItemRef>
                        <ListID>800000F0-1639001986</ListID>
                    </ItemRef>
                    <Desc>Item Description</Desc>
                    <Quantity>1</Quantity>
                    <Amount>350.00</Amount>
                </InvoiceLineAdd>
            </InvoiceAdd>
        </InvoiceAddRq>
    </QBXMLMsgsRq>
</QBXML>

Response

<?xml version="1.0" ?>
<QBXML>
    <QBXMLMsgsRs>
        <InvoiceAddRs requestID="SW52b2ljZUFkZHwyNTk0Ng==" statusCode="0" statusSeverity="Info" statusMessage="Status OK">
            <InvoiceRet>
                <TxnID>6741D-1666222191</TxnID>
                <TimeCreated>2022-10-19T16:29:51-08:00</TimeCreated>
                <TimeModified>2022-10-19T16:29:51-08:00</TimeModified>
                <EditSequence>1666222191</EditSequence>
                <TxnNumber>79922</TxnNumber>
                <CustomerRef>
                    <ListID>80000717-1371847043</ListID>
                    <FullName>LastName, FirstName</FullName>
                </CustomerRef>
                <ARAccountRef>
                    <ListID>8000002C-1215020650</ListID>
                    <FullName>Accounts Receivable</FullName>
                </ARAccountRef>
                <TemplateRef>
                    <ListID>80000001-1214875504</ListID>
                    <FullName>Intuit Product Invoice</FullName>
                </TemplateRef>
                <TxnDate>2022-10-18</TxnDate>
                <RefNumber>27345</RefNumber>
                <BillAddress>
                    <Addr1>Address 1</Addr1>
                    <Addr2>Address 2</Addr2>
                    <City>City</City>
                    <State>State</State>
                    <PostalCode>ZIP</PostalCode>
                </BillAddress>
                <IsPending>false</IsPending>
                <IsFinanceCharge>false</IsFinanceCharge>
                <DueDate>2022-10-18</DueDate>
                <ShipDate>2022-10-18</ShipDate>
                <Subtotal>350.00</Subtotal>
                <SalesTaxPercentage>0.00</SalesTaxPercentage>
                <SalesTaxTotal>0.00</SalesTaxTotal>
                <AppliedAmount>0.00</AppliedAmount>
                <BalanceRemaining>350.00</BalanceRemaining>
                <IsPaid>false</IsPaid>
                <IsToBePrinted>true</IsToBePrinted>
                <InvoiceLineRet>
                    <TxnLineID>6741F-1666222191</TxnLineID>
                    <ItemRef>
                        <ListID>800000F0-1639001986</ListID>
                        <FullName>Item Name</FullName>
                    </ItemRef>
                    <Desc>Item Description</Desc>
                    <Quantity>1</Quantity>
                    <Rate>350</Rate>
                    <Amount>350.00</Amount>
                    <SalesTaxCodeRef>
                        <ListID>80000002-1214875507</ListID>
                        <FullName>Non</FullName>
                    </SalesTaxCodeRef>
                </InvoiceLineRet>
            </InvoiceRet>
        </InvoiceAddRs>
    </QBXMLMsgsRs>
</QBXML>

Sending Payment

<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="2.0"?>
<QBXML>
    <QBXMLMsgsRq onError="stopOnError">
        <ReceivePaymentAddRq requestID="UmVjZWl2ZVBheW1lbnRBZGR8MzM0MDU=">
            <ReceivePaymentAdd>
                <CustomerRef>
                    <ListID>80000717-1371847043</ListID>
                </CustomerRef>
                
                <TxnDate>2022-10-18</TxnDate>
                <RefNumber>RefNumber</RefNumber>
                
                <TotalAmount>350.00</TotalAmount>
                
                <PaymentMethodRef>
                    <ListID>80000005-1214879441</ListID>
                </PaymentMethodRef>
                
                <Memo></Memo>
                
                <AppliedToTxnAdd>
                    <TxnID>6741D-1666222191</TxnID>
                    <PaymentAmount>350.00</PaymentAmount>
                </AppliedToTxnAdd>
            
            </ReceivePaymentAdd>
        </ReceivePaymentAddRq>
    </QBXMLMsgsRq>
</QBXML>

Searching Invoices, it returns in the search

<InvoiceRet>
    <TxnID>6741D-1666222191</TxnID>
    <TimeCreated>2022-10-19T16:29:51-08:00</TimeCreated>
    <TimeModified>2022-10-19T16:29:51-08:00</TimeModified>
    <EditSequence>1666222191</EditSequence>
    <TxnNumber>79922</TxnNumber>
    <CustomerRef>
        <ListID>80000717-1371847043</ListID>
        <FullName>LastName, FullName</FullName>
    </CustomerRef>
    <ARAccountRef>
        <ListID>8000002C-1215020650</ListID>
        <FullName>Accounts Receivable</FullName>
    </ARAccountRef>
    <TxnDate>2022-10-18</TxnDate>
    <RefNumber>27345</RefNumber>
    <BillAddress>
        <Addr1>Address 1</Addr1>
        <Addr2>Address 2</Addr2>
        <City>City</City>
        <State>State</State>
        <PostalCode>ZIP</PostalCode>
    </BillAddress>
    <IsPending>false</IsPending>
    <IsFinanceCharge>false</IsFinanceCharge>
    <DueDate>2022-10-18</DueDate>
    <ShipDate>2022-10-18</ShipDate>
    <Subtotal>350.00</Subtotal>
    <SalesTaxPercentage>0.00</SalesTaxPercentage>
    <SalesTaxTotal>0.00</SalesTaxTotal>
    <AppliedAmount>0.00</AppliedAmount>
    <BalanceRemaining>350.00</BalanceRemaining>
    <IsPaid>false</IsPaid>
    <IsToBePrinted>true</IsToBePrinted>
</InvoiceRet>
WannabeDev
  • 11
  • 1
  • 4

1 Answers1

0

Other things you should check on:

  • Try using a more recent qbXML version. You're using 2.0, which is like 15+ years old.
  • Try specifying the ARAccountRef/FullName the invoice is in when adding the payment. If you have multiple A/R accounts, it's possible QuickBooks is defaulting you to the other A/R account when trying to create the payment, and thus can't find the invoice that's in Accounts Receivable
  • Try adding the payment to QuickBooks manually, via the UI. Are you able to? Pull that payment via the API and take a look at the data. Anything unexpected? What if you specify all the same data returned, in your ReceivePaymentAdd request?
  • Try adding the payment, but using <IsAutoApply>true</IsAutoApply> instead of the <AppliedToTxnAdd> node.
Keith Palmer Jr.
  • 27,666
  • 16
  • 68
  • 105
  • With point 1. Tried with 14.0, still no dice. With 2 If I try to add the payment by using the ARAccountRef XML, it gives it returns a XML parsing error. Accounts Receivable. I have tried it with the ListID, just the ListID, just the FullName, but same XML Parse error. I will try adding a payment and see how that goes in the meantime – WannabeDev Oct 26 '22 at 04:17
  • Alright. So with #1, Max version I could use was 14.0. But even so, did not fix the error. With #2 and using version 14.0, I would get an XML parse error anytime I tried to add the ARAccountRef tag. Not sure why. WIth #3, I was able to add it manually to the best my knowledge (I am not an accountant, so yeah, not sure if I added payment correctly). But I did that, queried the payment, and looked pretty normal. There was some extra fields (DepositToAccountRef, TimeCreated, etc) that I did not send, or I added, but to no avail. – WannabeDev Oct 26 '22 at 06:44
  • The last point, #4. So far, I believe is the only way I could get a payment applied. But it looked different than prior payments, as in query seemed to apply payment to a different ARAccount. And I am not sure how it will affect their quickbooks stuff? I guess I will have to ask the client about it. But I still find it odd that this issue has popped up "randomly out of the blue" so to speak. – WannabeDev Oct 26 '22 at 06:46
  • With #2, I was able to get it to work. Apparently, QB is very specific of the order of XML elements. I put the ARAccountRef in the correct order instead of just randomly and it added the payment just fine. And it looks like it added like normal. Will have to verify further. – WannabeDev Oct 26 '22 at 07:06
  • Yes, the order of the tags _is_ important - you have to use the correct order. QuickBooks generally defaults the A/R account (`ARAccountRef/FullName`) to whatever was _last used in the UI_. So it's possible that someone in QuickBooks accidentally did something with that other A/R account, didn't tell you, and that changed the default which made you run into errors. In this case, specifying the A/R Account is the right thing to do. It will not negatively impact their books - payments were going there previously too, you just weren't aware of it because it was the default behavior. – Keith Palmer Jr. Oct 26 '22 at 08:38