本文整理汇总了PHP中Mage_Sales_Model_Order_Creditmemo::setBaseGrandTotal方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Order_Creditmemo::setBaseGrandTotal方法的具体用法?PHP Mage_Sales_Model_Order_Creditmemo::setBaseGrandTotal怎么用?PHP Mage_Sales_Model_Order_Creditmemo::setBaseGrandTotal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Order_Creditmemo
的用法示例。
在下文中一共展示了Mage_Sales_Model_Order_Creditmemo::setBaseGrandTotal方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: collect
/**
* Collect snap gift card account totals for credit memo
*
* @param Mage_Sales_Model_Order_Creditmemo $creditmemo
* @return $this
*/
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$order = $creditmemo->getOrder();
if ($order->getBaseSnapCardsAmount() && $order->getBaseSnapCardsInvoiced() != 0) {
$gcaLeft = $order->getBaseSnapCardsInvoiced() - $order->getBaseSnapCardsRefunded();
$used = 0;
$baseUsed = 0;
if ($gcaLeft >= $creditmemo->getBaseGrandTotal()) {
$baseUsed = $creditmemo->getBaseGrandTotal();
$used = $creditmemo->getGrandTotal();
$creditmemo->setBaseGrandTotal(0);
$creditmemo->setGrandTotal(0);
$creditmemo->setAllowZeroGrandTotal(true);
} else {
$baseUsed = $order->getBaseSnapCardsInvoiced() - $order->getBaseSnapCardsRefunded();
$used = $order->getSnapCardsInvoiced() - $order->getSnapCardsRefunded();
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() - $baseUsed);
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() - $used);
}
$creditmemo->setBaseSnapCardsAmount($baseUsed);
$creditmemo->setSnapCardsAmount($used);
}
$creditmemo->setBaseCustomerBalanceReturnMax($creditmemo->getBaseCustomerBalanceReturnMax() + $creditmemo->getBaseSnapCardsAmount());
$creditmemo->setCustomerBalanceReturnMax($creditmemo->getCustomerBalanceReturnMax() + $creditmemo->getSnapCardsAmount());
$creditmemo->setCustomerBalanceReturnMax($creditmemo->getCustomerBalanceReturnMax() + $creditmemo->getGrandTotal());
return $this;
}
示例2: collect
/**
* Collect reward totals for credit memo
*
* @param Mage_Sales_Model_Order_Creditmemo $creditmemo
* @return Enterprise_Reward_Model_Total_Creditmemo_Reward
*/
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$order = $creditmemo->getOrder();
$rewardCurrecnyAmountLeft = $order->getRewardCurrencyAmountInvoiced() - $order->getRewardCurrencyAmountRefunded();
$baseRewardCurrecnyAmountLeft = $order->getBaseRewardCurrencyAmountInvoiced() - $order->getBaseRewardCurrencyAmountRefunded();
if ($order->getBaseRewardCurrencyAmount() && $baseRewardCurrecnyAmountLeft > 0) {
if ($baseRewardCurrecnyAmountLeft >= $creditmemo->getBaseGrandTotal()) {
$rewardCurrecnyAmountLeft = $creditmemo->getGrandTotal();
$baseRewardCurrecnyAmountLeft = $creditmemo->getBaseGrandTotal();
$creditmemo->setGrandTotal(0);
$creditmemo->setBaseGrandTotal(0);
$creditmemo->setAllowZeroGrandTotal(true);
} else {
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() - $rewardCurrecnyAmountLeft);
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() - $baseRewardCurrecnyAmountLeft);
}
$pointValue = $order->getRewardPointsBalance() / $order->getBaseRewardCurrencyAmount();
$rewardPointsBalance = $baseRewardCurrecnyAmountLeft * ceil($pointValue);
$rewardPointsBalanceLeft = $order->getRewardPointsBalance() - $order->getRewardPointsBalanceRefunded();
if ($rewardPointsBalance > $rewardPointsBalanceLeft) {
$rewardPointsBalance = $rewardPointsBalanceLeft;
}
$creditmemo->setRewardPointsBalance($rewardPointsBalance);
$creditmemo->setRewardCurrencyAmount($rewardCurrecnyAmountLeft);
$creditmemo->setBaseRewardCurrencyAmount($baseRewardCurrecnyAmountLeft);
}
return $this;
}
示例3: collect
/**
* Collect customer balance totals for credit memo
*
* @param Mage_Sales_Model_Order_Creditmemo $creditmemo
* @return Enterprise_CustomerBalance_Model_Total_Creditmemo_Customerbalance
*/
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$creditmemo->setBsCustomerBalTotalRefunded(0);
$creditmemo->setCustomerBalTotalRefunded(0);
$creditmemo->setBaseCustomerBalanceReturnMax(0);
$creditmemo->setCustomerBalanceReturnMax(0);
if (!Mage::helper('enterprise_customerbalance')->isEnabled()) {
return $this;
}
$order = $creditmemo->getOrder();
if ($order->getBaseCustomerBalanceAmount() && $order->getBaseCustomerBalanceInvoiced() != 0) {
$cbLeft = $order->getBaseCustomerBalanceInvoiced() - $order->getBaseCustomerBalanceRefunded();
$used = 0;
$baseUsed = 0;
if ($cbLeft >= $creditmemo->getBaseGrandTotal()) {
$baseUsed = $creditmemo->getBaseGrandTotal();
$used = $creditmemo->getGrandTotal();
$creditmemo->setBaseGrandTotal(0);
$creditmemo->setGrandTotal(0);
$creditmemo->setAllowZeroGrandTotal(true);
} else {
$baseUsed = $order->getBaseCustomerBalanceInvoiced() - $order->getBaseCustomerBalanceRefunded();
$used = $order->getCustomerBalanceInvoiced() - $order->getCustomerBalanceRefunded();
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() - $baseUsed);
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() - $used);
}
$creditmemo->setBaseCustomerBalanceAmount($baseUsed);
$creditmemo->setCustomerBalanceAmount($used);
}
$creditmemo->setBaseCustomerBalanceReturnMax($creditmemo->getBaseCustomerBalanceReturnMax() + $creditmemo->getBaseGrandTotal());
$creditmemo->setBaseCustomerBalanceReturnMax($creditmemo->getBaseCustomerBalanceReturnMax() + $creditmemo->getBaseCustomerBalanceAmount());
$creditmemo->setCustomerBalanceReturnMax($creditmemo->getCustomerBalanceReturnMax() + $creditmemo->getCustomerBalanceAmount());
return $this;
}
示例4: collect
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$order = $creditmemo->getOrder();
$amount = number_format($order->getGiftCardValue(), 2);
if ($amount) {
if ($creditmemo->getGrandTotal() - $amount < 0) {
$creditmemo->setGrandTotal(number_format(0.0));
$creditmemo->setBaseGrandTotal(number_format(0.0));
} else {
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() - $amount);
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() - $amount);
}
}
return $this;
}
示例5: collect
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
if (!$creditmemo->getInvoice() || !$creditmemo->getInvoice()->getId()) {
return;
}
$order = $creditmemo->getOrder();
if ($order->getWebposCash() < 0.0001 || $order->getGrandTotal() < 0.0001) {
return;
}
$ratio = $creditmemo->getGrandTotal() / $order->getGrandTotal();
$cash = $order->getWebposCash() * $ratio;
$baseCash = $order->getWebposBaseCash() * $ratio;
$maxcash = $order->getWebposCash();
$maxbaseCash = $order->getWebposBaseCash();
foreach ($order->getCreditmemosCollection() as $existedCreditmemo) {
if ($maxcash > 0.0001) {
$maxcash -= $existedCreditmemo->getWebposCash();
$maxbaseCash -= $existedCreditmemo->getWebposBaseCash();
}
}
if ($cash > $maxcash) {
$cash = $maxcash;
$baseCash = $maxbaseCash;
}
if ($cash > 0.0001) {
$creditmemo->setWebposCash($cash)->setWebposBaseCash($baseCash);
if ($creditmemo->getGrandTotal() <= $cash) {
$creditmemo->setBaseGrandTotal(0.0)->setGrandTotal(0.0);
} else {
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() - $cash)->setBaseGrandTotal($creditmemo->getBaseGrandTotal() - $baseCash);
}
}
}
示例6: collect
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$order = $creditmemo->getOrder();
$allowedAmount = $order->getShippingAmount() - $order->getShippingRefunded();
$baseAllowedAmount = $order->getBaseShippingAmount() - $order->getBaseShippingRefunded();
/**
* Check if shipping amount was specified (from invoice or another source).
* Using has magic method to allow setting 0 as shipping amount.
*/
if ($creditmemo->hasBaseShippingAmount()) {
$baseShippingAmount = Mage::app()->getStore()->roundPrice($creditmemo->getBaseShippingAmount());
if ($baseShippingAmount < $baseAllowedAmount) {
$shippingAmount = $allowedAmount * $baseShippingAmount / $baseAllowedAmount;
$shippingAmount = Mage::app()->getStore()->roundPrice($shippingAmount);
} elseif ($baseShippingAmount == $baseAllowedAmount) {
$shippingAmount = $allowedAmount;
} else {
$baseAllowedAmount = $order->formatBasePrice($baseAllowedAmount);
Mage::throwException(Mage::helper('sales')->__('Maximum shipping amount allowed to refound is: %s', $baseAllowedAmount));
}
} else {
$baseShippingAmount = $baseAllowedAmount;
$shippingAmount = $allowedAmount;
}
$creditmemo->setShippingAmount($shippingAmount);
$creditmemo->setBaseShippingAmount($baseShippingAmount);
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $shippingAmount);
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $baseShippingAmount);
return $this;
}
示例7: collect
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$order = $creditmemo->getOrder();
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $order->getDesconto());
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $order->getBaseDesconto());
return $this;
}
示例8: 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;
}
示例9: 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;
}
示例10: 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;
}
示例11: collect
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$creditmemo->setGomageGiftWrapAmount(0);
$creditmemo->setBaseGomageGiftWrapAmount(0);
$order = $creditmemo->getOrder();
$totalGomageGiftWrapAmount = 0;
$baseTotalGomageGiftWrapAmount = 0;
foreach ($creditmemo->getAllItems() as $item) {
if ($item->getOrderItem()->isDummy()) {
continue;
}
$orderItemGomageGiftWrap = (double) $item->getOrderItem()->getGomageGiftWrapAmount();
$baseOrderItemGomageGiftWrap = (double) $item->getOrderItem()->getBaseGomageGiftWrapAmount();
$orderItemQty = $item->getOrderItem()->getQtyOrdered();
if ($orderItemGomageGiftWrap && $orderItemQty) {
$GomageGiftWrap = $orderItemGomageGiftWrap * $item->getQty() / $orderItemQty;
$baseGomageGiftWrap = $baseOrderItemGomageGiftWrap * $item->getQty() / $orderItemQty;
$GomageGiftWrap = $creditmemo->getStore()->roundPrice($GomageGiftWrap);
$baseGomageGiftWrap = $creditmemo->getStore()->roundPrice($baseGomageGiftWrap);
$item->setGomageGiftWrapAmount($GomageGiftWrap);
$item->setBaseGomageGiftWrapAmount($baseGomageGiftWrap);
$totalGomageGiftWrapAmount += $GomageGiftWrap;
$baseTotalGomageGiftWrapAmount += $baseGomageGiftWrap;
}
}
$creditmemo->setGomageGiftWrapAmount($totalGomageGiftWrapAmount);
$creditmemo->setBaseGomageGiftWrapAmount($baseTotalGomageGiftWrapAmount);
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $totalGomageGiftWrapAmount);
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $baseTotalGomageGiftWrapAmount);
return $this;
}
示例12: collect
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$baseDiscount = 0;
$discount = 0;
$order = $creditmemo->getOrder();
$baseOrderDiscount = $order->getBaseAffiliateCredit();
$orderDiscount = $order->getAffiliateCredit();
if ($creditmemo->getBaseGrandTotal() < 0.0001 || $baseOrderDiscount >= 0) {
return $this;
}
$baseInvoicedDiscount = 0;
$invoicedDiscount = 0;
foreach ($order->getCreditmemosCollection() as $_creditmemo) {
$baseInvoicedDiscount += $_creditmemo->getBaseAffiliateCredit();
$invoicedDiscount += $_creditmemo->getAffiliateCredit();
}
$baseOrderTotal = $order->getBaseGrandTotal() - $baseOrderDiscount;
$baseDiscount = $baseOrderDiscount * $creditmemo->getBaseGrandTotal() / $baseOrderTotal;
$discount = $orderDiscount * $creditmemo->getBaseGrandTotal() / $baseOrderTotal;
if ($baseDiscount < $baseOrderDiscount) {
$baseDiscount = $baseOrderDiscount;
$discount = $orderDiscount;
}
if ($baseDiscount) {
$baseDiscount = Mage::app()->getStore()->roundPrice($baseDiscount);
$discount = Mage::app()->getStore()->roundPrice($discount);
$creditmemo->setBaseAffiliateCredit($baseDiscount);
$creditmemo->setAffiliateCredit($discount);
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $baseDiscount);
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $discount);
$creditmemo->setAllowZeroGrandTotal(true);
}
return $this;
}
示例13: collect
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$creditmemo->setDiscountAmount(0);
$creditmemo->setBaseDiscountAmount(0);
$totalDiscountAmount = 0;
$baseTotalDiscountAmount = 0;
foreach ($creditmemo->getAllItems() as $item) {
$orderItemDiscount = (double) $item->getOrderItem()->getDiscountAmount();
$baseOrderItemDiscount = (double) $item->getOrderItem()->getBaseDiscountAmount();
$orderItemQty = $item->getOrderItem()->getQtyOrdered();
if ($orderItemDiscount && $orderItemQty) {
$discount = $orderItemDiscount * $item->getQty() / $orderItemQty;
$baseDiscount = $baseOrderItemDiscount * $item->getQty() / $orderItemQty;
$discount = $creditmemo->getStore()->roundPrice($discount);
$baseDiscount = $creditmemo->getStore()->roundPrice($baseDiscount);
$item->setDiscountAmount($discount);
$item->setBaseDiscountAmount($baseDiscount);
$totalDiscountAmount += $discount;
$baseTotalDiscountAmount += $baseDiscount;
}
}
$creditmemo->setDiscountAmount($totalDiscountAmount);
$creditmemo->setBaseDiscountAmount($baseTotalDiscountAmount);
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() - $totalDiscountAmount);
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() - $baseTotalDiscountAmount);
return $this;
}
示例14: collect
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$baseDiscount = 0;
$discount = 0;
foreach ($creditmemo->getAllItems() as $item) {
if ($item->getOrderItem()->isDummy()) {
continue;
}
$orderItem = $item->getOrderItem();
$orderItemDiscount = (double) $orderItem->getAffiliateplusAmount();
$baseOrderItemDiscount = (double) $orderItem->getBaseAffiliateplusAmount();
$orderItemQty = $orderItem->getQtyOrdered();
if ($orderItemDiscount && $orderItemQty) {
$discount -= $orderItemDiscount * $item->getQty() / $orderItemQty;
$baseDiscount -= $baseOrderItemDiscount * $item->getQty() / $orderItemQty;
}
}
if (!floatval($baseDiscount)) {
$order = $creditmemo->getOrder();
$baseDiscount = $order->getBaseAffiliateplusDiscount();
$discount = $order->getAffiliateplusDiscount();
}
if (floatval($baseDiscount)) {
$baseDiscount = Mage::app()->getStore()->roundPrice($baseDiscount);
$discount = Mage::app()->getStore()->roundPrice($discount);
$creditmemo->setBaseAffiliateplusDiscount($baseDiscount);
$creditmemo->setAffiliateplusDiscount($discount);
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $baseDiscount);
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $discount);
}
return $this;
}
示例15: 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;
}