BankAccount.php 6.6 KB

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