【问题标题】:How to remove lines from an Invoice using 'consolibyte/quickbooks-php'如何使用“consolibyte/quickbooks-php”从发票中删除行
【发布时间】:2016-03-04 18:03:45
【问题描述】:

有没有办法使用 Consolibyte quickbooks 工具包从发票中删除行?

我可以发送带有行的发票,但我也想更新发票,我认为最好的方法是删除每一行,然后按当前行发送。即:要更新发票,我将首先使用我在本地存储的 ref 从 quickbooks 获取发票,删除行,然后更新发票对象上的字段,然后添加新行,然后使用更新方法发送发票。

我看过这个例子:

https://github.com/consolibyte/quickbooks-php/blob/master/docs/partner_platform/example_app_ipp_v3/example_invoice_update.php

但我不确定如何更新各个行,因为我没有引用本地存储的它们,因此尝试删除它们然后重新创建。

【问题讨论】:

    标签: php quickbooks quickbooks-online


    【解决方案1】:

    在这里找到答案:

    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 的官方工具包,但它也不完美。设置起来有点困难,但更灵活。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多