TaxAdjustment.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Weee\Pricing\Render;
  7. use Magento\Framework\Pricing\PriceCurrencyInterface;
  8. use Magento\Framework\View\Element\Template;
  9. use Magento\Weee\Model\Tax;
  10. /**
  11. * Weee Price Adjustment that overrides part of the Tax module's Adjustment
  12. */
  13. class TaxAdjustment extends \Magento\Tax\Pricing\Render\Adjustment
  14. {
  15. /**
  16. * Weee helper
  17. *
  18. * @var \Magento\Weee\Helper\Data
  19. */
  20. protected $weeeHelper;
  21. /**
  22. * @param Template\Context $context
  23. * @param PriceCurrencyInterface $priceCurrency
  24. * @param \Magento\Tax\Helper\Data $helper
  25. * @param \Magento\Weee\Helper\Data $weeeHelper
  26. * @param array $data
  27. */
  28. public function __construct(
  29. Template\Context $context,
  30. PriceCurrencyInterface $priceCurrency,
  31. \Magento\Tax\Helper\Data $helper,
  32. \Magento\Weee\Helper\Data $weeeHelper,
  33. array $data = []
  34. ) {
  35. $this->weeeHelper = $weeeHelper;
  36. parent::__construct($context, $priceCurrency, $helper, $data);
  37. }
  38. /**
  39. * Returns the list of default exclusions
  40. *
  41. * @return array
  42. */
  43. public function getDefaultExclusions()
  44. {
  45. $exclusions = parent::getDefaultExclusions();
  46. $exclusions[] = \Magento\Weee\Pricing\TaxAdjustment::ADJUSTMENT_CODE;
  47. // Determine if the Weee amount should be excluded from the price
  48. if ($this->typeOfDisplay([Tax::DISPLAY_EXCL_DESCR_INCL, Tax::DISPLAY_EXCL])) {
  49. $exclusions[] = \Magento\Weee\Pricing\Adjustment::ADJUSTMENT_CODE;
  50. }
  51. return $exclusions;
  52. }
  53. /**
  54. * Returns display type for price accordingly to current zone
  55. *
  56. * @param int|int[]|null $compareTo
  57. * @param \Magento\Store\Model\Store|null $store
  58. * @return bool|int
  59. */
  60. protected function typeOfDisplay($compareTo = null, $store = null)
  61. {
  62. return $this->weeeHelper->typeOfDisplay($compareTo, $this->getZone(), $store);
  63. }
  64. }