当前位置: 首页>>代码示例>>PHP>>正文


PHP Mage_Sales_Model_Order_Invoice::setBaseDiscountAmount方法代码示例

本文整理汇总了PHP中Mage_Sales_Model_Order_Invoice::setBaseDiscountAmount方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Order_Invoice::setBaseDiscountAmount方法的具体用法?PHP Mage_Sales_Model_Order_Invoice::setBaseDiscountAmount怎么用?PHP Mage_Sales_Model_Order_Invoice::setBaseDiscountAmount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mage_Sales_Model_Order_Invoice的用法示例。


在下文中一共展示了Mage_Sales_Model_Order_Invoice::setBaseDiscountAmount方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: collect

 public function collect(Mage_Sales_Model_Order_Invoice $invoice)
 {
     $invoice->setDiscountAmount(0);
     $invoice->setBaseDiscountAmount(0);
     $totalDiscountAmount = 0;
     $baseTotalDiscountAmount = 0;
     /**
      * Checking if shipping discount was added in previous invoices.
      * So basically if we have invoice with positive discount and it
      * was not canceled we don't add shipping discount to this one.
      */
     $addShippingDicount = true;
     foreach ($invoice->getOrder()->getInvoiceCollection() as $previusInvoice) {
         if ($previusInvoice->getDiscountAmount()) {
             $addShippingDicount = false;
         }
     }
     if ($addShippingDicount) {
         $totalDiscountAmount = $totalDiscountAmount + $invoice->getOrder()->getShippingDiscountAmount();
         $baseTotalDiscountAmount = $baseTotalDiscountAmount + $invoice->getOrder()->getBaseShippingDiscountAmount();
     }
     /** @var $item Mage_Sales_Model_Order_Invoice_Item */
     foreach ($invoice->getAllItems() as $item) {
         $orderItem = $item->getOrderItem();
         if ($orderItem->isDummy()) {
             continue;
         }
         $orderItemDiscount = (double) $orderItem->getDiscountAmount();
         $baseOrderItemDiscount = (double) $orderItem->getBaseDiscountAmount();
         $orderItemQty = $orderItem->getQtyOrdered();
         if ($orderItemDiscount && $orderItemQty) {
             /**
              * Resolve rounding problems
              *
              * We dont want to include the weee discount amount as the right amount
              * is added when calculating the taxes.
              *
              * Also the subtotal is without weee
              */
             $discount = $orderItemDiscount - $orderItem->getDiscountInvoiced();
             $baseDiscount = $baseOrderItemDiscount - $orderItem->getBaseDiscountInvoiced();
             if (!$item->isLast()) {
                 $activeQty = $orderItemQty - $orderItem->getQtyInvoiced();
                 $discount = $invoice->roundPrice($discount / $activeQty * $item->getQty(), 'regular', true);
                 $baseDiscount = $invoice->roundPrice($baseDiscount / $activeQty * $item->getQty(), 'base', true);
             }
             $item->setDiscountAmount($discount);
             $item->setBaseDiscountAmount($baseDiscount);
             $totalDiscountAmount += $discount;
             $baseTotalDiscountAmount += $baseDiscount;
         }
     }
     $invoice->setDiscountAmount(-$totalDiscountAmount);
     $invoice->setBaseDiscountAmount(-$baseTotalDiscountAmount);
     $invoice->setGrandTotal($invoice->getGrandTotal() - $totalDiscountAmount);
     $invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() - $baseTotalDiscountAmount);
     return $this;
 }
开发者ID:hyhoocchan,项目名称:mage-local,代码行数:58,代码来源:Discount.php

示例2: collect

 public function collect(Mage_Sales_Model_Order_Invoice $invoice)
 {
     $invoice->setDiscountAmount(0);
     $invoice->setBaseDiscountAmount(0);
     $totalDiscountAmount = 0;
     $baseTotalDiscountAmount = 0;
     /**
      * Checking if shipping discount was added in previous invoices.
      * So basically if we have invoice with positive discount and it
      * was not canceled we don't add shipping discount to this one.
      */
     $addShippingDicount = true;
     foreach ($invoice->getOrder()->getInvoiceCollection() as $previusInvoice) {
         if ($previusInvoice->getDiscountAmount()) {
             $addShippingDicount = false;
         }
     }
     if ($addShippingDicount) {
         $totalDiscountAmount = $totalDiscountAmount + $invoice->getOrder()->getShippingDiscountAmount();
         $baseTotalDiscountAmount = $baseTotalDiscountAmount + $invoice->getOrder()->getBaseShippingDiscountAmount();
     }
     foreach ($invoice->getAllItems() as $item) {
         if ($item->getOrderItem()->isDummy()) {
             continue;
         }
         $orderItem = $item->getOrderItem();
         $orderItemDiscount = (double) $orderItem->getDiscountAmount();
         $baseOrderItemDiscount = (double) $orderItem->getBaseDiscountAmount();
         $orderItemQty = $orderItem->getQtyOrdered();
         if ($orderItemDiscount && $orderItemQty) {
             /**
              * Resolve rounding problems
              */
             if ($item->isLast()) {
                 $discount = $orderItemDiscount - $orderItem->getDiscountInvoiced();
                 $baseDiscount = $baseOrderItemDiscount - $orderItem->getBaseDiscountInvoiced();
             } else {
                 $discount = $orderItemDiscount * $item->getQty() / $orderItemQty;
                 $baseDiscount = $baseOrderItemDiscount * $item->getQty() / $orderItemQty;
                 $discount = $invoice->getStore()->roundPrice($discount);
                 $baseDiscount = $invoice->getStore()->roundPrice($baseDiscount);
             }
             $item->setDiscountAmount($discount);
             $item->setBaseDiscountAmount($baseDiscount);
             $totalDiscountAmount += $discount;
             $baseTotalDiscountAmount += $baseDiscount;
         }
     }
     $invoice->setDiscountAmount($totalDiscountAmount);
     $invoice->setBaseDiscountAmount($baseTotalDiscountAmount);
     $invoice->setGrandTotal($invoice->getGrandTotal() - $totalDiscountAmount);
     $invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() - $baseTotalDiscountAmount);
     return $this;
 }
