ItemDetails.php 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  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\TaxDetailsItemInterface;
  9. /**
  10. * @codeCoverageIgnore
  11. */
  12. class ItemDetails extends AbstractExtensibleModel implements TaxDetailsItemInterface
  13. {
  14. /**#@+
  15. * Constants defined for keys of array, makes typos less likely
  16. */
  17. const KEY_CODE = 'code';
  18. const KEY_TYPE = 'type';
  19. const KEY_TAX_PERCENT = 'tax_percent';
  20. const KEY_PRICE = 'price';
  21. const KEY_PRICE_INCL_TAX = 'price_incl_tax';
  22. const KEY_ROW_TOTAL = 'row_total';
  23. const KEY_ROW_TOTAL_INCL_TAX = 'row_total_incl_tax';
  24. const KEY_ROW_TAX = 'row_tax';
  25. const KEY_TAXABLE_AMOUNT = 'taxable_amount';
  26. const KEY_DISCOUNT_AMOUNT = 'discount_amount';
  27. const KEY_APPLIED_TAXES = 'applied_taxes';
  28. const KEY_ASSOCIATED_ITEM_CODE = 'associated_item_code';
  29. const KEY_DISCOUNT_TAX_COMPENSATION_AMOUNT = 'discount_tax_compensation_amount';
  30. /**#@-*/
  31. /**
  32. * {@inheritdoc}
  33. */
  34. public function getCode()
  35. {
  36. return $this->getData(self::KEY_CODE);
  37. }
  38. /**
  39. * {@inheritdoc}
  40. */
  41. public function getType()
  42. {
  43. return $this->getData(self::KEY_TYPE);
  44. }
  45. /**
  46. * {@inheritdoc}
  47. */
  48. public function getTaxPercent()
  49. {
  50. return $this->getData(self::KEY_TAX_PERCENT);
  51. }
  52. /**
  53. * {@inheritdoc}
  54. */
  55. public function getPrice()
  56. {
  57. return $this->getData(self::KEY_PRICE);
  58. }
  59. /**
  60. * {@inheritdoc}
  61. */
  62. public function getPriceInclTax()
  63. {
  64. return $this->getData(self::KEY_PRICE_INCL_TAX);
  65. }
  66. /**
  67. * {@inheritdoc}
  68. */
  69. public function getRowTotal()
  70. {
  71. return $this->getData(self::KEY_ROW_TOTAL);
  72. }
  73. /**
  74. * {@inheritdoc}
  75. */
  76. public function getRowTotalInclTax()
  77. {
  78. return $this->getData(self::KEY_ROW_TOTAL_INCL_TAX);
  79. }
  80. /**
  81. * {@inheritdoc}
  82. */
  83. public function getRowTax()
  84. {
  85. return $this->getData(self::KEY_ROW_TAX);
  86. }
  87. /**
  88. * {@inheritdoc}
  89. */
  90. public function getTaxableAmount()
  91. {
  92. return $this->getData(self::KEY_TAXABLE_AMOUNT);
  93. }
  94. /**
  95. * {@inheritdoc}
  96. */
  97. public function getDiscountAmount()
  98. {
  99. return $this->getData(self::KEY_DISCOUNT_AMOUNT);
  100. }
  101. /**
  102. * {@inheritdoc}
  103. */
  104. public function getDiscountTaxCompensationAmount()
  105. {
  106. return $this->getData(self::KEY_DISCOUNT_TAX_COMPENSATION_AMOUNT);
  107. }
  108. /**
  109. * {@inheritdoc}
  110. */
  111. public function getAppliedTaxes()
  112. {
  113. return $this->getData(self::KEY_APPLIED_TAXES);
  114. }
  115. /**
  116. * {@inheritdoc}
  117. */
  118. public function getAssociatedItemCode()
  119. {
  120. return $this->getData(self::KEY_ASSOCIATED_ITEM_CODE);
  121. }
  122. /**
  123. * Set code (sku or shipping code)
  124. *
  125. * @param string $code
  126. * @return $this
  127. */
  128. public function setCode($code)
  129. {
  130. return $this->setData(self::KEY_CODE, $code);
  131. }
  132. /**
  133. * Set type (shipping, product, weee, gift wrapping, etc
  134. *
  135. * @param string $type
  136. * @return $this
  137. */
  138. public function setType($type)
  139. {
  140. return $this->setData(self::KEY_TYPE, $type);
  141. }
  142. /**
  143. * Set tax_percent
  144. *
  145. * @param float $taxPercent
  146. * @return $this
  147. */
  148. public function setTaxPercent($taxPercent)
  149. {
  150. return $this->setData(self::KEY_TAX_PERCENT, $taxPercent);
  151. }
  152. /**
  153. * Set price
  154. *
  155. * @param float $price
  156. * @return $this
  157. */
  158. public function setPrice($price)
  159. {
  160. return $this->setData(self::KEY_PRICE, $price);
  161. }
  162. /**
  163. * Set price including tax
  164. *
  165. * @param float $priceInclTax
  166. * @return $this
  167. */
  168. public function setPriceInclTax($priceInclTax)
  169. {
  170. return $this->setData(self::KEY_PRICE_INCL_TAX, $priceInclTax);
  171. }
  172. /**
  173. * Set row total
  174. *
  175. * @param float $rowTotal
  176. * @return $this
  177. */
  178. public function setRowTotal($rowTotal)
  179. {
  180. return $this->setData(self::KEY_ROW_TOTAL, $rowTotal);
  181. }
  182. /**
  183. * Set row total including tax
  184. *
  185. * @param float $rowTotalInclTax
  186. * @return $this
  187. */
  188. public function setRowTotalInclTax($rowTotalInclTax)
  189. {
  190. return $this->setData(self::KEY_ROW_TOTAL_INCL_TAX, $rowTotalInclTax);
  191. }
  192. /**
  193. * Set row tax amount
  194. *
  195. * @param float $rowTax
  196. * @return $this
  197. */
  198. public function setRowTax($rowTax)
  199. {
  200. return $this->setData(self::KEY_ROW_TAX, $rowTax);
  201. }
  202. /**
  203. * Set taxable amount
  204. *
  205. * @param float $taxableAmount
  206. * @return $this
  207. */
  208. public function setTaxableAmount($taxableAmount)
  209. {
  210. return $this->setData(self::KEY_TAXABLE_AMOUNT, $taxableAmount);
  211. }
  212. /**
  213. * Set discount amount
  214. *
  215. * @param float $discountAmount
  216. * @return $this
  217. */
  218. public function setDiscountAmount($discountAmount)
  219. {
  220. return $this->setData(self::KEY_DISCOUNT_AMOUNT, $discountAmount);
  221. }
  222. /**
  223. * Set discount tax compensation amount
  224. *
  225. * @param float $discountTaxCompensationAmount
  226. * @return $this
  227. */
  228. public function setDiscountTaxCompensationAmount($discountTaxCompensationAmount)
  229. {
  230. return $this->setData(
  231. self::KEY_DISCOUNT_TAX_COMPENSATION_AMOUNT,
  232. $discountTaxCompensationAmount
  233. );
  234. }
  235. /**
  236. * Set applied taxes
  237. *
  238. * @param \Magento\Tax\Api\Data\AppliedTaxInterface[] $appliedTaxes
  239. * @return $this
  240. */
  241. public function setAppliedTaxes(array $appliedTaxes = null)
  242. {
  243. return $this->setData(self::KEY_APPLIED_TAXES, $appliedTaxes);
  244. }
  245. /**
  246. * Set associated item code
  247. *
  248. * @param int $associatedItemCode
  249. * @return $this
  250. */
  251. public function setAssociatedItemCode($associatedItemCode)
  252. {
  253. return $this->setData(self::KEY_ASSOCIATED_ITEM_CODE, $associatedItemCode);
  254. }
  255. /**
  256. * {@inheritdoc}
  257. *
  258. * @return \Magento\Tax\Api\Data\TaxDetailsItemExtensionInterface|null
  259. */
  260. public function getExtensionAttributes()
  261. {
  262. return $this->_getExtensionAttributes();
  263. }
  264. /**
  265. * {@inheritdoc}
  266. *
  267. * @param \Magento\Tax\Api\Data\TaxDetailsItemExtensionInterface $extensionAttributes
  268. * @return $this
  269. */
  270. public function setExtensionAttributes(\Magento\Tax\Api\Data\TaxDetailsItemExtensionInterface $extensionAttributes)
  271. {
  272. return $this->_setExtensionAttributes($extensionAttributes);
  273. }
  274. }