BankAccount.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493
  1. <?php
  2. namespace AppBundle\Entity\Bank;
  3. use AppBundle\Entity\AccessAndFunction\Access;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Dunglas\ApiBundle\Annotation\Iri;
  6. use Symfony\Component\Serializer\Annotation\Groups;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. use AppBundle\Entity\Organization\Organization;
  9. use AppBundle\Entity\Person\Person;
  10. use AppBundle\Entity\Traits\TimestampableEntity;
  11. use AppBundle\Entity\Traits\CreatorUpdaterEntity;
  12. /**
  13. * Coordonnées bancaires des Person et Organization
  14. *
  15. * @Iri("http://schema.org/BankAccount")
  16. */
  17. #[ORM\Entity(repositoryClass: 'AppBundle\Entity\Bank\Repository\BankAccountRepository')]
  18. class BankAccount
  19. {
  20. use TimestampableEntity;
  21. use CreatorUpdaterEntity;
  22. /**
  23. * @var int
  24. */
  25. #[ORM\Column(type: 'integer')]
  26. #[ORM\Id]
  27. #[ORM\GeneratedValue(strategy: 'AUTO')]
  28. #[Groups(['bankaccount', 'access_details_person', 'organization_details', 'sepa_debit_mandate_person', 'build_bills_access'])]
  29. private $id;
  30. /**
  31. * @var string
  32. */
  33. #[ORM\Column(type: 'string', nullable: true)]
  34. #[Assert\Type(type: 'string')]
  35. #[Assert\Length(max: 255, maxMessage: 'invalid-max-length')]
  36. #[Groups(['bankaccount', 'access_details_person', 'organization_details_bankaccount', 'build_bills_access'])]
  37. private $bankName;
  38. /**
  39. * @var string
  40. */
  41. #[ORM\Column(type: 'string', length: 11, nullable: true)]
  42. #[Assert\Bic(message: 'This is not a valid Business Identifier Code (BIC).')]
  43. #[Groups(['bankaccount', 'access_details_person', 'organization_details_bankaccount', 'sepa_debit_mandate_person', 'build_bills_access'])]
  44. private $bic;
  45. /**
  46. * @var string
  47. */
  48. #[ORM\Column(type: 'string', length: 255, nullable: true)]
  49. #[Groups(['bankaccount'])]
  50. private $bicInvalid;
  51. /**
  52. * @var string
  53. */
  54. #[ORM\Column(type: 'string', length: 34, nullable: true)]
  55. #[Assert\Iban(message: 'This is not a valid International Bank Account Number (IBAN).')]
  56. #[Groups(['bankaccount', 'access_details_person', 'organization_details_bankaccount', 'sepa_debit_mandate_person', 'build_bills_access'])]
  57. private $iban;
  58. /**
  59. * @var string
  60. */
  61. #[ORM\Column(type: 'string', length: 255, nullable: true)]
  62. #[Groups(['bankaccount'])]
  63. private $ibanInvalid;
  64. /**
  65. * @var bool
  66. */
  67. #[ORM\Column(type: 'boolean', options: ['default' => false])]
  68. #[Assert\Type(type: 'boolean')]
  69. #[Assert\NotNull]
  70. #[Groups(['bankaccount', 'access_details_person', 'sepa_debit_mandate_person', 'build_bills_access'])]
  71. private $holderIdDifferent = false;
  72. /**
  73. * 0 => jamais facturé, 1 => facturé 1 fois, 2 => facturé plusieurs fois
  74. * @var int
  75. */
  76. #[ORM\Column(type: 'integer', nullable: true, options: ['default' => 0])]
  77. #[Groups(['bankaccount', 'access_details_person', 'sepa_debit_mandate_person', 'build_bills_access'])]
  78. private $countInvoiced = 0;
  79. /**
  80. * @var string
  81. */
  82. #[ORM\Column(type: 'string', nullable: true)]
  83. #[Assert\Type(type: 'string')]
  84. #[Groups(['bankaccount', 'access_details_person', 'sepa_debit_mandate_person', 'build_bills_access'])]
  85. private $holder;
  86. /**
  87. * @var bool
  88. */
  89. #[ORM\Column(type: 'boolean', options: ['default' => false])]
  90. #[Assert\Type(type: 'boolean')]
  91. #[Assert\NotNull]
  92. #[Groups(['bankaccount', 'access_details_person', 'sepa_debit_mandate_person', 'build_bills_access'])]
  93. private $principal = false;
  94. /**
  95. * @var string
  96. */
  97. #[ORM\Column(type: 'text', nullable: true)]
  98. #[Assert\Type(type: 'string')]
  99. #[Assert\Length(max: 255, maxMessage: 'invalid-max-length')]
  100. #[Groups(['bankaccount', 'access_details_person', 'build_bills_access'])]
  101. private $debitAddress;
  102. /**
  103. * @var Organization
  104. */
  105. #[ORM\ManyToMany(targetEntity: 'AppBundle\Entity\Organization\Organization', mappedBy: 'bankAccount', cascade: ['persist'])]
  106. private $organization;
  107. /**
  108. * @var Person
  109. */
  110. #[ORM\ManyToMany(targetEntity: 'AppBundle\Entity\Person\Person', mappedBy: 'bankAccount', cascade: ['persist'])]
  111. private $person;
  112. /**
  113. * @var string
  114. */
  115. #[ORM\Column(type: 'string', length: 35, unique: true, nullable: true)]
  116. #[Assert\Type(type: 'string')]
  117. #[Groups(['bankaccount', 'access_details_person', 'sepa_debit_mandate_person', 'build_bills_access'])]
  118. #[Assert\Length(max: 35, maxMessage: 'invalid-max-length')]
  119. private $rum;
  120. /**
  121. * @var
  122. *
  123. * @Iri("https://schema.org/birthDate")
  124. */
  125. #[ORM\Column(type: 'date', nullable: true)]
  126. #[Assert\Date(message: 'invalid-date')]
  127. #[Groups(['bankaccount', 'access_details_person', 'build_bills_access'])]
  128. private $signatureDateSamplingMandate;
  129. /**
  130. * Constructor
  131. */
  132. public function __construct()
  133. {
  134. $this->organization = new \Doctrine\Common\Collections\ArrayCollection();
  135. $this->person = new \Doctrine\Common\Collections\ArrayCollection();
  136. }
  137. /**
  138. * Sets id.
  139. *
  140. * @param int $id
  141. *
  142. * @return $this
  143. */
  144. public function setId($id)
  145. {
  146. $this->id = $id;
  147. return $this;
  148. }
  149. /**
  150. * Gets id.
  151. *
  152. * @return int
  153. */
  154. public function getId()
  155. {
  156. return $this->id;
  157. }
  158. /**
  159. * Get organization
  160. *
  161. * @return \Doctrine\Common\Collections\Collection
  162. */
  163. public function getOrganization()
  164. {
  165. return $this->organization;
  166. }
  167. /**
  168. * Get person
  169. *
  170. * @return \Doctrine\Common\Collections\Collection
  171. */
  172. public function getPerson()
  173. {
  174. return $this->person;
  175. }
  176. /**
  177. * Sets bankName.
  178. *
  179. * @param string $bankName
  180. *
  181. * @return $this
  182. */
  183. public function setBankName($bankName)
  184. {
  185. $this->bankName = $bankName;
  186. return $this;
  187. }
  188. /**
  189. * Gets bankName.
  190. *
  191. * @return string
  192. */
  193. public function getBankName()
  194. {
  195. return $this->bankName;
  196. }
  197. /**
  198. * Sets bic.
  199. *
  200. * @param string $bic
  201. *
  202. * @return $this
  203. */
  204. public function setBic($bic)
  205. {
  206. $this->bic = $bic;
  207. if(!is_null($bic) && !is_null($this->getBicInvalid()))
  208. $this->setBicInvalid(NULL);
  209. return $this;
  210. }
  211. /**
  212. * Gets bic.
  213. *
  214. * @return string
  215. */
  216. public function getBic()
  217. {
  218. return $this->bic;
  219. }
  220. /**
  221. * Sets bic Invalid.
  222. *
  223. * @param string $bicInvalid
  224. *
  225. * @return $this
  226. */
  227. public function setBicInvalid($bicInvalid)
  228. {
  229. $this->bicInvalid = is_null($this->bic) ? $bicInvalid : NULL;
  230. return $this;
  231. }
  232. /**
  233. * Gets bic Invalid.
  234. *
  235. * @return string
  236. */
  237. public function getBicInvalid()
  238. {
  239. return $this->bicInvalid;
  240. }
  241. /**
  242. * Sets iban.
  243. *
  244. * @param string $iban
  245. *
  246. * @return $this
  247. */
  248. public function setIban($iban)
  249. {
  250. $this->iban = $iban;
  251. if(!is_null($iban) && !is_null($this->getIbanInvalid()))
  252. $this->setIbanInvalid(NULL);
  253. return $this;
  254. }
  255. /**
  256. * Gets iban.
  257. *
  258. * @return string
  259. */
  260. public function getIban()
  261. {
  262. return $this->iban;
  263. }
  264. /**
  265. * Sets ibanInvalid.
  266. *
  267. * @param string $ibanInvalid
  268. *
  269. * @return $this
  270. */
  271. public function setIbanInvalid($ibanInvalid)
  272. {
  273. $this->ibanInvalid = is_null($this->iban) ? $ibanInvalid : NULL;
  274. return $this;
  275. }
  276. /**
  277. * Gets ibanInvalid.
  278. *
  279. * @return string
  280. */
  281. public function getIbanInvalid()
  282. {
  283. return $this->ibanInvalid;
  284. }
  285. /**
  286. * Sets holder.
  287. *
  288. * @param string $holder
  289. *
  290. * @return $this
  291. */
  292. public function setHolder($holder)
  293. {
  294. $this->holder = $holder;
  295. return $this;
  296. }
  297. /**
  298. * Gets holder.
  299. *
  300. * @return string
  301. */
  302. public function getHolder()
  303. {
  304. return $this->holder;
  305. }
  306. /**
  307. * Sets principal.
  308. *
  309. * @param bool $principal
  310. *
  311. * @return $this
  312. */
  313. public function setPrincipal($principal)
  314. {
  315. $this->principal = $principal;
  316. return $this;
  317. }
  318. /**
  319. * Gets principal.
  320. *
  321. * @return bool
  322. */
  323. public function getPrincipal()
  324. {
  325. return $this->principal;
  326. }
  327. /**
  328. * Sets debitAddress.
  329. *
  330. * @param string $debitAddress
  331. *
  332. * @return $this
  333. */
  334. public function setDebitAddress($debitAddress)
  335. {
  336. $this->debitAddress = $debitAddress;
  337. return $this;
  338. }
  339. /**
  340. * Gets debitAddress.
  341. *
  342. * @return string
  343. */
  344. public function getDebitAddress()
  345. {
  346. return $this->debitAddress;
  347. }
  348. /**
  349. * Add organization
  350. *
  351. * @param \AppBundle\Entity\Organization\Organization $organization
  352. *
  353. * @return BankAccount
  354. */
  355. public function addOrganization(\AppBundle\Entity\Organization\Organization $organization)
  356. {
  357. $this->organization[] = $organization;
  358. return $this;
  359. }
  360. /**
  361. * Remove organization
  362. *
  363. * @param \AppBundle\Entity\Organization\Organization $organization
  364. */
  365. public function removeOrganization(\AppBundle\Entity\Organization\Organization $organization)
  366. {
  367. $this->organization->removeElement($organization);
  368. }
  369. /**
  370. * Add person
  371. *
  372. * @param \AppBundle\Entity\Person\Person $person
  373. *
  374. * @return BankAccount
  375. */
  376. public function addPerson(\AppBundle\Entity\Person\Person $person)
  377. {
  378. $this->person[] = $person;
  379. return $this;
  380. }
  381. /**
  382. * Remove person
  383. *
  384. * @param \AppBundle\Entity\Person\Person $person
  385. */
  386. public function removePerson(\AppBundle\Entity\Person\Person $person)
  387. {
  388. $this->person->removeElement($person);
  389. }
  390. /**
  391. * Get rum
  392. *
  393. * @return string
  394. */
  395. public function getRum()
  396. {
  397. return $this->rum;
  398. }
  399. /**
  400. * Set rum
  401. *
  402. * @param string $rum
  403. *
  404. * @return BankAccount
  405. */
  406. public function setRum($rum)
  407. {
  408. $this->rum = $rum;
  409. return $this;
  410. }
  411. /**
  412. * Set signatureDateSamplingMandate
  413. *
  414. * @param \DateTime $signatureDateSamplingMandate
  415. *
  416. * @return BankAccount
  417. */
  418. public function setSignatureDateSamplingMandate($signatureDateSamplingMandate)
  419. {
  420. $this->signatureDateSamplingMandate = $signatureDateSamplingMandate;
  421. return $this;
  422. }
  423. /**
  424. * Get signatureDateSamplingMandate
  425. *
  426. * @return \DateTime
  427. */
  428. public function getSignatureDateSamplingMandate()
  429. {
  430. return $this->signatureDateSamplingMandate ? $this->signatureDateSamplingMandate->format('Y-m-d') : $this->signatureDateSamplingMandate;
  431. }
  432. /**
  433. * Set holderIdDifferent
  434. *
  435. * @param boolean $holderIdDifferent
  436. *
  437. * @return BankAccount
  438. */
  439. public function setHolderIdDifferent($holderIdDifferent)
  440. {
  441. $this->holderIdDifferent = $holderIdDifferent;
  442. return $this;
  443. }
  444. /**
  445. * Get holderIdDifferent
  446. *
  447. * @return boolean
  448. */
  449. public function getHolderIdDifferent()
  450. {
  451. return $this->holderIdDifferent;
  452. }
  453. /**
  454. * Set countInvoiced
  455. *
  456. * @param integer $countInvoiced
  457. *
  458. * @return BankAccount
  459. */
  460. public function setCountInvoiced($countInvoiced)
  461. {
  462. $this->countInvoiced = $countInvoiced;
  463. return $this;
  464. }
  465. /**
  466. * Get countInvoiced
  467. *
  468. * @return integer
  469. */
  470. public function getCountInvoiced()
  471. {
  472. return $this->countInvoiced;
  473. }
  474. }