Quickbooks PHP 综合税错误

Quickbooks PHP integration tax error

我正在尝试使用提供的示例代码使用 PHP 集成 Quickbooks。这是针对修改了税制的印度。对于添加发票代码,我收到此错误:

error 6000:A business validation error has occurred while processing your request, Business Validation Error:

Make sure all your transactions have a sales tax rate before you save.

我的代码:

$InvoiceService = new QuickBooks_IPP_Service_Invoice();


$Invoice = new QuickBooks_IPP_Object_Invoice();

$Invoice->setDocNumber('WEB' . mt_rand(0, 10000));
$Invoice->setTxnDate('2013-10-11');

$Line = new QuickBooks_IPP_Object_Line();
$Line->setDetailType('SalesItemLineDetail');
$Line->setAmount(20.0000 * 1.0000 * 0.516129);
$Line->setDescription('Test description goes here.');

$SalesItemLineDetail = new QuickBooks_IPP_Object_SalesItemLineDetail();
$SalesItemLineDetail->setItemRef('8');
$SalesItemLineDetail->setUnitPrice(20 * 0.516129);
$SalesItemLineDetail->setQty(1.00000);
$SalesItemLineDetail->settax(10.00000);


$Line->addSalesItemLineDetail($SalesItemLineDetail);

$Invoice->addLine($Line);


$Invoice->setCustomerRef('67');


//if ($resp = $InvoiceService->add($Context, $realm, $Invoice)){
if ($resp = $InvoiceService->add($Context , $realm, $Invoice)){

    print('Our new Invoice ID is: [' . $resp . ']');
}else{

    print($InvoiceService->lastError());
}

文档中没有指定税收参数,发票响应中的参数也无法解决此问题。任何人都可以分享要发送的确切参数。

您可以将此代码和参数用于文档中指定的税收,发票响应中的参数是固定的

$Line = new QuickBooks_IPP_Object_Line();
$Line->setDetailType('SalesItemLineDetail');
$Line->setAmount(20.0000 * 1.0000 * 0.516129);
$Line->setDescription('test');
$SalesItemLineDetail = new QuickBooks_IPP_Object_SalesItemLineDetail();
$SalesItemLineDetail->setItemRef('1');
$SalesItemLineDetail->setUnitPrice(20 * 0.516129);
$SalesItemLineDetail->setQty(1.00000);
/*Tax Calculation*/
$SalesItemLineDetail->setTaxCodeRef("2");
$SalesItemLineDetail->set("DetailType","Sale Tax");
$SalesItemLineDetail->set("TaxPercent","8.25");
$SalesItemLineDetail->set("PercentBased","true");
$SalesItemLineDetail->set("IsTaxable", "true");
$SalesItemLineDetail->settax(10.00000);
$Line->addSalesItemLineDetail($SalesItemLineDetail);
$Invoice->addLine($Line);
$Invoice->setCustomerRef('90');