AccessBilling.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  1. <?php
  2. namespace AppBundle\Entity\Billing;
  3. use AppBundle\Entity\AccessAndFunction\Access;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Dunglas\ApiBundle\Annotation\Iri;
  7. use Symfony\Component\Serializer\Annotation\Groups;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. use AppBundle\Entity\Traits\TimestampableEntity;
  10. use AppBundle\Entity\Traits\CreatorUpdaterEntity;
  11. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  12. use AppBundle\Validator\Constraints\Billing as OpentalentAssert;
  13. /**
  14. * Paramètres de facturation pour un Access
  15. *
  16. * @Iri("http://schema.org/AccessBilling")
  17. * @OpentalentAssert\CustomerId
  18. */
  19. #[ORM\Entity(repositoryClass: 'AppBundle\Entity\Billing\Repository\AccessBillingRepository')]
  20. class AccessBilling
  21. {
  22. use TimestampableEntity;
  23. use CreatorUpdaterEntity;
  24. /**
  25. * @var int
  26. */
  27. #[ORM\Column(type: 'integer')]
  28. #[ORM\Id]
  29. #[ORM\GeneratedValue(strategy: 'AUTO')]
  30. #[Groups(['accessbilling', 'access_mass', 'access_details', 'access_details_accessbilling', 'student_registration', 'student_registration_guardians', 'accesses_list', 'student_list', 'guardians_list', 'adherent_list', 'personnels_list', 'payer_list', 'accessbilling_edit', 'sepa_debit_mandate', 'fusion_accesses', 'online_registration_access_details', 'account_balance_reimbursements', 'billpayment_list'])]
  31. private $id;
  32. /**
  33. * @var Access
  34. */
  35. #[Assert\Valid]
  36. #[ORM\OneToOne(targetEntity: 'AppBundle\Entity\AccessAndFunction\Access', inversedBy: 'accessBilling', cascade: ['persist'], fetch: 'EAGER')]
  37. #[ORM\JoinColumn(nullable: true, onDelete: 'CASCADE')]
  38. #[Groups(['accessbilling', 'billpayment_list_accessbillingaccountbalancereimbursement'])]
  39. private $access;
  40. /**
  41. * @var string
  42. */
  43. #[ORM\Column(type: 'string', nullable: true)]
  44. #[Assert\Type(type: 'string')]
  45. #[Groups(['accessbilling', 'student_registration_accessbilling', 'student_registration_guardians', 'payer_list_accessbilling', 'accessbilling_edit_accessbilling'])]
  46. private $customerId;
  47. /**
  48. * @var string
  49. */
  50. #[ORM\Column(type: 'string', nullable: true)]
  51. #[Assert\Type(type: 'string')]
  52. #[Assert\Choice(callback: ['\AppBundle\Enum\Billing\PaymentChoiceEnum', 'toArray'])]
  53. #[Groups(['accessbilling', 'student_registration_accessbilling', 'student_registration_guardians', 'bill_list_access', 'payer_list_accessbilling', 'accessbilling_edit_accessbilling', 'online_registration_access_details_accessbilling', 'build_bills_billlines', 'build_bills_access'])]
  54. private $paymentChoice;
  55. /**
  56. * @var FamilyQuotient
  57. */
  58. #[Assert\Valid]
  59. #[ORM\ManyToOne(targetEntity: 'FamilyQuotient', cascade: ['persist'], inversedBy: 'accessBilling')]
  60. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
  61. #[Groups(['accessbilling', 'student_registration_accessbilling', 'student_registration_accessbilling', 'access_mass_accessbilling', 'payer_list_accessbilling', 'accessbilling_edit_accessbilling', 'fusion_accesses_accessbilling', 'student_list_accessbilling'])]
  62. private $familyQuotient;
  63. /**
  64. * @var ResidenceArea
  65. */
  66. #[Assert\Valid]
  67. #[ORM\ManyToOne(targetEntity: 'ResidenceArea', cascade: ['persist'], inversedBy: 'accessBilling')]
  68. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
  69. #[Groups(['accessbilling', 'access_details_accessbilling', 'access_mass_accessbilling', 'student_registration_accessbilling', 'accesses_list_accessbilling', 'student_list_accessbilling', 'guardians_list_accessbilling', 'adherent_list_accessbilling', 'personnels_list_accessbilling', 'payer_list_accessbilling', 'accessbilling_edit_accessbilling', 'fusion_accesses_accessbilling', 'online_registration_access_details_accessbilling'])]
  70. private $residenceArea;
  71. /**
  72. * @var string
  73. */
  74. #[ORM\Column(type: 'string', nullable: true)]
  75. #[Assert\Type(type: 'string')]
  76. #[Assert\Choice(callback: ['\AppBundle\Enum\Billing\PeriodicityPaymentEnum', 'toArray'])]
  77. #[Groups(['accessbilling', 'student_registration_accessbilling', 'student_registration_guardians', 'payer_list_accessbilling', 'accessbilling_edit_accessbilling', 'sepa_debit_mandate_accessbilling'])]
  78. private $periodicityPayment;
  79. /**
  80. * @var ArrayCollection<Billpayment>
  81. */
  82. #[ORM\OneToMany(targetEntity: 'BillPayment', mappedBy: 'accessBilling', cascade: ['persist'], orphanRemoval: true)]
  83. #[Groups(['accessbilling_billpayment'])]
  84. private $billDetachedPayments;
  85. /**
  86. * @var ArrayCollection<BillDebitBalance>
  87. */
  88. #[ORM\OneToMany(targetEntity: 'BillDebitBalance', mappedBy: 'accessBilling', cascade: ['persist'], orphanRemoval: true)]
  89. #[Groups(['accessbilling_billdebitbalance'])]
  90. private $billDebitBalances;
  91. /**
  92. * @var string
  93. */
  94. #[ORM\Column(type: 'string', options: ['default' => 'APPLY_ADHESION'])]
  95. #[Assert\Type(type: 'string')]
  96. #[Assert\NotNull]
  97. #[Assert\Choice(callback: ['\AppBundle\Enum\Billing\AdhesionChoiceEnum', 'toArray'])]
  98. #[Groups(['accessbilling', 'student_registration_accessbilling', 'student_registration_guardians', 'accessbilling_edit_accessbilling'])]
  99. private $adhesionChoice = "APPLY_ADHESION";
  100. /**
  101. * @var float
  102. */
  103. #[ORM\Column(type: 'float', nullable: true)]
  104. #[Assert\Type(type: 'float')]
  105. #[Groups(['accessbilling', 'student_registration_accessbilling', 'student_registration_guardians', 'accessbilling_edit_accessbilling'])]
  106. private $adhesionAmount;
  107. /**
  108. * @var float
  109. */
  110. #[ORM\Column(type: 'float', nullable: true, options: ['default' => '0.0'])]
  111. #[Assert\Type(type: 'float')]
  112. #[Groups(['accessbilling', 'payer_list_accessbilling'])]
  113. private $accountBalance = 0.0;
  114. /**
  115. * @var \DateTime
  116. */
  117. #[ORM\Column(type: 'date', nullable: true)]
  118. #[Assert\Date]
  119. #[Groups(['accessbilling'])]
  120. private $accountBalanceUpdateDate;
  121. /**
  122. * @var float
  123. */
  124. #[ORM\Column(type: 'float', nullable: true, options: ['default' => '0.0'])]
  125. #[Assert\Type(type: 'float')]
  126. #[Groups(['accessbilling'])]
  127. private $reportPaymentsAmount = 0.0;
  128. /**
  129. * @var ArrayCollection<Billpayment>
  130. */
  131. #[ORM\OneToMany(targetEntity: 'BillPayment', mappedBy: 'accessBillingAccountBalanceReimbursement', cascade: ['persist'], orphanRemoval: true)]
  132. #[Groups(['accessbilling_accountbalancereimbursements', 'account_balance_reimbursements_accessbilling'])]
  133. private $accountBalanceReimbursements;
  134. /**
  135. * The constructor
  136. */
  137. public function __construct() {
  138. $this->billDetachedPayments = new ArrayCollection();
  139. $this->billDebitBalances = new ArrayCollection();
  140. $this->accountBalanceReimbursements = new ArrayCollection();
  141. }
  142. /**
  143. * Sets id.
  144. *
  145. * @param int $id
  146. *
  147. * @return $this
  148. */
  149. public function setId($id)
  150. {
  151. $this->id = $id;
  152. return $this;
  153. }
  154. /**
  155. * Gets id.
  156. *
  157. * @return int
  158. */
  159. public function getId()
  160. {
  161. return $this->id;
  162. }
  163. /**
  164. * Set customerId
  165. *
  166. * @param string $customerId
  167. *
  168. * @return AccessBilling
  169. */
  170. public function setCustomerId($customerId = null)
  171. {
  172. if(empty($customerId))
  173. $customerId = null;
  174. $this->customerId = $customerId;
  175. return $this;
  176. }
  177. /**
  178. * Get customerId
  179. *
  180. * @return string
  181. */
  182. public function getCustomerId()
  183. {
  184. return $this->customerId;
  185. }
  186. /**
  187. * Set paymentChoice
  188. *
  189. * @param string $paymentChoice
  190. *
  191. * @return AccessBilling
  192. */
  193. public function setPaymentChoice($paymentChoice)
  194. {
  195. $this->paymentChoice = $paymentChoice;
  196. return $this;
  197. }
  198. /**
  199. * Get paymentChoice
  200. *
  201. * @return string
  202. */
  203. public function getPaymentChoice()
  204. {
  205. return $this->paymentChoice;
  206. }
  207. /**
  208. * Set familyQuotient
  209. *
  210. * @param \AppBundle\Entity\Billing\FamilyQuotient $familyQuotient
  211. *
  212. * @return AccessBilling
  213. */
  214. public function setFamilyQuotient(\AppBundle\Entity\Billing\FamilyQuotient $familyQuotient = null)
  215. {
  216. $this->familyQuotient = $familyQuotient;
  217. return $this;
  218. }
  219. /**
  220. * Get familyQuotient
  221. *
  222. * @return \AppBundle\Entity\Billing\FamilyQuotient
  223. */
  224. public function getFamilyQuotient()
  225. {
  226. return $this->familyQuotient;
  227. }
  228. /**
  229. * Set residenceArea
  230. *
  231. * @param \AppBundle\Entity\Billing\ResidenceArea $residenceArea
  232. *
  233. * @return AccessBilling
  234. */
  235. public function setResidenceArea(\AppBundle\Entity\Billing\ResidenceArea $residenceArea = null)
  236. {
  237. $this->residenceArea = $residenceArea;
  238. return $this;
  239. }
  240. /**
  241. * Get residenceArea
  242. *
  243. * @return \AppBundle\Entity\Billing\ResidenceArea
  244. */
  245. public function getResidenceArea()
  246. {
  247. return $this->residenceArea;
  248. }
  249. /**
  250. * Set access
  251. *
  252. * @param \AppBundle\Entity\AccessAndFunction\Access $access
  253. *
  254. * @return AccessBilling
  255. */
  256. public function setAccess(\AppBundle\Entity\AccessAndFunction\Access $access = null)
  257. {
  258. $this->access = $access;
  259. return $this;
  260. }
  261. /**
  262. * Get access
  263. *
  264. * @return \AppBundle\Entity\AccessAndFunction\Access
  265. */
  266. public function getAccess()
  267. {
  268. return $this->access;
  269. }
  270. /**
  271. * Set periodicityPayment
  272. *
  273. * @param string $periodicityPayment
  274. *
  275. * @return AccessBilling
  276. */
  277. public function setPeriodicityPayment($periodicityPayment)
  278. {
  279. $this->periodicityPayment = $periodicityPayment;
  280. return $this;
  281. }
  282. /**
  283. * Get periodicityPayment
  284. *
  285. * @return string
  286. */
  287. public function getPeriodicityPayment()
  288. {
  289. return $this->periodicityPayment;
  290. }
  291. /**
  292. * Add billDetachedPayment
  293. *
  294. * @param \AppBundle\Entity\Billing\BillPayment $billDetachedPayment
  295. *
  296. * @return AccessBilling
  297. */
  298. public function addBillDetachedPayment(\AppBundle\Entity\Billing\BillPayment $billDetachedPayment)
  299. {
  300. $billDetachedPayment->setAccessBilling($this);
  301. $this->billDetachedPayments[] = $billDetachedPayment;
  302. return $this;
  303. }
  304. /**
  305. * Remove billDetachedPayment
  306. *
  307. * @param \AppBundle\Entity\Billing\BillPayment $billDetachedPayment
  308. */
  309. public function removeBillDetachedPayment(\AppBundle\Entity\Billing\BillPayment $billDetachedPayment)
  310. {
  311. $this->billDetachedPayments->removeElement($billDetachedPayment);
  312. }
  313. /**
  314. * Get billDetachedPayments
  315. *
  316. * @return \Doctrine\Common\Collections\Collection
  317. */
  318. public function getBillDetachedPayments()
  319. {
  320. return $this->billDetachedPayments;
  321. }
  322. /**
  323. * Add billDebitBalance
  324. *
  325. * @param \AppBundle\Entity\Billing\BillDebitBalance $billDebitBalance
  326. *
  327. * @return AccessBilling
  328. */
  329. public function addBillDebitBalance(\AppBundle\Entity\Billing\BillDebitBalance $billDebitBalance)
  330. {
  331. $billDebitBalance->setAccessBilling($this);
  332. $this->billDebitBalances[] = $billDebitBalance;
  333. return $this;
  334. }
  335. /**
  336. * Remove billDebitBalance
  337. *
  338. * @param \AppBundle\Entity\Billing\BillDebitBalance $billDebitBalance
  339. */
  340. public function removeBillDebitBalance(\AppBundle\Entity\Billing\BillDebitBalance $billDebitBalance)
  341. {
  342. $this->billDebitBalances->removeElement($billDebitBalance);
  343. }
  344. /**
  345. * Get billDebitBalances
  346. *
  347. * @return \Doctrine\Common\Collections\Collection
  348. */
  349. public function getBillDebitBalances()
  350. {
  351. return $this->billDebitBalances;
  352. }
  353. /**
  354. * Set adhesionChoice
  355. *
  356. * @param string $adhesionChoice
  357. *
  358. * @return AccessBilling
  359. */
  360. public function setAdhesionChoice($adhesionChoice)
  361. {
  362. $this->adhesionChoice = $adhesionChoice;
  363. return $this;
  364. }
  365. /**
  366. * Get adhesionChoice
  367. *
  368. * @return string
  369. */
  370. public function getAdhesionChoice()
  371. {
  372. return $this->adhesionChoice;
  373. }
  374. /**
  375. * Set adhesionAmount
  376. *
  377. * @param float $adhesionAmount
  378. *
  379. * @return AccessBilling
  380. */
  381. public function setAdhesionAmount($adhesionAmount)
  382. {
  383. $this->adhesionAmount = floatval($adhesionAmount);
  384. return $this;
  385. }
  386. /**
  387. * Get adhesionAmount
  388. *
  389. * @return float
  390. */
  391. public function getAdhesionAmount()
  392. {
  393. return $this->adhesionAmount;
  394. }
  395. /**
  396. * Set accountBalance
  397. *
  398. * @param float $accountBalance
  399. *
  400. * @return AccessBilling
  401. */
  402. public function setAccountBalance($accountBalance)
  403. {
  404. $this->accountBalance = $accountBalance;
  405. return $this;
  406. }
  407. /**
  408. * Get accountBalance
  409. *
  410. * @return float
  411. */
  412. public function getAccountBalance()
  413. {
  414. return $this->accountBalance;
  415. }
  416. /**
  417. * Set accountBalanceUpdateDate
  418. *
  419. * @param \DateTime $accountBalanceUpdateDate
  420. *
  421. * @return AccessBilling
  422. */
  423. public function setAccountBalanceUpdateDate($accountBalanceUpdateDate)
  424. {
  425. $this->accountBalanceUpdateDate = $accountBalanceUpdateDate;
  426. return $this;
  427. }
  428. /**
  429. * Get accountBalanceUpdateDate
  430. *
  431. * @return \DateTime
  432. */
  433. public function getAccountBalanceUpdateDate()
  434. {
  435. return $this->accountBalanceUpdateDate;
  436. }
  437. /**
  438. * Set reportPaymentsAmount
  439. *
  440. * @param float $reportPaymentsAmount
  441. *
  442. * @return AccessBilling
  443. */
  444. public function setReportPaymentsAmount($reportPaymentsAmount)
  445. {
  446. $this->reportPaymentsAmount = $reportPaymentsAmount;
  447. return $this;
  448. }
  449. /**
  450. * Get reportPaymentsAmount
  451. *
  452. * @return float
  453. */
  454. public function getReportPaymentsAmount()
  455. {
  456. return $this->reportPaymentsAmount;
  457. }
  458. /**
  459. * Add accountBalanceReimbursement
  460. *
  461. * @param \AppBundle\Entity\Billing\BillPayment $accountBalanceReimbursement
  462. *
  463. * @return AccessBilling
  464. */
  465. public function addAccountBalanceReimbursement(\AppBundle\Entity\Billing\BillPayment $accountBalanceReimbursement)
  466. {
  467. $accountBalanceReimbursement->setAccessBillingAccountBalanceReimbursement($this);
  468. $this->accountBalanceReimbursements[] = $accountBalanceReimbursement;
  469. return $this;
  470. }
  471. /**
  472. * Remove accountBalanceReimbursement
  473. *
  474. * @param \AppBundle\Entity\Billing\BillPayment $accountBalanceReimbursement
  475. */
  476. public function removeAccountBalanceReimbursement(\AppBundle\Entity\Billing\BillPayment $accountBalanceReimbursement)
  477. {
  478. $this->accountBalanceReimbursements->removeElement($accountBalanceReimbursement);
  479. }
  480. /**
  481. * Get accountBalanceReimbursements
  482. *
  483. * @return \Doctrine\Common\Collections\Collection
  484. */
  485. public function getAccountBalanceReimbursements()
  486. {
  487. return $this->accountBalanceReimbursements;
  488. }
  489. }