2017-06-27 61 views
0

我試圖通過PHP API將我的數據庫中的記錄更新到快速本本,但出現錯誤。從PHP API更新記錄到Quickbooks

我的代碼就像這樣更新,dataService正常工作。由於我已經使用它查詢記錄表格快速書是好的。

$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 

我也試着改變我的對象JSON和測試他們的API瀏覽器,它可以成功地更新。 我的代碼有什麼問題?

+0

這是一種所謂的空白地獄? – Clijsters

回答

0

這是由於格式錯誤的對象而導致IPPItem中的錯誤。您正在使用v3-php-sdk-2.4.1,它非常古老。最新版本提供了更好的方式來做到這一點:

$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" 
]); 

看看我們的Github上現在v3.2.6 PHP SDK:https://github.com/intuit/QuickBooks-V3-PHP-SDK

它能夠幫助你解決問題。

謝謝 好