IntangiblePriceAndDiscount.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <?php
  2. namespace AppBundle\Entity\Product;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Dunglas\ApiBundle\Annotation\Iri;
  6. use Symfony\Component\Serializer\Annotation\Groups;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. use AppBundle\Entity\Traits\TimestampableEntity;
  9. use AppBundle\Entity\Traits\CreatorUpdaterEntity;
  10. /**
  11. * Prix et application d'éventuelles réductions sur un Intangible
  12. *
  13. * @Iri("http://schema.org/IntangiblePriceAndDiscount")
  14. */
  15. #[ORM\Entity]
  16. class IntangiblePriceAndDiscount
  17. {
  18. use TimestampableEntity;
  19. use CreatorUpdaterEntity;
  20. /**
  21. * @var int
  22. */
  23. #[ORM\Column(type: 'integer')]
  24. #[ORM\Id]
  25. #[ORM\GeneratedValue(strategy: 'AUTO')]
  26. #[Groups(['intangiblepriceanddiscount', 'educational_project_intangible_list', 'access_intangible_list', 'intangible_list'])]
  27. private $id;
  28. /**
  29. * @var string
  30. */
  31. #[ORM\Column(type: 'string', nullable: true)]
  32. #[Assert\Type(type: 'string')]
  33. #[Assert\Choice(callback: ['AppBundle\Enum\Product\IntangibleAmountTypeEnum', 'toArray'])]
  34. #[Groups(['intangiblepriceanddiscount', 'educational_project_intangible_list_intangiblepriceanddiscount', 'access_intangible_list_intangiblepriceanddiscount', 'intangible_list_intangiblepriceanddiscount', 'access_intangible_list_intangible'])]
  35. private $amountType;
  36. /**
  37. * @var bool
  38. */
  39. #[ORM\Column(type: 'boolean', options: ['default' => true])]
  40. #[Assert\Type(type: 'boolean')]
  41. #[Assert\NotNull]
  42. #[Groups(['intangiblepriceanddiscount', 'educational_project_intangible_list_intangiblepriceanddiscount', 'access_intangible_list_intangiblepriceanddiscount', 'intangible_list_intangiblepriceanddiscount', 'access_intangible_list_intangible'])]
  43. private $applyDiscount = true;
  44. /**
  45. * @var ArrayCollection<IntangibleDiscountDetail>
  46. */
  47. #[Assert\Valid]
  48. #[ORM\OneToMany(targetEntity: 'IntangibleDiscountDetail', mappedBy: 'intangiblePriceAndDiscount', cascade: ['persist'], orphanRemoval: true)]
  49. #[Groups(['intangiblepriceanddiscount_intangiblediscountdetail'])]
  50. private $intangibleDiscountDetails;
  51. /**
  52. * @var float
  53. */
  54. #[ORM\Column(type: 'float', nullable: true)]
  55. #[Assert\Type(type: 'float')]
  56. #[Groups(['intangiblepriceanddiscount', 'educational_project_intangible_list_intangiblepriceanddiscount', 'access_intangible_list_intangiblepriceanddiscount'])]
  57. private $price;
  58. /**
  59. * @var bool
  60. */
  61. #[ORM\Column(type: 'boolean', options: ['default' => true])]
  62. #[Assert\Type(type: 'boolean')]
  63. #[Assert\NotNull]
  64. #[Groups(['intangiblepriceanddiscount'])]
  65. private $automaticDiscountCalculation = true;
  66. /**
  67. * Sets id.
  68. *
  69. * @param int $id
  70. *
  71. * @return $this
  72. */
  73. public function setId($id)
  74. {
  75. $this->id = $id;
  76. return $this;
  77. }
  78. /**
  79. * Gets id.
  80. *
  81. * @return int
  82. */
  83. public function getId()
  84. {
  85. return $this->id;
  86. }
  87. /**
  88. * Constructor
  89. */
  90. public function __construct()
  91. {
  92. $this->intangibleDiscountDetail = new ArrayCollection();
  93. }
  94. /**
  95. * Set amountType
  96. *
  97. * @param string $amountType
  98. *
  99. * @return IntangiblePriceAndDiscount
  100. */
  101. public function setAmountType($amountType)
  102. {
  103. $this->amountType = $amountType;
  104. return $this;
  105. }
  106. /**
  107. * Get amountType
  108. *
  109. * @return string
  110. */
  111. public function getAmountType()
  112. {
  113. return $this->amountType;
  114. }
  115. /**
  116. * Set applyDiscount
  117. *
  118. * @param boolean $applyDiscount
  119. *
  120. * @return IntangiblePriceAndDiscount
  121. */
  122. public function setApplyDiscount($applyDiscount)
  123. {
  124. $this->applyDiscount = $applyDiscount;
  125. return $this;
  126. }
  127. /**
  128. * Get applyDiscount
  129. *
  130. * @return boolean
  131. */
  132. public function getApplyDiscount()
  133. {
  134. return $this->applyDiscount;
  135. }
  136. /**
  137. * Set price
  138. *
  139. * @param float $price
  140. *
  141. * @return IntangiblePriceAndDiscount
  142. */
  143. public function setPrice($price)
  144. {
  145. $this->price = floatval($price);
  146. return $this;
  147. }
  148. /**
  149. * Get price
  150. *
  151. * @return float
  152. */
  153. public function getPrice()
  154. {
  155. return $this->price;
  156. }
  157. /**
  158. * Add intangibleDiscountDetail
  159. *
  160. * @param \AppBundle\Entity\Product\IntangibleDiscountDetail $intangibleDiscountDetail
  161. *
  162. * @return IntangiblePriceAndDiscount
  163. */
  164. public function addIntangibleDiscountDetail(\AppBundle\Entity\Product\IntangibleDiscountDetail $intangibleDiscountDetail)
  165. {
  166. $intangibleDiscountDetail->setIntangiblePriceAndDiscount($this);
  167. $this->intangibleDiscountDetails[] = $intangibleDiscountDetail;
  168. return $this;
  169. }
  170. /**
  171. * Remove intangibleDiscountDetail
  172. *
  173. * @param \AppBundle\Entity\Product\IntangibleDiscountDetail $intangibleDiscountDetail
  174. */
  175. public function removeIntangibleDiscountDetail(\AppBundle\Entity\Product\IntangibleDiscountDetail $intangibleDiscountDetail)
  176. {
  177. $this->intangibleDiscountDetails->removeElement($intangibleDiscountDetail);
  178. }
  179. /**
  180. * Get intangibleDiscountDetails
  181. *
  182. * @return \Doctrine\Common\Collections\Collection
  183. */
  184. public function getIntangibleDiscountDetails()
  185. {
  186. return $this->intangibleDiscountDetails;
  187. }
  188. /**
  189. * Set automaticDiscountCalculation
  190. *
  191. * @param boolean $automaticDiscountCalculation
  192. *
  193. * @return IntangiblePriceAndDiscount
  194. */
  195. public function setAutomaticDiscountCalculation($automaticDiscountCalculation)
  196. {
  197. $this->automaticDiscountCalculation = $automaticDiscountCalculation;
  198. return $this;
  199. }
  200. /**
  201. * Get automaticDiscountCalculation
  202. *
  203. * @return boolean
  204. */
  205. public function getAutomaticDiscountCalculation()
  206. {
  207. return $this->automaticDiscountCalculation;
  208. }
  209. }