<?php
namespace App\Entity;
use App\Repository\RemesasRecibosRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: RemesasRecibosRepository::class)]
class RemesasRecibos
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
private ?\DateTimeInterface $fecha = null;
#[ORM\Column(type: Types::TEXT)]
private ?string $ficheroremesa = null;
#[ORM\Column]
private ?bool $enviado = null;
#[ORM\OneToMany(mappedBy: 'remesa', targetEntity: RecibosTenants::class, cascade:['persist'] )]
private Collection $recibosTenants;
#[ORM\Column(length: 100)]
private ?string $nombre = null;
#[ORM\OneToMany(mappedBy: 'remesa', targetEntity: RecibosUtilities::class, cascade:['persist'] )]
private Collection $recibosUtilities;
private float $importeRemesa=0;
#[ORM\OneToMany(mappedBy: 'remesaRecibo', targetEntity: RecibosGestion::class, cascade:['persist'])]
private Collection $recibosGestions;
#[ORM\OneToMany(mappedBy: 'remesa', targetEntity: RecibosReparaciones::class, cascade:['persist'])]
private Collection $recibosReparaciones;
public function __construct()
{
$this->recibosTenants = new ArrayCollection();
$this->recibosUtilities = new ArrayCollection();
$this->recibosGestions = new ArrayCollection();
$this->recibosReparaciones = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getFecha(): ?\DateTimeInterface
{
return $this->fecha;
}
public function setFecha(\DateTimeInterface $fecha): static
{
$this->fecha = $fecha;
return $this;
}
public function getFicheroremesa(): ?string
{
return $this->ficheroremesa;
}
public function setFicheroremesa(string $ficheroremesa): static
{
$this->ficheroremesa = $ficheroremesa;
return $this;
}
public function isEnviado(): ?bool
{
return $this->enviado;
}
public function setEnviado(bool $enviado): static
{
$this->enviado = $enviado;
return $this;
}
/**
* @return Collection<int, RecibosTenants>
*/
public function getRecibosTenants(): Collection
{
return $this->recibosTenants;
}
public function addRecibosTenant(RecibosTenants $recibosTenant): static
{
if (!$this->recibosTenants->contains($recibosTenant)) {
$this->recibosTenants->add($recibosTenant);
$recibosTenant->setRemesa($this);
}
return $this;
}
public function removeRecibosTenant(RecibosTenants $recibosTenant): static
{
if ($this->recibosTenants->removeElement($recibosTenant)) {
// set the owning side to null (unless already changed)
if ($recibosTenant->getRemesa() === $this) {
$recibosTenant->setRemesa(null);
}
}
return $this;
}
public function getNombre(): ?string
{
return $this->nombre;
}
public function setNombre(string $nombre): static
{
$this->nombre = $nombre;
return $this;
}
/**
* @return Collection<int, RecibosUtilities>
*/
public function getRecibosUtilities(): Collection
{
return $this->recibosUtilities;
}
public function addRecibosUtility(RecibosUtilities $recibosUtility): static
{
if (!$this->recibosUtilities->contains($recibosUtility)) {
$this->recibosUtilities->add($recibosUtility);
$recibosUtility->setRemesa($this);
}
return $this;
}
public function removeRecibosUtility(RecibosUtilities $recibosUtility): static
{
if ($this->recibosUtilities->removeElement($recibosUtility)) {
// set the owning side to null (unless already changed)
if ($recibosUtility->getRemesa() === $this) {
$recibosUtility->setRemesa(null);
}
}
return $this;
}
public function getImporteRemesa():float{
$importe=0;
foreach($this->getRecibosTenants() as $recibo) {
$importe+=$recibo->getImporte();
}
foreach($this->getRecibosUtilities() as $reciboUtility){
$importe+=$reciboUtility->getImporte();
}
return $importe;
}
/**
* @return Collection<int, RecibosGestion>
*/
public function getRecibosGestions(): Collection
{
return $this->recibosGestions;
}
public function addRecibosGestion(RecibosGestion $recibosGestion): static
{
if (!$this->recibosGestions->contains($recibosGestion)) {
$this->recibosGestions->add($recibosGestion);
$recibosGestion->setRemesaRecibo($this);
}
return $this;
}
public function removeRecibosGestion(RecibosGestion $recibosGestion): static
{
if ($this->recibosGestions->removeElement($recibosGestion)) {
// set the owning side to null (unless already changed)
if ($recibosGestion->getRemesaRecibo() === $this) {
$recibosGestion->setRemesaRecibo(null);
}
}
return $this;
}
/**
* @return Collection<int, RecibosReparaciones>
*/
public function getRecibosReparaciones(): Collection
{
return $this->recibosReparaciones;
}
public function addRecibosReparacione(RecibosReparaciones $recibosReparacione): static
{
if (!$this->recibosReparaciones->contains($recibosReparacione)) {
$this->recibosReparaciones->add($recibosReparacione);
$recibosReparacione->setRemesa($this);
}
return $this;
}
public function removeRecibosReparacione(RecibosReparaciones $recibosReparacione): static
{
if ($this->recibosReparaciones->removeElement($recibosReparacione)) {
// set the owning side to null (unless already changed)
if ($recibosReparacione->getRemesa() === $this) {
$recibosReparacione->setRemesa(null);
}
}
return $this;
}
}