我们正在使用consolibyte / quickbooks-php wrapper,它可以正常运行所需的活动。但是当我们尝试从我们的crm创建发票时,它给出了2500:无效参考错误。
我们尝试使用相同的值以及相同的ref从在线quickbook中检索发票记录,并在我们尝试同步信息时在我们的crm中创建发票记录,它给出了相同的错误2500.但是当我们运行脚本时所有对象制作手册(而不是循环),然后运行代码创建发票。
$InvoiceService = new QuickBooks_IPP_Service_Invoice();
$Invoice = new QuickBooks_IPP_Object_Invoice();
$Invoice->setDocNumber('HELLO11');
$Invoice->setTxnDate($invoice['invoice_date']);
$Invoice->setCurrencyRef('INR');
$Invoice->setCurrencyRef_name('Indian Rupee');
$Invoice->setExchangeRate('1');
$Invoice->setCustomerRef($invoice['billing_acc_qb_id']);
$Invoice->setCurrencyRef_name($invoice['billing_account']);
$Invoice->setCustomerMemo('checking with script');
$Invoice->setDueDate($invoice['due_date']);
$Invoice->setTotalAmt($invoice['total_amount']);
$Invoice->setHomeTotalAmt($invoice['total_amount']);
$Invoice->setBalance($invoice['total_amount']);
$Invoice->setDeposit('0');
foreach($line_item as $row)
{
$ln=$row['line_item'];
$line_amount=($ln['product_unit_price']*$ln['product_qty']);
$Line = new QuickBooks_IPP_Object_Line();
$Line->setDetailType('SalesItemLineDetail');
$Line->setAmount($line_amount);
$Line->setDescription($row['tax_info']['Item_description']);
$SalesItemLineDetail = new QuickBooks_IPP_Object_SalesItemLineDetail();
$SalesItemLineDetail->setItemRef($ln['part_number']);
$SalesItemLineDetail->setUnitPrice(number_format((float)$ln['product_unit_price'], 2, '.', ''));
$SalesItemLineDetail->setQty($ln['product_qty']);
$SalesItemLineDetail->setTaxCodeRef($row['tax_info']['TaxCode']);
$Line->addSalesItemLineDetail($SalesItemLineDetail);
$Invoice->addLine($Line);
}
$TxnTaxDetail= new QuickBooks_IPP_Object_TxnTaxDetail();
$TxnTaxDetail->setTotalTax($invoice['tax_amount']);
//foreach($line_item as $row)
//{
//$tax_detail=$row['tax_info']['tax_detail'];
foreach($tax_arr as $row)
{
foreach($row as $tax_dtl)
{
$TaxLine= new QuickBooks_IPP_Object_TaxLine();
$TaxLine->setAmount($tax_dtl['TaxAmt']);
$TaxLine->setDetailType('TaxLineDetail');
$TaxLineDetail = new QuickBooks_IPP_Object_TaxLineDetail();
$TaxLineDetail->setTaxRateRef($tax_dtl['TaxRateRef']);
$TaxLineDetail->setPercentBased('true');
$TaxLineDetail->setTaxPercent($tax_dtl['RateValue']);
$TaxLineDetail->setNetAmountTaxable($tax_dtl['Principle_amt']);
$TaxLine->addTaxLineDetail($TaxLineDetail);
$TxnTaxDetail->addTaxLine($TaxLine);
}
}
//}
$Invoice->addTxnTaxDetail($TxnTaxDetail);
// adding billing email
$BillEmail = new QuickBooks_IPP_Object_BillEmail();
$BillEmail->setAddress('chadha.s@example.com, c.s_consultrctions@example.com');
$Invoice->setBillEmail($BillEmail);
echo "<pre>";
var_dump($Invoice);
if ($resp = $InvoiceService->add($Context, $realm, $Invoice))
{
print('Our new Invoice ID is: [' . $resp . ']');
}
else
{
print($InvoiceService->lastError());
print('<br><br>');
print('REQUEST: <code>' . htmlspecialchars($InvoiceService->lastRequest()) . '</code><br><br><br>');
print('RESPONSE: <code>' . htmlspecialchars($InvoiceService->lastResponse()) . '</code><br><br><br>');
}
最终发票对象与从在线Quickbook中检索的对象完全相似
<Invoice xmlns="http://schema.intuit.com/finance/v3">
<DocNumber>HELLO111</DocNumber>
<TxnDate>2017-04-16</TxnDate>
<CurrencyRef>INR</CurrencyRef>
<CurrencyRef_name>Chadha\&#039;s Consultants</CurrencyRef_name>
<ExchangeRate>1</ExchangeRate>
<CustomerRef>4</CustomerRef>
<CustomerMemo>checking with script</CustomerMemo>
<DueDate>2017-04-30</DueDate>
<TotalAmt>108146.5</TotalAmt>
<HomeTotalAmt>108146.5</HomeTotalAmt>
<Balance>108146.5</Balance>
<Deposit>0</Deposit>
<Line xmlns="http://schema.intuit.com/finance/v3">
<Amount>34000</Amount>
<DetailType>SalesItemLineDetail</DetailType>
<Description>Catering -- food & beverage</Description>
<SalesItemLineDetail xmlns="http://schema.intuit.com/finance/v3">
<ItemRef>3</ItemRef>
<UnitPrice>3400.00</UnitPrice>
<Qty>10</Qty>
<TaxCodeRef>4</TaxCodeRef>
</SalesItemLineDetail>
</Line>
<Line xmlns="http://schema.intuit.com/finance/v3">
<Amount>62250</Amount>
<DetailType>SalesItemLineDetail</DetailType>
<Description>Retreat - silver level</Description>
<SalesItemLineDetail xmlns="http://schema.intuit.com/finance/v3">
<ItemRef>23</ItemRef>
<UnitPrice>12450.00</UnitPrice>
<Qty>5</Qty>
<TaxCodeRef>4</TaxCodeRef>
</SalesItemLineDetail>
</Line>
<TxnTaxDetail xmlns="http://schema.intuit.com/finance/v3">
<TotalTax>11896.5</TotalTax>
<TaxLine xmlns="http://schema.intuit.com/finance/v3">
<Amount>7470</Amount>
<DetailType>TaxLineDetail</DetailType>
<TaxLineDetail xmlns="http://schema.intuit.com/finance/v3">
<TaxRateRef>10</TaxRateRef>
<PercentBased>true</PercentBased>
<TaxPercent>12</TaxPercent>
<NetAmountTaxable>62250</NetAmountTaxable>
</TaxLineDetail>
</TaxLine>
<TaxLine xmlns="http://schema.intuit.com/finance/v3">
<Amount>149.4</Amount>
<DetailType>TaxLineDetail</DetailType>
<TaxLineDetail xmlns="http://schema.intuit.com/finance/v3">
<TaxRateRef>11</TaxRateRef>
<PercentBased>true</PercentBased>
<TaxPercent>2</TaxPercent>
<NetAmountTaxable>7470</NetAmountTaxable>
</TaxLineDetail>
</TaxLine>
<TaxLine xmlns="http://schema.intuit.com/finance/v3">
<Amount>74.7</Amount>
<DetailType>TaxLineDetail</DetailType>
<TaxLineDetail xmlns="http://schema.intuit.com/finance/v3">
<TaxRateRef>12</TaxRateRef>
<PercentBased>true</PercentBased>
<TaxPercent>1</TaxPercent>
<NetAmountTaxable>7470</NetAmountTaxable>
</TaxLineDetail>
</TaxLine>
</TxnTaxDetail>
<BillEmail xmlns="http://schema.intuit.com/finance/v3">
<Address>chadha.s@example.com, c.s_consultrctions@example.com</Address>
</BillEmail>
</Invoice>