【问题标题】:How to update the status to Paid and update Amount Paid and Amount Due in XERO using API - PHP如何使用 API - PHP 在 XERO 中将状态更新为已支付并更新已支付金额和到期金额
【发布时间】:2019-10-14 22:41:40
【问题描述】:

我正在尝试使用 XERO-API 更新 XERO 中的发票。我可以将发票保存为“草稿”,这是客户需要支付的未结金额。付款完成后,我想向 Xero 发送请求并将状态更改为“已付款”; amountDue = '$ 0.00' 和 AmountPaid = '$XX.xx'。我无法更新此信息,我正在使用 PHP。对此也没有太多的讨论/研究。

$refXero  = 'INV-123456';
$invoices =  $xero->loadByGUID('Accounting\\Invoice', $refXero );

    **//I am getting errors from here onwards:-** 

$invoices->setAmountDue('0');
$invoices->setAmountPaid('50.00');
$invoices->setStatus('PAID');
$invoices->setDate('2019-10-15');
$invoices->save();

我得到的错误是'Call to undefined method XeroPHP\Models\Accounting\Invoice::setAmountDue()'

如何发送此信息并更新此信息。

谢谢

【问题讨论】:

    标签: php laravel xero-api


    【解决方案1】:

    要将 Xero 发票作为 PAID,您需要使用 /payments 端点创建相应金额的付款。一旦针对发票的付款总额与发票总额相匹配,它将被设置为已支付。

    /payments 端点的文档在这里:

    https://developer.xero.com/documentation/api/payments#PUT

    ...但它可能已经存在于您正在使用的 SDK 中。请注意,您需要先将发票设置为 AUTHORIZED,然后才能成功付款。

    【讨论】:

      【解决方案2】:

      我的发票编号是:97661-Z(保存在我的数据库和 XERO 中)

      $currRefNumber = $request->input('update_payment_refNumber'); //**Z**
      $refXero = $bookingID.'-'.$currRefNumber; //(**97661-Z**)
      

      此发票编号 97661-Z 在 XERO 中保存为草稿。

      所以基本上,当发票保存为草稿时,首先需要将其更新为授权,如下所示:-

      $invoices = XeroPrivate::loadByGUID('Accounting\\Invoice', $refXero);
      $invoices->setStatus(\XeroPHP\Models\Accounting\Invoice::INVOICE_STATUS_AUTHORISED);
      $invoices->save();
      

      以上内容会将发票状态从Draft更新为Awaiting Payment

      现在获取账户代码:-

      $account = XeroPrivate::loadByGUID('Accounting\\Account', '880');
      $dateInstance = new \DateTime();
      $newPayment = new \XeroPHP\Models\Accounting\Payment();
                    $newPayment
                              ->setInvoice($invoices)
                              ->setAccount($account)
                              ->setDate($dateInstance)
                              ->setAmount(600)
                              ->setIsReconciled(true)
                              ->setReference('Payment Received');
      
      XeroPrivate::save($newPayment);
      

      这将更改 status = Paid 并将更新信息 AccountDue = $0.00AccountPaid = $600.00

      我希望这将在需要时对其他人有所帮助。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-10-11
        • 1970-01-01
        • 1970-01-01
        • 2017-07-28
        • 2016-10-22
        • 2021-06-12
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多