<?php
namespace App\Entity;
use App\MDS\VenuesBundle\Entity\ReservationLoungeDetails;
use App\Repository\SpaceRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity(repositoryClass: SpaceRepository::class)]
class Space
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255)]
private $name;
#[ORM\Column(type: 'string', length: 10, nullable: true)]
private $billingSeries;
#[ORM\Column(type: 'boolean')]
private $isMain;
#[ORM\OneToMany(targetEntity: ReservationLoungeDetails::class, mappedBy: 'space', cascade: ['persist'], orphanRemoval: false)]
private $ReservationLounges;
#[ORM\Column(type: 'string', length: 10, nullable: true)]
private $rectifyingBillingSeries;
/**
* IVA en porcentaje (0–100)
*/
#[ORM\Column(type: 'decimal', precision: 5, scale: 2, nullable: true)]
#[Assert\Range(min: 0, max: 100, notInRangeMessage: 'El IVA debe estar entre 0 y 100.')]
private $iva;
public function __construct()
{
$this->ReservationLounges = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getBillingSeries(): ?string
{
return $this->billingSeries;
}
public function setBillingSeries(?string $billingSeries): self
{
$this->billingSeries = $billingSeries;
return $this;
}
public function isIsMain(): ?bool
{
return $this->isMain;
}
public function setIsMain(bool $isMain): self
{
$this->isMain = $isMain;
return $this;
}
/**
* @return Collection<int, ReservationLoungeDetails>
*/
public function getReservationLounges(): Collection
{
return $this->ReservationLounges;
}
public function addReservationLounge(ReservationLoungeDetails $reservationLounge): self
{
if (!$this->ReservationLounges->contains($reservationLounge)) {
$this->ReservationLounges[] = $reservationLounge;
$reservationLounge->setSpace($this);
}
return $this;
}
public function removeReservationLounge(ReservationLoungeDetails $reservationLounge): self
{
if ($this->ReservationLounges->removeElement($reservationLounge)) {
// set the owning side to null (unless already changed)
if ($reservationLounge->getSpace() === $this) {
$reservationLounge->setSpace(null);
}
}
return $this;
}
public function getRectifyingBillingSeries(): ?string
{
return $this->rectifyingBillingSeries;
}
public function setRectifyingBillingSeries(?string $rectifyingBillingSeries): self
{
$this->rectifyingBillingSeries = $rectifyingBillingSeries;
return $this;
}
public function getIva(): ?float
{
// Doctrine devuelve string para DECIMAL: lo convertimos a float
return $this->iva !== null ? (float) $this->iva : null;
}
public function setIva(?float $iva): self
{
$this->iva = $iva;
return $this;
}
}