src/Entity/Transaction.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Enum\Transaction\Status;
  4. use App\Enum\Transaction\Type;
  5. use App\Repository\TransactionRepository;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=TransactionRepository::class)
  9.  */
  10. class Transaction
  11. {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\Column(type="datetime")
  20.      */
  21.     private $createdAt;
  22.     /**
  23.      * @ORM\Column(type="enum", options={"values"="transaction_enum", "default"="new"})
  24.      */
  25.     private $status Status::STATUS_NEW;
  26.     /**
  27.      * @ORM\Column(type="enum", options={"values"="transaction_enum"})
  28.      */
  29.     private $type;
  30.     /**
  31.      * @ORM\Column(type="integer")
  32.      */
  33.     private $amount 0;
  34.     /**
  35.      * @ORM\Column(type="text", nullable=true)
  36.      */
  37.     private $bankStatementRow;
  38.     /**
  39.      * @ORM\Column(type="datetime", nullable=true)
  40.      */
  41.     private $date;
  42.     /**
  43.      * @ORM\ManyToOne(targetEntity=Candidate::class)
  44.      * @ORM\JoinColumn(nullable=true)
  45.      */
  46.     private $candidate;
  47.     /**
  48.      * @ORM\ManyToOne(targetEntity=Payment::class)
  49.      * @ORM\JoinColumn(nullable=true)
  50.      */
  51.     private $payment;
  52.     /**
  53.      * @ORM\ManyToOne(targetEntity=Invoice::class)
  54.      * @ORM\JoinColumn(nullable=true)
  55.      */
  56.     private $invoice;
  57.     /**
  58.      * @ORM\ManyToOne(targetEntity=FinanceCategory::class)
  59.      * @ORM\JoinColumn(nullable=true)
  60.      */
  61.     private $financeCategory;
  62.     /**
  63.      * @ORM\ManyToOne(targetEntity=Person::class)
  64.      */
  65.     private $person;
  66.     public function __construct()
  67.     {
  68.         $this->createdAt = new \DateTime();
  69.     }
  70.     public function getId(): ?int
  71.     {
  72.         return $this->id;
  73.     }
  74.     public function getCreatedAt(): ?\DateTimeInterface
  75.     {
  76.         return $this->createdAt;
  77.     }
  78.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  79.     {
  80.         $this->createdAt $createdAt;
  81.         return $this;
  82.     }
  83.     public function getStatus()
  84.     {
  85.         return $this->status;
  86.     }
  87.     public function setStatus($status): self
  88.     {
  89.         $this->status $status;
  90.         return $this;
  91.     }
  92.     public function getStatusText(): string
  93.     {
  94.         return Status::getText($this->status);
  95.     }
  96.     public function getStatusCss($prefix null): string
  97.     {
  98.         return Status::getCssClass($this->status$prefix);
  99.     }
  100.     public function isNewStatus(): bool
  101.     {
  102.         return $this->status === Status::STATUS_NEW;
  103.     }
  104.     public function isDeletedStatus(): bool
  105.     {
  106.         return $this->status === Status::STATUS_DELETED;
  107.     }
  108.     public function getType()
  109.     {
  110.         return $this->type;
  111.     }
  112.     public function setType($type): self
  113.     {
  114.         $this->type $type;
  115.         return $this;
  116.     }
  117.     public function getTypeText(): string
  118.     {
  119.         return Type::getText($this->type);
  120.     }
  121.     public function getTypeCss($prefix null): string
  122.     {
  123.         return Type::getCssClass($this->type$prefix);
  124.     }
  125.     public function isCreditType(): bool
  126.     {
  127.         return $this->type === Type::TYPE_CREDIT;
  128.     }
  129.     public function isDebitType(): bool
  130.     {
  131.         return $this->type === Type::TYPE_DEBIT;
  132.     }
  133.     public function getAmount(): ?int
  134.     {
  135.         return $this->amount;
  136.     }
  137.     public function setAmount(int $amount): self
  138.     {
  139.         $this->amount $amount;
  140.         return $this;
  141.     }
  142.     public function getBankStatementRow(): ?array
  143.     {
  144.         return json_decode($this->bankStatementRowtrue);
  145.     }
  146.     public function setBankStatementRow(?array $bankStatementRow): self
  147.     {
  148.         $this->bankStatementRow json_encode($bankStatementRow,
  149.             JSON_UNESCAPED_UNICODE JSON_UNESCAPED_SLASHES);
  150.         return $this;
  151.     }
  152.     public function getDate(): ?\DateTimeInterface
  153.     {
  154.         return $this->date;
  155.     }
  156.     public function setDate(?\DateTimeInterface $date): self
  157.     {
  158.         $this->date $date;
  159.         return $this;
  160.     }
  161.     public function getCandidate(): ?Candidate
  162.     {
  163.         return $this->candidate;
  164.     }
  165.     public function setCandidate(?Candidate $candidate): self
  166.     {
  167.         $this->candidate $candidate;
  168.         return $this;
  169.     }
  170.     public function getPayment(): ?Payment
  171.     {
  172.         return $this->payment;
  173.     }
  174.     public function setPayment(?Payment $payment): self
  175.     {
  176.         $this->payment $payment;
  177.         return $this;
  178.     }
  179.     public function getInvoice(): ?Invoice
  180.     {
  181.         return $this->invoice;
  182.     }
  183.     public function setInvoice(?Invoice $invoice): self
  184.     {
  185.         $this->invoice $invoice;
  186.         return $this;
  187.     }
  188.     public function getFinanceCategory(): ?FinanceCategory
  189.     {
  190.         return $this->financeCategory;
  191.     }
  192.     public function setFinanceCategory(?FinanceCategory $financeCategory): self
  193.     {
  194.         $this->financeCategory $financeCategory;
  195.         return $this;
  196.     }
  197.     public function getPerson(): ?Person
  198.     {
  199.         return $this->person;
  200.     }
  201.     public function setPerson(?Person $person): self
  202.     {
  203.         $this->person $person;
  204.         return $this;
  205.     }
  206.     public function getPurposeEntity()
  207.     {
  208.         if ($this->getPayment()) {
  209.             return $this->getPayment()->getCalendarEvent();
  210.         } elseif ($this->getInvoice()) {
  211.             return $this->getInvoice()->getCandidate() && $this->getInvoice()->getCandidate()->getCalendarEvent()
  212.                 ? $this->getInvoice()->getCandidate()->getCalendarEvent() : null;
  213.         }
  214.         return null;
  215.     }
  216.     public function getPurposeText(): ?string
  217.     {
  218.         $entity $this->getPurposeEntity();
  219.         if ($entity) {
  220.             return $entity->getName();
  221.         }
  222.         return null;
  223.     }
  224. }