<?php
namespace App\Entity;
use App\Enum\TipoOperacionEnum;
use DateTime;
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\DetalleOperacionRepository")
* @ORM\Table(name="detalle_operacion", schema="perseo")
* @ORM\InheritanceType("SINGLE_TABLE")
* @ORM\DiscriminatorColumn(name="type", type="string")
* @ORM\DiscriminatorMap({
* "operacion":"App\Entity\DetalleOperacion",
* "compra":"App\Entity\DetalleCompra",
* "venta":"App\Entity\DetalleVenta"
* })
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=true)
* @Vich\Uploadable
*/
class DetalleOperacion
{
/**
* @ORM\Id
* @ORM\Column(type="bigint")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(type="float", nullable=true, name="precio_coste", options={"default":"0.0","unsigned":true})
*/
protected $precioCoste;
/**
* @ORM\Column(type="float", nullable=true, precision=2, name="precio_promocion", options={"default":"0.00","unsigned":true})
*/
protected $precioPromocion;
/**
* @ORM\Column(type="string", nullable=true, name="reloj_foto")
*/
protected $relojFoto;
/**
* @Vich\UploadableField(mapping="reloj", fileNameProperty="relojFoto")
* @var File
*/
protected $relojFotoFile;
/**
* @ORM\Column(type="string", nullable=true, name="reloj_modelo1")
*/
protected $relojModelo1;
/**
* @ORM\Column(type="string", nullable=true)
*/
private $relojModelo2;
/**
* @ORM\Column(type="string", nullable=true, name="reloj_ref1")
*/
protected $relojRef1;
/**
* @ORM\Column(type="string", nullable=true)
*/
private $relojRef2;
/**
* @ORM\Column(type="string", nullable=true, name="reloj_serie")
*/
protected $relojSerie;
/**
* @ORM\Column(
* type="datetime",
* nullable=true,
* name="reloj_fecha",
* options={"comment":"Fecha comprado por primera vez"}
* )
*/
protected $relojFecha;
/**
* @ORM\Column(type="boolean", nullable=false, name="reloj_caja", options={"default":0})
*/
protected $relojCaja;
/**
* @ORM\Column(type="boolean", nullable=false, name="reloj_papeles", options={"default":0})
*/
protected $relojPapeles;
/**
* @ORM\Column(
* type="string",
* length=4,
* nullable=true,
* name="reloj_regimen",
* options={"comment":"Valores a tomar REBU รณ IVA, por defecto REBU"}
* )
*/
protected $relojRegimen;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $comentario;
/**
* @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\ActividadAbstract::class, mappedBy="detalleOperacion")
*/
private $actividad;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\EstadoAspecto", inversedBy="detalleCompras")
* @ORM\JoinColumn(name="reloj_aspecto_id", referencedColumnName="id")
*/
protected $relojAspecto;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Marca", inversedBy="detalleCompras")
* @ORM\JoinColumn(name="reloj_marca_id", referencedColumnName="id")
*/
protected $relojMarca;
protected $relojFechaStr;
public function __construct()
{
$this->relojCaja = false;
$this->relojPapeles = false;
}
public function getId(): ?int
{
return $this->id;
}
public function getPrecioCoste(): ?float
{
return $this->precioCoste;
}
public function setPrecioCoste(?float $precioCoste): self
{
$this->precioCoste = $precioCoste;
return $this;
}
public function getRelojFoto(): ?string
{
return $this->relojFoto;
}
public function setRelojFoto(?string $relojFoto): self
{
$this->relojFoto = $relojFoto;
return $this;
}
public function getRelojFotoFile(): ?File
{
return $this->relojFotoFile;
}
public function setRelojFotoFile(?File $relojFotoFile): self
{
$this->relojFotoFile = $relojFotoFile;
if ($relojFotoFile) {
// if 'updatedAt' is not defined in your entity, use another property
$this->setUpdatedAt(new DateTime('now'));
}
return $this;
}
public function getRelojModelo1(): ?string
{
return $this->relojModelo1;
}
public function setRelojModelo1(?string $relojModelo1): self
{
$this->relojModelo1 = $relojModelo1;
return $this;
}
public function getRelojRef1(): ?string
{
return $this->relojRef1;
}
public function setRelojRef1(?string $relojRef1): self
{
$this->relojRef1 = $relojRef1;
return $this;
}
public function getRelojSerie(): ?string
{
return $this->relojSerie;
}
public function setRelojSerie(?string $relojSerie): self
{
$this->relojSerie = $relojSerie;
return $this;
}
public function getRelojFecha(): ?\DateTimeInterface
{
return $this->relojFecha;
}
public function setRelojFecha(?\DateTimeInterface $relojFecha): self
{
$this->relojFecha = $relojFecha;
return $this;
}
public function isRelojCaja(): ?bool
{
return $this->relojCaja;
}
public function setRelojCaja(bool $relojCaja): self
{
$this->relojCaja = $relojCaja;
return $this;
}
public function isRelojPapeles(): ?bool
{
return $this->relojPapeles;
}
public function setRelojPapeles(bool $relojPapeles): self
{
$this->relojPapeles = $relojPapeles;
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 getRelojMarca(): ?Marca
{
return $this->relojMarca;
}
public function setRelojMarca(?Marca $relojMarca): self
{
$this->relojMarca = $relojMarca;
return $this;
}
public function getRelojAspecto(): ?EstadoAspecto
{
return $this->relojAspecto;
}
public function setRelojAspecto(?EstadoAspecto $relojAspecto): self
{
$this->relojAspecto = $relojAspecto;
return $this;
}
public function getRelojModelo2(): ?string
{
return $this->relojModelo2;
}
public function setRelojModelo2(?string $relojModelo2): self
{
$this->relojModelo2 = $relojModelo2;
return $this;
}
public function getRelojRef2(): ?string
{
return $this->relojRef2;
}
public function setRelojRef2(?string $relojRef2): self
{
$this->relojRef2 = $relojRef2;
return $this;
}
public function getRelojRegimen(): ?string
{
return $this->relojRegimen;
}
public function setRelojRegimen(?string $relojRegimen): self
{
$this->relojRegimen = $relojRegimen;
return $this;
}
public function getComentario(): ?string
{
return $this->comentario;
}
public function setComentario(?string $comentario): self
{
$this->comentario = $comentario;
return $this;
}
public function getPrecioPromocion(): ?float
{
return $this->precioPromocion;
}
public function setPrecioPromocion(?float $precioPromocion): static
{
$this->precioPromocion = $precioPromocion;
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->setDetalleOperacion(null);
}
// set the owning side of the relation if necessary
if ($actividad !== null && $actividad->getDetalleOperacion() !== $this) {
$actividad->setDetalleOperacion($this);
}
$this->actividad = $actividad;
return $this;
}
public function getType(): ?string
{
$type = null;
if($this instanceof DetalleCompra) $type = TipoOperacionEnum::OPERACION_COMPRA;
if($this instanceof DetalleVenta) $type = TipoOperacionEnum::OPERACION_VENTA;
return $type;
}
public function getOperacion(): ?Operacion
{
$operacion = null;
if($this instanceof DetalleCompra) $operacion = $this->getCompra()->getOperacion();
if($this instanceof DetalleVenta) $operacion = $this->getVenta()->getOperacion();
return $operacion;
}
public function getRelojFechaStr(): ?string
{
return $this->relojFecha?->format("d/m/Y");
}
}