Item.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Sales\Model\Order\Tax;
  7. /**
  8. * Sales Order Tax Item model
  9. */
  10. class Item extends \Magento\Framework\Model\AbstractExtensibleModel implements
  11. \Magento\Tax\Api\Data\OrderTaxDetailsItemInterface
  12. {
  13. /**#@+
  14. * Constants defined for keys of array, makes typos less likely
  15. */
  16. const KEY_TYPE = 'type';
  17. const KEY_ITEM_ID = 'item_id';
  18. const KEY_ASSOCIATED_ITEM_ID = 'associated_item_id';
  19. const KEY_APPLIED_TAXES = 'applied_taxes';
  20. /**#@-*/
  21. /**
  22. * {@inheritdoc}
  23. */
  24. protected function _construct()
  25. {
  26. $this->_init(\Magento\Sales\Model\ResourceModel\Order\Tax\Item::class);
  27. }
  28. /**
  29. * {@inheritdoc}
  30. */
  31. public function getType()
  32. {
  33. return $this->getData(self::KEY_TYPE);
  34. }
  35. /**
  36. * {@inheritdoc}
  37. */
  38. public function getItemId()
  39. {
  40. return $this->getData(self::KEY_ITEM_ID);
  41. }
  42. /**
  43. * {@inheritdoc}
  44. */
  45. public function getAssociatedItemId()
  46. {
  47. return $this->getData(self::KEY_ASSOCIATED_ITEM_ID);
  48. }
  49. /**
  50. * {@inheritdoc}
  51. */
  52. public function getAppliedTaxes()
  53. {
  54. return $this->getData(self::KEY_APPLIED_TAXES);
  55. }
  56. /**
  57. * Set type (shipping, product, weee, gift wrapping, etc)
  58. *
  59. * @param string $type
  60. * @return $this
  61. */
  62. public function setType($type)
  63. {
  64. return $this->setData(self::KEY_TYPE, $type);
  65. }
  66. /**
  67. * Set item id
  68. *
  69. * @param int $itemId
  70. * @return $this
  71. */
  72. public function setItemId($itemId)
  73. {
  74. return $this->setData(self::KEY_ITEM_ID, $itemId);
  75. }
  76. /**
  77. * Set associated item id
  78. *
  79. * @param int $associatedItemId
  80. * @return $this
  81. */
  82. public function setAssociatedItemId($associatedItemId)
  83. {
  84. return $this->setData(self::KEY_ASSOCIATED_ITEM_ID, $associatedItemId);
  85. }
  86. /**
  87. * Set applied taxes
  88. *
  89. * @param \Magento\Tax\Api\Data\OrderTaxDetailsAppliedTaxInterface[] $appliedTaxes
  90. * @return $this
  91. */
  92. public function setAppliedTaxes(array $appliedTaxes = null)
  93. {
  94. return $this->setData(self::KEY_APPLIED_TAXES, $appliedTaxes);
  95. }
  96. /**
  97. * {@inheritdoc}
  98. *
  99. * @return \Magento\Tax\Api\Data\OrderTaxDetailsItemExtensionInterface|null
  100. */
  101. public function getExtensionAttributes()
  102. {
  103. return $this->_getExtensionAttributes();
  104. }
  105. /**
  106. * {@inheritdoc}
  107. *
  108. * @param \Magento\Tax\Api\Data\OrderTaxDetailsItemExtensionInterface $extensionAttributes
  109. * @return $this
  110. */
  111. public function setExtensionAttributes(
  112. \Magento\Tax\Api\Data\OrderTaxDetailsItemExtensionInterface $extensionAttributes
  113. ) {
  114. return $this->_setExtensionAttributes($extensionAttributes);
  115. }
  116. }