<?php
namespace App\Entity;
use App\Enum\EstadoOperacionEnum;
use App\Enum\EstadoRelojEnum;
use App\Enum\TipoOperacionEnum;
use DateTime;
use DateTimeInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\Criteria;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Entity(repositoryClass="App\Repository\RelojRepository")
* @ORM\Table(name="reloj", schema="perseo")
* @ORM\EntityListeners({"App\EntityListener\Reloj\CalcularIDPerseoListener", "App\EntityListener\Reloj\CalcularCodigoListener"})
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=true)
* @Vich\Uploadable
*/
class Reloj
{
/**
* @ORM\Id
* @ORM\Column(type="bigint", options={"unsigned":true})
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(type="string", unique=true, nullable=false)
*/
protected $codigo;
/**
* @ORM\Column(
* type="string",
* unique=true,
* nullable=false,
* name="id_perseo",
* options={"comment":"Identificador de perseo único generado aleatoriamente combinación letras y números"}
* )
*/
protected $IDperseo;
/**
* @ORM\Column(
* type="string",
* length=4,
* nullable=true,
* options={"comment":"Valores a tomar REBU ó IVA, por defecto REBU"}
* )
*/
protected $regimen;
/**
* @ORM\Column(type="string", nullable=true)
*/
protected $foto;
/**
* @Vich\UploadableField(mapping="reloj", fileNameProperty="foto")
* @var File
*/
protected $fotoFile;
/**
* @ORM\Column(type="string", nullable=true, name="foto_valoracion")
*/
private $fotoValoracion;
/**
* @Vich\UploadableField(mapping="reloj", fileNameProperty="foto_valoracion")
* @var File
*/
protected $fotoValoracionFile;
/**
* @ORM\Column(type="string", nullable=true, name="foto_set")
*/
private $fotoSet;
/**
* @Vich\UploadableField(mapping="reloj", fileNameProperty="foto_set")
* @var File
*/
protected $fotoSetFile;
/**
* @ORM\Column(type="string", nullable=true, name="foto_crono", options={"comment":"foto del cronocomparador"})
*/
private $fotoCrono;
/**
* @Vich\UploadableField(mapping="reloj", fileNameProperty="foto_crono")
* @var File
*/
protected $fotoCronoFile;
/**
* @ORM\Column(type="string", nullable=true)
*/
private $video;
/**
* @Vich\UploadableField(mapping="reloj", fileNameProperty="video")
* @var File
*/
protected $videoFile;
/**
* @ORM\Column(type="string", nullable=true)
*/
protected $modelo1;
/**
* @ORM\Column(type="string", nullable=true)
*/
protected $modelo2;
/**
* @ORM\Column(type="string", nullable=true)
*/
protected $ref1;
/**
* @ORM\Column(type="string", nullable=true)
*/
protected $ref2;
/**
* @ORM\Column(type="string", nullable=true)
*/
protected $serie;
/**
* @ORM\Column(type="float", nullable=true, precision=2)
*/
protected $peso;
/**
* @ORM\Column(type="datetime", nullable=true, options={"comment":"Fecha comprado por primera vez"})
*/
protected $fecha;
/**
* @ORM\Column(type="boolean", nullable=false, options={"default":0})
*/
protected $caja;
/**
* @ORM\Column(type="boolean", nullable=false, options={"default":0})
*/
protected $papeles;
/**
* @ORM\Column(type="text", nullable=true)
*/
protected $otros;
/**
* @ORM\Column(type="float", nullable=true, name="itp", precision=2, options={"default":"0.0","comment":"%"})
*/
protected $ITP;
/**
* @ORM\Column(
* type="datetime",
* nullable=true,
* name="fecha_valoracion",
* options={"comment":"Fecha valoracion es la fecha enviada"}
* )
*/
private $fechaValoracion;
/**
* @ORM\Column(
* type="float",
* nullable=true,
* options={
* "default":"0.0",
* "comment":"Comsión CRONO esta en gastos , pero se duplica fuera para tener mejor acceso a ella %"
* }
* )
*/
protected $comision;
/**
* @ORM\Column(type="float", nullable=true, precision=2, name="precio_coste")
*/
protected $precioCoste;
/**
* @ORM\Column(
* type="float",
* nullable=true,
* name="precio_coste_total",
* precision=2,
* options={
* "default":"0.0",
* "comment":"Autocalculado, cada vez que se añade/modifique un coste ó cambie su coste (Coste del Reloj + Costes Asociados)"
* }
* )
*/
protected $precioCosteTotal;
/**
* @ORM\Column(type="float", nullable=true, precision=2, name="precio_min_venta")
*/
protected $precioMinVenta;
/**
* @ORM\Column(type="float", nullable=true, precision=2, name="precio_promocion", options={"default":"0.0"})
*/
protected $precioPromocion;
/**
* @ORM\Column(type="datetime", nullable=true, name="fecha_promocion")
*/
protected $fechaPromocion;
/**
* @ORM\Column(type="float", nullable=true, precision=2, name="precio_oferta")
*/
protected $precioOferta;
/**
* @deprecated Por cambios de funcionalidad
* @ORM\Column(type="boolean", nullable=true, precision=2, name="chrono24")
*/
protected $chrono24;
/**
* @ORM\Column(type="float", nullable=true, precision=2, name="precio_pagar")
*/
protected $precioPagar;
/**
* @ORM\Column(type="float", nullable=true, precision=2, name="precio_compra")
*/
protected $precioCompra;
/**
* @ORM\Column(type="datetime", nullable=true, name="fecha_compra")
*/
protected $fechaCompra;
/**
* @ORM\Column(type="float", nullable=true, precision=2)
*/
protected $precioVenta;
/**
* @ORM\Column(type="datetime", nullable=true, name="fecha_venta")
*/
protected $fechaVenta;
/**
* @ORM\Column(type="float", nullable=true, precision=2)
*/
protected $precioVentaTotal;
/**
* @ORM\Column(type="float", nullable=true, precision=0, name="margen_minimo")
*/
protected $margenMinimo;
/**
* @ORM\Column(type="float", nullable=true, precision=0, name="margen_deseado")
*/
protected $margenDeseado;
/**
* @ORM\Column(type="float", nullable=true, precision=2)
*/
private $recompra;
/**
* @ORM\Column(type="string", nullable=true)
*/
private $garantia;
/**
* @ORM\Column(
* type="integer",
* nullable=true,
* name="tiempo_en_venta",
* options={"comment":"Diff entre Fecha Venta y 1º Estado de Anuncio"}
* )
*/
private $tiempoEnVenta;
/**
* @ORM\Column(
* type="integer",
* nullable=true,
* name="tiempo_en_stock",
* options={"comment":"Diff entre Fecha Venta y Fecha Compra"}
* )
*/
private $tiempoEnStock;
/**
* @ORM\Column(type="datetime", nullable=true, name="fecha_recepcion")
*/
private $fechaRecepcion;
/**
* @ORM\Column(
* type="float",
* nullable=true,
* precision=0,
* name="margen_promocion",
* options={"default":"0.0","comment":"%"}
* )
*/
protected $margenPromocion;
/**
* @ORM\Column(
* type="float",
* nullable=true,
* precision=0,
* name="margen_bruto",
* options={"default":"0.0","comment":"%"}
* )
*/
protected $margenBruto;
/**
* @ORM\Column(type="float", nullable=true, name="margen_neto", precision=2,
* options={"default":"0.0","comment":"%"})
*/
protected $margenNeto;
/**
* @ORM\Column(type="boolean", nullable=false, options={"default":0,"comment":"Relojes comprados"})
*/
protected $stock;
/**
* @ORM\Column(type="boolean", nullable=true, options={"default":0,"comment":"Relojes en Gestión de Venta"})
*/
protected $custodia;
/**
* @ORM\Column(type="float", nullable=true, name="tiempo_venta", precision=2,
* options={"default":"0.0","comment":"%"})
*/
protected $tiempoVenta;
/**
* @ORM\Column(type="datetime", nullable=true, name="fecha_anuncio", options={"comment":"Fecha primer anuncio"})
*/
private $fechaAnuncio;
/**
* @ORM\Column(type="string", nullable=true)
*/
protected $descripcion;
/**
* @ORM\Column(type="text", nullable=true)
*/
protected $comentario;
/**
* @ORM\Column(
* type="string",
* unique=true,
* nullable=true,
* name="token_access",
* options={"comment":"Token de acceso a la información del reloj"}
* )
*/
protected $tokenAccess;
/**
* @ORM\Column(
* type="boolean",
* nullable=true,
* name="en_promocion",
* options={"default":0,"comment":"Cuando la Estado Operacion es Confirmada"}
* )
*/
protected $enPromocion;
/**
* @ORM\Column(
* type="boolean",
* nullable=true,
* name="en_servicio",
* options={"default":0,"comment":"Relojes Recepcionados y que se encuentren en una Ubicación tipo Proveedor"}
* )
*/
protected $enServicio;
/**
* @ORM\Column(
* type="boolean",
* nullable=true,
* name="sin_anunciar",
* options={"default":0,"comment":"Relojes Estado Listo y no han sido promocionados"}
* )
*/
protected $sinAnunciar;
/**
* @ORM\Column(type="boolean", nullable=true, options={"default":0})
*/
protected $enVenta;
/**
* @ORM\Column(
* type="boolean",
* nullable=true,
* name="tipo_bloqueo",
* options={"comment":"Valores a tomar RM(true) ó RI(false) ó NULL"}
* )
*/
protected $tipoBloqueo;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
protected $exportacion;
/**
* @ORM\Column(type="datetime", nullable=true, name="deleted_at")
*/
protected $deletedAt;
/**
* @ORM\Column(type="datetime", nullable=false, name="updated_at", options={"default":"2022-01-01 00:00:00"})
* @Gedmo\Timestampable(on="update")
*/
protected $updatedAt;
/**
* @ORM\Column(type="datetime", nullable=false, name="created_at", options={"default":"2022-01-01 00:00:00"})
* @Gedmo\Timestampable(on="create")
*/
protected $createdAt;
/**
* @ORM\OneToOne(targetEntity=\App\Entity\ValoracionesRelojesSinStock::class, mappedBy="relojInventario")
*/
private $valoracionReloj;
/**
* @ORM\OneToMany(targetEntity=\App\Entity\DetalleCompra::class, mappedBy="reloj")
*/
protected $detalleCompra;
/**
* @ORM\OneToMany(targetEntity=\App\Entity\DetalleVenta::class, mappedBy="reloj")
*/
protected $detalleVenta;
/**
* @ORM\OneToOne(targetEntity=\App\Entity\RegistroPolicial::class, mappedBy="reloj")
*/
protected $registroPolicial;
/*
* @ORM\OneToOne(targetEntity=\App\Entity\ActividadAbstract::class, mappedBy="reloj")
*/
private $actividad;
/**
* @ORM\OneToOne(targetEntity=\App\Entity\Promocion::class, mappedBy="reloj")
*/
protected $promociones;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Gasto", mappedBy="reloj")
*/
protected $gastos;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Trazabilidad", mappedBy="reloj")
*/
protected $trazas;
/**
* @ORM\OneToMany(targetEntity="App\Entity\ValoracionesRelojes", mappedBy="reloj", cascade={"persist"})
*/
protected $valoracionesRelojes;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\EstadoReloj", inversedBy="relojes")
* @ORM\JoinColumn(name="estado_reloj_id", referencedColumnName="id", nullable=true)
*/
protected $estado;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Marca", inversedBy="relojes")
* @ORM\JoinColumn(name="marca_id", referencedColumnName="id")
*/
protected $marca;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\EstadoAspecto", inversedBy="relojes")
* @ORM\JoinColumn(name="estado_aspecto_id", referencedColumnName="id")
*/
protected $aspecto;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\EstadoCheck", inversedBy="relojes")
* @ORM\JoinColumn(name="estado_check_id", referencedColumnName="id")
*/
protected $check;
/*
* @ORM\OneToOne(targetEntity=\App\Entity\Operacion::class, inversedBy="relojGestion")
* @ORM\JoinColumn(name="operacion_gestion_id", referencedColumnName="id", unique=true)
*/
/**
* @ORM\JoinColumn(name="operacion_gestion_id", referencedColumnName="id")
* @ORM\ManyToOne(targetEntity=\App\Entity\Operacion::class, inversedBy="relojesGestion")
*/
private $operacionGestion;
/**
* @ORM\JoinColumn(name="operacion_venta_id", referencedColumnName="id")
* @ORM\ManyToOne(targetEntity=\App\Entity\Operacion::class, inversedBy="relojesVenta")
*/
private $operacionVenta;
/**
* @ORM\JoinColumn(name="operacion_compra_id", referencedColumnName="id")
* @ORM\ManyToOne(targetEntity=\App\Entity\Operacion::class, inversedBy="relojesCompra")
*/
private $operacionCompra;
/**
* @ORM\ManyToOne(targetEntity=\App\Entity\Valoracion::class, inversedBy="relojes")
* @ORM\JoinColumn(name="valoracion_id", referencedColumnName="id")
*/
private $valoracion;
/**
* @ORM\OneToOne(targetEntity=\App\Entity\ActividadCompra::class, mappedBy="reloj")
*/
private $actividadCompra;
/**
* @ORM\OneToOne(targetEntity=\App\Entity\ActividadVenta::class, mappedBy="reloj")
*/
private $actividadVenta;
private $fechaStr;
public function __construct()
{
$this->reservado = false;
$this->papeles = false;
$this->caja = false;
$this->stock = false;
$this->custodia = false;
$this->gastos = new ArrayCollection();
$this->trazas = new ArrayCollection();
$this->valoracionesRelojes = new ArrayCollection();
$this->detalleVenta = new ArrayCollection();
$this->detalleCompra = new ArrayCollection();
}
public function __toString(): string
{
return (string)($this->getCodigo() ?? $this->getIDperseo());
}
public function getId(): ?string
{
return $this->id;
}
public function getIDperseo(): ?string
{
return $this->IDperseo;
}
public function setIDperseo(string $IDperseo): self
{
$this->IDperseo = $IDperseo;
return $this;
}
public function getRegimen(): ?string
{
return $this->regimen;
}
public function setRegimen(?string $regimen): self
{
$this->regimen = $regimen;
return $this;
}
public function getFoto(): ?string
{
return $this->foto;
}
public function setFoto(?string $foto): self
{
$this->foto = $foto;
return $this;
}
public function getFotoFile(): ?File
{
return $this->fotoFile;
}
public function setFotoFile(?File $fotoFile): self
{
$this->fotoFile = $fotoFile;
if ($fotoFile) {
// if 'updatedAt' is not defined in your entity, use another property
$this->setUpdatedAt(new DateTime('now'));
}
return $this;
}
public function getModelo1(): ?string
{
return $this->modelo1;
}
public function setModelo1(?string $modelo1): self
{
$this->modelo1 = $modelo1;
return $this;
}
public function getModelo2(): ?string
{
return $this->modelo2;
}
public function setModelo2(?string $modelo2): self
{
$this->modelo2 = $modelo2;
return $this;
}
public function getRef1(): ?string
{
return $this->ref1;
}
public function setRef1(?string $ref1): self
{
$this->ref1 = $ref1;
return $this;
}
public function getRef2(): ?string
{
return $this->ref2;
}
public function setRef2(?string $ref2): self
{
$this->ref2 = $ref2;
return $this;
}
public function getSerie(): ?string
{
return $this->serie;
}
public function setSerie(?string $serie): self
{
$this->serie = $serie;
return $this;
}
public function getFecha(): ?DateTimeInterface
{
return $this->fecha;
}
public function setFecha(?DateTimeInterface $fecha): self
{
$this->fecha = $fecha;
return $this;
}
public function isCaja(): ?bool
{
return $this->caja;
}
public function getCaja(): ?bool
{
return $this->caja;
}
public function setCaja(bool $caja): self
{
$this->caja = $caja;
return $this;
}
public function isPapeles(): ?bool
{
return $this->papeles;
}
public function getPapeles(): ?bool
{
return $this->papeles;
}
public function setPapeles(bool $papeles): self
{
$this->papeles = $papeles;
return $this;
}
public function getOtros(): ?string
{
return $this->otros;
}
public function setOtros(?string $otros): self
{
$this->otros = $otros;
return $this;
}
public function getITP(): ?float
{
return $this->ITP;
}
public function setITP(?float $ITP): self
{
$this->ITP = $ITP;
return $this;
}
public function getComision(): ?float
{
return $this->comision;
}
public function setComision(?float $comision): self
{
$this->comision = $comision;
return $this;
}
public function getPrecioCoste(): ?float
{
return $this->precioCoste;
}
public function setPrecioCoste(?float $precioCoste): self
{
$this->precioCoste = $precioCoste;
return $this;
}
public function getPrecioCosteTotal(): ?float
{
return $this->precioCosteTotal;
}
public function setPrecioCosteTotal(?float $precioCosteTotal): self
{
$this->precioCosteTotal = $precioCosteTotal;
return $this;
}
public function getPrecioMinVenta(): ?float
{
return $this->precioMinVenta;
}
public function setPrecioMinVenta(?float $precioMinVenta): self
{
$this->precioMinVenta = $precioMinVenta;
return $this;
}
public function getPrecioPromocion(): ?float
{
return $this->precioPromocion;
}
public function setPrecioPromocion(?float $precioPromocion): self
{
$this->precioPromocion = $precioPromocion;
return $this;
}
public function getPrecioOferta(): ?float
{
return $this->precioOferta;
}
public function setPrecioOferta(?float $precioOferta): self
{
$this->precioOferta = $precioOferta;
return $this;
}
public function getPrecioPagar(): ?float
{
return $this->precioPagar;
}
public function setPrecioPagar(?float $precioPagar): self
{
$this->precioPagar = $precioPagar;
return $this;
}
public function getPrecioVenta(): ?float
{
return $this->precioVenta;
}
public function setPrecioVenta(?float $precioVenta): self
{
$this->precioVenta = $precioVenta;
return $this;
}
public function getPrecioVentaTotal(): ?float
{
return $this->precioVentaTotal;
}
public function setPrecioVentaTotal(?float $precioVentaTotal): self
{
$this->precioVentaTotal = $precioVentaTotal;
return $this;
}
public function getMargenMinimo(): ?float
{
return $this->margenMinimo;
}
public function setMargenMinimo(?float $margenMinimo): self
{
$this->margenMinimo = $margenMinimo;
return $this;
}
public function getMargenDeseado(): ?float
{
return $this->margenDeseado;
}
public function setMargenDeseado(?float $margenDeseado): self
{
$this->margenDeseado = $margenDeseado;
return $this;
}
public function getMargenPromocion(): ?float
{
return $this->margenPromocion;
}
public function setMargenPromocion(?float $margenPromocion): self
{
$this->margenPromocion = $margenPromocion;
return $this;
}
public function getMargenBruto(): ?float
{
return $this->margenBruto;
}
public function setMargenBruto(?float $margenBruto): self
{
$this->margenBruto = $margenBruto;
return $this;
}
public function getStock(): ?bool
{
return $this->stock;
}
public function setStock(bool $stock): self
{
$this->stock = $stock;
return $this;
}
public function getComentario(): ?string
{
return $this->comentario;
}
public function setComentario(?string $comentario): self
{
$this->comentario = $comentario;
return $this;
}
public function getReservado(): ?bool
{
return $this->reservado;
}
public function setReservado(bool $reservado): self
{
$this->reservado = $reservado;
return $this;
}
public function getTokenAccess(): ?string
{
return $this->tokenAccess;
}
public function setTokenAccess(?string $tokenAccess): self
{
$this->tokenAccess = $tokenAccess;
return $this;
}
public function getTipoBloqueo(): ?string
{
return $this->tipoBloqueo;
}
public function setTipoBloqueo(?string $tipoBloqueo): self
{
$this->tipoBloqueo = $tipoBloqueo;
return $this;
}
public function getExportacionStr():string
{
return $this->isExportacion() ? 'Exportacion' : 'Europa';
}
public function getExportacion(): ?bool
{
return $this->exportacion;
}
public function setExportacion(?bool $exportacion): self
{
$this->exportacion = $exportacion;
return $this;
}
public function getDeletedAt(): ?DateTimeInterface
{
return $this->deletedAt;
}
public function setDeletedAt(?DateTimeInterface $deletedAt): self
{
$this->deletedAt = $deletedAt;
return $this;
}
public function getUpdatedAt(): ?DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getCreatedAt(): ?DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getRegistroPolicial(): ?RegistroPolicial
{
return $this->registroPolicial;
}
public function setRegistroPolicial(?RegistroPolicial $registroPolicial): self
{
// unset the owning side of the relation if necessary
if ($registroPolicial === null && $this->registroPolicial !== null) {
$this->registroPolicial->setReloj(null);
}
// set the owning side of the relation if necessary
if ($registroPolicial !== null && $registroPolicial->getReloj() !== $this) {
$registroPolicial->setReloj($this);
}
$this->registroPolicial = $registroPolicial;
return $this;
}
/**
* @return Collection|Gasto[]
*/
public function getGastos(): Collection
{
return $this->gastos;
}
public function addGasto(Gasto $gasto): self
{
if (!$this->gastos->contains($gasto)) {
$this->gastos[] = $gasto;
$gasto->setReloj($this);
}
return $this;
}
public function removeGasto(Gasto $gasto): self
{
if ($this->gastos->removeElement($gasto)) {
// set the owning side to null (unless already changed)
if ($gasto->getReloj() === $this) {
$gasto->setReloj(null);
}
}
return $this;
}
/**
* @return Collection|Trazabilidad[]
*/
public function getTrazas(): Collection
{
return $this->trazas;
}
public function addTraza(Trazabilidad $traza): self
{
if (!$this->trazas->contains($traza)) {
$this->trazas[] = $traza;
$traza->setReloj($this);
}
return $this;
}
public function removeTraza(Trazabilidad $traza): self
{
if ($this->trazas->removeElement($traza)) {
// set the owning side to null (unless already changed)
if ($traza->getReloj() === $this) {
$traza->setReloj(null);
}
}
return $this;
}
public function getEstado(): ?EstadoReloj
{
return $this->estado;
}
public function setEstado(?EstadoReloj $estado): self
{
$this->estado = $estado;
return $this;
}
public function getMarca(): ?Marca
{
return $this->marca;
}
public function setMarca(?Marca $marca): self
{
$this->marca = $marca;
return $this;
}
/**
* @return Collection|ValoracionesRelojes[]
*/
public function getValoracionesRelojes(): Collection
{
return $this->valoracionesRelojes;
}
public function addValoracionesReloje(ValoracionesRelojes $valoracionesReloje): self
{
if (!$this->valoracionesRelojes->contains($valoracionesReloje)) {
$this->valoracionesRelojes[] = $valoracionesReloje;
$valoracionesReloje->setReloj($this);
}
return $this;
}
public function removeValoracionesReloje(ValoracionesRelojes $valoracionesReloje): self
{
if ($this->valoracionesRelojes->removeElement($valoracionesReloje)) {
// set the owning side to null (unless already changed)
if ($valoracionesReloje->getReloj() === $this) {
$valoracionesReloje->setReloj(null);
}
}
return $this;
}
public function isStock(): ?bool
{
return $this->stock;
}
public function isReservado(): ?bool
{
return $this->reservado;
}
public function isExportacion(): ?bool
{
return $this->exportacion;
}
public function getFechaPromocion(): ?DateTimeInterface
{
return $this->fechaPromocion;
}
public function setFechaPromocion(?DateTimeInterface $fechaPromocion): self
{
$this->fechaPromocion = $fechaPromocion;
return $this;
}
public function getFechaVenta(): ?DateTimeInterface
{
return $this->fechaVenta;
}
public function setFechaVenta(?DateTimeInterface $fechaVenta): self
{
$this->fechaVenta = $fechaVenta;
return $this;
}
public function getMargenNeto(): ?float
{
return $this->margenNeto;
}
public function setMargenNeto(?float $margenNeto): self
{
$this->margenNeto = $margenNeto;
return $this;
}
public function isCustodia(): ?bool
{
return $this->custodia;
}
public function setCustodia(bool $custodia): self
{
$this->custodia = $custodia;
return $this;
}
public function getTiempoVenta(): ?float
{
return $this->tiempoVenta;
}
public function setTiempoVenta(?float $tiempoVenta): self
{
$this->tiempoVenta = $tiempoVenta;
return $this;
}
public function isEnPromocion(): ?bool
{
return $this->enPromocion;
}
public function setEnPromocion(?bool $enPromocion): self
{
$this->enPromocion = $enPromocion;
return $this;
}
public function isEnServicio(): ?bool
{
return $this->enServicio;
}
public function setEnServicio(?bool $enServicio): self
{
$this->enServicio = $enServicio;
return $this;
}
public function isTipoBloqueo(): ?bool
{
return $this->tipoBloqueo;
}
public function getAspecto(): ?EstadoAspecto
{
return $this->aspecto;
}
public function setAspecto(?EstadoAspecto $aspecto): self
{
$this->aspecto = $aspecto;
return $this;
}
public function getCheck(): ?EstadoCheck
{
return $this->check;
}
public function setCheck(?EstadoCheck $check): self
{
$this->check = $check;
return $this;
}
public function isSinAnunciar(): ?bool
{
return $this->sinAnunciar;
}
public function setSinAnunciar(?bool $sinAnunciar): self
{
$this->sinAnunciar = $sinAnunciar;
return $this;
}
public function isEnVenta(): ?bool
{
return $this->enVenta;
}
public function setEnVenta(?bool $enVenta): self
{
$this->enVenta = $enVenta;
return $this;
}
public function getUrlImage():string
{
/* TODO cogerlo de la configuracion vich */
return '/uploads/reloj/'.$this->getId().'/'.$this->getFoto();
}
public function getFechaCompra(): ?DateTimeInterface
{
return $this->fechaCompra;
}
public function setFechaCompra(?DateTimeInterface $fechaCompra): static
{
$this->fechaCompra = $fechaCompra;
return $this;
}
public function getPromociones(): ?Promocion
{
return $this->promociones;
}
public function setPromociones(?Promocion $promociones): static
{
// unset the owning side of the relation if necessary
if ($promociones === null && $this->promociones !== null) {
$this->promociones->setReloj(null);
}
// set the owning side of the relation if necessary
if ($promociones !== null && $promociones->getReloj() !== $this) {
$promociones->setReloj($this);
}
$this->promociones = $promociones;
return $this;
}
public function getCodigo(): ?string
{
return $this->codigo;
}
public function setCodigo(string $codigo): static
{
$this->codigo = $codigo;
return $this;
}
public function getModelos(): ?string
{
return implode(' ', [$this->getModelo1(), $this->getModelo2()]);
}
/*public function setModelos(?string $modelos): static
{
$modelosArray = explode(',', $modelos);
$this->setModelo1(@$modelosArray[0]);
$this->setModelo2(@$modelosArray[1]);
return $this;
}*/
public function getRefs(): ?string
{
return implode('', [$this->getRef1(), $this->getRef2()]);
}
/*public function setRefs(?string $refs): static
{
$refsArray = explode(',', $refs);
$this->setRef1(@$refsArray[0]);
$this->setRef2(@$refsArray[1]);
return $this;
}*/
public function getActividad(): ?ActividadAbstract
{
return $this->actividad;
}
public function setActividad(?ActividadAbstract $actividad): static
{
// unset the owning side of the relation if necessary
if ($actividad === null && $this->actividad !== null) {
$this->actividad->setReloj(null);
}
// set the owning side of the relation if necessary
if ($actividad !== null && $actividad->getReloj() !== $this) {
$actividad->setReloj($this);
}
$this->actividad = $actividad;
return $this;
}
public function getFotoValoracion(): ?string
{
return $this->fotoValoracion;
}
public function setFotoValoracion(?string $fotoValoracion): static
{
$this->fotoValoracion = $fotoValoracion;
return $this;
}
public function getFotoValoracionFile(): ?File
{
return $this->fotoValoracionFile;
}
public function setFotoValoracionFile(?File $fotoValoracionFile): self
{
$this->fotoValoracionFile = $fotoValoracionFile;
if ($fotoValoracionFile) {
// if 'updatedAt' is not defined in your entity, use another property
$this->setUpdatedAt(new DateTime('now'));
}
return $this;
}
public function getFotoSet(): ?string
{
return $this->fotoSet;
}
public function setFotoSet(?string $fotoSet): static
{
$this->fotoSet = $fotoSet;
return $this;
}
public function getFotoSetFile(): ?File
{
return $this->fotoSetFile;
}
public function setFotoSetFile(?File $fotoSetFile): self
{
$this->fotoSetFile = $fotoSetFile;
if ($fotoSetFile) {
// if 'updatedAt' is not defined in your entity, use another property
$this->setUpdatedAt(new DateTime('now'));
}
return $this;
}
public function getFotoCrono(): ?string
{
return $this->fotoCrono;
}
public function setFotoCrono(?string $fotoCrono): static
{
$this->fotoCrono = $fotoCrono;
return $this;
}
public function getFotoCronoFile(): ?File
{
return $this->fotoCronoFile;
}
public function setFotoCronoFile(?File $fotoCronoFile): self
{
$this->fotoCronoFile = $fotoCronoFile;
if ($fotoCronoFile) {
// if 'updatedAt' is not defined in your entity, use another property
$this->setUpdatedAt(new DateTime('now'));
}
return $this;
}
public function getVideo(): ?string
{
return $this->video;
}
public function setVideo(?string $video): static
{
$this->video = $video;
return $this;
}
public function getVideoFile(): ?File
{
return $this->videoFile;
}
public function setVideoFile(?File $videoFile): self
{
$this->videoFile = $videoFile;
if ($videoFile) {
// if 'updatedAt' is not defined in your entity, use another property
$this->setUpdatedAt(new DateTime('now'));
}
return $this;
}
/**
* @return bool|null
* @deprecated Por cambios de funcionalidad
*/
public function isChrono24(): ?bool
{
return $this->chrono24;
}
/**
* @deprecated Por cambios de funcionalidad
* @param bool|null $chrono24
* @return $this
*/
public function setChrono24(?bool $chrono24): static
{
$this->chrono24 = $chrono24;
return $this;
}
/**
* @return Collection<int, DetalleVenta>
*/
public function getDetalleVenta(): Collection
{
return $this->detalleVenta;
}
public function getDetalleVentaAsentada(): ?DetalleVenta
{
return ($this->getDetalleVenta()->filter(fn($dc) => $dc->getVenta()->getOperacion()->getEstado()->getKey() === EstadoOperacionEnum::ESTADO_ASENTADA))->first();
}
public function addDetalleVentum(DetalleVenta $detalleVentum): static
{
if (!$this->detalleVenta->contains($detalleVentum)) {
$this->detalleVenta->add($detalleVentum);
$detalleVentum->setReloj($this);
}
return $this;
}
public function removeDetalleVentum(DetalleVenta $detalleVentum): static
{
if ($this->detalleVenta->removeElement($detalleVentum)) {
// set the owning side to null (unless already changed)
if ($detalleVentum->getReloj() === $this) {
$detalleVentum->setReloj(null);
}
}
return $this;
}
public function getPrecioCompra(): ?float
{
return $this->precioCompra;
}
public function setPrecioCompra(?float $precioCompra): static
{
$this->precioCompra = $precioCompra;
return $this;
}
/**
* @deprecated A partir del 04/06/2024 cuando se realiza el ciclo completo sustituir por "getOperacionCompra"
* @return Operacion|null
*/
public function getOperacion():?Operacion
{
return $this->getDetalleCompra()?->getCompra()?->getOperacion();
}
public function getOperacionCompra():?Operacion
{
//return $this->getDetalleCompra()?->getCompra()?->getOperacion()->filter(fn($operacion) => $operacion->getEstado()?->getKey() === EstadoOperacionEnum::ESTADO_CONFIRMADA || $operacion->getEstado()?->getKey() === EstadoOperacionEnum::ESTADO_ASENTADA);
return $this->operacionCompra;
}
public function getOperacionGestionCompra():?Operacion
{
return $this->getOperacionCompra()??$this->getOperacionGestion();
}
public function getOperacionVenta():?Operacion
{
/*$detalle = $this->getDetalleVenta();
if($detalle->count() !== 1 && $detalle->count() !== 0) throw new Exception('ERROR, PENDIENTE de resolver / controlar');
return $detalle->count() === 0 ? null : $this->getDetalleVenta()->first()->getVenta()?->getOperacion();*/
return $this->operacionVenta;
}
public function getRecompra(): ?float
{
return $this->recompra;
}
public function setRecompra(?float $recompra): static
{
$this->recompra = $recompra;
return $this;
}
public function getGarantia(): ?string
{
return $this->garantia;
}
public function setGarantia(?string $garantia): static
{
$this->garantia = $garantia;
return $this;
}
public function getOperacionGestion(): ?Operacion
{
return $this->operacionGestion;
}
public function setOperacionGestion(?Operacion $operacionGestion): static
{
$this->operacionGestion = $operacionGestion;
return $this;
}
public function setOperacionVenta(?Operacion $operacionVenta): static
{
$this->operacionVenta = $operacionVenta;
return $this;
}
public function setOperacionCompra(?Operacion $operacionCompra): static
{
$this->operacionCompra = $operacionCompra;
return $this;
}
public function getActividadCompra(): ?ActividadCompra
{
return $this->actividadCompra;
}
public function setActividadCompra(?ActividadCompra $actividadCompra): static
{
// unset the owning side of the relation if necessary
if ($actividadCompra === null && $this->actividadCompra !== null) {
$this->actividadCompra->setReloj(null);
}
// set the owning side of the relation if necessary
if ($actividadCompra !== null && $actividadCompra->getReloj() !== $this) {
$actividadCompra->setReloj($this);
}
$this->actividadCompra = $actividadCompra;
return $this;
}
public function getActividadVenta(): ?ActividadVenta
{
return $this->actividadVenta;
}
public function setActividadVenta(?ActividadVenta $actividadVenta): static
{
// unset the owning side of the relation if necessary
if ($actividadVenta === null && $this->actividadVenta !== null) {
$this->actividadVenta->setReloj(null);
}
// set the owning side of the relation if necessary
if ($actividadVenta !== null && $actividadVenta->getReloj() !== $this) {
$actividadVenta->setReloj($this);
}
$this->actividadVenta = $actividadVenta;
return $this;
}
public function getPeso(): ?float
{
return $this->peso;
}
public function setPeso(?float $peso): static
{
$this->peso = $peso;
return $this;
}
public function getDescripcion(): ?string
{
return $this->descripcion;
}
public function setDescripcion(?string $descripcion): static
{
$this->descripcion = $descripcion;
return $this;
}
public function getFechaStr(): ?string
{
return $this->fecha?->format("d/m/Y");
}
public function getExportPeso():?string
{
return number_format($this->peso, 2, ',', '.') . ' g.';
}
public function getExportPrecioCompra():?string
{
return number_format($this->precioCompra, 2, ',', '.') . ' €';
}
/**
* @return Collection<int, DetalleCompra>
*/
public function getDetalleCompra(): Collection
{
return $this->detalleCompra;
}
public function getDetalleCompraAsentada(): ?DetalleCompra
{
return ($this->getDetalleCompra()->filter(fn($dc) => $dc->getCompra()->getOperacion()->getTipo() === TipoOperacionEnum::OPERACION_COMPRA || $dc->getCompra()->getOperacion()->getTipo() === TipoOperacionEnum::OPERACION_PERMUTA))->first();
}
public function addDetalleCompra(DetalleCompra $detalleCompra): static
{
if (!$this->detalleCompra->contains($detalleCompra)) {
$this->detalleCompra->add($detalleCompra);
$detalleCompra->setReloj($this);
}
return $this;
}
public function removeDetalleCompra(DetalleCompra $detalleCompra): static
{
if ($this->detalleCompra->removeElement($detalleCompra)) {
// set the owning side to null (unless already changed)
if ($detalleCompra->getReloj() === $this) {
$detalleCompra->setReloj(null);
}
}
return $this;
}
public function getTiempoEnVenta(): ?int
{
return $this->tiempoEnVenta;
}
public function setTiempoEnVenta(?int $tiempoEnVenta): static
{
$this->tiempoEnVenta = $tiempoEnVenta;
return $this;
}
public function getTiempoEnStock(): ?int
{
return $this->tiempoEnStock;
}
public function setTiempoEnStock(?int $tiempoEnStock): static
{
$this->tiempoEnStock = $tiempoEnStock;
return $this;
}
public function getFechaRecepcion(): ?DateTimeInterface
{
return $this->fechaRecepcion;
}
public function getFechaRecepcionStr(): ?string
{
return $this->fechaRecepcion?->format("d/m/Y");
}
public function setFechaRecepcion(?DateTimeInterface $fechaRecepcion): static
{
$this->fechaRecepcion = $fechaRecepcion;
return $this;
}
public function getFechaValoracion(): ?DateTimeInterface
{
return $this->fechaValoracion;
}
public function setFechaValoracion(?DateTimeInterface $fechaValoracion): static
{
$this->fechaValoracion = $fechaValoracion;
return $this;
}
public function getFechaAnuncio(): ?DateTimeInterface
{
return $this->fechaAnuncio;
}
public function setFechaAnuncio(?DateTimeInterface $fechaAnuncio): static
{
$this->fechaAnuncio = $fechaAnuncio;
return $this;
}
public function getValoracion(): ?Valoracion
{
return $this->valoracion;
}
public function setValoracion(?Valoracion $valoracion): static
{
$this->valoracion = $valoracion;
return $this;
}
public function getValoracionReloj(): ?ValoracionesRelojesSinStock
{
return $this->valoracionReloj;
}
public function setValoracionReloj(?ValoracionesRelojesSinStock $valoracionReloj): static
{
// unset the owning side of the relation if necessary
if ($valoracionReloj === null && $this->valoracionReloj !== null) {
$this->valoracionReloj->setRelojInventario(null);
}
// set the owning side of the relation if necessary
if ($valoracionReloj !== null && $valoracionReloj->getRelojInventario() !== $this) {
$valoracionReloj->setRelojInventario($this);
}
$this->valoracionReloj = $valoracionReloj;
return $this;
}
public function hasBeenSold():bool
{
if($this->getEstado()?->getKey() === EstadoRelojEnum::ESTADO_VENDIDO) return true;
$criteria = Criteria::create()
->orderBy(['fecha' => Criteria::DESC])
->setMaxResults(1);
$ultimaAccion = $this->getPromociones()?->getAcciones()
?->filter(fn($accion) => $accion instanceof AccionEstado)
?->matching($criteria)
?->first();
return $ultimaAccion?->getEstado()?->getKey() === EstadoRelojEnum::ESTADO_VENDIDO;
}
}