我尝试通过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 :(得分: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 for v3.2.6 php sdk:https://github.com/intuit/QuickBooks-V3-PHP-SDK
它可以帮助您解决问题。
由于 豪