/** * Get array of arrays with tax information for display in PDF * array( * $index => array( * 'amount' => $amount, * 'label' => $label, * 'font_size'=> $font_size * ) * ) * * @return array */ public function getFullTaxInfo() { $fontSize = $this->getFontSize() ? $this->getFontSize() : 7; $taxClassAmount = $this->_taxHelper->getCalculatedTaxes($this->getOrder()); $shippingTax = $this->_taxHelper->getShippingTax($this->getOrder()); $taxClassAmount = array_merge($shippingTax, $taxClassAmount); if (!empty($taxClassAmount)) { foreach ($taxClassAmount as &$tax) { $percent = $tax['percent'] ? ' (' . $tax['percent'] . '%)' : ''; $tax['amount'] = $this->getAmountPrefix() . $this->getOrder()->formatPriceTxt($tax['tax_amount']); $tax['label'] = __($tax['title']) . $percent . ':'; $tax['font_size'] = $fontSize; } } else { /** @var $orders \Magento\Tax\Model\Resource\Sales\Order\Tax\Collection */ $orders = $this->_taxOrdersFactory->create(); $rates = $orders->loadByOrder($this->getOrder())->toArray(); $fullInfo = $this->_taxCalculation->reproduceProcess($rates['items']); $tax_info = array(); if ($fullInfo) { foreach ($fullInfo as $info) { if (isset($info['hidden']) && $info['hidden']) { continue; } $_amount = $info['amount']; foreach ($info['rates'] as $rate) { $percent = $rate['percent'] ? ' (' . $rate['percent'] . '%)' : ''; $tax_info[] = array('amount' => $this->getAmountPrefix() . $this->getOrder()->formatPriceTxt($_amount), 'label' => __($rate['title']) . $percent . ':', 'font_size' => $fontSize); } } } $taxClassAmount = $tax_info; } return $taxClassAmount; }
/** * Get full information about taxes applied to order * * @return array */ public function getFullTaxInfo() { /** @var $source \Magento\Sales\Model\Order */ $source = $this->getOrder(); $taxClassAmount = array(); if ($source instanceof \Magento\Sales\Model\Order) { $taxClassAmount = $this->_taxHelper->getCalculatedTaxes($source); $shippingTax = $this->_taxHelper->getShippingTax($source); $taxClassAmount = array_merge($taxClassAmount, $shippingTax); if (empty($taxClassAmount)) { $rates = $this->_taxOrderFactory->create()->getCollection()->loadByOrder($source)->toArray(); $taxClassAmount = $this->_taxCalculation->reproduceProcess($rates['items']); } } return $taxClassAmount; }