<?php
namespace App\Entity;
use App\Repository\PaymentRepository;
use Doctrine\ORM\Mapping as ORM;
use App\Enum\Payment\Type as PaymentType;
/**
* @ORM\Entity(repositoryClass=PaymentRepository::class)
*/
class Payment
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="integer")
*/
private $amount;
/**
* @ORM\Column(type="datetime")
*/
private $createdAt;
/**
* @ORM\ManyToOne(targetEntity=CalendarEvent::class)
*/
private $calendarEvent;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $comment;
/**
* @ORM\Column(type="datetime")
*/
private $dateTime;
/**
* @ORM\ManyToOne(targetEntity=User::class)
* @ORM\JoinColumn(nullable=false)
*/
private $createdBy;
/**
* @ORM\ManyToOne(targetEntity=Person::class)
* @ORM\JoinColumn(nullable=false)
*/
private $person;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $receiptFile;
/**
* @var string
*/
private $newReceiptFile;
/**
* @ORM\Column(type="enum", nullable=true, options={"values"="payment_enum"})
*/
private $type;
/**
* @ORM\ManyToOne(targetEntity=FinanceCategory::class)
* @ORM\JoinColumn(nullable=true)
*/
private $financeCategory;
/**
* @ORM\OneToOne(targetEntity=Transaction::class, inversedBy="payment", cascade={"persist", "remove"})
*/
private $transaction;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $bankStatementRowMd5;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $bankStatementAmount;
public function __construct()
{
$this->createdAt = new \DateTime();
// $this->dateTime = new \DateTime();
}
public function getId(): ?int
{
return $this->id;
}
public function getAmount(): ?int
{
return $this->amount;
}
public function setAmount(int $amount): self
{
$this->amount = $amount;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getCalendarEvent(): ?CalendarEvent
{
return $this->calendarEvent;
}
public function setCalendarEvent(?CalendarEvent $calendarEvent): self
{
if ($calendarEvent && !$calendarEvent->getFinanceCategory()) {
throw new \InvalidArgumentException('Невозможно создать платеж. В мероприятии не указана статья финансов. Обратитесь к администратору.');
}
$this->calendarEvent = $calendarEvent;
$this->setFinanceCategory($calendarEvent ? $calendarEvent->getFinanceCategory() : null);
return $this;
}
public function getComment(): ?string
{
return $this->comment;
}
public function setComment(?string $comment): self
{
$this->comment = $comment;
return $this;
}
public function getDateTime(): ?\DateTimeInterface
{
return $this->dateTime;
}
public function setDateTime(\DateTimeInterface $dateTime): self
{
$this->dateTime = $dateTime;
return $this;
}
public function getCreatedBy(): ?User
{
return $this->createdBy;
}
public function setCreatedBy(?User $createdBy): self
{
$this->createdBy = $createdBy;
return $this;
}
public function getPerson(): ?Person
{
return $this->person;
}
public function setPerson(?Person $person): self
{
$this->person = $person;
return $this;
}
public function getReceiptFile(): ?string
{
return $this->receiptFile;
}
public function setReceiptFile(?string $receiptFile): self
{
$this->receiptFile = $receiptFile;
return $this;
}
public function getNewReceiptFile(): ?string
{
return $this->newReceiptFile;
}
public function setNewReceiptFile(?string $newReceiptFile): self
{
$this->newReceiptFile = $newReceiptFile;
return $this;
}
public function getType()
{
return $this->type;
}
public function setType($type): self
{
$this->type = $type;
return $this;
}
public function getTypeText(): ?string
{
return PaymentType::getText($this->getType());
}
public function getTypeCssClass($prefix = null): ?string
{
return PaymentType::getCssClass($this->getType(), $prefix);
}
public function getFinanceCategory(): ?FinanceCategory
{
return $this->financeCategory;
}
public function setFinanceCategory(?FinanceCategory $financeCategory): self
{
$this->financeCategory = $financeCategory;
return $this;
}
public function getTransaction(): ?Transaction
{
return $this->transaction;
}
public function setTransaction(?Transaction $transaction): self
{
$this->transaction = $transaction;
return $this;
}
public function getBankStatementRowMd5(): ?string
{
return $this->bankStatementRowMd5;
}
public function setBankStatementRowMd5(?string $bankStatementRowMd5): self
{
$this->bankStatementRowMd5 = $bankStatementRowMd5;
return $this;
}
public function getBankStatementAmount(): ?int
{
return $this->bankStatementAmount;
}
public function setBankStatementAmount(int $bankStatementAmount): self
{
$this->bankStatementAmount = $bankStatementAmount;
return $this;
}
}