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