<?php
namespace App\Entity;
use App\Enum\EstadoActividadEnum;
use App\Validator as PerseoAssert;
use DateTime;
use DateTimeInterface;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\Validator\Constraints as Assert;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Entity(repositoryClass="App\Repository\ActividadAbstractRepository")
* @ORM\Table(name="actividad", schema="perseo")
* @ORM\EntityListeners({
* "App\EntityListener\Actividad\CalcularIDPerseoListener",
* "App\EntityListener\Actividad\UpdateDatesListener"
* })
* @ORM\InheritanceType("SINGLE_TABLE")
* @ORM\DiscriminatorColumn(name="type", type="string")
* @ORM\DiscriminatorMap({"compra":"App\Entity\ActividadCompra","venta":"App\Entity\ActividadVenta"})
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=true)
* @Vich\Uploadable
* @PerseoAssert\ContraintsValidarEntidadCp()
*/
Abstract class ActividadAbstract
{
/**
* @ORM\Id
* @ORM\Column(type="bigint", options={"unsigned":true})
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\Column(type="string", nullable=true)
*/
private $tipo;
/**
* @ORM\Column(type="string", length=2, nullable=true, options={"default":"es"})
*/
private $idioma;
/**
* @ORM\Column(type="string", nullable=true)
*/
private $IDperseo;
/**
* @ORM\Column(type="datetime", nullable=true, name="fecha")
*/
private $fecha;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $exportacion;
/**
* @ORM\Column(type="string", length=4, nullable=true)
*/
private $regimen;
/**
* @ORM\Column(type="boolean", nullable=true, options={"comment":"0 => particular, 1 => empresa"})
*/
private $tipoCliente;
/**
* @ORM\Column(type="string", length=2, nullable=true, name="cliente_idioma")
*/
private $clienteIdioma;
/**
* @ORM\Column(type="string", nullable=true, name="cliente_razon_social")
*/
private $clienteRazonSocial;
/**
* @ORM\Column(
* type="string",
* nullable=true,
* name="cliente_identificacion_tipo",
* options={"comment":"DNI, Pasaporte, Licencia de Condución"}
* )
*/
private $clienteIdentificacionTipo;
/**
* @ORM\Column(type="string", nullable=true, name="cliente_identificacion")
*/
private $clienteIdentificacion;
/**
* @ORM\Column(type="string", nullable=true, name="cliente_direccion")
*/
private $clienteDireccion;
/**
* @ORM\Column(type="string", length=12, nullable=true, name="cliente_cp")
* @Assert\Length(min = 5, max = 12)
*/
private $clienteCp;
/**
* @ORM\Column(type="string", nullable=true, name="cliente_region")
*/
protected $clienteRegion;
/**
* @ORM\Column(type="string", nullable=true, name="cliente_ciudad")
*/
private $clienteCiudad;
/**
* @ORM\Column(type="string", nullable=true, name="cliente_provincia")
*/
private $clienteProvincia;
/**
* @ORM\Column(type="string", nullable=true, name="cliente_ccaa")
*/
private $clienteCcaa;
/**
* @ORM\Column(type="string", nullable=true, name="cliente_pais")
*/
private $clientePais;
/**
* @ORM\Column(type="string", nullable=true, name="cliente_identificacion_frontal")
*/
private $clienteIdentificacionFrontal;
/**
* @Vich\UploadableField(mapping="cliente", fileNameProperty="clienteIdentificacionFrontal")
* @var File
*/
private $clienteIdentificacionFrontalFile;
/**
* @ORM\Column(type="string", nullable=true, name="cliente_identificacion_trasera")
*/
private $clienteIdentificacionTrasera;
/**
* @Vich\UploadableField(mapping="cliente", fileNameProperty="clienteIdentificacionTrasera")
* @var File
*/
private $clienteIdentificacionTraseraFile;
/**
* @ORM\Column(type="string", nullable=true, name="cliente_entidad_bancaria")
*/
private $clienteEntidadBancaria;
/**
* @ORM\Column(type="string", nullable=true, name="cliente_iban")
*/
private $clienteIban;
/**
* @ORM\Column(type="text", nullable=true, name="cliente_observaciones")
*/
private $clienteObservaciones;
/**
* @ORM\Column(type="string", nullable=true, name="reloj_foto")
*/
private $relojFoto;
/**
* @Vich\UploadableField(mapping="reloj", fileNameProperty="relojFoto")
* @var File
*/
protected $relojFotoFile;
/**
* @ORM\Column(type="string", nullable=true, name="reloj_modelo")
*/
private $relojModelo1;
/**
* @ORM\Column(type="string", nullable=true)
*/
private $relojModelo2;
/**
* @ORM\Column(type="string", nullable=true, name="reloj_ref")
*/
private $relojRef1;
/**
* @ORM\Column(type="string", nullable=true)
*/
private $relojRef2;
/**
* @ORM\Column(type="string", nullable=true, name="reloj_serie")
*/
private $relojSerie;
/**
* @ORM\Column(
* type="datetime",
* nullable=true,
* name="reloj_fecha",
* options={"comment":"Fecha comprado por primera vez"}
* )
*/
private $relojFecha;
/**
* @ORM\Column(type="boolean", nullable=false, name="reloj_caja", options={"default":0})
*/
private $relojCaja;
/**
* @ORM\Column(type="boolean", nullable=false, name="reloj_papeles", options={"default":0})
*/
private $relojPapeles;
/**
* @ORM\Column(type="datetime", nullable=true, name="fecha_asentada")
*/
private $fechaAsentada;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $fechaConfirmada;
/**
* @ORM\Column(type="datetime", nullable=true, name="fecha_facturada")
*/
private $fechaFacturada;
/**
* @ORM\Column(type="datetime", nullable=true, name="fecha_cancelada")
*/
private $fechaCancelada;
/**
* @ORM\Column(type="datetime", nullable=true, name="deleted_at")
*/
private $deletedAt;
/**
* @ORM\Column(type="datetime", nullable=false, name="updated_at", options={"default":"2022-01-01 00:00:00"})
* @Gedmo\Timestampable(on="update")
*/
private $updatedAt;
/**
* @ORM\Column(type="datetime", nullable=false, name="created_at", options={"default":"2022-01-01 00:00:00"})
* @Gedmo\Timestampable(on="create")
*/
private $createdAt;
/**
* @ORM\OneToOne(targetEntity=\App\Entity\DetalleOperacion::class, inversedBy="actividad")
* @ORM\JoinColumn(name="detalle_operacion_id", referencedColumnName="id", unique=true)
*/
private $detalleOperacion;
/**
* @ORM\ManyToOne(targetEntity=\App\Entity\Cliente::class, inversedBy="actividades")
* @ORM\JoinColumn(name="cliente_id", referencedColumnName="id")
*/
private $cliente;
/**
* @ORM\ManyToOne(targetEntity=\App\Entity\Marca::class, inversedBy="actividades")
* @ORM\JoinColumn(name="reloj_marca_id", referencedColumnName="id")
*/
private $relojMarca;
/**
* @ORM\ManyToOne(targetEntity=\App\Entity\EstadoAspecto::class, inversedBy="actividades")
* @ORM\JoinColumn(name="reloj_estado_id", referencedColumnName="id")
*/
private $relojAspecto;
/**
* @ORM\ManyToOne(targetEntity=\App\Entity\UnidadNegocio::class, inversedBy="actividades")
* @ORM\JoinColumn(name="unidad_negocio_id", referencedColumnName="id")
*/
private $unidadNegocio;
/**
* @ORM\ManyToOne(targetEntity=\App\Entity\Usuario::class, inversedBy="actividades")
* @ORM\JoinColumn(name="usuario_id", referencedColumnName="id")
*/
private $usuario;
/**
* @ORM\ManyToOne(targetEntity=\App\Entity\Canal::class, inversedBy="actividades")
* @ORM\JoinColumn(name="canal_id", referencedColumnName="id")
*/
private $canal;
/**
* @ORM\ManyToOne(targetEntity=\App\Entity\EstadoActividad::class, inversedBy="actividades")
* @ORM\JoinColumn(name="estado_id", referencedColumnName="id")
*/
private $estado;
public function __toString(): string
{
return $this->IDperseo??'---';
}
public function getId(): ?string
{
return $this->id;
}
public function getIDperseo(): ?string
{
return $this->IDperseo;
}
public function setIDperseo(?string $IDperseo): static
{
$this->IDperseo = $IDperseo;
return $this;
}
public function getFecha(): ?DateTimeInterface
{
return $this->fecha;
}
public function setFecha(?DateTimeInterface $fecha): static
{
$this->fecha = $fecha;
return $this;
}
public function isExportacion(): ?bool
{
return $this->exportacion;
}
public function setExportacion(?bool $exportacion): static
{
$this->exportacion = $exportacion;
return $this;
}
public function getRegimen(): ?string
{
return $this->regimen;
}
public function setRegimen(?string $regimen): static
{
$this->regimen = $regimen;
return $this;
}
public function getClienteIdioma(): ?string
{
return $this->clienteIdioma;
}
public function setClienteIdioma(?string $clienteIdioma): static
{
$this->clienteIdioma = $clienteIdioma;
return $this;
}
public function getClienteRazonSocial(): ?string
{
return $this->clienteRazonSocial;
}
public function setClienteRazonSocial(?string $clienteRazonSocial): static
{
$this->clienteRazonSocial = $clienteRazonSocial;
return $this;
}
public function getClienteIdentificacionTipo(): ?string
{
return $this->clienteIdentificacionTipo;
}
public function setClienteIdentificacionTipo(?string $clienteIdentificacionTipo): static
{
$this->clienteIdentificacionTipo = $clienteIdentificacionTipo;
return $this;
}
public function getClienteIdentificacion(): ?string
{
return $this->clienteIdentificacion;
}
public function setClienteIdentificacion(?string $clienteIdentificacion): static
{
$this->clienteIdentificacion = $clienteIdentificacion;
return $this;
}
public function getClienteDireccion(): ?string
{
return $this->clienteDireccion;
}
public function setClienteDireccion(?string $clienteDireccion): static
{
$this->clienteDireccion = $clienteDireccion;
return $this;
}
public function getClienteCp(): ?string
{
return $this->clienteCp;
}
public function setClienteCp(?string $clienteCp): static
{
$this->clienteCp = $clienteCp;
return $this;
}
public function getClienteCiudad(): ?string
{
return $this->clienteCiudad;
}
public function setClienteCiudad(?string $clienteCiudad): static
{
$this->clienteCiudad = $clienteCiudad;
return $this;
}
public function getClienteProvincia(): ?string
{
return $this->clienteProvincia;
}
public function setClienteProvincia(?string $clienteProvincia): static
{
$this->clienteProvincia = $clienteProvincia;
return $this;
}
public function getClienteCcaa(): ?string
{
return $this->clienteCcaa;
}
public function setClienteCcaa(?string $clienteCcaa): static
{
$this->clienteCcaa = $clienteCcaa;
return $this;
}
public function getClientePais(): ?string
{
return $this->clientePais;
}
public function setClientePais(?string $clientePais): static
{
$this->clientePais = $clientePais;
return $this;
}
public function getClienteIdentificacionFrontal(): ?string
{
return $this->clienteIdentificacionFrontal;
}
public function setClienteIdentificacionFrontal(?string $clienteIdentificacionFrontal): static
{
$this->clienteIdentificacionFrontal = $clienteIdentificacionFrontal;
return $this;
}
public function getClienteIdentificacionFrontalFile(): ?File
{
return $this->clienteIdentificacionFrontalFile;
}
public function setClienteIdentificacionFrontalFile(?File $clienteIdentificacionFrontalFile): static
{
$this->clienteIdentificacionFrontalFile = $clienteIdentificacionFrontalFile;
if ($clienteIdentificacionFrontalFile) {
// if 'updatedAt' is not defined in your entity, use another property
$this->setUpdatedAt(new DateTime('now'));
}
return $this;
}
public function getClienteIdentificacionTrasera(): ?string
{
return $this->clienteIdentificacionTrasera;
}
public function setClienteIdentificacionTrasera(?string $clienteIdentificacionTrasera): static
{
$this->clienteIdentificacionTrasera = $clienteIdentificacionTrasera;
return $this;
}
public function getClienteIdentificacionTraseraFile(): ?File
{
return $this->clienteIdentificacionTraseraFile;
}
public function setClienteIdentificacionTraseraFile(?File $clienteIdentificacionTraseraFile): static
{
$this->clienteIdentificacionTraseraFile = $clienteIdentificacionTraseraFile;
if ($clienteIdentificacionTraseraFile) {
// if 'updatedAt' is not defined in your entity, use another property
$this->setUpdatedAt(new DateTime('now'));
}
return $this;
}
public function getClienteEntidadBancaria(): ?string
{
return $this->clienteEntidadBancaria;
}
public function setClienteEntidadBancaria(?string $clienteEntidadBancaria): static
{
$this->clienteEntidadBancaria = $clienteEntidadBancaria;
return $this;
}
public function getClienteIban(): ?string
{
return $this->clienteIban;
}
public function setClienteIban(?string $clienteIban): static
{
$this->clienteIban = $clienteIban;
return $this;
}
public function getClienteObservaciones(): ?string
{
return $this->clienteObservaciones;
}
public function setClienteObservaciones(?string $clienteObservaciones): static
{
$this->clienteObservaciones = $clienteObservaciones;
return $this;
}
public function getDeletedAt(): ?DateTimeInterface
{
return $this->deletedAt;
}
public function setDeletedAt(?DateTimeInterface $deletedAt): static
{
$this->deletedAt = $deletedAt;
return $this;
}
public function getUpdatedAt(): ?DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(DateTimeInterface $updatedAt): static
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getCreatedAt(): ?DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(DateTimeInterface $createdAt): static
{
$this->createdAt = $createdAt;
return $this;
}
public function getDetalleOperacion(): ?DetalleOperacion
{
return $this->detalleOperacion;
}
public function setDetalleOperacion(?DetalleOperacion $detalleOperacion): static
{
$this->detalleOperacion = $detalleOperacion;
return $this;
}
public function getCliente(): ?Cliente
{
return $this->cliente;
}
public function setCliente(?Cliente $cliente): static
{
$this->cliente = $cliente;
return $this;
}
public function getExportacionStr():string
{
return $this->isExportacion() ? 'Exportacion' : 'Europa';
}
public function getRelojFoto(): ?string
{
return $this->relojFoto;
}
public function setRelojFoto(?string $relojFoto): static
{
$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): static
{
$this->relojModelo1 = $relojModelo1;
return $this;
}
public function getRelojModelo2(): ?string
{
return $this->relojModelo2;
}
public function setRelojModelo2(?string $relojModelo2): static
{
$this->relojModelo2 = $relojModelo2;
return $this;
}
public function getRelojRef1(): ?string
{
return $this->relojRef1;
}
public function setRelojRef1(?string $relojRef1): static
{
$this->relojRef1 = $relojRef1;
return $this;
}
public function getRelojRef2(): ?string
{
return $this->relojRef2;
}
public function setRelojRef2(?string $relojRef2): static
{
$this->relojRef2 = $relojRef2;
return $this;
}
public function getRelojSerie(): ?string
{
return $this->relojSerie;
}
public function setRelojSerie(?string $relojSerie): static
{
$this->relojSerie = $relojSerie;
return $this;
}
public function getRelojFecha(): ?DateTimeInterface
{
return $this->relojFecha;
}
public function setRelojFecha(?DateTimeInterface $relojFecha): static
{
$this->relojFecha = $relojFecha;
return $this;
}
public function isRelojCaja(): ?bool
{
return $this->relojCaja;
}
public function setRelojCaja(bool $relojCaja): static
{
$this->relojCaja = $relojCaja;
return $this;
}
public function isRelojPapeles(): ?bool
{
return $this->relojPapeles;
}
public function setRelojPapeles(bool $relojPapeles): static
{
$this->relojPapeles = $relojPapeles;
return $this;
}
public function getRelojAspecto(): ?EstadoAspecto
{
return $this->relojAspecto;
}
public function setRelojAspecto(?EstadoAspecto $relojAspecto): static
{
$this->relojAspecto = $relojAspecto;
return $this;
}
public function getRelojMarca(): ?Marca
{
return $this->relojMarca;
}
public function setRelojMarca(?Marca $relojMarca): static
{
$this->relojMarca = $relojMarca;
return $this;
}
public function getUnidadNegocio(): ?UnidadNegocio
{
return $this->unidadNegocio;
}
public function setUnidadNegocio(?UnidadNegocio $unidadNegocio): static
{
$this->unidadNegocio = $unidadNegocio;
return $this;
}
public function getUsuario(): ?Usuario
{
return $this->usuario;
}
public function setUsuario(?Usuario $usuario): static
{
$this->usuario = $usuario;
return $this;
}
public function getCanal(): ?Canal
{
return $this->canal;
}
public function setCanal(?Canal $canal): static
{
$this->canal = $canal;
return $this;
}
public function isTipoCliente(): ?bool
{
return $this->tipoCliente;
}
public function setTipoCliente(?bool $tipoCliente): static
{
$this->tipoCliente = $tipoCliente;
return $this;
}
public function getIdioma(): ?string
{
return $this->idioma;
}
public function setIdioma(?string $idioma): static
{
$this->idioma = $idioma;
return $this;
}
public function getTipo(): ?string
{
return $this->tipo;
}
public function setTipo(?string $tipo): static
{
$this->tipo = $tipo;
return $this;
}
public function getImporte():?float
{
return $this instanceof ActividadCompra ? $this->getPrecioCoste() : $this->getPrecio();
}
public function getRelojStr():string
{
return implode(', ', [$this->getRelojMarca(), $this->getRelojModelo1()]);
}
public function getFechaVenta():?DateTimeInterface
{
return $this instanceof ActividadVenta ? $this->getFecha() : null;
}
public function getPrecioCoste():?float
{
return $this instanceof ActividadCompra ? $this->getPrecioCoste() : null;
}
public function getPrecioVenta():?float
{
return $this instanceof ActividadVenta ? $this->getPrecioVenta() : null;
}
public function getClienteRegion(): ?string
{
return $this->clienteRegion;
}
public function setClienteRegion(?string $clienteRegion): static
{
$this->clienteRegion = $clienteRegion;
return $this;
}
public function getEstado(): ?EstadoActividad
{
return $this->estado;
}
public function setEstado(?EstadoActividad $estado): static
{
$this->estado = $estado;
return $this;
}
public function getFechaAsentada(): ?\DateTimeInterface
{
return $this->fechaAsentada;
}
public function setFechaAsentada(?\DateTimeInterface $fechaAsentada): static
{
$this->fechaAsentada = $fechaAsentada;
return $this;
}
public function getFechaConfirmada(): ?\DateTimeInterface
{
return $this->fechaConfirmada;
}
public function setFechaConfirmada(?\DateTimeInterface $fechaConfirmada): static
{
$this->fechaConfirmada = $fechaConfirmada;
return $this;
}
public function getFechaFacturada(): ?\DateTimeInterface
{
return $this->fechaFacturada;
}
public function setFechaFacturada(?\DateTimeInterface $fechaFacturada): static
{
$this->fechaFacturada = $fechaFacturada;
return $this;
}
public function getFechaCancelada(): ?\DateTimeInterface
{
return $this->fechaCancelada;
}
public function setFechaCancelada(?\DateTimeInterface $fechaCancelada): static
{
$this->fechaCancelada = $fechaCancelada;
return $this;
}
public function getEstadoFecha(): ?DateTimeInterface
{
switch($this->getEstado()?->getKey())
{
case EstadoActividadEnum::ESTADO_ASENTADA:
$fecha = $this->getFechaAsentada();
break;
case EstadoActividadEnum::ESTADO_CONFIRMADA:
$fecha = $this->getFechaConfirmada();
break;
case EstadoActividadEnum::ESTADO_FACTURADA:
$fecha = $this->getFechaFacturada();
break;
case EstadoActividadEnum::ESTADO_CANCELADA:
$fecha = $this->getFechaCancelada();
break;
default:
$fecha = null;
break;
}
return $fecha;
}
}