Search code examples
phpquickbooks

Problem passing Deposit from PHP application to Quickbooks Desktop via Consolibyte Quickbooks PHP DevKit


I'm in the process of implementing Keith Palmer's QuickBooks PHP DevKit (https://github.com/consolibyte/quickbooks-php/) so that my PHP application can pass data to Quickbooks Desktop via Quickbooks Web Connector. I've worked through several hiccups due to changes in PHP and Quickbooks, and now the example web connector app does work and successfully passes customers to Quickbooks.

My actual goal is to simulate transactionally through PHP what is accomplished in Quickbooks by the relatively simple process of:
Banking-->Use Register, (Select Account), and entering either a Payment or a Deposit amount, an Account, a Memo, and Clicking Record.

I thought that this (at least the deposit portion) would be accomplished via DepositAddRq by using the QUICKBOOKS_ADD_DEPOSIT method in the PHP DevKit. Now that I'm rewriting things to use this method, I'm receiving the following error:

3180: There was an error when saving a Deposit line.. QuickBooks error message: The given record number is not in the Payments to Deposit list.

The SOAP server is generating the following XML:

        <?qbxml version="2.0"?>
        <QBXML>
            <QBXMLMsgsRq onError="stopOnError">
                <DepositAddRq requestID="19">
                    <DepositAdd>
                        <DepositToAccountRef>
                            <FullName>test account</FullName>
                        </DepositToAccountRef>
                        <Memo>Memo</Memo>
                        <DepositLineAdd>
                            <PaymentTxnID>3D95-1071497093</PaymentTxnID>
                        </DepositLineAdd>
                    </DepositAdd>
                </DepositAddRq>
            </QBXMLMsgsRq>
        </QBXML>

And I'm receiving this XML response from Quickbooks:

<?xml version="1.0" ?>
<QBXML>
<QBXMLMsgsRs>
<DepositAddRs requestID="19" statusCode="3180" statusSeverity="Error" statusMessage="There was an error when saving a Deposit line..  QuickBooks error message: The given record number is not in the Payments to Deposit list." />
</QBXMLMsgsRs>
</QBXML>

I receive the same error when passing the QuickBooks SDK 15 sample XML code for DepositAddRq:

<QBXMLMsgsRq onError="stopOnError">
<DepositAddRq requestID="0">
<DepositAdd>
<DepositToAccountRef>
<FullName>Checking</FullName>
</DepositToAccountRef>
<DepositLineAdd>
<PaymentTxnID>3D95-1071497099</PaymentTxnID>
</DepositLineAdd>
</DepositAdd>
</DepositAddRq>
</QBXMLMsgsRq>
</QBXML>

Should I be using a completely different method to record the Deposits and Payments from an account, are there additional steps required, or am I going about this completely wrong?

Thanks in advance!


Solution

  • This is a little tricky, but if you look at the docs you can sort of see what it wants:

    Specifically, look at this section:

    <DepositLineAdd defMacro="MACROTYPE"> <!-- optional, may repeat -->
            <!-- BEGIN OR -->
                    <PaymentTxnID  useMacro="MACROTYPE">IDTYPE</PaymentTxnID> <!-- required -->
                    <PaymentTxnLineID  useMacro="MACROTYPE">IDTYPE</PaymentTxnLineID> <!-- optional -->
                    <OverrideMemo >STRTYPE</OverrideMemo> <!-- optional -->
                    <OverrideCheckNumber >STRTYPE</OverrideCheckNumber> <!-- optional -->
                    <OverrideClassRef> <!-- optional -->
                            <ListID >IDTYPE</ListID> <!-- optional -->
                            <FullName >STRTYPE</FullName> <!-- optional -->
                    </OverrideClassRef>
            <!-- OR -->
                    <EntityRef> <!-- optional -->
                            <ListID >IDTYPE</ListID> <!-- optional -->
                            <FullName >STRTYPE</FullName> <!-- optional -->
                    </EntityRef>
                    <AccountRef> <!-- required -->
                            <ListID >IDTYPE</ListID> <!-- optional -->
                            <FullName >STRTYPE</FullName> <!-- optional -->
                    </AccountRef>
                    <Memo >STRTYPE</Memo> <!-- optional -->
                    <CheckNumber >STRTYPE</CheckNumber> <!-- optional -->
                    <PaymentMethodRef> <!-- optional -->
                            <ListID >IDTYPE</ListID> <!-- optional -->
                            <FullName >STRTYPE</FullName> <!-- optional -->
                    </PaymentMethodRef>
                    <ClassRef> <!-- optional -->
                            <ListID >IDTYPE</ListID> <!-- optional -->
                            <FullName >STRTYPE</FullName> <!-- optional -->
                    </ClassRef>
                    <Amount >AMTTYPE</Amount> <!-- optional -->
            <!-- END OR -->
    </DepositLineAdd>
    

    What this means is that you can EITHER provide a link to a payment (<PaymentTxnID>) OR you can provide a link to an account (<AccountRef>).

    What you describe in your post, and what you show in your XML, are two different things. In your XML, you're trying to link to an existing undeposited payment (e.g. you're trying to mark an existing payment as having been deposited into the bank):

    <PaymentTxnID>3D95-1071497099</PaymentTxnID>

    But what you're describing is specifying an Account and a Memo:

    ... (Select Account), and entering either a Payment or a Deposit amount, an Account, a Memo, and Clicking Record.
    

    If you're trying to emulate entering an Account, Memo, etc., then you need to provide the XML to specify an Account, Memo, etc. For example, something like:

    <?xml version="1.0" encoding="utf-8"?>
    <?qbxml version="15.0"?>
    <QBXML>
            <QBXMLMsgsRq onError="stopOnError">
                    <DepositAddRq>
                            <DepositAdd>
                                    <DepositToAccountRef>
                                            <FullName>Your Bank Account</FullName>
                                    </DepositToAccountRef>
    
                                    <DepositLineAdd>
    
                                            <AccountRef>
                                                    <FullName>Account Name Here</FullName>
                                            </AccountRef>
                                            <Memo>Memo test</Memo>
    
                                            <Amount>100.00</Amount>
                                                    
                                    </DepositLineAdd>
                            </DepositAdd>
    
                    </DepositAddRq>
            </QBXMLMsgsRq>
    </QBXML>