本文整理汇总了PHP中Mage_Sales_Model_Order_Creditmemo::setTaxAmount方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Order_Creditmemo::setTaxAmount方法的具体用法?PHP Mage_Sales_Model_Order_Creditmemo::setTaxAmount怎么用?PHP Mage_Sales_Model_Order_Creditmemo::setTaxAmount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Order_Creditmemo
的用法示例。
在下文中一共展示了Mage_Sales_Model_Order_Creditmemo::setTaxAmount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: collect
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$totalTax = 0;
$baseTotalTax = 0;
foreach ($creditmemo->getAllItems() as $item) {
$orderItemTax = $item->getOrderItem()->getTaxAmount();
$baseOrderItemTax = $item->getOrderItem()->getBaseTaxAmount();
$orderItemQty = $item->getOrderItem()->getQtyOrdered();
if ($orderItemTax && $orderItemQty) {
$tax = $orderItemTax * $item->getQty() / $orderItemQty;
$baseTax = $baseOrderItemTax * $item->getQty() / $orderItemQty;
$tax = $creditmemo->getStore()->roundPrice($tax);
$baseTax = $creditmemo->getStore()->roundPrice($baseTax);
$item->setTaxAmount($tax);
$item->setBaseTaxAmount($baseTax);
$totalTax += $tax;
$baseTotalTax += $baseTax;
}
}
$creditmemo->setTaxAmount($totalTax);
$creditmemo->setBaseTaxAmount($baseTotalTax);
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $totalTax);
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $baseTotalTax);
return $this;
}
示例3: 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;
}
示例4: collect
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$shippingTaxAmount = 0;
$baseShippingTaxAmount = 0;
$totalTax = 0;
$baseTotalTax = 0;
foreach ($creditmemo->getAllItems() as $item) {
if ($item->getOrderItem()->isDummy()) {
continue;
}
$orderItemTax = $item->getOrderItem()->getTaxAmount();
$baseOrderItemTax = $item->getOrderItem()->getBaseTaxAmount();
$orderItemQty = $item->getOrderItem()->getQtyOrdered();
if ($orderItemTax && $orderItemQty) {
$tax = $orderItemTax * $item->getQty() / $orderItemQty;
$baseTax = $baseOrderItemTax * $item->getQty() / $orderItemQty;
$tax = $creditmemo->getStore()->roundPrice($tax);
$baseTax = $creditmemo->getStore()->roundPrice($baseTax);
$item->setTaxAmount($tax);
$item->setBaseTaxAmount($baseTax);
$totalTax += $tax;
$baseTotalTax += $baseTax;
}
}
if ($invoice = $creditmemo->getInvoice()) {
$totalTax += $invoice->getShippingTaxAmount();
$baseTotalTax += $invoice->getBaseShippingTaxAmount();
$creditmemo->setShippingTaxAmount($invoice->getShippingTaxAmount());
$creditmemo->setBaseShippingTaxAmount($invoice->getBaseShippingTaxAmount());
} else {
$shippingAmount = $creditmemo->getOrder()->getBaseShippingAmount();
$shippingRefundedAmount = $creditmemo->getOrder()->getBaseShippingRefunded();
$shippingTaxAmount = 0;
$baseShippingTaxAmount = 0;
if ($shippingAmount - $shippingRefundedAmount > $creditmemo->getShippingAmount()) {
$shippingTaxAmount = $creditmemo->getShippingAmount() * ($creditmemo->getOrder()->getShippingTaxAmount() / $shippingAmount);
$baseShippingTaxAmount = $creditmemo->getBaseShippingAmount() * ($creditmemo->getOrder()->getBaseShippingTaxAmount() / $shippingAmount);
$shippingTaxAmount = $creditmemo->getStore()->roundPrice($shippingTaxAmount);
$baseShippingTaxAmount = $creditmemo->getStore()->roundPrice($baseShippingTaxAmount);
} elseif ($shippingAmount - $shippingRefundedAmount == $creditmemo->getShippingAmount()) {
$shippingTaxAmount = $creditmemo->getOrder()->getShippingTaxAmount() - $creditmemo->getOrder()->getShippingTaxRefunded();
$baseShippingTaxAmount = $creditmemo->getOrder()->getBaseShippingTaxAmount() - $creditmemo->getOrder()->getBaseShippingTaxRefunded();
}
$totalTax += $shippingTaxAmount;
$baseTotalTax += $baseShippingTaxAmount;
}
$tmpBaseTotalTax = $baseTotalTax - ($creditmemo->getOrder()->getBaseTaxRefunded() - $creditmemo->getOrder()->getBaseShippingTaxRefunded());
if ($tmpBaseTotalTax < 0) {
$baseTotalTax = 0;
$totalTax = 0;
}
$creditmemo->setTaxAmount($totalTax);
$creditmemo->setBaseTaxAmount($baseTotalTax);
$creditmemo->setShippingTaxAmount($shippingTaxAmount);
$creditmemo->setBaseShippingTaxAmount($baseShippingTaxAmount);
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $totalTax);
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $baseTotalTax);
return $this;
}
示例5: 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;
}
示例6: 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;
}
示例7: 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;
}
示例8: 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;
}
示例9: 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;
}
示例10: 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;
}
示例11: 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;
}
示例12: 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;
}
示例13: 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;
}
示例14: 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;
}
示例15: collect
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$shippingTaxAmount = 0;
$baseShippingTaxAmount = 0;
$totalTax = 0;
$baseTotalTax = 0;
$totalHiddenTax = 0;
$baseTotalHiddenTax = 0;
$order = $creditmemo->getOrder();
foreach ($creditmemo->getAllItems() as $item) {
if ($item->getOrderItem()->isDummy()) {
continue;
}
$orderItem = $item->getOrderItem();
$orderItemTax = $item->getOrderItem()->getTaxAmount();
$baseOrderItemTax = $item->getOrderItem()->getBaseTaxAmount();
$orderItemQty = $item->getOrderItem()->getQtyOrdered();
if ($orderItemTax && $orderItemQty) {
/**
* Check item tax amount
*/
if ($item->isLast()) {
$tax = $orderItemTax - $item->getOrderItem()->getTaxRefunded() - $item->getOrderItem()->getTaxCanceled();
$baseTax = $baseOrderItemTax - $item->getOrderItem()->getTaxRefunded() - $item->getOrderItem()->getTaxCanceled();
$hiddenTax = $orderItem->getHiddenTaxAmount() - $orderItem->getHiddenTaxRefunded() - $item->getOrderItem()->getHiddenTaxCanceled();
$baseHiddenTax = $orderItem->getBaseHiddenTaxAmount() - $orderItem->getBaseHiddenTaxRefunded() - $item->getOrderItem()->getHiddenTaxCanceled();
} else {
$tax = $orderItemTax * $item->getQty() / $orderItemQty;
$baseTax = $baseOrderItemTax * $item->getQty() / $orderItemQty;
$hiddenTax = $orderItem->getHiddenTaxAmount() * $item->getQty() / $orderItemQty;
$baseHiddenTax = $orderItem->getBaseHiddenTaxAmount() * $item->getQty() / $orderItemQty;
$tax = $creditmemo->getStore()->roundPrice($tax);
$baseTax = $creditmemo->getStore()->roundPrice($baseTax);
$hiddenTax = $creditmemo->getStore()->roundPrice($hiddenTax);
$baseHiddenTax = $creditmemo->getStore()->roundPrice($baseHiddenTax);
}
$item->setTaxAmount($tax);
$item->setBaseTaxAmount($baseTax);
$item->setHiddenTaxAmount($hiddenTax);
$item->setBaseHiddenTaxAmount($baseHiddenTax);
$totalTax += $tax;
$baseTotalTax += $baseTax;
$totalHiddenTax += $hiddenTax;
$baseTotalHiddenTax += $baseHiddenTax;
}
}
if ($invoice = $creditmemo->getInvoice()) {
$totalTax += $invoice->getShippingTaxAmount();
$baseTotalTax += $invoice->getBaseShippingTaxAmount();
$totalHiddenTax += $invoice->getShippingHiddenTaxAmount();
$baseTotalHiddenTax += $invoice->getBaseShippingHiddenTaxAmount();
$shippingTaxAmount = $invoice->getShippingTaxAmount();
$baseShippingTaxAmount = $invoice->getBaseShippingTaxAmount();
$shippingHiddenTaxAmount = $invoice->getShippingHiddenTaxAmount();
$baseShippingHiddenTaxAmount = $invoice->getBaseShippingHiddenTaxAmount();
} 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;
if ($baseOrderShippingAmount - $baseOrderShippingRefundedAmount > $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->getStore()->roundPrice($shippingTaxAmount);
$baseShippingTaxAmount = $creditmemo->getStore()->roundPrice($baseShippingTaxAmount);
$shippingHiddenTaxAmount = $creditmemo->getStore()->roundPrice($shippingHiddenTaxAmount);
$baseShippingHiddenTaxAmount = $creditmemo->getStore()->roundPrice($baseShippingHiddenTaxAmount);
} elseif ($baseOrderShippingAmount - $baseOrderShippingRefundedAmount == $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->getTaxAmount() - $order->getTaxRefunded();
$allowedBaseTax = $order->getBaseTaxAmount() - $order->getBaseTaxRefunded();
$allowedHiddenTax = $order->getHiddenTaxAmount() + $order->getShippingHiddenTaxAmount() - $order->getHiddenTaxRefunded() - $order->getShippingHiddenTaxRefunded();
$allowedBaseHiddenTax = $order->getBaseHiddenTaxAmount() + $order->getBaseShippingHiddenTaxAmount() - $order->getBaseHiddenTaxRefunded() - $order->getBaseShippingHiddenTaxRefunded();
$totalTax = min($allowedTax, $totalTax);
$baseTotalTax = min($allowedBaseTax, $baseTotalTax);
$totalHiddenTax = min($allowedHiddenTax, $totalHiddenTax);
$baseTotalHiddenTax = min($allowedBaseHiddenTax, $baseTotalHiddenTax);
$creditmemo->setTaxAmount($totalTax);
$creditmemo->setBaseTaxAmount($baseTotalTax);
$creditmemo->setHiddenTaxAmount($totalHiddenTax);
$creditmemo->setBaseHiddenTaxAmount($baseTotalHiddenTax);
//.........这里部分代码省略.........