_taxConfig = $taxConfig; $this->priceCurrency = $priceCurrency; parent::__construct($context, $data); } /** * Initialize creditmemo adjustment totals * * @return $this */ public function initTotals() { $parent = $this->getParentBlock(); $this->_source = $parent->getSource(); $total = new \Magento\Framework\DataObject(['code' => 'agjustments', 'block_name' => $this->getNameInLayout()]); $parent->removeTotal('shipping'); $parent->removeTotal('adjustment_positive'); $parent->removeTotal('adjustment_negative'); $parent->addTotal($total); return $this; } /** * Get source object * * @return \Magento\Framework\DataObject */ public function getSource() { return $this->_source; } /** * Get credit memo shipping amount depend on configuration settings * * @return float */ public function getShippingAmount() { $source = $this->getSource(); if ($this->_taxConfig->displaySalesShippingInclTax($source->getOrder()->getStoreId())) { $shipping = $source->getBaseShippingInclTax(); } else { $shipping = $source->getBaseShippingAmount(); } return $this->priceCurrency->round($shipping) * 1; } /** * Get label for shipping total based on configuration settings * * @return string */ public function getShippingLabel() { $source = $this->getSource(); if ($this->_taxConfig->displaySalesShippingInclTax($source->getOrder()->getStoreId())) { $label = __('Refund Shipping (Incl. Tax)'); } elseif ($this->_taxConfig->displaySalesShippingBoth($source->getOrder()->getStoreId())) { $label = __('Refund Shipping (Excl. Tax)'); } else { $label = __('Refund Shipping'); } return $label; } }