AccessBilling.php 5.7 KB

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