<?php
namespace App\Entity;
use App\Repository\PaymentRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ORM\Entity(repositoryClass=PaymentRepository::class)
*/
class Payment
{
const STATUS_PAID = 'PAID';
const STATUS_NOTPAID = 'NOT_PAID';
const STATUS_COOLDOWN = 'COOLDOWN';
const PAYMENT_STATUSES = [self::STATUS_PAID,self::STATUS_NOTPAID, self::STATUS_COOLDOWN];
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({"PaymentList"})
*/
private $id;
/**
* @ORM\Column(type="datetime", nullable=true)
* @Groups({"PaymentList"})
*/
private $dateFor;
/**
* @ORM\Column(type="float", nullable=true)
* @Groups({"PaymentList"})
*/
private $hours;
/**
* @ORM\Column(type="float", nullable=true)
* @Groups({"PaymentList"})
*/
private $amount;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $paymentId;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $dateAdd;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $dateUpd;
/**
* @ORM\ManyToOne(targetEntity=Guardian::class, inversedBy="payments")
*/
private $guardian;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"PaymentList"})
*/
private $status;
/**
* @ORM\Column(type="float", nullable=true)
* @Groups({"PaymentList"})
*/
private $expectedAmount;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $kevinStatus;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $notificationStatus;
/**
* @ORM\OneToMany(targetEntity=PaymentNotificationLog::class, mappedBy="payment")
*/
private $paymentNotificationLogs;
/**
* @ORM\Column(type="float", nullable=true)
* @Groups({"PaymentList"})
*/
private $correctionAmount = 0;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $paidAt;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $montonioStatus;
/**
* @ORM\OneToMany(targetEntity=PaymentBonus::class, mappedBy="payment")
*/
private $paymentBonuses;
public function __construct()
{
$this->dateAdd = new \DateTime();
$this->paymentNotificationLogs = new ArrayCollection();
$this->paymentBonuses = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getPaymentId(): ?string
{
return $this->paymentId;
}
public function setPaymentId(?string $paymentId): self
{
$this->paymentId = $paymentId;
return $this;
}
public function getDateAdd(): ?\DateTimeInterface
{
return $this->dateAdd;
}
public function setDateAdd(?\DateTimeInterface $dateAdd): self
{
$this->dateAdd = $dateAdd;
return $this;
}
public function getDateUpd(): ?\DateTimeInterface
{
return $this->dateUpd;
}
public function setDateUpd(?\DateTimeInterface $dateUpd): self
{
$this->dateUpd = $dateUpd;
return $this;
}
public function getAmount(): ?float
{
return $this->amount;
}
public function setAmount(?float $amount): self
{
$this->amount = $amount;
return $this;
}
public function getGuardian(): ?Guardian
{
return $this->guardian;
}
public function setGuardian(?Guardian $guardian): self
{
$this->guardian = $guardian;
return $this;
}
public function getStatus(): ?string
{
if($this->dateUpd > new \DateTime() && $this->status != self::STATUS_PAID)
{
return self::STATUS_COOLDOWN;
}
return $this->status;
}
public function setStatus(?string $status): self
{
$this->status = $status;
return $this;
}
public function getDateFor(): ?\DateTimeInterface
{
return $this->dateFor;
}
public function setDateFor(?\DateTimeInterface $dateFor): self
{
$this->dateFor = $dateFor;
return $this;
}
public function getHours(): ?float
{
return $this->hours;
}
public function setHours(?float $hours): self
{
$this->hours = $hours;
return $this;
}
public function getExpectedAmount(): ?float
{
return $this->expectedAmount;
}
public function setExpectedAmount(?float $expectedAmount): self
{
$this->expectedAmount = $expectedAmount;
return $this;
}
public function getKevinStatus(): ?string
{
return $this->kevinStatus;
}
public function setKevinStatus(?string $kevinStatus): self
{
$this->kevinStatus = $kevinStatus;
return $this;
}
public function getNotificationStatus(): ?string
{
return $this->notificationStatus;
}
public function setNotificationStatus(?string $notificationStatus): self
{
$this->notificationStatus = $notificationStatus;
return $this;
}
/**
* @return Collection|PaymentNotificationLog[]
*/
public function getPaymentNotificationLogs(): Collection
{
return $this->paymentNotificationLogs;
}
public function addPaymentNotificationLog(PaymentNotificationLog $paymentNotificationLog): self
{
if (!$this->paymentNotificationLogs->contains($paymentNotificationLog)) {
$this->paymentNotificationLogs[] = $paymentNotificationLog;
$paymentNotificationLog->setPayment($this);
}
return $this;
}
public function removePaymentNotificationLog(PaymentNotificationLog $paymentNotificationLog): self
{
if ($this->paymentNotificationLogs->removeElement($paymentNotificationLog)) {
// set the owning side to null (unless already changed)
if ($paymentNotificationLog->getPayment() === $this) {
$paymentNotificationLog->setPayment(null);
}
}
return $this;
}
public function getCorrectionAmount(): ?float
{
return $this->correctionAmount;
}
public function setCorrectionAmount(?float $correctionAmount): self
{
$this->correctionAmount = $correctionAmount;
return $this;
}
public function getPaidAt(): ?\DateTimeInterface
{
return $this->paidAt;
}
public function setPaidAt(?\DateTimeInterface $paidAt): self
{
$this->paidAt = $paidAt;
return $this;
}
public function getMontonioStatus(): ?string
{
return $this->montonioStatus;
}
public function setMontonioStatus(?string $montonioStatus): self
{
$this->montonioStatus = $montonioStatus;
return $this;
}
/**
* @return Collection<int, PaymentBonus>
*/
public function getPaymentBonuses(): Collection
{
return $this->paymentBonuses;
}
public function addPaymentBonus(PaymentBonus $paymentBonus): self
{
if (!$this->paymentBonuses->contains($paymentBonus)) {
$this->paymentBonuses[] = $paymentBonus;
$paymentBonus->setPayment($this);
}
return $this;
}
public function removePaymentBonus(PaymentBonus $paymentBonus): self
{
if ($this->paymentBonuses->removeElement($paymentBonus)) {
// set the owning side to null (unless already changed)
if ($paymentBonus->getPayment() === $this) {
$paymentBonus->setPayment(null);
}
}
return $this;
}
}