我正在使用consolibyte Quickbook在线版for php。 我正在创建发票,它对我来说很好。 而且我在纳税。但我必须删除该税,并希望增加整体税。 有人可以帮助我。
一切都很好我只想添加与附加图像相同的税。 请帮忙 提前致谢
我添加发票的代码:
公共功能addInvoice($ invoiceArray,$ chargeArray,$ customerRef,$ db_product,$ invoice_id,$ other_charges,$ price_grid,$ payment,$ orderId,$ quickbook_id,$ display_order_id,$ payment_terms_name,$ payment_terms_day){
$IPP = new \QuickBooks_IPP($this->QBO_DSN);
// Get our OAuth credentials from the database
$creds = $this->IntuitAnywhere->load(Session::get('useremail'), Session::get('user_id'));
// Tell the framework to load some data from the OAuth store
$IPP->authMode(
\QuickBooks_IPP::AUTHMODE_OAUTH,
Session::get('useremail'),
$creds);
if ($this->is_sandbox) {
// Turn on sandbox mode/URLs
$IPP->sandbox(true);
}
// This is our current realm
$this->realm = $creds['qb_realm'];
// Load the OAuth information from the database
$this->context = $IPP->context();
$InvoiceService = new \QuickBooks_IPP_Service_Invoice();
if($quickbook_id > 0) {
$retr = $InvoiceService->delete($this->context, $this->realm, $quickbook_id);
}
$Invoice = new \QuickBooks_IPP_Object_Invoice();
$CustomField = new \QuickBooks_IPP_Object_CustomField();
$CustomField->setDefinitionId('2');
$CustomField->setName('Sales Rep');
$CustomField->setType('StringType');
$CustomField->setStringValue($invoiceArray[0]->sales_name);
$Invoice->addCustomField($CustomField);
$CustomField1 = new \QuickBooks_IPP_Object_CustomField();
$CustomField1->setDefinitionId('1');
$CustomField1->setName('Customer PO');
$CustomField1->setType('StringType');
$CustomField1->setStringValue($invoiceArray[0]->custom_po);
$Invoice->addCustomField($CustomField1);
$Invoice->setDocNumber('INV-' . $display_order_id);
$Invoice->setTxnDate(date('Y-m-d'));
if($payment_terms_name != '') {
if($payment_terms_day > 0) {
$due_day = $payment_terms_day;
} else {
$due_day = 0;
}
$TermService = new \QuickBooks_IPP_Service_Term();
$terms = $TermService->query($this->context, $this->realm, "SELECT * FROM Term WHERE Name = '".$payment_terms_name."' ");
$Term = new \QuickBooks_IPP_Object_Term();
$payment_terms_id = 0;
if(!empty($terms)){
$Term = $terms[0];
$payment_terms_id = $Term->getId();
$payment_terms_id = str_replace('{','',$payment_terms_id);
$payment_terms_id = str_replace('}','',$payment_terms_id);
$payment_terms_id = abs($payment_terms_id);
}
if($payment_terms_id > 0) {
$Invoice->setSalesTermRef($payment_terms_id);
} else {
$Term->setName($payment_terms_name);
$Term->setDueDays($due_day);
if ($resp = $TermService->add($this->context, $this->realm, $Term))
{
$payment_terms_id = $this->getId($resp);
$Invoice->setSalesTermRef($payment_terms_id);
}
}
if($due_day > 0) {
$setDate = date('Y-m-d', strtotime("+".$due_day. "days"));
$Invoice->setDueDate($setDate);
} else {
$Invoice->setDueDate(date('Y-m-d'));
}
}
foreach ($invoiceArray as $key => $value) {
$desc = array();
foreach ($value->sizeData as $sizeAll) {
$desc[] = $sizeAll->size.'('.$sizeAll->qnty.')';
}
$description = implode(', ' , $desc);
$product_name_desc_display = $value->product_name.' : '.$value->color_name.' : '.$description;
$Line = new \QuickBooks_IPP_Object_Line();
$Line->setDetailType('SalesItemLineDetail');
$Line->setAmount($value->total_line_charge * $value->total_qnty);
$Line->setDescription($product_name_desc_display);
$SalesItemLineDetail = new \QuickBooks_IPP_Object_SalesItemLineDetail();
if($value->vendor_id == 1) {
$SalesItemLineDetail->setItemRef($db_product[0]->ss);
} else {
$SalesItemLineDetail->setItemRef($db_product[0]->custom_product);
}
$SalesItemLineDetail->setUnitPrice($value->total_line_charge);
$SalesItemLineDetail->setQty($value->total_qnty);
$Line->addSalesItemLineDetail($SalesItemLineDetail);
$Invoice->addLine($Line);
$Invoice->setCustomerRef($customerRef);
}
if($chargeArray[0]->order_total != 0 && $chargeArray[0]->order_total != '') {
$Line = new \QuickBooks_IPP_Object_Line();
$Line->setDetailType('SalesItemLineDetail');
$Line->setAmount($chargeArray[0]->tax);
$Line->setDescription('Tax-'.$chargeArray[0]->tax_rate);
$SalesItemLineDetail = new \QuickBooks_IPP_Object_SalesItemLineDetail();
$SalesItemLineDetail->setItemRef($db_product[0]->tax_charge);
$SalesItemLineDetail->setUnitPrice($chargeArray[0]->tax);
$SalesItemLineDetail->setQty(1);
$Line->addSalesItemLineDetail($SalesItemLineDetail);
$Invoice->addLine($Line);
$Invoice->setCustomerRef($customerRef);
}
if($chargeArray[0]->discount != 0 && $chargeArray[0]->discount != '') {
$Line = new \QuickBooks_IPP_Object_Line();
$Line->setDetailType('SalesItemLineDetail');
$Line->setAmount(-$chargeArray[0]->discount);
$Line->setDescription('Discount');
$SalesItemLineDetail = new \QuickBooks_IPP_Object_SalesItemLineDetail();
$SalesItemLineDetail->setItemRef($db_product[0]->discount_charge);
$SalesItemLineDetail->setUnitPrice(-$chargeArray[0]->discount);
$SalesItemLineDetail->setQty(1);
$Line->addSalesItemLineDetail($SalesItemLineDetail);
$Invoice->addLine($Line);
$Invoice->setCustomerRef($customerRef);
}
if ($resp = $InvoiceService->add($this->context, $this->realm, $Invoice))
{
$qb_invoice_id = $this->getId($resp);
$this->common->UpdateTableRecords('invoice',array('id' => $invoice_id),array('qb_id' => $qb_invoice_id));
//if($quickbook_id > 0) {
$this->common->UpdateTableRecords('payment_history',array('order_id' => $orderId),array('qb_id' => $qb_invoice_id,'qb_flag' => 0));
// }
return 1;
}
else
{
return 0;
}
}