Topic: Possible API bug

I am trying to add a payment that has zero cents,  as in 65.00,  using the API but when the qbxml is generated the TotalAmount field has the decimal and trailing zeros stripped out and this causes a qb error. This is only with the total amount field.  the payment amount field come through fine.  Are amounts being formated somewhere and this one is set to the wrong type?

This comes through as 65.00 - $AppliedTo->setPaymentAmount('65.00');
This comes through as 65 - $PaymentAdd->setTotalAmount('65.00');

I even tried using number_format as in
$result->amount = number_format($result->amount, 2, '.', ''); 
but the output is still the same.


<?xml version="1.0" encoding="utf-8"?>
            <?qbxml version="{$version}"?>
                <QBXMLMsgsRq onError="{$onerror}"><ReceivePaymentAddRq>
            <FullName>Accounts Receivable</FullName>
        <Memo>ACH Invoice Payment Invoice Number </Memo>

Re: Possible API bug

Tom: I'll look into this and get back to you later today.

As a temporary workaround, you should be able to just not set the TotalAmount field at all, and it should be auto-calculated for you as the sum of the AppliedTo amounts.

Re: Possible API bug

Tom: A fix has been checked in to the SVN code, and should show up in tomorrow morning's nightly build.

The fix adds some simple data type checking to QuickBooks/Object.php. If you're using a release, send me the QuickBooks/Object.php file and I'll patch it for you.

                    // Do some simple data type casting... 
                    if ($schema->dataType($path) == QUICKBOOKS_QBXML_SCHEMA_TYPE_AMTTYPE)
                        $this->_object[$path] = sprintf('%01.2f', $this->_object[$path]);

Re: Possible API bug

Thanks Keith!  I am using the code from svn so I will grab it when it builds.  BTW this is Tom that talked to you some via email about the WHMCS connector.  I hope all is going ok with that project.  I ended up plowing through and I tihnk I have somewhat better grasp how to use the API. 
If you could though, would you clarify a couple of things.  I want to make sure that I am implementing use of the API correctly as it is a bit different than how I have used the regular server method.
I think I should probably start a new thread for that though so I will start one.

BTW, I noticed that the Purchase Order and Bill code has yet to be done.  Is it possible to "sponsor" creation of these parts?


Last edited by tom (2010-01-11 22:09:05)

Re: Possible API bug

OK, will reply in your other thread!

Re: Possible API bug

I just remembered this.  Not a big deal but I found that in example_api_client.php that


is missing.

Re: Possible API bug

Fixed. That was a hold-over from some previous bad behavior. Thanks!