EducationalProjectIntangible.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <?php
  2. namespace AppBundle\Entity\Billing;
  3. use AppBundle\Entity\AccessAndFunction\Access;
  4. use AppBundle\Entity\Booking\EducationalProject;
  5. use AppBundle\Entity\Product\Intangible;
  6. use AppBundle\Entity\Traits\LockableTrait;
  7. use AppBundle\Enum\Billing\PeriodicityTypeEnum;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Dunglas\ApiBundle\Annotation\Iri;
  11. use Symfony\Component\Serializer\Annotation\Groups;
  12. use Symfony\Component\Validator\Constraints as Assert;
  13. use AppBundle\Entity\Traits\TimestampableEntity;
  14. use AppBundle\Entity\Traits\CreatorUpdaterEntity;
  15. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  16. /**
  17. * Fais le lien entre l'Access qui règle la facture et l'EducationalProject concerné
  18. *
  19. * @Iri("http://schema.org/EducationalProjectIntangible")
  20. */
  21. #[ORM\Entity]
  22. class EducationalProjectIntangible extends AbstractBillingIntangible
  23. {
  24. use TimestampableEntity;
  25. use CreatorUpdaterEntity;
  26. use LockableTrait;
  27. /**
  28. * @var EducationalProject
  29. */
  30. #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\Booking\EducationalProject', inversedBy: 'educationalProjectIntangibles')]
  31. #[Groups(['educationalprojectintangible'])]
  32. private $educationalProject;
  33. /**
  34. * @var ArrayCollection<BillingIntangibleExcludeDate>
  35. */
  36. #[Assert\Valid]
  37. #[ORM\OneToMany(targetEntity: 'BillingIntangibleExcludeDate', mappedBy: 'educationalProjectIntangible', cascade: ['persist'], orphanRemoval: true)]
  38. #[Groups(['accessintangible'])]
  39. private $billingIntangibleExcludeDates;
  40. /**
  41. * @var float
  42. */
  43. #[ORM\Column(type: 'float', nullable: true)]
  44. #[Assert\Type(type: 'float')]
  45. #[Groups(['educationalprojectintangible'])]
  46. private $unitPrice;
  47. /**
  48. * Constructor
  49. */
  50. public function __construct()
  51. {
  52. parent::__construct();
  53. $this->billingIntangibleExcludeDates = new ArrayCollection();
  54. }
  55. /**
  56. * Set educationalProject
  57. *
  58. * @param \AppBundle\Entity\Booking\EducationalProject $educationalProject
  59. *
  60. * @return EducationalProjectIntangible
  61. */
  62. public function setEducationalProject(\AppBundle\Entity\Booking\EducationalProject $educationalProject)
  63. {
  64. $this->educationalProject = $educationalProject;
  65. return $this;
  66. }
  67. /**
  68. * Get educationalProject
  69. *
  70. * @return \AppBundle\Entity\Booking\EducationalProject
  71. */
  72. public function getEducationalProject()
  73. {
  74. return $this->educationalProject;
  75. }
  76. /**
  77. * applyLock
  78. */
  79. public function applyLock()
  80. {
  81. // if(!is_null($this->getExcludeRule()) && $this->getIntangible()->getBillingPeriodicityType() === PeriodicityTypeEnum::PUNCTUAL){
  82. // $this->setLockable(true);
  83. // }
  84. }
  85. public function adminCanChange(){
  86. return false;
  87. }
  88. /**
  89. * Add billingIntangibleExcludeDate
  90. *
  91. * @param \AppBundle\Entity\Billing\BillingIntangibleExcludeDate $billingIntangibleExcludeDate
  92. *
  93. * @return EducationalProjectIntangible
  94. */
  95. public function addBillingIntangibleExcludeDate(\AppBundle\Entity\Billing\BillingIntangibleExcludeDate $billingIntangibleExcludeDate)
  96. {
  97. $this->billingIntangibleExcludeDates[] = $billingIntangibleExcludeDate;
  98. return $this;
  99. }
  100. /**
  101. * Remove billingIntangibleExcludeDate
  102. *
  103. * @param \AppBundle\Entity\Billing\BillingIntangibleExcludeDate $billingIntangibleExcludeDate
  104. */
  105. public function removeBillingIntangibleExcludeDate(\AppBundle\Entity\Billing\BillingIntangibleExcludeDate $billingIntangibleExcludeDate)
  106. {
  107. $this->billingIntangibleExcludeDates->removeElement($billingIntangibleExcludeDate);
  108. }
  109. /**
  110. * Get billingIntangibleExcludeDates
  111. *
  112. * @return \Doctrine\Common\Collections\Collection
  113. */
  114. public function getBillingIntangibleExcludeDates()
  115. {
  116. return $this->billingIntangibleExcludeDates;
  117. }
  118. /**
  119. * Set unitPrice
  120. *
  121. * @param float $unitPrice
  122. *
  123. * @return EducationalProjectIntangible
  124. */
  125. public function setUnitPrice($unitPrice)
  126. {
  127. $this->unitPrice = floatval($unitPrice);
  128. return $this;
  129. }
  130. /**
  131. * Get unitPrice
  132. *
  133. * @return float
  134. */
  135. public function getUnitPrice()
  136. {
  137. return $this->unitPrice;
  138. }
  139. }