douxu5233 2017-06-27 08:00
浏览 33

从PHP API更新Quickbooks记录

I have try to update a record from my database to quickbooks by PHP API, but there is an errors comes out.

My code to update just like this, the dataService is work normally. Since i have use it for query record form quickbooks is ok.

$resultingObj = $dataService->Update($entities[0]);

Object Dump: 
object(IPPItem)#2586 (54) {   
["Name"]=>   string(20)    "Factor 46 - X7Y7d-P1"   
["Sku"]=>   string(8) "X7Y7d-P1"      
["Description"]=>   string(9) "Factor 46"   
["Active"]=>   string(4)    "true"   
["SubItem"]=>   NULL   
["ParentRef"]=>   NULL   
["Level"]=>     NULL   
["FullyQualifiedName"]=>   string(20) "Factor 46 - X7Y7d-P1"      
["Taxable"]=>   string(4) "true"   
["SalesTaxIncluded"]=>   NULL      
["PercentBased"]=>   NULL   
["UnitPrice"]=>   string(8) "11390.00"      
["RatePercent"]=>   NULL   
["Type"]=>   string(9) "Inventory"      
["PaymentMethodRef"]=>   NULL   
["UOMSetRef"]=>   NULL      
["IncomeAccountRef"]=>   array(2) {   
 ["value"]=>    string(2) "79"    
 ["name"]=>    string(23) "Sales of Product Income"   
}  
["PurchaseDesc"]=>   NULL   
["PurchaseTaxIncluded"]=>   NULL   
["PurchaseCost"]=>      string(1) "0"   
["ExpenseAccountRef"]=>   array(2) {    
 ["value"]=>    string(2) "80"    
 ["name"]=>    string(18) "Cost of Goods Sold"   
}   
["COGSAccountRef"]=>   NULL   
["AssetAccountRef"]=>   array(2) {    
 ["value"]=>    string(2) "81"    
 ["name"]=>    string(15) "Inventory Asset"   
}   
["PrefVendorRef"]=>   NULL   
["AvgCost"]=>   NULL   
["TrackQtyOnHand"]=>   string(4) "true"      
["QtyOnHand"]=>   int(0)   
["QtyOnPurchaseOrder"]=>   NULL      
["QtyOnSalesOrder"]=>   NULL   
["ReorderPoint"]=>   NULL      
["ManPartNum"]=>   NULL   
["DepositToAccountRef"]=>   NULL      
["SalesTaxCodeRef"]=>   NULL   
["PurchaseTaxCodeRef"]=>   NULL      
["InvStartDate"]=>   string(10) "2016-11-05"   
["BuildPoint"]=>      NULL   
["PrintGroupedItems"]=>   NULL   
["SpecialItem"]=>   NULL      
["SpecialItemType"]=>   NULL   
["ItemGroupDetail"]=>   NULL      
["ItemAssemblyDetail"]=>   NULL   
["AbatementRate"]=>   NULL      
["ReverseChargeRate"]=>   NULL   
["ServiceType"]=>   NULL      
["ItemCategoryType"]=>   NULL   
["ItemEx"]=>   NULL   
["Id"]=>      string(2) "19"   
["SyncToken"]=>   string(1) "0"   
["MetaData"]=>      object(IPPModificationMetaData)#2569 (6) {    
 ["CreatedByRef"]=>    NULL    
 ["CreateTime"]=>    string(25) "2017-06-22T10:25:37-07:00"    
 ["LastModifiedByRef"]=>    NULL    
 ["LastUpdatedTime"]=>    string(25) "2017-06-22T10:25:37-07:00"    
 ["LastChangedInQB"]=>    NULL    
 ["Synchronized"]=>    NULL   
}   
["CustomField"]=>   NULL   
["AttachableRef"]=>   NULL   
["domain"]=>   NULL   
["status"]=>   NULL   
["sparse"]=>   NULL 
}

Exception Call Stack (Class 79 does not exist):

In     (/data/app/frameworks/yii2/vendor/intuit/QuickBooks/v3-php-sdk-2.4.1/XSD2PHP/src/com/mikebevz/xsd2php/Php2Xml.php)    on 257 getXmlFromObj()     
XmlObjectSerializer.php:68 getPostXmlFromArbitraryEntity()
XmlObjectSerializer.php:175 Serialize()
DataService.php:447 executeObjectSerializer()
DataService.php:189 Update()
QuickBooksApi.php:347 syncProduct()
QuickBooksController.php:191 actionSyncProduct() :
call_user_func_array()
    InlineAction.php:55     runWithParams()
    Controller.php:154  runAction()
    Module.php:454  runAction()
    Application.php:100     handleRequest()
    Application.php:375     run()
    index.php:20

I also try change my object to JSON and test in their API Explorer, it can update successfully. What is my problem on my code?

  • 写回答

1条回答 默认 最新

  • dongxiaoke2018 2017-07-11 02:07
    关注

    That is an error in your IPPItem due to malformed object. You are using v3-php-sdk-2.4.1, which is really old. The latest version has provided a better way to do it:

    $ItemObj = Item::update($oldItemObj, [
       "Name" => "Rock Fountain",
       "Description" => "New, updated description for Rock Fountain",
       "Active" => true,
       "FullyQualifiedName" => "Rock Fountain",
       "Taxable" => true,
       "UnitPrice" => 275,
       "Type" => "Inventory",
       "IncomeAccountRef" => [
           "value" => "79",
           "name" => "Sales of Product Income"
       ],
       "PurchaseDesc" => "Rock Fountain",
       "PurchaseCost" => 125,
       "ExpenseAccountRef" => [
           "value" => "80",
           "name" => "Cost of Goods Sold"
       ],
       "AssetAccountRef": [
           "value" => "81",
           "name" => "Inventory Asset"
       ],
       "Id" => "5",
       "SyncToken" => "2"
    ]);
    

    Take a look at our Github for v3.2.6 php sdk now: https://github.com/intuit/QuickBooks-V3-PHP-SDK

    It should help you fix the issue.

    Thanks hao

    评论

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥20 求用stm32f103c6t6在lcd1206上显示Door is open和password:
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法