<?php
namespace App\Entity;
use App\Entity\Club1895\TransactionWire as Club1895TransactionWire;
use App\Entity\Traits\Timestampable;
use App\Repository\WireRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: WireRepository::class)]
#[ORM\Table(name: 'payment_wire')]
class Wire implements CancellableInterface
{
use Timestampable;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255)]
private $number;
#[ORM\Column(type: 'float')]
private $amount;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $bank;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $drawer;
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')]
private $parent;
#[ORM\OneToMany(mappedBy: 'parent', targetEntity: self::class)]
private $children;
#[ORM\OneToMany(mappedBy: 'wire', targetEntity: TransactionWire::class)]
private $transactionWires;
#[ORM\Column(type: 'date_immutable', nullable: true)]
private $date;
#[ORM\Column(type: 'boolean')]
private $isCancelled = false;
#[ORM\OneToMany(mappedBy: 'wire', targetEntity: BenefactorTransactionWire::class)]
private Collection $benefactorTransactionWires;
#[ORM\OneToMany(mappedBy: 'wire', targetEntity: Club1895TransactionWire::class)]
private Collection $club1895TransactionWires;
public function __construct()
{
$this->children = new ArrayCollection();
$this->transactionWires = new ArrayCollection();
$this->benefactorTransactionWires = new ArrayCollection();
$this->club1895TransactionWires = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getBank(): ?string
{
return $this->bank;
}
public function setBank(?string $bank): self
{
$this->bank = $bank;
return $this;
}
public function getDrawer(): ?string
{
return $this->drawer;
}
public function setDrawer(?string $drawer): self
{
$this->drawer = $drawer;
return $this;
}
public function getAmount(): ?float
{
return $this->amount;
}
public function setAmount(float $amount): self
{
$this->amount = $amount;
return $this;
}
public function getNumber(): ?string
{
return $this->number;
}
public function setNumber(string $number): self
{
$this->number = $number;
return $this;
}
public function getParent(): ?self
{
return $this->parent;
}
public function setParent(?self $parent): self
{
$this->parent = $parent;
return $this;
}
/**
* @return Collection<int, self>
*/
public function getChildren(): Collection
{
return $this->children;
}
public function addChild(self $child): self
{
if (!$this->children->contains($child)) {
$this->children[] = $child;
$child->setParent($this);
}
return $this;
}
public function removeChild(self $child): self
{
if ($this->children->removeElement($child)) {
// set the owning side to null (unless already changed)
if ($child->getParent() === $this) {
$child->setParent(null);
}
}
return $this;
}
/**
* @return Collection<int, TransactionWire>
*/
public function getTransactionWires(): Collection
{
return $this->transactionWires;
}
public function addTransactionWire(TransactionWire $transactionWire): self
{
if (!$this->transactionWires->contains($transactionWire)) {
$this->transactionWires[] = $transactionWire;
$transactionWire->setWire($this);
}
return $this;
}
public function removeTransactionWire(TransactionWire $transactionWire): self
{
if ($this->transactionWires->removeElement($transactionWire)) {
// set the owning side to null (unless already changed)
if ($transactionWire->getWire() === $this) {
$transactionWire->setWire(null);
}
}
return $this;
}
public function getDate(): ?\DateTimeImmutable
{
return $this->date;
}
public function setDate(?\DateTimeImmutable $date): self
{
$this->date = $date;
return $this;
}
public function isIsCancelled(): ?bool
{
return $this->isCancelled;
}
public function setIsCancelled(bool $isCancelled): self
{
$this->isCancelled = $isCancelled;
return $this;
}
public function getCancelReason(): ?string
{
$transaction = $this->getTransactionWires()->first();
if ($transaction) {
return $transaction->getCancelReason();
}
return null;
}
/**
* @return Collection<int, BenefactorTransactionWire>
*/
public function getBenefactorTransactionWires(): Collection
{
return $this->benefactorTransactionWires;
}
public function addBenefactorTransactionWire(BenefactorTransactionWire $benefactorTransactionWire): self
{
if (!$this->benefactorTransactionWires->contains($benefactorTransactionWire)) {
$this->benefactorTransactionWires->add($benefactorTransactionWire);
$benefactorTransactionWire->setWire($this);
}
return $this;
}
public function removeBenefactorTransactionWire(BenefactorTransactionWire $benefactorTransactionWire): self
{
if ($this->benefactorTransactionWires->removeElement($benefactorTransactionWire)) {
// set the owning side to null (unless already changed)
if ($benefactorTransactionWire->getWire() === $this) {
$benefactorTransactionWire->setWire(null);
}
}
return $this;
}
/**
* @return Collection<int, TransactionWire>
*/
public function getClub1895TransactionWires(): Collection
{
return $this->club1895TransactionWires;
}
public function addClub1895TransactionWire(TransactionWire $club1895TransactionWire): self
{
if (!$this->club1895TransactionWires->contains($club1895TransactionWire)) {
$this->club1895TransactionWires->add($club1895TransactionWire);
$club1895TransactionWire->setWire($this);
}
return $this;
}
public function removeClub1895TransactionWire(TransactionWire $club1895TransactionWire): self
{
if ($this->club1895TransactionWires->removeElement($club1895TransactionWire)) {
// set the owning side to null (unless already changed)
if ($club1895TransactionWire->getWire() === $this) {
$club1895TransactionWire->setWire(null);
}
}
return $this;
}
}