本文整理汇总了PHP中Mage_Sales_Model_Order_Invoice::setBaseCodTaxAmount方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Order_Invoice::setBaseCodTaxAmount方法的具体用法?PHP Mage_Sales_Model_Order_Invoice::setBaseCodTaxAmount怎么用?PHP Mage_Sales_Model_Order_Invoice::setBaseCodTaxAmount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Order_Invoice
的用法示例。
在下文中一共展示了Mage_Sales_Model_Order_Invoice::setBaseCodTaxAmount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: collect
public function collect(Mage_Sales_Model_Order_Invoice $invoice)
{
$codTax = 0;
$baseCodTax = 0;
$includeCodTax = true;
/**
* Check Cod amount in previus invoices
*/
foreach ($invoice->getOrder()->getInvoiceCollection() as $previusInvoice) {
if ($previusInvoice->getCodFee() && !$previusInvoice->isCanceled()) {
$includeCodTax = false;
}
}
if ($includeCodTax) {
$codTax += $invoice->getOrder()->getCodTaxAmount();
$baseCodTax += $invoice->getOrder()->getBaseCodTaxAmount();
$invoice->setCodTaxAmount($invoice->getOrder()->getCodTaxAmount());
$invoice->setBaseCodTaxAmount($invoice->getOrder()->getBaseCodTaxAmount());
$invoice->getOrder()->setCodTaxAmountInvoiced($codTax);
$invoice->getOrder()->setBaseCodTaxAmountInvoice($baseCodTax);
}
//$invoice->setTaxAmount($invoice->getTaxAmount() + $codTax);
//$invoice->setBaseTaxAmount($invoice->getBaseTaxAmount() + $baseCodTax);
//$invoice->setGrandTotal($invoice->getGrandTotal() + $codTax);
//$invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() + $baseCodTax);
return $this;
}
示例2: collect
public function collect(Mage_Sales_Model_Order_Invoice $invoice)
{
$codTax = 0;
$baseCodTax = 0;
$order = $invoice->getOrder();
$includeCodTax = true;
if ($order->getPayment()->getMethodInstance()->getCode() != 'phoenix_cashondelivery') {
return $this;
}
/**
* Check Cod amount in previus invoices
*/
foreach ($order->getInvoiceCollection() as $previousInvoice) {
if ($previousInvoice->getCodFee() && !$previousInvoice->isCanceled()) {
$includeCodTax = false;
}
}
if ($includeCodTax) {
$codTax = $order->getCodTaxAmount();
$baseCodTax = $order->getBaseCodTaxAmount();
$invoice->setCodTaxAmount($order->getCodTaxAmount());
$invoice->setBaseCodTaxAmount($order->getBaseCodTaxAmount());
$invoice->getOrder()->setCodTaxAmountInvoiced($codTax);
$invoice->getOrder()->setBaseCodTaxAmountInvoiced($baseCodTax);
}
/**
* Not isLast() invoice case handling
* totalTax adjustment
* check Mage_Sales_Model_Order_Invoice_Total_Tax::collect()
*/
$allowedTax = $order->getTaxAmount() - $order->getTaxInvoiced();
$allowedBaseTax = $order->getBaseTaxAmount() - $order->getBaseTaxInvoiced();
$totalTax = $invoice->getTaxAmount();
$baseTotalTax = $invoice->getBaseTaxAmount();
if (!$invoice->isLast() && $allowedTax > $totalTax) {
$newTotalTax = min($allowedTax, $totalTax + $codTax);
$newBaseTotalTax = min($allowedBaseTax, $baseTotalTax + $baseCodTax);
$invoice->setTaxAmount($newTotalTax);
$invoice->setBaseTaxAmount($newBaseTotalTax);
$invoice->setGrandTotal($invoice->getGrandTotal() - $totalTax + $newTotalTax);
$invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() - $baseTotalTax + $newBaseTotalTax);
}
return $this;
}