开发者ID:hirentricore,项目名称:devmagento,代码行数:54,代码来源:Discount.php

示例3: collect

 /**
  * collect discout total for invoice
  * 
  * - on payment method "sofortrechnung" discount will invoice on first invoice complete including canceled items
  * 
  * @param Mage_Sales_Model_Order_Invoice $invoice
  * @return Mage_Sales_Model_Order_Invoice_Total_Discount
  * @see app/code/core/Mage/Sales/Model/Order/Invoice/Total/Mage_Sales_Model_Order_Invoice_Total_Discount::collect()
  */
 public function collect(Mage_Sales_Model_Order_Invoice $invoice)
 {
     // special case for modified sofortrechnung
     if ($invoice->getOrder()->getPayment()->getMethod() == "sofortrechnung") {
         // special special case if configurable product  is in basket
         $hackDiff = 0;
         $enableDiff = false;
         $discountTax = 100;
         foreach ($invoice->getOrder()->getAllVisibleItems() as $item) {
             $enableDiff = $enableDiff || $item->product_type == 'configurable';
             if ($item->getTaxPercent() > 0) {
                 // tax of discount is min of cart-items
                 $discountTax = min($item->getTaxPercent(), $discountTax);
             }
         }
         $totalDiscountAmount = -$invoice->getOrder()->getDiscountInvoiced() - $invoice->getOrder()->getDiscountAmount();
         $baseTotalDiscountAmount = -$invoice->getOrder()->getBaseDiscountInvoiced() - $invoice->getOrder()->getBaseDiscountAmount();
         $invoice->setDiscountAmount(-$totalDiscountAmount);
         $invoice->setBaseDiscountAmount(-$baseTotalDiscountAmount);
         if ($enableDiff) {
             $hackDiff = $totalDiscountAmount - $totalDiscountAmount * (100 / ($discountTax + 100));
         }
         $invoice->setGrandTotal($invoice->getGrandTotal() - $totalDiscountAmount + $hackDiff);
         $invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() - $baseTotalDiscountAmount + $hackDiff);
         return $this;
     }
     return parent::collect($invoice);
 }
开发者ID:jronatay,项目名称:ultimo-magento-jron,代码行数:37,代码来源:Discount.php

示例4: collect

 public function collect(Mage_Sales_Model_Order_Invoice $invoice)
 {
     $invoice->setDiscountAmount(0);
     $invoice->setBaseDiscountAmount(0);
     $totalDiscountAmount = 0;
     $baseTotalDiscountAmount = 0;
     foreach ($invoice->getAllItems() as $item) {
         if ($item->getOrderItem()->isDummy()) {
             continue;
         }
         $orderItem = $item->getOrderItem();
         $orderItemDiscount = (double) $orderItem->getDiscountAmount();
         $baseOrderItemDiscount = (double) $orderItem->getBaseDiscountAmount();
         $orderItemQty = $orderItem->getQtyOrdered();
         if ($orderItemDiscount && $orderItemQty) {
             /**
              * Resolve rounding problems
              */
             if ($item->isLast()) {
                 $discount = $orderItemDiscount - $orderItem->getDiscountInvoiced();
                 $baseDiscount = $baseOrderItemDiscount - $orderItem->getBaseDiscountInvoiced();
             } else {
                 $discount = $orderItemDiscount * $item->getQty() / $orderItemQty;
                 $baseDiscount = $baseOrderItemDiscount * $item->getQty() / $orderItemQty;
                 $discount = $invoice->getStore()->roundPrice($discount);
                 $baseDiscount = $invoice->getStore()->roundPrice($baseDiscount);
             }
             $item->setDiscountAmount($discount);
             $item->setBaseDiscountAmount($baseDiscount);
             $totalDiscountAmount += $discount;
             $baseTotalDiscountAmount += $baseDiscount;
         }
     }
     $invoice->setDiscountAmount($totalDiscountAmount);
     $invoice->setBaseDiscountAmount($baseTotalDiscountAmount);
     $invoice->setGrandTotal($invoice->getGrandTotal() - $totalDiscountAmount);
     $invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() - $baseTotalDiscountAmount);
     return $this;
 }
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:39,代码来源:Order_Invoice_Total_Discount.php

示例5: collect

 public function collect(Mage_Sales_Model_Order_Invoice $invoice)
 {
     $order = $invoice->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 = $invoice->getAllItems();
     if (!count($items)) {
         return $this;
     }
     $invoice->setBaseDiscountAmount($invoice->getBaseDiscountAmount() - $baseTotalDiscountAmount);
     $invoice->setGrandTotal($invoice->getGrandTotal() - $totalDiscountAmount);
     $invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() - $baseTotalDiscountAmount);
     return $this;
 }
开发者ID:Gilbertoavitia1,项目名称:AHBS,代码行数:18,代码来源:Affiliate.php


注:本文中的Mage_Sales_Model_Order_Invoice::setBaseDiscountAmount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。