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; }
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; }
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo) { $creditmemo->setWebposGiftwrapAmount(0); $orderGiftwrapAmount = $creditmemo->getOrder()->getWebposGiftwrapAmount(); $baseOrderShippingAmount = $creditmemo->getOrder()->getWebposGiftwrapAmount(); if ($orderGiftwrapAmount) { $creditmemo->setWebposGiftwrapAmount($orderGiftwrapAmount); $creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $orderGiftwrapAmount); $creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $orderGiftwrapAmount); } return $this; }
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo) { $creditmemo->setPaymentCharge(0); $creditmemo->setBasePaymentCharge(0); $amount = $creditmemo->getOrder()->getPaymentCharge(); $creditmemo->setPaymentCharge($amount); $amount = $creditmemo->getOrder()->getBasePaymentCharge(); $creditmemo->setBasePaymentCharge($amount); $creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $creditmemo->getPaymentCharge()); $creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $creditmemo->getBasePaymentCharge()); return $this; }
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); } } }
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; }
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; }
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; }
/** * 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; }
/** * 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; }
/** * Save order in AvaTax system * * @see OnePica_AvaTax_Model_Observer_SalesOrderCreditmemoSaveAfter::execute() * @param Mage_Sales_Model_Order_Creditmemo $creditmemo * @param OnePica_AvaTax_Model_Records_Queue $queue * @return mixed * @throws OnePica_AvaTax_Exception * @throws OnePica_AvaTax_Model_Service_Exception_Commitfailure * @throws OnePica_AvaTax_Model_Service_Exception_Unbalanced */ public function process($creditmemo, $queue) { $order = $creditmemo->getOrder(); $storeId = $order->getStoreId(); $this->setStoreId($storeId); $shippingAddress = $order->getShippingAddress() ? $order->getShippingAddress() : $order->getBillingAddress(); if (!$shippingAddress) { throw new OnePica_AvaTax_Exception($this->_getHelper()->__('There is no address attached to this order')); } /** @var OnePica_AvaTax_Model_Service_Result_Creditmemo $creditmemoResult */ $creditmemoResult = $this->_getService()->creditmemo($creditmemo, $queue); //if successful if (!$creditmemoResult->getHasError()) { $message = $this->_getHelper()->__('Credit memo #%s was saved to AvaTax', $creditmemoResult->getDocumentCode()); $this->_getHelper()->addStatusHistoryComment($order, $message); $totalTax = $creditmemoResult->getTotalTax(); if ($totalTax != $creditmemo->getBaseTaxAmount() * -1) { throw new OnePica_AvaTax_Model_Service_Exception_Unbalanced('Collected: ' . $creditmemo->getTaxAmount() . ', Actual: ' . $totalTax); } //if not successful } else { $messages = $creditmemoResult->getErrors(); throw new OnePica_AvaTax_Model_Service_Exception_Commitfailure(implode(' // ', $messages)); } return true; }
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; }
public function collect(Mage_Sales_Model_Order_Creditmemo $cm) { $order = $cm->getOrder(); if ($order->getPayment()->getMethodInstance()->getCode() != 'cashondelivery') { return $this; } $baseCmTotal = $cm->getBaseGrandTotal(); $cmTotal = $cm->getGrandTotal(); $baseCodFeeCredited = $order->getBaseCodFeeCredited(); $codFeeCredited = $order->getCodFeeCredited(); $baseCodFeeInvoiced = $order->getBaseCodFeeInvoiced(); $codFeeInvoiced = $order->getCodFeeInvoiced(); if ($cm->getInvoice()) { $invoice = $cm->getInvoice(); $baseCodFeeToCredit = $invoice->getBaseCodFee(); $codFeeToCredit = $invoice->getCodFee(); } else { $baseCodFeeToCredit = $baseCodFeeInvoiced; $codFeeToCredit = $codFeeInvoiced; } if (!$baseCodFeeToCredit > 0) { return $this; } // Subtracting invoiced COD fee from Credit memo total //$cm->setBaseGrandTotal($baseCmTotal-$baseCodFeeToCredit); //$cm->setGrandTotal($cmTotal-$codFeeToCredit); //$cm->setBaseCodFee($baseCodFeeToCredit); //$cm->setCodFee($codFeeToCredit); //$order->setBaseCodFeeCredited($baseCodFeeCredited+$baseCodFeeToCredit); //$order->setCodFeeCredited($codFeeCredited+$baseCodFeeToCredit); return $this; }
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; }
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo) { $order = $creditmemo->getOrder(); $invoice = $order->getInvoiceCollection()->getFirstItem(); $payment = $order->getPayment(); $paymentMethod = $payment->getMethod(); if ($this->getHelper()->isBillpayRatPayment($paymentMethod)) { $info = $payment->getMethodInstance()->getInfoInstance(); // Temporary set creditmemo amount to current amount (will be overriden after partialCancel-request was successful) $creditmemo->setBillpayRateSurcharge($info->getBillpayRateSurcharge()); $creditmemo->setBillpayRateFee($info->getBillpayRateFee()); $creditmemo->setBillpayRateFeeNet($info->getBillpayRateFeeNet()); $creditmemo->setBillpayRateTotalAmount($info->getBillpayRateTotalAmount()); $creditmemo->setBillpayRateFeeTax($info->getBillpayRateFeeTax()); // TODO: ... /*if ($diff < 0 && -$diff = $feeTaxAmount) { // must be a full cancel $creditmemo->setGrandTotal($creditmemo->getGrandTotal() - $feeTaxAmount); } else if ($diff == 0) { $creditmemo->setTaxAmount($creditmemo->getTaxAmount() + $feeTaxAmount); } $diffBase = $order->getBaseGrandTotal() - $order->getBaseTotalRefunded() - $creditmemo->getBaseGrandTotal(); if ($diffBase < 0 && -$diffBase = $feeTaxAmount) { // must be a full cancel $creditmemo->setBaseGrandTotal($creditmemo->getGrandTotal() - $feeTaxAmount); } else if ($diff == 0) { $creditmemo->setBaseTaxAmount($creditmemo->getBaseTaxAmount() + $feeTaxAmount); }*/ } return $this; }
/** * 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; }
/** * 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; }
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo) { $amount = $this->_giftWrapAmount($creditmemo->getOrder()); $creditmemo->setGiftWrapAmount($amount); $creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $amount); $creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $amount); return $this; }
public function collect(Mage_Sales_Model_Order_Creditmemo $invoice) { $order = $invoice->getOrder(); $myTotal = $order->getJurosAmount(); $baseMyTotal = $order->getBaseJurosAmount(); $invoice->setGrandTotal($invoice->getGrandTotal() + $myTotal); $invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() + $baseMyTotal); return $this; }
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; }
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo) { if (!$creditmemo->getInvoice() || !$creditmemo->getInvoice()->getId()) { return; } $order = $creditmemo->getOrder(); if ($order->getWebposChange() < 0.0001) { return; } $creditmemo->setWebposChange($order->getWebposChange())->setWebposBaseChange($order->getWebposBaseChange()); }
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo) { return $this; $order = $creditmemo->getOrder(); $orderDiscountTotal = $order->getDiscountTotal(); if ($orderDiscountTotal) { $creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $orderDiscountTotal); $creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $orderDiscountTotal); } return $this; }
/** * 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; }
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo) { $creditmemo->setWebposDiscountAmount(0); $orderWebposDiscount = $creditmemo->getOrder()->getWebposDiscountAmount(); if ($orderWebposDiscount) { $creditmemo->setWebposDiscountAmount($orderWebposDiscount); $creditmemo->setGrandTotal($creditmemo->getGrandTotal() - $orderWebposDiscount); $creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() - $orderWebposDiscount); } return $this; }
public function collect(Mage_Sales_Model_Order_Creditmemo $invoice) { $order = $invoice->getOrder(); $amount = $order->getMspCashondelivery(); $baseAmount = $order->getMspBaseCashondelivery(); $invoice->setGrandTotal($invoice->getGrandTotal() + $amount); $invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() + $baseAmount); $invoice->setMspCashondelivery($amount); $invoice->setMspBaseCashondelivery($baseAmount); return $this; }
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo) { $order = $creditmemo->getOrder(); $baseDiscount = $order->getBaseLuckydrawDiscount(); $discount = $order->getLuckydrawDiscount(); if (floatval($baseDiscount)) { $creditmemo->setBaseLuckydrawDiscount($baseDiscount); $creditmemo->setLuckydrawDiscount($discount); $creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $baseDiscount); $creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $discount); } return $this; }
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->setGrandTotal($creditmemo->getGrandTotal() + $feeAmountLeft); $creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $basefeeAmountLeft); $creditmemo->setFeeAmount($feeAmountLeft); $creditmemo->setBaseFeeAmount($basefeeAmountLeft); } return $this; }
/** * Collect reward total for invoice * * @param Mage_Sales_Model_Order_Creditmemo $creditmemo * @return Rewards_Model_Sales_Invoice_Total */ public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo) { $order = $creditmemo->getOrder(); if (!$order->getHasSpentPoints()) { return $this; } list($acc_diff, $acc_diff_base) = $this->getAccumulatedDiscounts($order); //@nelkaake -a 12/01/11: This will help us make sure we never go below $0 $acc_diff = min($acc_diff, $creditmemo->getGrandTotal()); $acc_diff_base = min($acc_diff_base, $creditmemo->getBaseGrandTotal()); $creditmemo->setGrandTotal($creditmemo->getGrandTotal() - $acc_diff); $creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() - $acc_diff_base); return $this; }
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo) { $order = $creditmemo->getOrder(); $totalDiscountAmount = $order->getMwRewardpointDiscountShow(); $baseTotalDiscountAmount = $order->getMwRewardpointDiscount(); /* $creditmemo->setGrandTotal($creditmemo->getGrandTotal() - $totalDiscountAmount); $creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() - $baseTotalDiscountAmount); */ $creditmemo->setGrandTotal($creditmemo->getGrandTotal()); $creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal()); $creditmemo->setMwRewardpoint($order->getMwRewardpoint()); $creditmemo->setMwRewardpointDiscountShow($totalDiscountAmount); $creditmemo->setMwRewardpointDiscount($baseTotalDiscountAmount); return $this; }
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo) { $order = $creditmemo->getOrder(); $creditpointAmountLeft = $order->getCreditpointAmountInvoiced() - $order->getCreditpointAmountRefunded(); $basecreditpointAmountLeft = $order->getBaseCreditpointAmountInvoiced() - $order->getBaseCreditpointAmountRefunded(); if ($basecreditpointAmountLeft > 0) { //customer redeemed discount so we are subtracting the value from total $creditmemo->setGrandTotal($creditmemo->getGrandTotal() - $creditpointAmountLeft); $creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() - $basecreditpointAmountLeft); $creditmemo->setCreditpointAmount($creditpointAmountLeft); $creditmemo->setBaseCreditpointAmount($basecreditpointAmountLeft); } return $this; }