<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* ContaBancaria
*
* @ORM\Table(name="conta_bancaria")
* @ORM\Entity(repositoryClass="App\Repository\ContaBancariaRepository")
*/
class ContaBancaria
{
/**
* @var \Ramsey\Uuid\UuidInterface
*
* @ORM\Id
* @ORM\Column(type="uuid", unique=true)
* @ORM\GeneratedValue(strategy="CUSTOM")
* @ORM\CustomIdGenerator(class="Ramsey\Uuid\Doctrine\UuidGenerator")
* @Groups("BankAccounts")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="numero", type="string", length=255, nullable=true)
* @Groups("BankAccounts")
*/
private $numero;
/**
* @var string
*
* @ORM\Column(name="titulo", type="string", length=255, nullable=true)
* @Groups("BankAccounts")
*/
private $titulo;
/**
* @var string
*
* @ORM\Column(name="swift_code", type="string", length=255, nullable=true)
* @Groups("BankAccounts")
*/
private $swiftCode;
/**
* @var float
*
* @ORM\Column(name="valor", type="float", nullable=true)
* @Groups("BankAccounts")
*/
private $valor;
/**
* @var string
*
* @ORM\Column(name="iban", type="string", length=255, nullable=true)
* @Groups("BankAccounts")
*/
private $iban;
private $nib;
/**
* @var string
*
* @ORM\Column(name="balcao", type="string", length=255, nullable=true)
* @Groups("BankAccounts")
*/
private $balcao;
/**
* @var string
*
* @ORM\Column(name="descricao", type="string", length=255, nullable=true)
* @Groups("BankAccounts")
*/
private $descricao;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Banco", inversedBy="banco")
* @Groups("BankAccounts")
*/
private $banco;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Moeda", inversedBy="moeda")
* @Groups("BankAccounts")
*/
private $moeda;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Company", inversedBy="company")
*/
private $company;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Pagamento", mappedBy="contaDestino")
*/
private $pagamentos;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Recebimento", mappedBy="contaDestino")
*/
private $recebimentos;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Account", inversedBy="account")
*/
private $account;
private $saldoActual;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\WareHouse", inversedBy="bankAccounts")
*/
private $wareHouses;
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set numero
*
* @param string $numero
*
* @return ContaBancaria
*/
public function setNumero($numero)
{
$this->numero = $numero;
return $this;
}
/**
* Get numero
*
* @return string
*/
public function getNumero()
{
return $this->numero;
}
/**
* Set banco
*
* @param Banco $banco
*
* @return ContaBancaria
*/
public function setBanco($banco)
{
$this->banco = $banco;
return $this;
}
/**
* Get banco
*
* @return Banco
*/
public function getBanco()
{
return $this->banco;
}
/**
* Set valor
*
* @param string $valor
*
* @return ContaBancaria
*/
public function setValor($valor)
{
$valor = str_replace('.', '', $valor);
$this->valor = $valor;
return $this;
}
/**
* Get valor
*
* @return float
*/
public function getValor()
{
return $this->valor;
}
/**
* Set iban
*
* @param string $iban
*
* @return ContaBancaria
*/
public function setIban($iban)
{
$this->iban = $iban;
return $this;
}
/**
* Get iban
*
* @return string
*/
public function getIban()
{
return join('.',explode('-',$this->iban));
}
/**
* Set balcao
*
* @param string $balcao
*
* @return ContaBancaria
*/
public function setBalcao($balcao)
{
$this->balcao = $balcao;
return $this;
}
/**
* Get balcao
*
* @return string
*/
public function getBalcao()
{
return $this->balcao;
}
/**
* Set descricao
*
* @param string $descricao
*
* @return ContaBancaria
*/
public function setDescricao($descricao)
{
$this->descricao = $descricao;
return $this;
}
/**
* Get descricao
*
* @return string
*/
public function getDescricao()
{
return $this->descricao;
}
/**
* @return mixed
*/
public function getMoeda()
{
return $this->moeda;
}
/**
* @param mixed $moeda
*/
public function setMoeda($moeda)
{
$this->moeda = $moeda;
}
/**
* @return string
*/
public function getTitulo()
{
return $this->titulo;
}
/**
* @param string $titulo
*/
public function setTitulo(string $titulo)
{
$this->titulo = $titulo;
}
/**
* @return mixed
*/
public function getCompany()
{
return $this->company;
}
/**
* @param mixed $company
*/
public function setCompany($company)
{
$this->company = $company;
}
/**
* @return string
*/
public function getSwiftCode()
{
return $this->swiftCode;
}
/**
* @param string $swiftCode
*/
public function setSwiftCode(string $swiftCode)
{
$this->swiftCode = $swiftCode;
}
/**
* @return mixed
*/
public function getPagamentos()
{
return $this->pagamentos;
}
/**
* @param mixed $pagamentos
*/
public function setPagamentos($pagamentos)
{
$this->pagamentos = $pagamentos;
}
/**
* @return mixed
*/
public function getRecebimentos()
{
return $this->recebimentos;
}
/**
* @param mixed $recebimentos
*/
public function setRecebimentos($recebimentos)
{
$this->recebimentos = $recebimentos;
}
/**
* @return mixed
*/
public function getSaldoActual()
{
$saldo = 0;
if(is_null($this->getAccount()))
return $this->saldoActual;
foreach ($this->getAccount()->getMoviments() as $moviment)
if($moviment->getTransactionNature())
$saldo -= $moviment->getAmount();
else
$saldo += $moviment->getAmount();
$this->setSaldoActual($saldo);
return $this->saldoActual;
}
/**
* @param mixed $saldoActual
*/
public function setSaldoActual($saldoActual)
{
$this->saldoActual = $saldoActual;
}
/**
* @return mixed
*/
public function getNib()
{
return str_replace('AO06','',$this->iban);
}
/**
* @param mixed $nib
*/
public function setNib($nib)
{
$this->nib = $nib;
}
/**
* @return Account
*/
public function getAccount()
{
return $this->account;
}
/**
* @param Account $account
*/
public function setAccount($account)
{
$this->account = $account;
}
/**
* @return []WareHouse
*/
public function getWareHouses()
{
return $this->wareHouses;
}
/**
* @param []$wareHouses
*/
public function setWareHouses($wareHouses)
{
$this->wareHouses = $wareHouses;
}
}