BillPayment.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  1. <?php
  2. namespace AppBundle\Entity\Billing;
  3. use AppBundle\Entity\AccessAndFunction\Access;
  4. use AppBundle\Entity\Core\Tagg;
  5. use AppBundle\Enum\Billing\PaymentChoiceEnum;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Dunglas\ApiBundle\Annotation\Iri;
  9. use Symfony\Component\Serializer\Annotation\Groups;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. use AppBundle\Entity\Traits\TimestampableEntity;
  12. use AppBundle\Entity\Traits\CreatorUpdaterEntity;
  13. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  14. /**
  15. * Données de paiement d'une facture BillAccounting
  16. * NB: il peut y avoir plusieurs lignes pour une facture en cas de paiement en plusieurs fois
  17. *
  18. * @Iri("http://schema.org/BillPayment")
  19. */
  20. #[ORM\Entity]
  21. class BillPayment
  22. {
  23. use TimestampableEntity;
  24. use CreatorUpdaterEntity;
  25. /**
  26. * @var int
  27. */
  28. #[ORM\Column(type: 'integer')]
  29. #[ORM\Id]
  30. #[ORM\GeneratedValue(strategy: 'AUTO')]
  31. #[Groups(['billpayment', 'billpayment_list', 'build_bills', 'billpayment_list', 'account_balance_reimbursements_accessbilling'])]
  32. private $id;
  33. /**
  34. * @var BillAccounting
  35. */
  36. #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\Billing\BillAccounting', inversedBy: 'billPayments', cascade: ['persist'])]
  37. #[ORM\JoinColumn(nullable: true)]
  38. #[Groups(['billpayment', 'billpayment_list'])]
  39. private $bill;
  40. /**
  41. * @var AccessBilling
  42. */
  43. #[ORM\ManyToOne(targetEntity: 'AccessBilling', inversedBy: 'billDetachedPayments', cascade: ['persist'])]
  44. #[ORM\JoinColumn(nullable: true)]
  45. #[Groups(['billpayment'])]
  46. private $accessBilling;
  47. /**
  48. * @var \DateTime
  49. */
  50. #[ORM\Column(type: 'date', nullable: true)]
  51. #[Assert\Date]
  52. #[Groups(['billpayment', 'billpayment_list', 'build_bills_billpayments'])]
  53. private $receiptDate;
  54. /**
  55. * @var \DateTime
  56. */
  57. #[ORM\Column(type: 'date', nullable: true)]
  58. #[Assert\Date]
  59. #[Groups(['billpayment', 'billpayment_list', 'build_bills_billpayments', 'billpayment_list', 'account_balance_reimbursements_accessbilling'])]
  60. private $effectiveReceiptDate;
  61. /**
  62. * @var string
  63. */
  64. #[ORM\Column(type: 'string', nullable: true)]
  65. #[Assert\Type(type: 'string')]
  66. #[Assert\Choice(callback: ['\AppBundle\Enum\Billing\PaymentChoiceEnum', 'toArray'])]
  67. #[Groups(['billpayment', 'billpayment_list', 'build_bills_billpayments', 'billpayment_list', 'account_balance_reimbursements_accessbilling'])]
  68. private $paymentChoice;
  69. /**
  70. * @var string
  71. */
  72. #[ORM\Column(type: 'string', nullable: true)]
  73. #[Assert\Type(type: 'string')]
  74. #[Assert\Choice(callback: ['\AppBundle\Enum\Billing\BankEnum', 'toArray'])]
  75. #[Groups(['billpayment', 'billpayment_list', 'account_balance_reimbursements_accessbilling'])]
  76. private $bank;
  77. /**
  78. * @var string
  79. *
  80. *
  81. */
  82. #[ORM\Column(type: 'string', nullable: true)]
  83. #[Assert\Type(type: 'string')]
  84. #[Groups(['billpayment', 'billpayment_list', 'account_balance_reimbursements_accessbilling'])]
  85. private $agency;
  86. /**
  87. * @var string
  88. *
  89. *
  90. */
  91. #[ORM\Column(type: 'string', nullable: true)]
  92. #[Assert\Type(type: 'string')]
  93. #[Groups(['billpayment', 'billpayment_list', 'account_balance_reimbursements_accessbilling'])]
  94. private $checkNumber;
  95. /**
  96. * @var string
  97. *
  98. *
  99. */
  100. #[ORM\Column(type: 'string', nullable: true)]
  101. #[Assert\Type(type: 'string')]
  102. #[Groups(['billpayment', 'billpayment_list', 'account_balance_reimbursements_accessbilling'])]
  103. private $reference;
  104. /**
  105. * @var float
  106. */
  107. #[ORM\Column(type: 'float', nullable: true)]
  108. #[Assert\Type(type: 'float')]
  109. #[Groups(['billpayment', 'billpayment_list', 'account_balance_reimbursements_accessbilling', 'billpayment_list', 'build_bills_billpayments'])]
  110. private $amount;
  111. /**
  112. * @var BillDebitBalance
  113. */
  114. #[ORM\OneToMany(targetEntity: 'BillDebitBalance', mappedBy: 'billPayment', cascade: ['persist'], orphanRemoval: true)]
  115. #[ORM\JoinColumn(nullable: true)]
  116. #[Groups(['billpayment_billdebitbalance'])]
  117. private $billDebitBalances;
  118. /**
  119. * @var AccessBilling
  120. */
  121. #[ORM\ManyToOne(targetEntity: 'AccessBilling', inversedBy: 'accountBalanceReimbursements', cascade: ['persist'])]
  122. #[ORM\JoinColumn(nullable: true)]
  123. #[Groups(['billpayment', 'billpayment_list'])]
  124. private $accessBillingAccountBalanceReimbursement;
  125. /**
  126. * @var boolean
  127. */
  128. #[Groups(['billpayment', 'billpayment_list'])]
  129. private $isAcquired;
  130. /**
  131. * @var string
  132. */
  133. #[ORM\Column(type: 'string', options: ['default' => 'PAYMENT'])]
  134. #[Assert\Type(type: 'string')]
  135. #[Assert\NotNull]
  136. #[Assert\Choice(callback: ['\AppBundle\Enum\Billing\PaymentTypeEnum', 'toArray'])]
  137. #[Groups(['billpayment', 'billpayment_list', 'account_balance_reimbursements_accessbilling', 'build_bills_billpayments'])]
  138. private $type= 'PAYMENT';
  139. /**
  140. * @var ArrayCollection<Tagg>
  141. */
  142. #[ORM\ManyToMany(targetEntity: 'AppBundle\Entity\Core\Tagg', cascade: ['persist'], inversedBy: 'payments')]
  143. #[Assert\Valid]
  144. #[ORM\JoinTable(name: 'tag_billPayment', joinColumns: [], inverseJoinColumns: [])]
  145. #[ORM\JoinColumn(name: 'billPayment_id', referencedColumnName: 'id')]
  146. #[ORM\JoinColumn(name: 'tag_id', referencedColumnName: 'id')]
  147. #[Groups(['billpayment_tags', 'manage_tags', 'billpayment_list'])]
  148. private $tags;
  149. /**
  150. * Constructor
  151. */
  152. public function __construct()
  153. {
  154. $this->billDebitBalances = new ArrayCollection();
  155. $this->tags = new ArrayCollection();
  156. }
  157. /**
  158. * Sets id.
  159. *
  160. * @param int $id
  161. *
  162. * @return $this
  163. */
  164. public function setId($id)
  165. {
  166. $this->id = $id;
  167. return $this;
  168. }
  169. /**
  170. * Gets id.
  171. *
  172. * @return int
  173. */
  174. public function getId()
  175. {
  176. return $this->id;
  177. }
  178. /**
  179. * Set receiptDate
  180. *
  181. * @param \DateTime $receiptDate
  182. *
  183. * @return BillPayment
  184. */
  185. public function setReceiptDate($receiptDate)
  186. {
  187. $this->receiptDate = $receiptDate;
  188. return $this;
  189. }
  190. /**
  191. * Get receiptDate
  192. *
  193. * @return \DateTime
  194. */
  195. public function getReceiptDate()
  196. {
  197. return $this->receiptDate ? $this->receiptDate->format('Y-m-d') : $this->receiptDate;
  198. }
  199. /**
  200. * Set effectiveReceiptDate
  201. *
  202. * @param \DateTime $effectiveReceiptDate
  203. *
  204. * @return BillPayment
  205. */
  206. public function setEffectiveReceiptDate($effectiveReceiptDate)
  207. {
  208. $this->effectiveReceiptDate = $effectiveReceiptDate;
  209. return $this;
  210. }
  211. /**
  212. * Get effectiveReceiptDate
  213. *
  214. * @return \DateTime
  215. */
  216. public function getEffectiveReceiptDate()
  217. {
  218. return $this->effectiveReceiptDate ? $this->effectiveReceiptDate->format('Y-m-d') : $this->effectiveReceiptDate;
  219. }
  220. /**
  221. * Set paymentChoice
  222. *
  223. * @param string $paymentChoice
  224. *
  225. * @return BillPayment
  226. */
  227. public function setPaymentChoice($paymentChoice)
  228. {
  229. $this->paymentChoice = $paymentChoice;
  230. return $this;
  231. }
  232. /**
  233. * Get paymentChoice
  234. *
  235. * @return string
  236. */
  237. public function getPaymentChoice()
  238. {
  239. return $this->paymentChoice;
  240. }
  241. /**
  242. * Set bank
  243. *
  244. * @param string $bank
  245. *
  246. * @return BillPayment
  247. */
  248. public function setBank($bank)
  249. {
  250. $this->bank = $bank;
  251. return $this;
  252. }
  253. /**
  254. * Get bank
  255. *
  256. * @return string
  257. */
  258. public function getBank()
  259. {
  260. return $this->bank;
  261. }
  262. /**
  263. * Set agency
  264. *
  265. * @param string $agency
  266. *
  267. * @return BillPayment
  268. */
  269. public function setAgency($agency)
  270. {
  271. $this->agency = $agency;
  272. return $this;
  273. }
  274. /**
  275. * Get agency
  276. *
  277. * @return string
  278. */
  279. public function getAgency()
  280. {
  281. return $this->agency;
  282. }
  283. /**
  284. * Set checkNumber
  285. *
  286. * @param string $checkNumber
  287. *
  288. * @return BillPayment
  289. */
  290. public function setCheckNumber($checkNumber)
  291. {
  292. $this->checkNumber = $checkNumber;
  293. return $this;
  294. }
  295. /**
  296. * Get checkNumber
  297. *
  298. * @return string
  299. */
  300. public function getCheckNumber()
  301. {
  302. return $this->checkNumber;
  303. }
  304. /**
  305. * Set reference
  306. *
  307. * @param string $reference
  308. *
  309. * @return BillPayment
  310. */
  311. public function setReference($reference)
  312. {
  313. $this->reference = $reference;
  314. return $this;
  315. }
  316. /**
  317. * Get reference
  318. *
  319. * @return string
  320. */
  321. public function getReference()
  322. {
  323. return $this->reference;
  324. }
  325. /**
  326. * Set amount
  327. *
  328. * @param float $amount
  329. *
  330. * @return BillPayment
  331. */
  332. public function setAmount($amount)
  333. {
  334. $this->amount = floatval($amount);
  335. return $this;
  336. }
  337. /**
  338. * Get amount
  339. *
  340. * @return float
  341. */
  342. public function getAmount()
  343. {
  344. return $this->amount;
  345. }
  346. /**
  347. * Set bill
  348. *
  349. * @param \AppBundle\Entity\Billing\BillAccounting $bill
  350. *
  351. * @return BillPayment
  352. */
  353. public function setBill($bill = null)
  354. {
  355. $this->bill = $bill;
  356. return $this;
  357. }
  358. /**
  359. * Get bill
  360. *
  361. * @return \AppBundle\Entity\Billing\BillAccounting
  362. */
  363. public function getBill()
  364. {
  365. return $this->bill;
  366. }
  367. /**
  368. * Gets isAcquired.
  369. *
  370. * @return boolean
  371. */
  372. public function getIsAcquired()
  373. {
  374. $isAcquired = false;
  375. if($this->getAmount() && !is_null($this->getEffectiveReceiptDate())){
  376. $isAcquired = true;
  377. }
  378. return $isAcquired;
  379. }
  380. /**
  381. * Set accessBilling
  382. *
  383. * @param \AppBundle\Entity\Billing\AccessBilling $accessBilling
  384. *
  385. * @return BillPayment
  386. */
  387. public function setAccessBilling(\AppBundle\Entity\Billing\AccessBilling $accessBilling = null)
  388. {
  389. $this->accessBilling = $accessBilling;
  390. return $this;
  391. }
  392. /**
  393. * Get accessBilling
  394. *
  395. * @return \AppBundle\Entity\Billing\AccessBilling
  396. */
  397. public function getAccessBilling()
  398. {
  399. return $this->accessBilling;
  400. }
  401. /**
  402. * Add billDebitBalance
  403. *
  404. * @param \AppBundle\Entity\Billing\BillDebitBalance $billDebitBalance
  405. *
  406. * @return BillPayment
  407. */
  408. public function addBillDebitBalance(\AppBundle\Entity\Billing\BillDebitBalance $billDebitBalance)
  409. {
  410. $billDebitBalance->setBillPayment($this);
  411. $this->billDebitBalances[] = $billDebitBalance;
  412. return $this;
  413. }
  414. /**
  415. * Remove billDebitBalance
  416. *
  417. * @param \AppBundle\Entity\Billing\BillDebitBalance $billDebitBalance
  418. */
  419. public function removeBillDebitBalance(\AppBundle\Entity\Billing\BillDebitBalance $billDebitBalance)
  420. {
  421. $this->billDebitBalances->removeElement($billDebitBalance);
  422. }
  423. /**
  424. * Get billDebitBalances
  425. *
  426. * @return \Doctrine\Common\Collections\Collection
  427. */
  428. public function getBillDebitBalances()
  429. {
  430. return $this->billDebitBalances;
  431. }
  432. /**
  433. * Set type
  434. *
  435. * @param string $type
  436. *
  437. * @return BillPayment
  438. */
  439. public function setType($type)
  440. {
  441. $this->type = $type;
  442. return $this;
  443. }
  444. /**
  445. * Get type
  446. *
  447. * @return string
  448. */
  449. public function getType()
  450. {
  451. return $this->type;
  452. }
  453. /**
  454. * Add tag
  455. *
  456. * @param \AppBundle\Entity\Core\Tagg $tag
  457. *
  458. * @return BillPayment
  459. */
  460. public function addTag(\AppBundle\Entity\Core\Tagg $tag)
  461. {
  462. $this->tags[] = $tag;
  463. return $this;
  464. }
  465. /**
  466. * Remove tag
  467. *
  468. * @param \AppBundle\Entity\Core\Tagg $tag
  469. */
  470. public function removeTag(\AppBundle\Entity\Core\Tagg $tag)
  471. {
  472. $this->tags->removeElement($tag);
  473. }
  474. /**
  475. * Get tags
  476. *
  477. * @return \Doctrine\Common\Collections\Collection
  478. */
  479. public function getTags()
  480. {
  481. return $this->tags;
  482. }
  483. /**
  484. * Set accessBillingAccountBalanceReimbursement
  485. *
  486. * @param \AppBundle\Entity\Billing\AccessBilling $accessBillingAccountBalanceReimbursement
  487. *
  488. * @return BillPayment
  489. */
  490. public function setAccessBillingAccountBalanceReimbursement(\AppBundle\Entity\Billing\AccessBilling $accessBillingAccountBalanceReimbursement = null)
  491. {
  492. $this->accessBillingAccountBalanceReimbursement = $accessBillingAccountBalanceReimbursement;
  493. return $this;
  494. }
  495. /**
  496. * Get accessBillingAccountBalanceReimbursement
  497. *
  498. * @return \AppBundle\Entity\Billing\AccessBilling
  499. */
  500. public function getAccessBillingAccountBalanceReimbursement()
  501. {
  502. return $this->accessBillingAccountBalanceReimbursement;
  503. }
  504. }