【发布时间】:2014-01-16 17:54:55
【问题描述】:
我正在使用 QuickBooks PHP DevKit 来获取每个客户的发票。这很好用,但我需要从发票中的每一行获取每个项目以简单地显示它,并且由于某种原因我难以获取此信息。
我可以用
获得 ItemRef$Item = $Line->getSalesItemLineDetail();
$itemRef = $Item->getItemRef();
但它会引发致命错误:“调用非对象上的成员函数 getItemRef()”并终止脚本。
这是我的代码。
//get QuickBooks customer ID
$customers = $CustomerService->query($Context, $realm, "SELECT * FROM Customer WHERE id = '18' ");
if (count($customers))
{
foreach ($customers as $Customer)
{
$invoices = $InvoiceService->query($Context, $realm, "SELECT * FROM Invoice WHERE CustomerRef = '" . QuickBooks_IPP_IDS::usableIDType($Customer->getId()) . "' ");
if (count($invoices))
{
foreach ($invoices as $Invoice)
{
echo $Invoice->getTotalAmt();
$line_count = $Invoice->countLine();
for ($i = 0; $i < $line_count; $i++)
{
$Line = $Invoice->getLine($i);
//print_r($Line);
$Item = $Line->getSalesItemLineDetail();
$itemRef = $Item->getItemRef();
$item = $ItemService->query($Context, $realm, "SELECT * FROM Item WHERE id = '" . QuickBooks_IPP_IDS::usableIDType($itemRef) . "' ");
foreach($item as $Item){
echo $Item->getName();
}
}
}
}
else
{
print(' This customer has no invoices.<br>');
}
}
}
else
{
print('There are no customers with the provided ID');
}
简而言之,在发票的每一行中查询项目的正确方法是什么?
【问题讨论】:
标签: php quickbooks quickbooks-online