Renderer.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Weee\Block\Adminhtml\Items\Price;
  7. use Magento\Sales\Model\Order\Creditmemo\Item as CreditmemoItem;
  8. use Magento\Sales\Model\Order\Invoice\Item as InvoiceItem;
  9. use Magento\Sales\Model\Order\Item;
  10. use Magento\Quote\Model\Quote\Item\AbstractItem as QuoteItem;
  11. use Magento\Weee\Block\Item\Price\Renderer as ItemPriceRenderer;
  12. /**
  13. * Sales Order items price column renderer
  14. *
  15. * @api
  16. * @since 100.0.2
  17. */
  18. class Renderer extends \Magento\Tax\Block\Adminhtml\Items\Price\Renderer
  19. {
  20. /**
  21. * @var \Magento\Weee\Block\Item\Price\Renderer
  22. */
  23. protected $itemPriceRenderer;
  24. /**
  25. * @param \Magento\Backend\Block\Template\Context $context
  26. * @param \Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn $defaultColumnRenderer
  27. * @param \Magento\Tax\Helper\Data $taxHelper
  28. * @param ItemPriceRenderer $itemPriceRenderer
  29. * @param array $data
  30. */
  31. public function __construct(
  32. \Magento\Backend\Block\Template\Context $context,
  33. \Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn $defaultColumnRenderer,
  34. \Magento\Tax\Helper\Data $taxHelper,
  35. ItemPriceRenderer $itemPriceRenderer,
  36. array $data = []
  37. ) {
  38. parent::__construct(
  39. $context,
  40. $defaultColumnRenderer,
  41. $taxHelper,
  42. $itemPriceRenderer,
  43. $data
  44. );
  45. }
  46. /**
  47. * Whether to display weee details together with price
  48. *
  49. * @return bool
  50. */
  51. public function displayPriceWithWeeeDetails()
  52. {
  53. return $this->itemPriceRenderer->displayPriceWithWeeeDetails();
  54. }
  55. /**
  56. * Whether to display final price that include Weee amounts
  57. *
  58. * @return bool
  59. */
  60. public function displayFinalPrice()
  61. {
  62. return $this->itemPriceRenderer->displayFinalPrice();
  63. }
  64. /**
  65. * Return HTML for unit price excl tax
  66. *
  67. * @return string
  68. */
  69. public function getUnitPriceExclTaxHtml()
  70. {
  71. $baseUnitPriceExclTax = $this->itemPriceRenderer->getBaseUnitDisplayPriceExclTax();
  72. $unitPriceExclTax = $this->itemPriceRenderer->getUnitDisplayPriceExclTax();
  73. return $this->displayPrices($baseUnitPriceExclTax, $unitPriceExclTax);
  74. }
  75. /**
  76. * Return HTML for row price excl tax
  77. *
  78. * @return string
  79. */
  80. public function getRowPriceExclTaxHtml()
  81. {
  82. $baseRowPriceExclTax = $this->itemPriceRenderer->getBaseRowDisplayPriceExclTax();
  83. $rowPriceExclTax = $this->itemPriceRenderer->getRowDisplayPriceExclTax();
  84. return $this->displayPrices($baseRowPriceExclTax, $rowPriceExclTax);
  85. }
  86. /**
  87. * Return HTML for unit price incl tax
  88. *
  89. * @return string
  90. */
  91. public function getUnitPriceInclTaxHtml()
  92. {
  93. $baseUnitPriceInclTax = $this->itemPriceRenderer->getBaseUnitDisplayPriceInclTax();
  94. $unitPriceInclTax = $this->itemPriceRenderer->getUnitDisplayPriceInclTax();
  95. return $this->displayPrices($baseUnitPriceInclTax, $unitPriceInclTax);
  96. }
  97. /**
  98. * Return HTML for row price incl tax
  99. *
  100. * @return string
  101. */
  102. public function getRowPriceInclTaxHtml()
  103. {
  104. $baseRowPriceInclTax = $this->itemPriceRenderer->getBaseRowDisplayPriceInclTax();
  105. $rowPriceInclTax = $this->itemPriceRenderer->getRowDisplayPriceInclTax();
  106. return $this->displayPrices($baseRowPriceInclTax, $rowPriceInclTax);
  107. }
  108. /**
  109. * Return HTML for final unit price excl tax
  110. *
  111. * @return string
  112. */
  113. public function getFinalUnitPriceExclTaxHtml()
  114. {
  115. $baseUnitPriceExclTax = $this->itemPriceRenderer->getBaseFinalUnitDisplayPriceExclTax();
  116. $unitPriceExclTax = $this->itemPriceRenderer->getFinalUnitDisplayPriceExclTax();
  117. return $this->displayPrices($baseUnitPriceExclTax, $unitPriceExclTax);
  118. }
  119. /**
  120. * Return HTML for final row price excl tax
  121. *
  122. * @return string
  123. */
  124. public function getFinalRowPriceExclTaxHtml()
  125. {
  126. $baseRowPriceExclTax = $this->itemPriceRenderer->getBaseFinalRowDisplayPriceExclTax();
  127. $rowPriceExclTax = $this->itemPriceRenderer->getFinalRowDisplayPriceExclTax();
  128. return $this->displayPrices($baseRowPriceExclTax, $rowPriceExclTax);
  129. }
  130. /**
  131. * Return HTML for final unit price incl tax
  132. *
  133. * @return string
  134. */
  135. public function getFinalUnitPriceInclTaxHtml()
  136. {
  137. $baseUnitPriceInclTax = $this->itemPriceRenderer->getBaseFinalUnitDisplayPriceInclTax();
  138. $unitPriceInclTax = $this->itemPriceRenderer->getFinalUnitDisplayPriceInclTax();
  139. return $this->displayPrices($baseUnitPriceInclTax, $unitPriceInclTax);
  140. }
  141. /**
  142. * Return HTML for final row price incl tax
  143. *
  144. * @return string
  145. */
  146. public function getFinalRowPriceInclTaxHtml()
  147. {
  148. $baseRowPriceInclTax = $this->itemPriceRenderer->getBaseFinalRowDisplayPriceInclTax();
  149. $rowPriceInclTax = $this->itemPriceRenderer->getFinalRowDisplayPriceInclTax();
  150. return $this->displayPrices($baseRowPriceInclTax, $rowPriceInclTax);
  151. }
  152. /**
  153. * Calculate total amount for the item
  154. *
  155. * @param Item|QuoteItem|InvoiceItem|CreditmemoItem $item
  156. * @return mixed
  157. */
  158. public function getTotalAmount($item)
  159. {
  160. return $this->itemPriceRenderer->getTotalAmount($item);
  161. }
  162. /**
  163. * Calculate base total amount for the item
  164. *
  165. * @param Item|QuoteItem|InvoiceItem|CreditmemoItem $item
  166. * @return mixed
  167. */
  168. public function getBaseTotalAmount($item)
  169. {
  170. return $this->itemPriceRenderer->getBaseTotalAmount($item);
  171. }
  172. }