BillPayment.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\Billing;
  4. use ApiPlatform\Metadata\ApiResource;
  5. use App\Entity\Core\Tagg;
  6. // use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
  7. use App\Entity\Person\PersonActivity;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Doctrine\Common\Collections\Collection;
  10. use Doctrine\ORM\Mapping as ORM;
  11. /**
  12. * Données de paiement d'une facture BillAccounting
  13. * NB: il peut y avoir plusieurs lignes pour une facture en cas de paiement en plusieurs fois
  14. */
  15. // #[Auditable]
  16. #[ApiResource(operations: [])]
  17. #[ORM\Entity]
  18. class BillPayment
  19. {
  20. #[ORM\Id]
  21. #[ORM\Column]
  22. #[ORM\GeneratedValue]
  23. private ?int $id = null;
  24. #[ORM\ManyToOne(cascade: ['persist'], inversedBy: 'billPayments')]
  25. #[ORM\JoinColumn(nullable: true)]
  26. private BillAccounting|null $bill = null;
  27. #[ORM\ManyToOne(cascade: ['persist'], inversedBy: 'billDetachedPayments')]
  28. #[ORM\JoinColumn(nullable: true)]
  29. private ?AccessBilling $accessBilling = null;
  30. /** @var Collection<int, BillDebitBalance> */
  31. #[ORM\OneToMany(targetEntity: BillDebitBalance::class, mappedBy: 'billPayment', cascade: ['persist'], orphanRemoval: true)]
  32. #[ORM\JoinColumn(nullable: true)]
  33. private Collection $billDebitBalances;
  34. #[ORM\ManyToOne(cascade: ['persist'], inversedBy: 'accountBalanceReimbursements')]
  35. #[ORM\JoinColumn(nullable: true)]
  36. private ?AccessBilling $accessBillingAccountBalanceReimbursement = null;
  37. /** @var Collection<int, Tagg> */
  38. #[ORM\ManyToMany(targetEntity: Tagg::class, inversedBy: 'payments', cascade: ['persist'])]
  39. #[ORM\JoinTable(name: 'tag_billPayment')]
  40. #[ORM\JoinColumn(name: 'billPayment_id', referencedColumnName: 'id')]
  41. #[ORM\InverseJoinColumn(name: 'tag_id', referencedColumnName: 'id')]
  42. private Collection $tags;
  43. #[ORM\ManyToOne(targetEntity: SddBank::class, cascade: ['persist'], inversedBy: 'billPayments')]
  44. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
  45. protected SddBank $sddBank;
  46. #[ORM\ManyToOne(targetEntity: SddRegie::class, cascade: ['persist'], inversedBy: 'billPayments')]
  47. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
  48. protected SddRegie $sddRegie;
  49. public function __construct()
  50. {
  51. $this->billDebitBalances = new ArrayCollection();
  52. $this->tags = new ArrayCollection();
  53. }
  54. public function getId(): ?int
  55. {
  56. return $this->id;
  57. }
  58. public function getBill(): ?AbstractBillAccounting
  59. {
  60. return $this->bill;
  61. }
  62. public function setBill(?AbstractBillAccounting $bill): self
  63. {
  64. $this->bill = $bill;
  65. return $this;
  66. }
  67. public function getAccessBilling(): ?AccessBilling
  68. {
  69. return $this->accessBilling;
  70. }
  71. public function setAccessBilling(?AccessBilling $accessBilling): self
  72. {
  73. $this->accessBilling = $accessBilling;
  74. return $this;
  75. }
  76. /**
  77. * @return Collection<int, BillDebitBalance>
  78. */
  79. public function getBillDebitBalances(): Collection
  80. {
  81. return $this->billDebitBalances;
  82. }
  83. public function addBillDebitBalance(BillDebitBalance $billDebitBalance): self
  84. {
  85. if (!$this->billDebitBalances->contains($billDebitBalance)) {
  86. $this->billDebitBalances[] = $billDebitBalance;
  87. $billDebitBalance->setBillPayment($this);
  88. }
  89. return $this;
  90. }
  91. public function removeBillDebitBalance(BillDebitBalance $billDebitBalance): self
  92. {
  93. if ($this->billDebitBalances->removeElement($billDebitBalance)) {
  94. // set the owning side to null (unless already changed)
  95. if ($billDebitBalance->getBillPayment() === $this) {
  96. $billDebitBalance->setBillPayment(null);
  97. }
  98. }
  99. return $this;
  100. }
  101. public function getAccessBillingAccountBalanceReimbursement(): ?AccessBilling
  102. {
  103. return $this->accessBillingAccountBalanceReimbursement;
  104. }
  105. public function setAccessBillingAccountBalanceReimbursement(?AccessBilling $accessBillingAccountBalanceReimbursement): self
  106. {
  107. $this->accessBillingAccountBalanceReimbursement = $accessBillingAccountBalanceReimbursement;
  108. return $this;
  109. }
  110. /**
  111. * @return Collection<int, Tagg>
  112. */
  113. public function getTags(): Collection
  114. {
  115. return $this->tags;
  116. }
  117. public function addTag(Tagg $tag): self
  118. {
  119. if (!$this->tags->contains($tag)) {
  120. $this->tags[] = $tag;
  121. }
  122. return $this;
  123. }
  124. public function removeTag(Tagg $tag): self
  125. {
  126. $this->tags->removeElement($tag);
  127. return $this;
  128. }
  129. public function getSddBank(): SddBank
  130. {
  131. return $this->sddBank;
  132. }
  133. public function setSddBank(SddBank $sddBank): self
  134. {
  135. $this->sddBank = $sddBank;
  136. return $this;
  137. }
  138. public function getSddRegie(): SddRegie
  139. {
  140. return $this->sddRegie;
  141. }
  142. public function setSddRegie(SddRegie $sddRegie): self
  143. {
  144. $this->sddRegie = $sddRegie;
  145. return $this;
  146. }
  147. }