intuit / QuickBooks-V3-PHP-SDK

Official PHP SDK for QuickBooks REST API v3.0: https://developer.intuit.com/
Apache License 2.0
246 stars 246 forks source link

How can I update the TaxRate using PHP SDK #42

Closed amitcorcrm closed 7 years ago

amitcorcrm commented 7 years ago

I want to update the TaxRate value of existing TaxRate in Quickbooks Online using PHP SDK. I am not able to do that . Please Help me on this how can i update it. currently i am doing below scenario ---

function updateTaxRate($taxRateId, $taxRate){
$taxRateArray = $dataService->Query("select * From TaxRate where Id= '$taxRateId'");
$taxRateObject = current($taxRateArray);
$taxRateObject->RateValue = $taxRate;
try{
$resultingTaxRateObj = $dataService->Add($taxRateObject);
}
catch(Exception $e){
echo $e->getMessage();
}
}

it throwing below error.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
   <IntuitResponse xmlns="http://schema.intuit.com/finance/v3" time="2017-07-13T02:25:41.779-07:00">
  <Fault type="ValidationFault">
  <Error code="500" element="Operation">
         <Message>Unsupported Operation</Message>
         <Detail>Operation Update is not supported.</Detail>
   </Error>
</Fault>
</IntuitResponse>
markwoods241 commented 7 years ago

Looks like you are calling the Add function, instead of Update?

Does it work if you replace this:

try{
    $resultingTaxRateObj = $dataService->Add($taxRateObject);
}

with this:

try{
    $resultingTaxRateObj = $dataService->Update($taxRateObject);
}
hlu2 commented 7 years ago

@amitcorcrm I will put a Facade class member for TaxService in the release after next Monday release. I am currently busy with a new Release right now for PHP SDK, I will write a TaxService Example here and in the _Samples folder.

amitcorcrm commented 7 years ago

@markwoods241 Thanks for reply. I have tried to used Update() function instead of Add() function, but still it was not working it throw below error

Invalid auth/bad request (got a 400, expected HTTP/1.1 20X or a redirect)Array
(
    [0] => 400
    [1] => <?xml version="1.0" encoding="UTF-8" standalone="yes"?><IntuitResponse xmlns="http://schema.intuit.com/finance/v3" time="2017-07-16T21:49:03.237-07:00"><Fault type="ValidationFault"><Error code="500" element="Operation"><Message>Unsupported Operation</Message><Detail>Operation Create is not supported.</Detail></Error></Fault></IntuitResponse>
    [2] => Array
        (
            [Server] => nginx
            [Content-Type] => application/xml
            [Content-Length] => 344
            [Connection] => close
            [Strict-Transport-Security] => max-age=15552000
            [intuit_tid] => efe5dcc3-6557-223e-126c-9eddc1c269de
            [X-NewRelic-App-Data] => PxQEVFFbAQoTVVlSDwEAUVYTGhE1AwE2QgNWEVlbQFtcC2VOfw5BDwVaXhsDB21BWThOVgcBa0lOExoDTFZPUh5SCFoADwQFBl0VVAZRH0BUUgJXVQcKBgMHU1pVAlReRh1QUg4VBj8=
            [Vary] => Accept-Encoding
        )

)
amitcorcrm commented 7 years ago

@hlu2 Thanks for the update, please notify me when you release that Facade class member for TaxService.

hlu2 commented 7 years ago

@amitcorcrm Hi, all I have created the TaxRate and TaxService Facade on v3.3.0; however, I was told that on the API, you cannot change the TaxRate or TaxCode, it is only available for UI. If you want to change, just create a new one. I have sent an E-mail to QBO team to verify it. Will update here once I get replied.

hlu2 commented 7 years ago

@all I just confirmed from QBO Team: TaxCode and TaxRate are NOT EDITABLE THROUGH API, ONLY EDITABLE in the UI. That means, it is not a supported function in the PHP SDK as well. Also, from API, you can only delete Tax codes.

If you really want to change the value, instead of editing the existed one, creating a new one should resolve your issue.

Hao