BankAccount.php 5.9 KB

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