本文整理汇总了PHP中Mage_Sales_Model_Order_Creditmemo::getAllItems方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Order_Creditmemo::getAllItems方法的具体用法?PHP Mage_Sales_Model_Order_Creditmemo::getAllItems怎么用?PHP Mage_Sales_Model_Order_Creditmemo::getAllItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Order_Creditmemo
的用法示例。
在下文中一共展示了Mage_Sales_Model_Order_Creditmemo::getAllItems方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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;
}
示例4: 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;
}
示例5: 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;
}
示例6: 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;
}
示例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
/**
* Collect total cost of refunded items
*
* @param Mage_Sales_Model_Order_Creditmemo $creditmemo
* @return Mage_Sales_Model_Order_Creditmemo_Total_Cost
*/
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$baseRefundTotalCost = 0;
foreach ($creditmemo->getAllItems() as $item) {
if (!$item->getHasChildren()) {
$baseRefundTotalCost += $item->getBaseCost() * $item->getQty();
}
}
$creditmemo->setBaseCost($baseRefundTotalCost);
return $this;
}
示例9: collect
/**
* Collect Creditmemo subtotal
*
* @param Mage_Sales_Model_Order_Creditmemo $creditmemo
* @return Mage_Sales_Model_Order_Creditmemo_Total_Subtotal
*/
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$subtotal = 0;
$baseSubtotal = 0;
foreach ($creditmemo->getAllItems() as $item) {
$item->calcRowTotal();
$subtotal += $item->getRowTotal();
$baseSubtotal += $item->getBaseRowTotal();
}
$creditmemo->setSubtotal($subtotal);
$creditmemo->setBaseSubtotal($baseSubtotal);
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $subtotal);
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $baseSubtotal);
return $this;
}
示例10: creditmemoToFeed
/**
* Convert a creditmemo to a LinkShare refund row.
*
* @param Mage_Sales_Model_Order_Creditmemo $creditmemo
* @return array
*/
public function creditmemoToFeed(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$orderDate = new Zend_Date($creditmemo->getOrderDate(), Varien_Date::DATETIME_INTERNAL_FORMAT);
$orderDate = $orderDate->toString('yyyy-MM-dd');
$cmDate = new Zend_Date($creditmemo->getCreatedAt(), Varien_Date::DATETIME_INTERNAL_FORMAT);
$cmDate = $cmDate->toString('yyyy-MM-dd');
$rows = array();
foreach ($creditmemo->getAllItems() as $cmItem) {
/* @var $cmItem Mage_Sales_Model_Order_Creditmemo_Item */
if ($cmItem->getBaseRowTotal()) {
$rows[] = array('order_id' => $creditmemo->getOrderIncrementId(), 'site_id' => '', 'order_date' => $orderDate, 'transaction_date' => $cmDate, 'sku' => $cmItem->getSku(), 'quantity' => round($cmItem->getQty()), 'amount' => ($cmItem->getBaseRowTotal() - $cmItem->getBaseDiscountAmount()) * -100, 'currency' => $creditmemo->getBaseCurrencyCode(), 'blank' => '', 'blank' => '', 'blank' => '', 'product_name' => '');
}
}
return $rows;
}
示例11: collect
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$creditmemo->setDiscountAmount(0);
$creditmemo->setBaseDiscountAmount(0);
$order = $creditmemo->getOrder();
$totalDiscountAmount = 0;
$baseTotalDiscountAmount = 0;
/**
* Calculate how much shipping discount should be applied
* basing on how much shipping should be refunded.
*/
$baseShippingAmount = $creditmemo->getBaseShippingAmount();
if ($baseShippingAmount) {
$baseShippingDiscount = $baseShippingAmount * $order->getBaseShippingDiscountAmount() / $order->getBaseShippingAmount();
$shippingDiscount = $order->getShippingAmount() * $baseShippingDiscount / $order->getBaseShippingAmount();
$totalDiscountAmount = $totalDiscountAmount + $shippingDiscount;
$baseTotalDiscountAmount = $baseTotalDiscountAmount + $baseShippingDiscount;
}
/** @var $item Mage_Sales_Model_Order_Invoice_Item */
foreach ($creditmemo->getAllItems() as $item) {
$orderItem = $item->getOrderItem();
if ($orderItem->isDummy()) {
continue;
}
$orderItemDiscount = (double) $orderItem->getDiscountInvoiced();
$baseOrderItemDiscount = (double) $orderItem->getBaseDiscountInvoiced();
$orderItemQty = $orderItem->getQtyInvoiced();
if ($orderItemDiscount && $orderItemQty) {
$discount = $orderItemDiscount - $orderItem->getDiscountRefunded();
$baseDiscount = $baseOrderItemDiscount - $orderItem->getBaseDiscountRefunded();
if (!$item->isLast()) {
$availableQty = $orderItemQty - $orderItem->getQtyRefunded();
$discount = $creditmemo->roundPrice($discount / $availableQty * $item->getQty(), 'regular', true);
$baseDiscount = $creditmemo->roundPrice($baseDiscount / $availableQty * $item->getQty(), 'base', true);
}
$totalDiscountAmount += $discount;
$baseTotalDiscountAmount += $baseDiscount;
$item->setDiscountAmount($discount);
$item->setBaseDiscountAmount($baseDiscount);
}
}
$creditmemo->setDiscountAmount(-$totalDiscountAmount);
$creditmemo->setBaseDiscountAmount(-$baseTotalDiscountAmount);
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() - $totalDiscountAmount);
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() - $baseTotalDiscountAmount);
return $this;
}
示例12: collect
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$order = $creditmemo->getOrder();
//$affiliate = Mage::getModel('credit/creditorder')->load($order->getIncrementId())->getAffiliate();
$affiliate = 0;
//$credit = Mage::getModel('credit/creditorder')->load($order->getIncrementId())->getCredit();
$credit = 0;
$totalDiscountAmount = $affiliate + $credit;
$baseTotalDiscountAmount = $affiliate + $credit;
$items = $creditmemo->getAllItems();
if (!count($items)) {
return $this;
}
$creditmemo->setBaseDiscountAmount($creditmemo->getBaseDiscountAmount() - $baseTotalDiscountAmount);
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() - $totalDiscountAmount);
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() - $baseTotalDiscountAmount);
return $this;
}
示例13: collect
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$creditmemo->setDiscountAmount(0);
$creditmemo->setBaseDiscountAmount(0);
$order = $creditmemo->getOrder();
$totalDiscountAmount = 0;
$baseTotalDiscountAmount = 0;
/**
* Calculate how much shipping discount should be applied
* basing on how much shipping should be refunded.
*/
$baseShippingAmount = $creditmemo->getBaseShippingAmount();
if ($baseShippingAmount) {
$baseShippingDiscount = $baseShippingAmount * $order->getBaseShippingDiscountAmount() / $order->getBaseShippingAmount();
$shippingDiscount = $order->getShippingAmount() * $baseShippingDiscount / $order->getBaseShippingAmount();
$totalDiscountAmount = $totalDiscountAmount + $shippingDiscount;
$baseTotalDiscountAmount = $baseTotalDiscountAmount + $baseShippingDiscount;
}
foreach ($creditmemo->getAllItems() as $item) {
if ($item->getOrderItem()->isDummy()) {
continue;
}
$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)
{
// Changed By Adam 22/09/2014
if (!Mage::helper('affiliateplus')->isAffiliateModuleEnabled()) {
return $this;
}
$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;
}
}
/* Changed By Adam 30/09/2014: to solve the problem:
* invoice san pham ko phai affiliate nhung van hien discount
*/
// 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
/**
* Collect Creditmemo subtotal
*
* @param Mage_Sales_Model_Order_Creditmemo $creditmemo
* @return Mage_Sales_Model_Order_Creditmemo_Total_Subtotal
*/
public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
{
$subtotal = 0;
$baseSubtotal = 0;
$subtotalInclTax = 0;
$baseSubtotalInclTax = 0;
foreach ($creditmemo->getAllItems() as $item) {
if ($item->getOrderItem()->isDummy()) {
continue;
}
$item->calcRowTotal();
$subtotal += $item->getRowTotal();
$baseSubtotal += $item->getBaseRowTotal();
$subtotalInclTax += $item->getRowTotalInclTax();
$baseSubtotalInclTax += $item->getBaseRowTotalInclTax();
}
$creditmemo->setSubtotal($subtotal);
$creditmemo->setBaseSubtotal($baseSubtotal);
$creditmemo->setSubtotalInclTax($subtotalInclTax);
$creditmemo->setBaseSubtotalInclTax($baseSubtotalInclTax);
$creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $subtotal);
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $baseSubtotal);
return $this;
}