在这里找到了答案:
How to access Quickbooks Invoice Line Items using php api
我的解决办法是这样的,使用Laravel:
public function qbUpdateInvoice(Invoice $invoice)
{
if ($invoice->qb_ref == null) {
throw new \Exception('Invoice Quickbooks ref not available.');
}
$qbInvoice = $this->findInvoiceByRef($invoice);
$count = $qbInvoice->countLine();
for ($i = 0; $i < $count; $i++) {
$qbInvoice->unsetLine($i);
}
$qbInvoice = $this->setInvoiceDetails($invoice, $qbInvoice);
$qbInvoice = $this->setInvoiceLines($invoice, $qbInvoice);
$response = $this->qbInvoiceService->update($this->context, $this->realm, $qbInvoice->getId(), $qbInvoice);
if (!$response) {
throw new \Exception($this->qbInvoiceService->lastError());
}
return $response;
}
我要尝试实现这个使用Consolibyte与Laravel为好,做这个解决方案适合你吗? unsetLine和findInvoiceByRef函数是您编写的Consolibyte工具包或函数的一部分吗? –
说实话,我不会推荐Consolibyte工具箱,因为它有错误,你必须破解工具包才能正常工作。它也使用不推荐使用的函数,如果升级到PHP7,它将停止工作。您也无法直接使用Laravel DB连接。您必须创建单独的数据库连接,因为它只接受DSN,并且不支持PDO。我最终选择了Quickbooks的官方工具包,这也不完美。设置起来有点困难,但更加灵活。 – Steven1978