本文整理汇总了PHP中Magento\Weee\Helper\Data::isTaxIncluded方法的典型用法代码示例。如果您正苦于以下问题:PHP Data::isTaxIncluded方法的具体用法?PHP Data::isTaxIncluded怎么用?PHP Data::isTaxIncluded使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Weee\Helper\Data
的用法示例。
在下文中一共展示了Data::isTaxIncluded方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: collect
/**
* 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;
}