src/Entity/Payment.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PaymentRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Serializer\Annotation\Groups;
  8. /**
  9. * @ORM\Entity(repositoryClass=PaymentRepository::class)
  10. */
  11. class Payment
  12. {
  13. const STATUS_PAID = 'PAID';
  14. const STATUS_NOTPAID = 'NOT_PAID';
  15. const STATUS_COOLDOWN = 'COOLDOWN';
  16. const PAYMENT_STATUSES = [self::STATUS_PAID,self::STATUS_NOTPAID, self::STATUS_COOLDOWN];
  17. /**
  18. * @ORM\Id
  19. * @ORM\GeneratedValue
  20. * @ORM\Column(type="integer")
  21. * @Groups({"PaymentList"})
  22. */
  23. private $id;
  24. /**
  25. * @ORM\Column(type="datetime", nullable=true)
  26. * @Groups({"PaymentList"})
  27. */
  28. private $dateFor;
  29. /**
  30. * @ORM\Column(type="float", nullable=true)
  31. * @Groups({"PaymentList"})
  32. */
  33. private $hours;
  34. /**
  35. * @ORM\Column(type="float", nullable=true)
  36. * @Groups({"PaymentList"})
  37. */
  38. private $amount;
  39. /**
  40. * @ORM\Column(type="string", length=255, nullable=true)
  41. */
  42. private $paymentId;
  43. /**
  44. * @ORM\Column(type="datetime", nullable=true)
  45. */
  46. private $dateAdd;
  47. /**
  48. * @ORM\Column(type="datetime", nullable=true)
  49. */
  50. private $dateUpd;
  51. /**
  52. * @ORM\ManyToOne(targetEntity=Guardian::class, inversedBy="payments")
  53. */
  54. private $guardian;
  55. /**
  56. * @ORM\Column(type="string", length=255, nullable=true)
  57. * @Groups({"PaymentList"})
  58. */
  59. private $status;
  60. /**
  61. * @ORM\Column(type="float", nullable=true)
  62. * @Groups({"PaymentList"})
  63. */
  64. private $expectedAmount;
  65. /**
  66. * @ORM\Column(type="string", length=255, nullable=true)
  67. */
  68. private $kevinStatus;
  69. /**
  70. * @ORM\Column(type="string", length=255, nullable=true)
  71. */
  72. private $notificationStatus;
  73. /**
  74. * @ORM\OneToMany(targetEntity=PaymentNotificationLog::class, mappedBy="payment")
  75. */
  76. private $paymentNotificationLogs;
  77. /**
  78. * @ORM\Column(type="float", nullable=true)
  79. * @Groups({"PaymentList"})
  80. */
  81. private $correctionAmount = 0;
  82. /**
  83. * @ORM\Column(type="datetime", nullable=true)
  84. */
  85. private $paidAt;
  86. /**
  87. * @ORM\Column(type="string", length=255, nullable=true)
  88. */
  89. private $montonioStatus;
  90. /**
  91. * @ORM\OneToMany(targetEntity=PaymentBonus::class, mappedBy="payment")
  92. */
  93. private $paymentBonuses;
  94. public function __construct()
  95. {
  96. $this->dateAdd = new \DateTime();
  97. $this->paymentNotificationLogs = new ArrayCollection();
  98. $this->paymentBonuses = new ArrayCollection();
  99. }
  100. public function getId(): ?int
  101. {
  102. return $this->id;
  103. }
  104. public function getPaymentId(): ?string
  105. {
  106. return $this->paymentId;
  107. }
  108. public function setPaymentId(?string $paymentId): self
  109. {
  110. $this->paymentId = $paymentId;
  111. return $this;
  112. }
  113. public function getDateAdd(): ?\DateTimeInterface
  114. {
  115. return $this->dateAdd;
  116. }
  117. public function setDateAdd(?\DateTimeInterface $dateAdd): self
  118. {
  119. $this->dateAdd = $dateAdd;
  120. return $this;
  121. }
  122. public function getDateUpd(): ?\DateTimeInterface
  123. {
  124. return $this->dateUpd;
  125. }
  126. public function setDateUpd(?\DateTimeInterface $dateUpd): self
  127. {
  128. $this->dateUpd = $dateUpd;
  129. return $this;
  130. }
  131. public function getAmount(): ?float
  132. {
  133. return $this->amount;
  134. }
  135. public function setAmount(?float $amount): self
  136. {
  137. $this->amount = $amount;
  138. return $this;
  139. }
  140. public function getGuardian(): ?Guardian
  141. {
  142. return $this->guardian;
  143. }
  144. public function setGuardian(?Guardian $guardian): self
  145. {
  146. $this->guardian = $guardian;
  147. return $this;
  148. }
  149. public function getStatus(): ?string
  150. {
  151. if($this->dateUpd > new \DateTime() && $this->status != self::STATUS_PAID)
  152. {
  153. return self::STATUS_COOLDOWN;
  154. }
  155. return $this->status;
  156. }
  157. public function setStatus(?string $status): self
  158. {
  159. $this->status = $status;
  160. return $this;
  161. }
  162. public function getDateFor(): ?\DateTimeInterface
  163. {
  164. return $this->dateFor;
  165. }
  166. public function setDateFor(?\DateTimeInterface $dateFor): self
  167. {
  168. $this->dateFor = $dateFor;
  169. return $this;
  170. }
  171. public function getHours(): ?float
  172. {
  173. return $this->hours;
  174. }
  175. public function setHours(?float $hours): self
  176. {
  177. $this->hours = $hours;
  178. return $this;
  179. }
  180. public function getExpectedAmount(): ?float
  181. {
  182. return $this->expectedAmount;
  183. }
  184. public function setExpectedAmount(?float $expectedAmount): self
  185. {
  186. $this->expectedAmount = $expectedAmount;
  187. return $this;
  188. }
  189. public function getKevinStatus(): ?string
  190. {
  191. return $this->kevinStatus;
  192. }
  193. public function setKevinStatus(?string $kevinStatus): self
  194. {
  195. $this->kevinStatus = $kevinStatus;
  196. return $this;
  197. }
  198. public function getNotificationStatus(): ?string
  199. {
  200. return $this->notificationStatus;
  201. }
  202. public function setNotificationStatus(?string $notificationStatus): self
  203. {
  204. $this->notificationStatus = $notificationStatus;
  205. return $this;
  206. }
  207. /**
  208. * @return Collection|PaymentNotificationLog[]
  209. */
  210. public function getPaymentNotificationLogs(): Collection
  211. {
  212. return $this->paymentNotificationLogs;
  213. }
  214. public function addPaymentNotificationLog(PaymentNotificationLog $paymentNotificationLog): self
  215. {
  216. if (!$this->paymentNotificationLogs->contains($paymentNotificationLog)) {
  217. $this->paymentNotificationLogs[] = $paymentNotificationLog;
  218. $paymentNotificationLog->setPayment($this);
  219. }
  220. return $this;
  221. }
  222. public function removePaymentNotificationLog(PaymentNotificationLog $paymentNotificationLog): self
  223. {
  224. if ($this->paymentNotificationLogs->removeElement($paymentNotificationLog)) {
  225. // set the owning side to null (unless already changed)
  226. if ($paymentNotificationLog->getPayment() === $this) {
  227. $paymentNotificationLog->setPayment(null);
  228. }
  229. }
  230. return $this;
  231. }
  232. public function getCorrectionAmount(): ?float
  233. {
  234. return $this->correctionAmount;
  235. }
  236. public function setCorrectionAmount(?float $correctionAmount): self
  237. {
  238. $this->correctionAmount = $correctionAmount;
  239. return $this;
  240. }
  241. public function getPaidAt(): ?\DateTimeInterface
  242. {
  243. return $this->paidAt;
  244. }
  245. public function setPaidAt(?\DateTimeInterface $paidAt): self
  246. {
  247. $this->paidAt = $paidAt;
  248. return $this;
  249. }
  250. public function getMontonioStatus(): ?string
  251. {
  252. return $this->montonioStatus;
  253. }
  254. public function setMontonioStatus(?string $montonioStatus): self
  255. {
  256. $this->montonioStatus = $montonioStatus;
  257. return $this;
  258. }
  259. /**
  260. * @return Collection<int, PaymentBonus>
  261. */
  262. public function getPaymentBonuses(): Collection
  263. {
  264. return $this->paymentBonuses;
  265. }
  266. public function addPaymentBonus(PaymentBonus $paymentBonus): self
  267. {
  268. if (!$this->paymentBonuses->contains($paymentBonus)) {
  269. $this->paymentBonuses[] = $paymentBonus;
  270. $paymentBonus->setPayment($this);
  271. }
  272. return $this;
  273. }
  274. public function removePaymentBonus(PaymentBonus $paymentBonus): self
  275. {
  276. if ($this->paymentBonuses->removeElement($paymentBonus)) {
  277. // set the owning side to null (unless already changed)
  278. if ($paymentBonus->getPayment() === $this) {
  279. $paymentBonus->setPayment(null);
  280. }
  281. }
  282. return $this;
  283. }
  284. }