BankAccount.php 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\Core;
  4. use ApiPlatform\Metadata\ApiResource;
  5. use App\Entity\Billing\ResidenceArea;
  6. use App\Entity\Organization\Organization;
  7. use App\Entity\Person\Person;
  8. use App\Repository\Core\BankAccountRepository;
  9. // use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
  10. use Doctrine\Common\Collections\ArrayCollection;
  11. use Doctrine\Common\Collections\Collection;
  12. use Doctrine\ORM\Mapping as ORM;
  13. use JetBrains\PhpStorm\Pure;
  14. use Symfony\Component\Validator\Constraints as Assert;
  15. /**
  16. * Données bancaire d'une Person ou d'une Organization.
  17. *
  18. * Security :
  19. *
  20. * * @see App\Security\Voter\BankAccountVoter
  21. */
  22. #[ApiResource(operations: [])]
  23. // #[Auditable]
  24. #[ORM\Entity(repositoryClass: BankAccountRepository::class)]
  25. class BankAccount
  26. {
  27. #[ORM\Id]
  28. #[ORM\Column]
  29. #[ORM\GeneratedValue]
  30. private ?int $id = null;
  31. #[ORM\Column(length: 255, nullable: true)]
  32. private ?string $bankName = null;
  33. #[ORM\Column(length: 11, nullable: true)]
  34. #[Assert\Bic(message: 'invalid_bic')]
  35. private ?string $bic = null;
  36. #[ORM\Column(length: 255, nullable: true)]
  37. private ?string $bicInvalid = null;
  38. #[ORM\Column(length: 34, nullable: true)]
  39. #[Assert\Iban(message: 'invalid_iban')]
  40. private ?string $iban = null;
  41. #[ORM\Column(length: 255, nullable: true)]
  42. private ?string $ibanInvalid = null;
  43. #[ORM\Column(options: ['default' => false])]
  44. private bool $holderIdDifferent = false;
  45. /**
  46. * 0 => jamais facturé, 1 => facturé 1 fois, 2 => facturé plusieurs fois.
  47. */
  48. #[ORM\Column(options: ['default' => 0])]
  49. private int $countInvoiced = 0;
  50. #[ORM\Column(length: 255, nullable: true)]
  51. private ?string $holder = null;
  52. #[ORM\Column(options: ['default' => false])]
  53. #[Assert\NotNull]
  54. private bool $principal = false;
  55. #[ORM\Column(type: 'text', nullable: true)]
  56. private ?string $debitAddress = null;
  57. #[ORM\Column(length: 35, unique: true, nullable: true)]
  58. private ?string $rum = null;
  59. #[ORM\Column(type: 'date', nullable: true)]
  60. private ?\DateTimeInterface $signatureDateSamplingMandate;
  61. /** @var Collection<int, Organization> */
  62. #[ORM\ManyToMany(targetEntity: Organization::class, mappedBy: 'bankAccounts', cascade: ['persist'])]
  63. private Collection $organization;
  64. /** @var Collection<int, Person> */
  65. #[ORM\ManyToMany(targetEntity: Person::class, mappedBy: 'bankAccount', cascade: ['persist'])]
  66. private Collection $person;
  67. #[Pure]
  68. public function __construct()
  69. {
  70. $this->organization = new ArrayCollection();
  71. $this->person = new ArrayCollection();
  72. }
  73. public function getId(): ?int
  74. {
  75. return $this->id;
  76. }
  77. public function getBankName(): ?string
  78. {
  79. return $this->bankName;
  80. }
  81. public function setBankName(?string $bankName): self
  82. {
  83. $this->bankName = $bankName;
  84. return $this;
  85. }
  86. public function getBic(): ?string
  87. {
  88. return $this->bic;
  89. }
  90. public function setBic(?string $bic): self
  91. {
  92. $this->bic = $bic;
  93. return $this;
  94. }
  95. public function getBicInvalid(): ?string
  96. {
  97. return $this->bicInvalid;
  98. }
  99. public function setBicInvalid(?string $bicInvalid): self
  100. {
  101. $this->bicInvalid = $bicInvalid;
  102. return $this;
  103. }
  104. public function getIban(): ?string
  105. {
  106. return $this->iban;
  107. }
  108. public function setIban(?string $iban): self
  109. {
  110. $this->iban = $iban;
  111. return $this;
  112. }
  113. public function getIbanInvalid(): ?string
  114. {
  115. return $this->ibanInvalid;
  116. }
  117. public function setIbanInvalid(?string $ibanInvalid): self
  118. {
  119. $this->ibanInvalid = $ibanInvalid;
  120. return $this;
  121. }
  122. public function getHolderIdDifferent(): bool
  123. {
  124. return $this->holderIdDifferent;
  125. }
  126. public function setHolderIdDifferent(bool $holderIdDifferent): self
  127. {
  128. $this->holderIdDifferent = $holderIdDifferent;
  129. return $this;
  130. }
  131. public function getCountInvoiced(): int
  132. {
  133. return $this->countInvoiced;
  134. }
  135. public function setCountInvoiced(int $countInvoiced): self
  136. {
  137. $this->countInvoiced = $countInvoiced;
  138. return $this;
  139. }
  140. public function getHolder(): ?string
  141. {
  142. return $this->holder;
  143. }
  144. public function setHolder(?string $holder): self
  145. {
  146. $this->holder = $holder;
  147. return $this;
  148. }
  149. public function getPrincipal(): bool
  150. {
  151. return $this->principal;
  152. }
  153. public function setPrincipal(bool $principal): self
  154. {
  155. $this->principal = $principal;
  156. return $this;
  157. }
  158. public function getDebitAddress(): ?string
  159. {
  160. return $this->debitAddress;
  161. }
  162. public function setDebitAddress(?string $debitAddress): self
  163. {
  164. $this->debitAddress = $debitAddress;
  165. return $this;
  166. }
  167. public function getOrganization(): Collection
  168. {
  169. return $this->organization;
  170. }
  171. public function addOrganization(Organization $organization): self
  172. {
  173. if (!$this->organization->contains($organization)) {
  174. $this->organization[] = $organization;
  175. $organization->addBankAccount($this);
  176. }
  177. return $this;
  178. }
  179. public function removeOrganization(Organization $organization): self
  180. {
  181. if ($this->organization->removeElement($organization)) {
  182. $organization->removeBankAccount($this);
  183. }
  184. return $this;
  185. }
  186. public function getRum(): ?string
  187. {
  188. return $this->rum;
  189. }
  190. public function setRum(?string $rum): self
  191. {
  192. $this->rum = $rum;
  193. return $this;
  194. }
  195. public function getSignatureDateSamplingMandate(): ?\DateTimeInterface
  196. {
  197. return $this->signatureDateSamplingMandate;
  198. }
  199. public function setSignatureDateSamplingMandate(?\DateTimeInterface $signatureDateSamplingMandate): self
  200. {
  201. $this->signatureDateSamplingMandate = $signatureDateSamplingMandate;
  202. return $this;
  203. }
  204. /**
  205. * @return Collection<int, Person>
  206. */
  207. public function getPerson(): Collection
  208. {
  209. return $this->person;
  210. }
  211. public function addPerson(Person $person): self
  212. {
  213. if (!$this->person->contains($person)) {
  214. $this->person[] = $person;
  215. $person->addBankAccount($this);
  216. }
  217. return $this;
  218. }
  219. public function removePerson(Person $person): self
  220. {
  221. if ($this->person->removeElement($person)) {
  222. $person->removeBankAccount($this);
  223. }
  224. return $this;
  225. }
  226. }