本文整理汇总了PHP中Mage_Sales_Model_Order_Creditmemo::getBaseTaxAmount方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Order_Creditmemo::getBaseTaxAmount方法的具体用法?PHP Mage_Sales_Model_Order_Creditmemo::getBaseTaxAmount怎么用?PHP Mage_Sales_Model_Order_Creditmemo::getBaseTaxAmount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Order_Creditmemo
的用法示例。
在下文中一共展示了Mage_Sales_Model_Order_Creditmemo::getBaseTaxAmount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: collect
/**
* Collect the order total
*
* @param object $creditmemo The Creditmemo instance to collect from
*
* @return Mage_Sales_Model_Order_Creditmemo_Total_Abstract
*/
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$method = $creditmemo->getOrder()->getPayment()->getMethodInstance();
if (substr($method->getCode(), 0, 5) != 'sisow') {
return $this;
}
$info = $method->getInfoInstance();
if (!$info) {
return $this;
}
$invoiceFee = $info->getAdditionalInformation('invoice_fee');
$baseInvoiceFee = $info->getAdditionalInformation('base_invoice_fee');
if (!$invoiceFee) {
return $this;
}
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $baseInvoiceFee);
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $invoiceFee);
$creditmemo->setBaseInvoiceFee($baseInvoiceFee);
$creditmemo->setInvoiceFee($invoiceFee);
$tax = $info->getAdditionalInformation('invoice_tax_amount');
$baseTax = $info->getAdditionalInformation('base_invoice_tax_amount');
if (!$tax) {
return $this;
}
$creditmemo->setBaseTaxAmount($creditmemo->getBaseTaxAmount() + $baseTax);
$creditmemo->setTaxAmount($creditmemo->getTaxAmount() + $tax);
return $this;
}
示例2: collect
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$creditmemo->setPaymentCharge(0);
$creditmemo->setBasePaymentCharge(0);
$paymentCharge = $creditmemo->getOrder()->getPaymentCharge();
$basePaymentCharge = $creditmemo->getOrder()->getBasePaymentCharge();
// we moeten de btw meenemen in de berekening
$paymentMethod = $creditmemo->getOrder()->getPayment()->getMethod();
$taxClass = Mage::helper('pay_payment')->getPaymentChargeTaxClass($paymentMethod);
$storeId = Mage::app()->getStore()->getId();
$taxCalculationModel = Mage::getSingleton('tax/calculation');
$request = $taxCalculationModel->getRateRequest($creditmemo->getOrder()->getShippingAddress(), $creditmemo->getOrder()->getBillingAddress(), null, $storeId);
$request->setStore(Mage::app()->getStore());
$rate = $taxCalculationModel->getRate($request->setProductClassId($taxClass));
if ($rate > 0) {
$baseChargeTax = round($creditmemo->getBasePaymentCharge() / (1 + $rate / 100) * ($rate / 100), 2);
$chargeTax = round($creditmemo->getPaymentCharge() / (1 + $rate / 100) * ($rate / 100), 2);
} else {
$baseChargeTax = 0;
$chargeTax = 0;
}
$creditmemo->setPaymentCharge($paymentCharge);
$creditmemo->setBasePaymentCharge($basePaymentCharge);
$creditmemo->setBaseTaxAmount($creditmemo->getBaseTaxAmount() + $baseChargeTax);
$creditmemo->setTaxAmount($creditmemo->getTaxAmount() + $chargeTax);
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $creditmemo->getPaymentCharge());
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $creditmemo->getBasePaymentCharge());
return $this;
}
示例3: collect
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$store = $creditmemo->getStore();
$totalTax = 0;
$baseTotalTax = 0;
$weeeTaxAmount = 0;
$baseWeeeTaxAmount = 0;
foreach ($creditmemo->getAllItems() as $item) {
$orderItem = $item->getOrderItem();
if ($orderItem->isDummy()) {
continue;
}
$orderItemQty = $orderItem->getQtyOrdered();
$weeeRowDiscountAmount = $orderItem->getDiscountAppliedForWeeeTax();
$weeeDiscountAmount = $creditmemo->roundPrice($weeeRowDiscountAmount / $orderItemQty * $item->getQty(), 'regular', true);
$baseWeeeRowDiscountAmount = $orderItem->getBaseDiscountAppliedForWeeeTax();
$baseWeeeDiscountAmount = $creditmemo->roundPrice($baseWeeeRowDiscountAmount / $orderItemQty * $item->getQty(), 'base', true);
$weeeAmountExclTax = (Mage::helper('weee')->getWeeeTaxInclTax($item) - Mage::helper('weee')->getTotalTaxAppliedForWeeeTax($item)) * $item->getQty();
$totalTax += $weeeAmountExclTax - $weeeDiscountAmount;
$baseWeeeAmountExclTax = (Mage::helper('weee')->getBaseWeeeTaxInclTax($item) - Mage::helper('weee')->getBaseTotalTaxAppliedForWeeeTax($item)) * $item->getQty();
$baseTotalTax += $baseWeeeAmountExclTax - $baseWeeeDiscountAmount;
$item->setWeeeTaxAppliedRowAmount($weeeAmountExclTax);
$item->setBaseWeeeTaxAppliedRowAmount($baseWeeeAmountExclTax);
$weeeTaxAmount += Mage::helper('weee')->getWeeeTaxInclTax($item) * $item->getQty();
$baseWeeeTaxAmount += Mage::helper('weee')->getBaseWeeeTaxInclTax($item) * $item->getQty();
$newApplied = array();
$applied = Mage::helper('weee')->getApplied($item);
foreach ($applied as $one) {
$one['base_row_amount'] = $one['base_amount'] * $item->getQty();
$one['row_amount'] = $one['amount'] * $item->getQty();
$one['base_row_amount_incl_tax'] = $one['base_amount_incl_tax'] * $item->getQty();
$one['row_amount_incl_tax'] = $one['amount_incl_tax'] * $item->getQty();
$one['weee_discount'] = $weeeDiscountAmount;
$one['base_weee_discount'] = $baseWeeeDiscountAmount;
$newApplied[] = $one;
}
Mage::helper('weee')->setApplied($item, $newApplied);
$item->setWeeeTaxRowDisposition($item->getWeeeTaxDisposition() * $item->getQty());
$item->setBaseWeeeTaxRowDisposition($item->getBaseWeeeTaxDisposition() * $item->getQty());
}
/*
* please refer the description in weee - invoice section for reasoning
*/
if (Mage::helper('weee')->includeInSubtotal($store)) {
$creditmemo->setSubtotal($creditmemo->getSubtotal() + $totalTax);
$creditmemo->setBaseSubtotal($creditmemo->getBaseSubtotal() + $baseTotalTax);
} else {
$creditmemo->setTaxAmount($creditmemo->getTaxAmount() + $totalTax);
$creditmemo->setBaseTaxAmount($creditmemo->getBaseTaxAmount() + $baseTotalTax);
}
//Increment the subtotal
$creditmemo->setSubtotalInclTax($creditmemo->getSubtotalInclTax() + $weeeTaxAmount);
$creditmemo->setBaseSubtotalInclTax($creditmemo->getBaseSubtotalInclTax() + $baseWeeeTaxAmount);
//Increment the grand total
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $totalTax);
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $baseTotalTax);
return $this;
}
示例4: collect
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$creditmemo->setSveaPaymentFeeAmount(0);
$creditmemo->setBaseSveaPaymentFeeAmount(0);
$creditmemo->setSveaPaymentFeeTaxAmount(0);
$creditmemo->setBaseSveaPaymentFeeTaxAmount(0);
$creditmemo->setSveaPaymentFeeInclTax(0);
$creditmemo->setBaseSveaPaymentFeeInclTax(0);
$order = $creditmemo->getOrder();
if (!$order->getSveaPaymentFeeAmount()) {
return $this;
}
$paymentFeeAmount = 0;
$basePaymentFeeAmount = 0;
$paymentFeeTaxAmount = 0;
$basePaymentFeeTaxAmount = 0;
$paymentFeeTaxInclTax = 0;
$grandTotal = $creditmemo->getGrandTotal();
$baseGrandTotal = $creditmemo->getBaseGrandTotal();
$taxAmount = $creditmemo->getTaxAmount();
$baseTaxAmount = $creditmemo->getBaseTaxAmount();
if ($invoice = $creditmemo->getInvoice()) {
if ($invoice->getSveaPaymentFeeAmount()) {
// Refund specific invoice
$source = $invoice;
}
} else {
if (!$order->getSveaPaymentFeeRefunded()) {
// Refund from order values
$source = $order;
}
}
if (isset($source)) {
$paymentFeeAmount = $source->getSveaPaymentFeeAmount();
$basePaymentFeeAmount = $source->getBaseSveaPaymentFeeAmount();
$paymentFeeTaxAmount = $source->getSveaPaymentFeeTaxAmount();
$basePaymentFeeTaxAmount = $source->getBaseSveaPaymentFeeTaxAmount();
$paymentFeeTaxInclTax = $source->getSveaPaymentFeeInclTax();
$basePaymentFeeInclTax = $source->getBaseSveaPaymentFeeInclTax();
}
$taxAmount += $paymentFeeTaxAmount;
$baseTaxAmount += $basePaymentFeeTaxAmount;
$grandTotal += $paymentFeeTaxInclTax;
$baseGrandTotal += $basePaymentFeeInclTax;
$creditmemo->setSveaPaymentFeeAmount($paymentFeeAmount);
$creditmemo->setBaseSveaPaymentFeeAmount($basePaymentFeeAmount);
$creditmemo->setSveaPaymentFeeTaxAmount($paymentFeeTaxAmount);
$creditmemo->setBaseSveaPaymentFeeTaxAmount($basePaymentFeeTaxAmount);
$creditmemo->setSveaPaymentFeeInclTax($paymentFeeTaxInclTax);
$creditmemo->setBaseSveaPaymentFeeInclTax($basePaymentFeeInclTax);
$creditmemo->setTaxAmount($taxAmount);
$creditmemo->setBaseTaxAmount($baseTaxAmount);
$creditmemo->setGrandTotal($grandTotal);
$creditmemo->setBaseGrandTotal($baseGrandTotal);
return $this;
}
示例5: collect
/**
* Collect gift wrapping tax totals
*
* @param Mage_Sales_Model_Order_Creditmemo $creditmemo
* @return Enterprise_GiftWrapping_Model_Total_Creditmemo_Tax_Giftwrapping
*/
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$order = $creditmemo->getOrder();
/**
* Wrapping for items
*/
$refunded = 0;
$baseRefunded = 0;
foreach ($creditmemo->getAllItems() as $creditmemoItem) {
if (!$creditmemoItem->getQty() || $creditmemoItem->getQty() == 0) {
continue;
}
$orderItem = $creditmemoItem->getOrderItem();
if ($orderItem->getGwId() && $orderItem->getGwBaseTaxAmountInvoiced() && $orderItem->getGwBaseTaxAmountInvoiced() != $orderItem->getGwBaseTaxAmountRefunded()) {
$orderItem->setGwBaseTaxAmountRefunded($orderItem->getGwBaseTaxAmountInvoiced());
$orderItem->setGwTaxAmountRefunded($orderItem->getGwTaxAmountInvoiced());
$baseRefunded += $orderItem->getGwBaseTaxAmountInvoiced() * $creditmemoItem->getQty();
$refunded += $orderItem->getGwTaxAmountInvoiced() * $creditmemoItem->getQty();
}
}
if ($refunded > 0 || $baseRefunded > 0) {
$order->setGwItemsBaseTaxRefunded($order->getGwItemsBaseTaxRefunded() + $baseRefunded);
$order->setGwItemsTaxRefunded($order->getGwItemsTaxRefunded() + $refunded);
$creditmemo->setGwItemsBaseTaxAmount($baseRefunded);
$creditmemo->setGwItemsTaxAmount($refunded);
}
/**
* Wrapping for order
*/
if ($order->getGwId() && $order->getGwBaseTaxAmountInvoiced() && $order->getGwBaseTaxAmountInvoiced() != $order->getGwBaseTaxAmountRefunded()) {
$order->setGwBaseTaxAmountRefunded($order->getGwBaseTaxAmountInvoiced());
$order->setGwTaxAmountRefunded($order->getGwTaxAmountInvoiced());
$creditmemo->setGwBaseTaxAmount($order->getGwBaseTaxAmountInvoiced());
$creditmemo->setGwTaxAmount($order->getGwTaxAmountInvoiced());
}
/**
* Printed card
*/
if ($order->getGwAddCard() && $order->getGwCardBaseTaxInvoiced() && $order->getGwCardBaseTaxInvoiced() != $order->getGwCardBaseTaxRefunded()) {
$order->setGwCardBaseTaxRefunded($order->getGwCardBaseTaxInvoiced());
$order->setGwCardTaxRefunded($order->getGwCardTaxInvoiced());
$creditmemo->setGwCardBaseTaxAmount($order->getGwCardBaseTaxInvoiced());
$creditmemo->setGwCardTaxAmount($order->getGwCardTaxInvoiced());
}
$baseTaxAmount = $creditmemo->getGwItemsBaseTaxAmount() + $creditmemo->getGwBaseTaxAmount() + $creditmemo->getGwCardBaseTaxAmount();
$taxAmount = $creditmemo->getGwItemsTaxAmount() + $creditmemo->getGwTaxAmount() + $creditmemo->getGwCardTaxAmount();
$creditmemo->setBaseTaxAmount($creditmemo->getBaseTaxAmount() + $baseTaxAmount);
$creditmemo->setTaxAmount($creditmemo->getTaxAmount() + $taxAmount);
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $baseTaxAmount);
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $taxAmount);
$creditmemo->setBaseCustomerBalanceReturnMax($creditmemo->getBaseCustomerBalanceReturnMax() + $baseTaxAmount);
$creditmemo->setCustomerBalanceReturnMax($creditmemo->getCustomerBalanceReturnMax() + $taxAmount);
return $this;
}
示例6: collect
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$order = $creditmemo->getOrder();
$feeAmountLeft = $order->getFeeAmountInvoiced() - $order->getFeeAmountRefunded();
$basefeeAmountLeft = $order->getBaseFeeAmountInvoiced() - $order->getBaseFeeAmountRefunded();
if ($basefeeAmountLeft > 0) {
$creditmemo->setFeeAmount($feeAmountLeft);
$creditmemo->setBaseFeeAmount($basefeeAmountLeft);
$creditmemo->setTaxAmount($creditmemo->getTaxAmount() + $feeAmountLeft - $basefeeAmountLeft);
$creditmemo->setBaseTaxAmount($creditmemo->getBaseTaxAmount() + $feeAmountLeft - $basefeeAmountLeft);
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $feeAmountLeft);
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $feeAmountLeft);
}
return $this;
}
示例7: collect
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$_helper = Mage::helper('msp_cashondelivery');
$_model = Mage::getModel('msp_cashondelivery/cashondelivery');
$order = $creditmemo->getOrder();
$baseAmount = $order->getMspBaseCashondelivery();
$baseAmountInclTax = $order->getMspBaseCashondeliveryInclTax();
$amount = $order->getMspCashondelivery();
$amountInclTax = $order->getMspCashondeliveryInclTax();
$codTax = $amountInclTax - $amount;
$codBaseTax = $baseAmountInclTax - $baseAmount;
$creditmemo->setTaxAmount($creditmemo->getTaxAmount() + $codTax);
$creditmemo->setBaseTaxAmount($creditmemo->getBaseTaxAmount() + $codBaseTax);
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $codTax);
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $codBaseTax);
return $this;
}
示例8: collect
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$order = $creditmemo->getOrder();
//recalculate tax amounts in case if refund shipping value was changed
if ((double) $creditmemo->getBasePaymentFeeAmount() && (double) $order->getBasePaymentFeeAmount()) {
$taxFactor = $creditmemo->getBasePaymentFeeAmount() / $order->getBasePaymentFeeAmount();
$paymentFeeTax = $creditmemo->getPaymentFeeTax() * $taxFactor;
$paymentBaseFeeTax = $creditmemo->getBasePaymentFeeTax() * $taxFactor;
} else {
$paymentFeeTax = $creditmemo->getPaymentFeeTax();
$paymentBaseFeeTax = $creditmemo->getBasePaymentFeeTax();
}
// set the tax fee
$creditmemo->setPaymentFeeTax($paymentFeeTax);
$creditmemo->setBasePaymentFeeTax($paymentBaseFeeTax);
// use the tax fee to calculate total tax amount
$creditmemo->setTaxAmount($creditmemo->getTaxAmount() + $creditmemo->getPaymentFeeTax());
$creditmemo->setBaseTaxAmount($creditmemo->getBaseTaxAmount() + $creditmemo->getBasePaymentFeeTax());
return $this;
}
示例9: collect
public function collect(Mage_Sales_Model_Order_Creditmemo $cm)
{
$order = $cm->getOrder();
if (!preg_match('/capayable/', $order->getPayment()->getMethodInstance()->getCode())) {
return $this;
}
$baseCmTotal = $cm->getBaseGrandTotal();
$cmTotal = $cm->getGrandTotal();
$baseTaxAmount = $cm->getBaseTaxAmount();
$taxAmount = $cm->getTaxAmount();
$basePaymentFeeInvoiced = $order->getBaseCapayableFeeInvoiced();
$paymentFeeInvoiced = $order->getCapayableFeeInvoiced();
$basePaymentFeeTaxAmount = $order->getBaseCapayableFeeTaxAmount();
$paymentFeeTaxAmount = $order->getCapayableFeeTaxAmount();
if ($cm->getInvoice()) {
$invoice = $cm->getInvoice();
$basePaymentsFeeToCredit = $invoice->getBaseCapayableFee();
$paymentFeeToCredit = $invoice->getCapayableFee();
$basePaymentFeeTaxAmountToCredit = $invoice->getBaseCapayableFeeTaxAmount();
$paymentFeeTaxAmountToCredit = $invoice->getCapayableFeeTaxAmount();
} else {
$basePaymentsFeeToCredit = $basePaymentFeeInvoiced;
$paymentFeeToCredit = $paymentFeeInvoiced;
$basePaymentFeeTaxAmountToCredit = $basePaymentFeeTaxAmount;
$paymentFeeTaxAmountToCredit = $paymentFeeTaxAmount;
}
if (!$basePaymentsFeeToCredit > 0) {
return $this;
}
// Subtracting invoiced Payment fee from Credit memo total
$cm->setBaseGrandTotal($baseCmTotal + ($basePaymentsFeeToCredit + $basePaymentFeeTaxAmountToCredit));
$cm->setGrandTotal($cmTotal + ($paymentFeeToCredit + $paymentFeeTaxAmountToCredit));
$cm->setTaxAmount($taxAmount + $paymentFeeTaxAmountToCredit);
$cm->setBaseTaxAmount($baseTaxAmount + $basePaymentFeeTaxAmountToCredit);
$cm->setBaseCapayableFee($basePaymentsFeeToCredit);
$cm->setCapayableFee($paymentFeeToCredit);
$cm->setBaseCapayableFeeTaxAmount($basePaymentFeeTaxAmountToCredit);
$cm->setCapayableFeeTaxAmount($paymentFeeTaxAmountToCredit);
return $this;
}
示例10: collect
/**
* @param Mage_Sales_Model_Order_Creditmemo $creditmemo
* @return $this|Mage_Sales_Model_Order_Creditmemo_Total_Abstract
*/
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$order = $creditmemo->getOrder();
if ($order->getMultifeesAmount() > 0 && $order->getMultifeesRefunded() < $order->getMultifeesInvoiced()) {
$creditmemo->setMultifeesAmount($order->getMultifeesInvoiced() - $order->getMultifeesRefunded());
$creditmemo->setBaseMultifeesAmount($order->getBaseMultifeesInvoiced() - $order->getBaseMultifeesRefunded());
$creditmemo->setMultifeesTaxAmount($order->getMultifeesTaxAmount());
$creditmemo->setBaseMultifeesTaxAmount($order->getBaseMultifeesTaxAmount());
$creditmemo->setDetailsMultifees($order->getDetailsMultifees());
$creditmemo->setTaxAmount($creditmemo->getTaxAmount() + $creditmemo->getMultifeesTaxAmount());
$creditmemo->setBaseTaxAmount($creditmemo->getBaseTaxAmount() + $creditmemo->getBaseMultifeesTaxAmount());
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $creditmemo->getMultifeesAmount());
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $creditmemo->getBaseMultifeesAmount());
} else {
$creditmemo->setMultifeesAmount(0);
$creditmemo->setBaseMultifeesAmount(0);
$creditmemo->setMultifeesTaxAmount(0);
$creditmemo->setBaseMultifeesTaxAmount(0);
$creditmemo->setDetailsMultifees('');
}
return $this;
}
示例11: collect
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$order = $creditmemo->getOrder();
if ($order->getPayment()->getMethodInstance()->getCode() != 'Balticode_cashondelivery') {
return $this;
}
$creditmemoBaseGrandTotal = $creditmemo->getBaseGrandTotal();
$creditmemoGrandTotal = $creditmemo->getGrandTotal();
$creditmemoBaseTaxAmount = $creditmemo->getBaseTaxAmount();
$creditmemoTaxAmount = $creditmemo->getTaxAmount();
$baseCodTaxAmountRefunded = $order->getBaseCodTaxAmountRefunded();
$codTaxAmountRefunded = $order->getCodTaxAmountRefunded();
$baseCodTaxAmountInvoiced = $order->getBaseCodTaxAmountInvoiced();
$codTaxAmountInvoiced = $order->getCodTaxAmountInvoiced();
$baseCodTaxAmountToRefund = abs($baseCodTaxAmountInvoiced - $baseCodTaxAmountRefunded);
$codTaxAmountToRefund = abs($codTaxAmountInvoiced - $codTaxAmountRefunded);
if ($baseCodTaxAmountToRefund <= 0) {
return $this;
}
$creditmemo->setBaseGrandTotal($creditmemoBaseGrandTotal + $baseCodTaxAmountToRefund)->setGrandTotal($creditmemoGrandTotal + $codTaxAmountToRefund)->setBaseTaxAmount($creditmemoBaseTaxAmount + $baseCodTaxAmountToRefund)->setTaxAmount($creditmemoTaxAmount + $codTaxAmountToRefund)->setBaseCodTaxAmount($codTaxAmountToRefund)->setCodTaxAmount($codTaxAmountToRefund);
$order->setBaseCodTaxAmountRefunded($baseCodTaxAmountRefunded + $baseCodTaxAmountToRefund)->setCodTaxAmountRefunded($codTaxAmountRefunded + $codTaxAmountToRefund);
return $this;
}
示例12: collect
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$store = $creditmemo->getStore();
$totalTax = 0;
$baseTotalTax = 0;
foreach ($creditmemo->getAllItems() as $item) {
if ($item->getOrderItem()->isDummy()) {
continue;
}
$orderItemQty = $item->getOrderItem()->getQtyOrdered();
$totalTax += $item->getWeeeTaxAppliedAmount() * $item->getQty();
$baseTotalTax += $item->getBaseWeeeTaxAppliedAmount() * $item->getQty();
$newApplied = array();
$applied = Mage::helper('weee')->getApplied($item);
foreach ($applied as $one) {
$one['base_row_amount'] = $one['base_amount'] * $item->getQty();
$one['row_amount'] = $one['amount'] * $item->getQty();
$one['base_row_amount_incl_tax'] = $one['base_amount_incl_tax'] * $item->getQty();
$one['row_amount_incl_tax'] = $one['amount_incl_tax'] * $item->getQty();
$newApplied[] = $one;
}
Mage::helper('weee')->setApplied($item, $newApplied);
$item->setWeeeTaxRowDisposition($item->getWeeeTaxDisposition() * $item->getQty());
$item->setBaseWeeeTaxRowDisposition($item->getBaseWeeeTaxDisposition() * $item->getQty());
}
if (Mage::helper('weee')->includeInSubtotal($store)) {
$creditmemo->setSubtotal($creditmemo->getSubtotal() + $totalTax);
$creditmemo->setBaseSubtotal($creditmemo->getBaseSubtotal() + $baseTotalTax);
} else {
$creditmemo->setTaxAmount($creditmemo->getTaxAmount() + $totalTax);
$creditmemo->setBaseTaxAmount($creditmemo->getBaseTaxAmount() + $baseTotalTax);
}
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $totalTax);
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $baseTotalTax);
return $this;
}
示例13: collect
//.........这里部分代码省略.........
$orderItemHiddenTax = $orderItem->getHiddenTaxInvoiced();
$baseOrderItemHiddenTax = $orderItem->getBaseHiddenTaxInvoiced();
$orderItemQty = $orderItem->getQtyInvoiced();
if (($orderItemTax || $orderItemHiddenTax) && $orderItemQty) {
/**
* Check item tax amount
*/
$tax = $orderItemTax - $orderItem->getTaxRefunded();
$baseTax = $baseOrderItemTax - $orderItem->getTaxRefunded();
$hiddenTax = $orderItemHiddenTax - $orderItem->getHiddenTaxRefunded();
$baseHiddenTax = $baseOrderItemHiddenTax - $orderItem->getBaseHiddenTaxRefunded();
if (!$item->isLast()) {
$availableQty = $orderItemQty - $orderItem->getQtyRefunded();
$tax = $creditmemo->roundPrice($tax / $availableQty * $item->getQty());
$baseTax = $creditmemo->roundPrice($baseTax / $availableQty * $item->getQty(), 'base');
$hiddenTax = $creditmemo->roundPrice($hiddenTax / $availableQty * $item->getQty());
$baseHiddenTax = $creditmemo->roundPrice($baseHiddenTax / $availableQty * $item->getQty(), 'base');
}
$item->setTaxAmount($tax);
$item->setBaseTaxAmount($baseTax);
$item->setHiddenTaxAmount($hiddenTax);
$item->setBaseHiddenTaxAmount($baseHiddenTax);
$totalTax += $tax;
$baseTotalTax += $baseTax;
$totalHiddenTax += $hiddenTax;
$baseTotalHiddenTax += $baseHiddenTax;
}
}
$invoice = $creditmemo->getInvoice();
if ($invoice) {
//recalculate tax amounts in case if refund shipping value was changed
if ($order->getBaseShippingAmount() && $creditmemo->getBaseShippingAmount()) {
$taxFactor = $creditmemo->getBaseShippingAmount() / $order->getBaseShippingAmount();
$shippingTaxAmount = $invoice->getShippingTaxAmount() * $taxFactor;
$baseShippingTaxAmount = $invoice->getBaseShippingTaxAmount() * $taxFactor;
$totalHiddenTax += $invoice->getShippingHiddenTaxAmount() * $taxFactor;
$baseTotalHiddenTax += $invoice->getBaseShippingHiddenTaxAmount() * $taxFactor;
$shippingHiddenTaxAmount = $invoice->getShippingHiddenTaxAmount() * $taxFactor;
$baseShippingHiddenTaxAmount = $invoice->getBaseShippingHiddenTaxAmount() * $taxFactor;
$shippingTaxAmount = $creditmemo->roundPrice($shippingTaxAmount);
$baseShippingTaxAmount = $creditmemo->roundPrice($baseShippingTaxAmount, 'base');
$totalHiddenTax = $creditmemo->roundPrice($totalHiddenTax);
$baseTotalHiddenTax = $creditmemo->roundPrice($baseTotalHiddenTax, 'base');
$shippingHiddenTaxAmount = $creditmemo->roundPrice($shippingHiddenTaxAmount);
$baseShippingHiddenTaxAmount = $creditmemo->roundPrice($baseShippingHiddenTaxAmount, 'base');
$totalTax += $shippingTaxAmount;
$baseTotalTax += $baseShippingTaxAmount;
}
} else {
$orderShippingAmount = $order->getShippingAmount();
$baseOrderShippingAmount = $order->getBaseShippingAmount();
$orderShippingHiddenTaxAmount = $order->getShippingHiddenTaxAmount();
$baseOrderShippingHiddenTaxAmount = $order->getBaseShippingHiddenTaxAmount();
$baseOrderShippingRefundedAmount = $order->getBaseShippingRefunded();
$baseOrderShippingHiddenTaxRefunded = $order->getBaseShippingHiddenTaxRefunded();
$shippingTaxAmount = 0;
$baseShippingTaxAmount = 0;
$shippingHiddenTaxAmount = 0;
$baseShippingHiddenTaxAmount = 0;
$shippingDelta = $baseOrderShippingAmount - $baseOrderShippingRefundedAmount;
if ($shippingDelta > $creditmemo->getBaseShippingAmount()) {
$part = $creditmemo->getShippingAmount() / $orderShippingAmount;
$basePart = $creditmemo->getBaseShippingAmount() / $baseOrderShippingAmount;
$shippingTaxAmount = $order->getShippingTaxAmount() * $part;
$baseShippingTaxAmount = $order->getBaseShippingTaxAmount() * $basePart;
$shippingHiddenTaxAmount = $order->getShippingHiddenTaxAmount() * $part;
$baseShippingHiddenTaxAmount = $order->getBaseShippingHiddenTaxAmount() * $basePart;
$shippingTaxAmount = $creditmemo->roundPrice($shippingTaxAmount);
$baseShippingTaxAmount = $creditmemo->roundPrice($baseShippingTaxAmount, 'base');
$shippingHiddenTaxAmount = $creditmemo->roundPrice($shippingHiddenTaxAmount);
$baseShippingHiddenTaxAmount = $creditmemo->roundPrice($baseShippingHiddenTaxAmount, 'base');
} elseif ($shippingDelta == $creditmemo->getBaseShippingAmount()) {
$shippingTaxAmount = $order->getShippingTaxAmount() - $order->getShippingTaxRefunded();
$baseShippingTaxAmount = $order->getBaseShippingTaxAmount() - $order->getBaseShippingTaxRefunded();
$shippingHiddenTaxAmount = $order->getShippingHiddenTaxAmount() - $order->getShippingHiddenTaxRefunded();
$baseShippingHiddenTaxAmount = $order->getBaseShippingHiddenTaxAmount() - $order->getBaseShippingHiddenTaxRefunded();
}
$totalTax += $shippingTaxAmount;
$baseTotalTax += $baseShippingTaxAmount;
$totalHiddenTax += $shippingHiddenTaxAmount;
$baseTotalHiddenTax += $baseShippingHiddenTaxAmount;
}
$allowedTax = $order->getTaxInvoiced() - $order->getTaxRefunded() - $creditmemo->getTaxAmount();
$allowedBaseTax = $order->getBaseTaxInvoiced() - $order->getBaseTaxRefunded() - $creditmemo->getBaseTaxAmount();
$allowedHiddenTax = $order->getHiddenTaxInvoiced() + $order->getShippingHiddenTaxAmount() - $order->getHiddenTaxRefunded() - $order->getShippingHiddenTaxRefunded();
$allowedBaseHiddenTax = $order->getBaseHiddenTaxInvoiced() + $order->getBaseShippingHiddenTaxAmount() - $order->getBaseHiddenTaxRefunded() - $order->getBaseShippingHiddenTaxRefunded();
$totalTax = min($allowedTax, $totalTax);
$baseTotalTax = min($allowedBaseTax, $baseTotalTax);
$totalHiddenTax = min($allowedHiddenTax, $totalHiddenTax);
$baseTotalHiddenTax = min($allowedBaseHiddenTax, $baseTotalHiddenTax);
$creditmemo->setTaxAmount($creditmemo->getTaxAmount() + $totalTax);
$creditmemo->setBaseTaxAmount($creditmemo->getBaseTaxAmount() + $baseTotalTax);
$creditmemo->setHiddenTaxAmount($totalHiddenTax);
$creditmemo->setBaseHiddenTaxAmount($baseTotalHiddenTax);
$creditmemo->setShippingTaxAmount($shippingTaxAmount);
$creditmemo->setBaseShippingTaxAmount($baseShippingTaxAmount);
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $totalTax + $totalHiddenTax);
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $baseTotalTax + $baseTotalHiddenTax);
return $this;
}
示例14: collect
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$creditmemo->setTaxAmount($creditmemo->getTaxAmount() + $creditmemo->getPaymentFeeTax());
$creditmemo->setBaseTaxAmount($creditmemo->getBaseTaxAmount() + $creditmemo->getBasePaymentFeeTax());
return $this;
}
示例15: collect
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$order = $creditmemo->getOrder();
$paymentMethod = $order->getPayment()->getMethod();
if ($this->getHelper()->isBillpayPayment($paymentMethod)) {
$action = Mage::app()->getRequest()->getActionName();
switch ($action) {
case 'updateQty':
case 'new':
$gross = $order->getBillpayChargedFee();
$net = $order->getBillpayChargedFeeNet();
$baseGross = $order->getBaseBillpayChargedFee();
$baseNet = $order->getBaseBillpayChargedFeeNet();
$refundable = $order->getBillpayChargedFee() - $order->getBillpayChargedFeeRefunded();
$baseRefundable = $order->getBaseBillpayChargedFee() - $order->getBaseBillpayChargedFeeRefunded();
$refundableTax = $refundable - ($order->getBillpayChargedFeeNet() - $order->getBillpayChargedFeeRefundedNet());
$baseRefundableTax = $baseRefundable - ($order->getBaseBillpayChargedFeeNet() - $order->getBaseBillpayChargedFeeRefundedNet());
// increase tax amount
$creditmemo->setTaxAmount($creditmemo->getTaxAmount() + $refundableTax);
$creditmemo->setBaseTaxAmount($creditmemo->getBaseTaxAmount() + $baseRefundableTax);
// increase grand total
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $refundable);
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $baseRefundable);
// We have to set the value for subtotal incl. tax here when a fee tax is present
// Otherwise the value will be calculated wrongly in Mage_Tax_Block_Sales_Order_Tax::_initSubtotal
if (!$creditmemo->getSubtotalInclTax() && $refundableTax > 0) {
$subtotalInclTax = $creditmemo->getSubtotal() + $creditmemo->getTaxAmount() - $creditmemo->getShippingTaxAmount() - $refundableTax;
$creditmemo->setSubtotalInclTax($subtotalInclTax);
}
break;
case 'save':
$data = Mage::app()->getRequest()->getPost('creditmemo');
if (isset($data)) {
if (array_key_exists('billpay_charged_fee_refund', $data)) {
$storeId = $creditmemo->getOrder()->getStore()->getStoreId();
$baseChargedFeeRefunded = Mage::app()->getStore()->roundPrice($data['billpay_charged_fee_refund']);
if ($baseChargedFeeRefunded < 0) {
Mage::throwException('Refunded billpay fee must not be smaller than zero');
}
$baseOrderGross = $order->getBaseBillpayChargedFee();
$baseOrderNet = $order->getBaseBillpayChargedFeeNet();
$orderGross = $order->getBillpayChargedFee();
$orderNet = $order->getBillpayChargedFeeNet();
$baseAllowedRefund = $baseOrderGross - $order->getBaseBillpayChargedFeeRefunded();
if ((string) (double) $baseChargedFeeRefunded > (string) (double) $baseAllowedRefund) {
$baseAllowedRefund = $order->formatBasePrice($baseAllowedRefund);
Mage::throwException("Maximum billpay fee amount to refund is: {$baseAllowedRefund}");
}
if ($baseOrderGross > 0 && $baseOrderNet > 0) {
if ($this->getHelper()->getConfigData('fee/display_incl_tax_admin', $storeId)) {
$part = $baseChargedFeeRefunded / $baseOrderGross;
$baseChargedFeeRefundedNet = Mage::app()->getStore()->roundPrice($baseOrderNet * $part);
} else {
$part = $baseChargedFeeRefunded / $baseOrderNet;
$baseChargedFeeRefundedNet = $baseChargedFeeRefunded;
$baseChargedFeeRefunded = Mage::app()->getStore()->roundPrice($baseOrderGross * $part);
}
$chargedFeeRefunded = Mage::app()->getStore()->roundPrice($orderGross * $part);
$chargedFeeRefundedNet = Mage::app()->getStore()->roundPrice($orderNet * $part);
$allowedRefund = $orderGross - $order->getBillpayChargedFeeRefunded();
$allowedRefundNet = $orderNet - $order->getBillpayChargedFeeRefundedNet();
if ($chargedFeeRefunded > $allowedRefund) {
$chargedFeeRefunded = $allowedRefund;
}
if ($chargedFeeRefundedNet > $allowedRefundNet) {
$chargedFeeRefundedNet = $allowedRefundNet;
}
$order->setBaseBillpayChargedFeeRefunded($order->getBaseBillpayChargedFeeRefunded() + $baseChargedFeeRefunded);
$order->setBaseBillpayChargedFeeRefundedNet($order->getBaseBillpayChargedFeeRefundedNet() + $baseChargedFeeRefundedNet);
$order->setBillpayChargedFeeRefunded($order->getBillpayChargedFeeRefunded() + $chargedFeeRefunded);
$order->setBillpayChargedFeeRefundedNet($order->getBillpayChargedFeeRefundedNet() + $chargedFeeRefundedNet);
$creditmemo->setBillpayChargedFeeRefunded($chargedFeeRefunded);
$creditmemo->setBillpayChargedFeeRefundedNet($chargedFeeRefundedNet);
$creditmemo->setBaseBillpayChargedFeeRefunded($baseChargedFeeRefunded);
$creditmemo->setBaseBillpayChargedFeeRefundedNet($baseChargedFeeRefundedNet);
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $baseChargedFeeRefunded);
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $chargedFeeRefunded);
$creditmemo->setTaxAmount($creditmemo->getTaxAmount() + ($chargedFeeRefunded - $chargedFeeRefundedNet));
$creditmemo->setBaseTaxAmount($creditmemo->getBaseTaxAmount() + ($baseChargedFeeRefunded - $baseChargedFeeRefundedNet));
}
}
}
break;
}
}
return $this;
}