Beispiel #1
0
 /**
  * Get base final unit display price including tax, this will add Weee amount to unit price include tax
  *
  * @return float
  */
 public function getBaseFinalUnitDisplayPriceInclTax()
 {
     $basePriceInclTax = $this->getItem()->getBasePriceInclTax();
     if (!$this->weeeHelper->isEnabled()) {
         return $basePriceInclTax;
     }
     return $basePriceInclTax + $this->weeeHelper->getBaseWeeeTaxInclTax($this->getItem());
 }
Beispiel #2
0
 /**
  * Collect Weee amounts for the credit memo
  *
  * @param Creditmemo $creditmemo
  * @return $this
  */
 public function collect(Creditmemo $creditmemo)
 {
     $store = $creditmemo->getStore();
     $totalTax = 0;
     $baseTotalTax = 0;
     $weeeTaxAmount = 0;
     $baseWeeeTaxAmount = 0;
     foreach ($creditmemo->getAllItems() as $item) {
         if ($item->getOrderItem()->isDummy()) {
             continue;
         }
         $weeeAmountExclTax = ($this->_weeeData->getWeeeTaxInclTax($item) - $this->_weeeData->getTotalTaxAppliedForWeeeTax($item)) * $item->getQty();
         $totalTax += $weeeAmountExclTax;
         $baseWeeeAmountExclTax = ($this->_weeeData->getBaseWeeeTaxInclTax($item) - $this->_weeeData->getBaseTotalTaxAppliedForWeeeTax($item)) * $item->getQty();
         $baseTotalTax += $baseWeeeAmountExclTax;
         $item->setWeeeTaxAppliedRowAmount($weeeAmountExclTax);
         $item->setBaseWeeeTaxAppliedRowAmount($baseWeeeAmountExclTax);
         $weeeTaxAmount += $this->_weeeData->getWeeeTaxInclTax($item) * $item->getQty();
         $baseWeeeTaxAmount += $this->_weeeData->getBaseWeeeTaxInclTax($item) * $item->getQty();
         $newApplied = array();
         $applied = $this->_weeeData->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;
         }
         $this->_weeeData->setApplied($item, $newApplied);
         $item->setWeeeTaxRowDisposition($item->getWeeeTaxDisposition() * $item->getQty());
         $item->setBaseWeeeTaxRowDisposition($item->getBaseWeeeTaxDisposition() * $item->getQty());
     }
     if ($this->_weeeData->includeInSubtotal($store)) {
         $creditmemo->setSubtotal($creditmemo->getSubtotal() + $totalTax);
         $creditmemo->setBaseSubtotal($creditmemo->getBaseSubtotal() + $baseTotalTax);
     }
     $creditmemo->setSubtotalInclTax($creditmemo->getSubtotalInclTax() + $weeeTaxAmount);
     $creditmemo->setBaseSubtotalInclTax($creditmemo->getBaseSubtotalInclTax() + $baseWeeeTaxAmount);
     $creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $totalTax);
     $creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $baseTotalTax);
     return $this;
 }
Beispiel #3
0
 /**
  * Collect Weee amounts for the invoice
  *
  * @param \Magento\Sales\Model\Order\Invoice $invoice
  * @return $this
  */
 public function collect(\Magento\Sales\Model\Order\Invoice $invoice)
 {
     $store = $invoice->getStore();
     $totalTax = 0;
     $baseTotalTax = 0;
     $weeeInclTax = 0;
     $baseWeeeInclTax = 0;
     foreach ($invoice->getAllItems() as $item) {
         $orderItem = $item->getOrderItem();
         $orderItemQty = $orderItem->getQtyOrdered();
         if (!$orderItemQty || $orderItem->isDummy()) {
             continue;
         }
         $weeeTaxAmount = $item->getWeeeTaxAppliedAmount() * $item->getQty();
         $baseWeeeTaxAmount = $item->getBaseWeeeTaxAppliedAmount() * $item->getQty();
         $weeeTaxAmountInclTax = $this->_weeeData->getWeeeTaxInclTax($item) * $item->getQty();
         $baseWeeeTaxAmountInclTax = $this->_weeeData->getBaseWeeeTaxInclTax($item) * $item->getQty();
         $item->setWeeeTaxAppliedRowAmount($weeeTaxAmount);
         $item->setBaseWeeeTaxAppliedRowAmount($baseWeeeTaxAmount);
         $newApplied = array();
         $applied = $this->_weeeData->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;
         }
         $this->_weeeData->setApplied($item, $newApplied);
         $item->setWeeeTaxRowDisposition($item->getWeeeTaxDisposition() * $item->getQty());
         $item->setBaseWeeeTaxRowDisposition($item->getBaseWeeeTaxDisposition() * $item->getQty());
         $totalTax += $weeeTaxAmount;
         $baseTotalTax += $baseWeeeTaxAmount;
         $weeeInclTax += $weeeTaxAmountInclTax;
         $baseWeeeInclTax += $baseWeeeTaxAmountInclTax;
     }
     // Add FPT to subtotal and grand total
     if ($this->_weeeData->includeInSubtotal($store)) {
         $order = $invoice->getOrder();
         $allowedSubtotal = $order->getSubtotal() - $order->getSubtotalInvoiced() - $invoice->getSubtotal();
         $allowedBaseSubtotal = $order->getBaseSubtotal() - $order->getBaseSubtotalInvoiced() - $invoice->getBaseSubtotal();
         $totalTax = min($allowedSubtotal, $totalTax);
         $baseTotalTax = min($allowedBaseSubtotal, $baseTotalTax);
         $invoice->setSubtotal($invoice->getSubtotal() + $totalTax);
         $invoice->setBaseSubtotal($invoice->getBaseSubtotal() + $baseTotalTax);
     }
     $useWeeeInclTax = true;
     if ($this->_weeeData->isTaxIncluded($store) && $invoice->isLast()) {
         $useWeeeInclTax = false;
     }
     if ($useWeeeInclTax) {
         // need to add the Weee amounts including all their taxes
         $invoice->setSubtotalInclTax($invoice->getSubtotalInclTax() + $weeeInclTax);
         $invoice->setBaseSubtotalInclTax($invoice->getBaseSubtotalInclTax() + $baseWeeeInclTax);
     } else {
         // since the Subtotal Incl Tax line will already have the taxes on Weee, just add the non-taxable amounts
         $invoice->setSubtotalInclTax($invoice->getSubtotalInclTax() + $totalTax);
         $invoice->setBaseSubtotalInclTax($invoice->getBaseSubtotalInclTax() + $baseTotalTax);
     }
     $invoice->setGrandTotal($invoice->getGrandTotal() + $totalTax);
     $invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() + $baseTotalTax);
     return $this;
 }