AccessBilling.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <?php
  2. declare (strict_types=1);
  3. namespace App\Entity\Billing;
  4. use ApiPlatform\Metadata\Get;
  5. use ApiPlatform\Metadata\Put;
  6. use App\Entity\Access\Access;
  7. //use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use ApiPlatform\Metadata\ApiResource;
  10. use ApiPlatform\Metadata\GetCollection;
  11. use Doctrine\Common\Collections\Collection;
  12. use Doctrine\Common\Collections\ArrayCollection;
  13. /**
  14. * Classe ... qui ...
  15. */
  16. #[ApiResource(
  17. operations: [
  18. new Get(
  19. security: 'is_granted(\'ROLE_ADMIN\') and object.getAccess().getOrganization().getId() == user.getOrganization().getId()'
  20. )
  21. ]
  22. )]
  23. //#[Auditable]
  24. #[ORM\Entity]
  25. class AccessBilling
  26. {
  27. #[ORM\Column]
  28. #[ORM\Id]
  29. #[ORM\GeneratedValue]
  30. private ?int $id = null;
  31. #[ORM\OneToOne(inversedBy: 'accessBilling', cascade: ['persist'], fetch: 'EAGER')]
  32. #[ORM\JoinColumn(nullable: true, onDelete: 'CASCADE')]
  33. private Access $access;
  34. #[ORM\ManyToOne(cascade: ['persist'], inversedBy: 'accessBilling')]
  35. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
  36. private FamilyQuotient $familyQuotient;
  37. #[ORM\ManyToOne(cascade: ['persist'], inversedBy: 'accessBilling')]
  38. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
  39. private ResidenceArea $residenceArea;
  40. #[ORM\OneToMany(mappedBy: 'accessBilling', targetEntity: BillPayment::class, cascade: ['persist'], orphanRemoval: true)]
  41. private Collection $billDetachedPayments;
  42. #[ORM\OneToMany(mappedBy: 'accessBilling', targetEntity: BillDebitBalance::class, cascade: ['persist'], orphanRemoval: true)]
  43. private Collection $billDebitBalances;
  44. #[ORM\OneToMany(mappedBy: 'accessBillingAccountBalanceReimbursement', targetEntity: BillPayment::class, cascade: ['persist'], orphanRemoval: true)]
  45. private Collection $accountBalanceReimbursements;
  46. public function __construct()
  47. {
  48. $this->billDetachedPayments = new ArrayCollection();
  49. $this->billDebitBalances = new ArrayCollection();
  50. $this->accountBalanceReimbursements = new ArrayCollection();
  51. }
  52. public function getId(): ?int
  53. {
  54. return $this->id;
  55. }
  56. public function getFamilyQuotient(): ?FamilyQuotient
  57. {
  58. return $this->familyQuotient;
  59. }
  60. public function setFamilyQuotient(?FamilyQuotient $familyQuotient): self
  61. {
  62. $this->familyQuotient = $familyQuotient;
  63. return $this;
  64. }
  65. public function getResidenceArea(): ?ResidenceArea
  66. {
  67. return $this->residenceArea;
  68. }
  69. public function setResidenceArea(?ResidenceArea $residenceArea): self
  70. {
  71. $this->residenceArea = $residenceArea;
  72. return $this;
  73. }
  74. /**
  75. * @return Collection<int, BillPayment>
  76. */
  77. public function getBillDetachedPayments(): Collection
  78. {
  79. return $this->billDetachedPayments;
  80. }
  81. public function addBillDetachedPayment(BillPayment $billDetachedPayment): self
  82. {
  83. if (!$this->billDetachedPayments->contains($billDetachedPayment)) {
  84. $this->billDetachedPayments[] = $billDetachedPayment;
  85. $billDetachedPayment->setAccessBilling($this);
  86. }
  87. return $this;
  88. }
  89. public function removeBillDetachedPayment(BillPayment $billDetachedPayment): self
  90. {
  91. if ($this->billDetachedPayments->removeElement($billDetachedPayment)) {
  92. // set the owning side to null (unless already changed)
  93. if ($billDetachedPayment->getAccessBilling() === $this) {
  94. $billDetachedPayment->setAccessBilling(null);
  95. }
  96. }
  97. return $this;
  98. }
  99. /**
  100. * @return Collection<int, BillDebitBalance>
  101. */
  102. public function getBillDebitBalances(): Collection
  103. {
  104. return $this->billDebitBalances;
  105. }
  106. public function addBillDebitBalance(BillDebitBalance $billDebitBalance): self
  107. {
  108. if (!$this->billDebitBalances->contains($billDebitBalance)) {
  109. $this->billDebitBalances[] = $billDebitBalance;
  110. $billDebitBalance->setAccessBilling($this);
  111. }
  112. return $this;
  113. }
  114. public function removeBillDebitBalance(BillDebitBalance $billDebitBalance): self
  115. {
  116. if ($this->billDebitBalances->removeElement($billDebitBalance)) {
  117. // set the owning side to null (unless already changed)
  118. if ($billDebitBalance->getAccessBilling() === $this) {
  119. $billDebitBalance->setAccessBilling(null);
  120. }
  121. }
  122. return $this;
  123. }
  124. /**
  125. * @return Collection<int, BillPayment>
  126. */
  127. public function getAccountBalanceReimbursements(): Collection
  128. {
  129. return $this->accountBalanceReimbursements;
  130. }
  131. public function addAccountBalanceReimbursement(BillPayment $accountBalanceReimbursement): self
  132. {
  133. if (!$this->accountBalanceReimbursements->contains($accountBalanceReimbursement)) {
  134. $this->accountBalanceReimbursements[] = $accountBalanceReimbursement;
  135. $accountBalanceReimbursement->setAccessBillingAccountBalanceReimbursement($this);
  136. }
  137. return $this;
  138. }
  139. public function removeAccountBalanceReimbursement(BillPayment $accountBalanceReimbursement): self
  140. {
  141. if ($this->accountBalanceReimbursements->removeElement($accountBalanceReimbursement)) {
  142. // set the owning side to null (unless already changed)
  143. if ($accountBalanceReimbursement->getAccessBillingAccountBalanceReimbursement() === $this) {
  144. $accountBalanceReimbursement->setAccessBillingAccountBalanceReimbursement(null);
  145. }
  146. }
  147. return $this;
  148. }
  149. public function getAccess(): ?Access
  150. {
  151. return $this->access;
  152. }
  153. public function setAccess(?Access $access): self
  154. {
  155. $this->access = $access;
  156. return $this;
  157. }
  158. }