<?php
namespace App\Entity;
use App\Repository\AccountRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=AccountRepository::class)
* @ORM\HasLifecycleCallbacks()
*/
class Account
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=Bank::class, inversedBy="accounts")
* @ORM\JoinColumn(nullable=false)
*/
private $bank;
/**
* @ORM\ManyToOne(targetEntity=Province::class)
* @ORM\JoinColumn(nullable=true)
*/
private $province;
/**
* @ORM\ManyToOne(targetEntity=Territoire::class)
* @ORM\JoinColumn(nullable=true)
*/
private $territoire;
/**
* @ORM\Column(type="string", length=100, unique=true)
*/
private $accountNumber;
/**
* @ORM\Column(type="string", length=255)
*/
private $accountName;
/**
* @ORM\Column(type="string", length=20, nullable=true)
*/
private $accountingNumber;
/**
* @ORM\Column(type="string", length=3, options={"default": "USD"})
*/
private $currency = 'USD';
/**
* @ORM\Column(type="boolean", options={"default": true})
*/
private $isActive = true;
/**
* @ORM\Column(type="boolean", options={"default": true})
*/
private $isAvailableForPayment = true;
/**
* @ORM\OneToMany(targetEntity=AccountHistory::class, mappedBy="account", cascade={"persist", "remove"})
*/
private $history;
/**
* @ORM\Column(type="datetime")
*/
private $createdAt;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $updatedAt;
public function __construct()
{
$this->createdAt = new \DateTime();
$this->isActive = true;
$this->isAvailableForPayment = true;
$this->currency = 'USD';
$this->history = new ArrayCollection();
}
/**
* @ORM\PreUpdate
*/
public function setUpdatedAtValue(): void
{
$this->updatedAt = new \DateTime();
}
public function getId(): ?int
{
return $this->id;
}
public function getBank(): ?Bank
{
return $this->bank;
}
public function setBank(?Bank $bank): self
{
$this->bank = $bank;
return $this;
}
public function getProvince(): ?Province
{
return $this->province;
}
public function setProvince(?Province $province): self
{
$this->province = $province;
return $this;
}
public function getTerritoire(): ?Territoire
{
return $this->territoire;
}
public function setTerritoire(?Territoire $territoire): self
{
$this->territoire = $territoire;
return $this;
}
public function getAccountNumber(): ?string
{
return $this->accountNumber;
}
public function setAccountNumber(string $accountNumber): self
{
$this->accountNumber = $accountNumber;
return $this;
}
public function getAccountName(): ?string
{
return $this->accountName;
}
public function setAccountName(string $accountName): self
{
$this->accountName = $accountName;
return $this;
}
public function getAccountingNumber(): ?string
{
return $this->accountingNumber;
}
public function setAccountingNumber(?string $accountingNumber): self
{
$this->accountingNumber = $accountingNumber;
return $this;
}
public function getCurrency(): ?string
{
return $this->currency;
}
public function setCurrency(string $currency): self
{
$this->currency = $currency;
return $this;
}
public function getIsActive(): ?bool
{
return $this->isActive;
}
public function setIsActive(bool $isActive): self
{
$this->isActive = $isActive;
return $this;
}
public function getIsAvailableForPayment(): ?bool
{
return $this->isAvailableForPayment;
}
public function setIsAvailableForPayment(bool $isAvailableForPayment): self
{
$this->isAvailableForPayment = $isAvailableForPayment;
return $this;
}
/**
* @return Collection|AccountHistory[]
*/
public function getHistory(): Collection
{
return $this->history;
}
public function addHistory(AccountHistory $history): self
{
if (!$this->history->contains($history)) {
$this->history[] = $history;
$history->setAccount($this);
}
return $this;
}
public function removeHistory(AccountHistory $history): self
{
if ($this->history->removeElement($history)) {
if ($history->getAccount() === $this) {
$history->setAccount(null);
}
}
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function __toString(): string
{
return $this->accountNumber . ' - ' . $this->accountName;
}
}