AccessIntangible.php 4.3 KB

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