当我尝试创建新发票时,Twinfield会出错

时间:2018-06-06 12:34:59

标签: php lumen twinfield

我想创建第三方发票软件的发票,即API的双字段。我根据它的库和doc给出所有参数,并从API调用,但它会给出错误。

  

{       “成功”:虚假,       “错误”:“找不到商品代码。,无法调整商品系列的说明。” }

API为php-twinfield

代码如下。

public function saveInvoice($values)
{
    try 
    {
        $user = $values['user'];
        $password = $values['password'];
        $organization = $values['organisation'];
        $officecode = $values['officecode'];
        $connection = new \PhpTwinfield\Secure\WebservicesAuthentication($user, $password, $organization);
        $customerApiConnector = new \PhpTwinfield\ApiConnectors\CustomerApiConnector($connection);
        $office   = Office::fromCode($officecode);
        $customer = $customerApiConnector->get('1008',$office);

        $InvoiceApiConnector = new \PhpTwinfield\ApiConnectors\InvoiceApiConnector($connection);
        //class invoiceline object 
        $line = new \PhpTwinfield\InvoiceLine();
        $line
            ->setArticle(2)
            ->setQuantity(2)
            ->setValueExcl(100)
            ->setUnits(1)
            ->setVatCode('VH')
            ->setUnitsPriceExcl(100)
            ->setDim1(8020)
            ->setDescription("Testinvoice anand")
            ->setAllowDiscountOrPremium(false);
        //class invoice object
        $invoice = new \PhpTwinfield\Invoice();
        $invoice
            ->setCustomer($customer)
            ->setBank('BNK')
            ->setDueDate(\Carbon\Carbon::now()->addMonth())
            ->setPeriod('2018/12')
            ->setCurrency('EUR')
            ->setStatus('concept')
            ->setInvoiceDate('20180606')
            ->addLine($line)
            ->setPaymentMethod('cash')
            ->setInvoiceType('FACTUUR');

        $result = $InvoiceApiConnector->send($invoice);
        print_r($result);
        //$jsonResponse = JsonResponse::success($result);
    }

    catch (SoapFault $e)
    {
        $jsonResponse = empty($e->getMessage()) ? JsonResponse::error(class_basename($e)) : JsonResponse::error($e->getMessage());
    }
    //return $jsonResponse;
}

如果此行中的更改 $ line-> setArticle(0),则错误就是这样。

  

{       “成功”:虚假,       “error”:“ResponseException”}

0 个答案:

没有答案