AppliedTax.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Tax\Model\TaxDetails;
  7. use Magento\Framework\Model\AbstractExtensibleModel;
  8. use Magento\Tax\Api\Data\AppliedTaxInterface;
  9. /**
  10. * @codeCoverageIgnore
  11. */
  12. class AppliedTax extends AbstractExtensibleModel implements AppliedTaxInterface
  13. {
  14. /**#@+
  15. * Constants defined for keys of array, makes typos less likely
  16. */
  17. const KEY_TAX_RATE_KEY = 'tax_rate_key';
  18. const KEY_PERCENT = 'percent';
  19. const KEY_AMOUNT = 'amount';
  20. const KEY_RATES = 'rates';
  21. /**#@-*/
  22. /**
  23. * {@inheritdoc}
  24. */
  25. public function getTaxRateKey()
  26. {
  27. return $this->getData(self::KEY_TAX_RATE_KEY);
  28. }
  29. /**
  30. * {@inheritdoc}
  31. */
  32. public function getPercent()
  33. {
  34. return $this->getData(self::KEY_PERCENT);
  35. }
  36. /**
  37. * {@inheritdoc}
  38. */
  39. public function getAmount()
  40. {
  41. return $this->getData(self::KEY_AMOUNT);
  42. }
  43. /**
  44. * {@inheritdoc}
  45. */
  46. public function getRates()
  47. {
  48. return $this->getData(self::KEY_RATES);
  49. }
  50. /**
  51. * Set tax rate key
  52. *
  53. * @param string $taxRateKey
  54. * @return $this
  55. */
  56. public function setTaxRateKey($taxRateKey)
  57. {
  58. return $this->setData(self::KEY_TAX_RATE_KEY, $taxRateKey);
  59. }
  60. /**
  61. * Set percent
  62. *
  63. * @param float $percent
  64. * @return $this
  65. */
  66. public function setPercent($percent)
  67. {
  68. return $this->setData(self::KEY_PERCENT, $percent);
  69. }
  70. /**
  71. * Get amount
  72. *
  73. * @param float $amount
  74. * @return $this
  75. */
  76. public function setAmount($amount)
  77. {
  78. return $this->setData(self::KEY_AMOUNT, $amount);
  79. }
  80. /**
  81. * Set rates
  82. *
  83. * @param \Magento\Tax\Api\Data\AppliedTaxRateInterface[] $rates
  84. * @return $this
  85. */
  86. public function setRates(array $rates = null)
  87. {
  88. return $this->setData(self::KEY_RATES, $rates);
  89. }
  90. /**
  91. * {@inheritdoc}
  92. *
  93. * @return \Magento\Tax\Api\Data\AppliedTaxExtensionInterface|null
  94. */
  95. public function getExtensionAttributes()
  96. {
  97. return $this->_getExtensionAttributes();
  98. }
  99. /**
  100. * {@inheritdoc}
  101. *
  102. * @param \Magento\Tax\Api\Data\AppliedTaxExtensionInterface $extensionAttributes
  103. * @return $this
  104. */
  105. public function setExtensionAttributes(\Magento\Tax\Api\Data\AppliedTaxExtensionInterface $extensionAttributes)
  106. {
  107. return $this->_setExtensionAttributes($extensionAttributes);
  108. }
  109. }