src/Entity/DetalleVenta.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Enum\IdiomaEnum;
  4. use App\Enum\TipoGarantiaEnum;
  5. use DateInterval;
  6. use DateTimeInterface;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. /**
  10.  * @ORM\Entity(repositoryClass="App\Repository\DetalleVentaRepository")
  11.  * @ORM\Table(name="detalle_venta", schema="perseo")
  12.  * @ORM\EntityListeners({
  13.  *     "App\EntityListener\DetalleVenta\CrearAccionEnviadoListener",
  14.  *     "App\EntityListener\DetalleVenta\ControlRelojesOperacionListener"
  15.  * })
  16.  */
  17. class DetalleVenta extends DetalleOperacion
  18. {
  19.     /**
  20.      * @ORM\Column(
  21.      *     type="float",
  22.      *     nullable=true,
  23.      *     precision=2,
  24.      *     name="precio_coste_total",
  25.      *     options={"default":"0.00","comment":"Coste del reloj + costes reparación, servicios u otros añadidos en PROMOCION"}
  26.      * )
  27.      */
  28.     protected $precioCosteTotal;
  29.     /**
  30.      * @ORM\Column(type="float", nullable=true, precision=2, name="precio_venta", options={"default":"0.00","unsigned":true})
  31.      */
  32.     protected $precioVenta;
  33.     /**
  34.      * @ORM\Column(type="float", nullable=true, precision=2, name="margen_beneficio", options={"default":"0.00","comment":"%"})
  35.      */
  36.     protected $margenBeneficio;
  37.     /**
  38.      * @ORM\Column(type="float", nullable=true, precision=2, options={"default":"0.00"})
  39.      */
  40.     protected $descuento;
  41.     /**
  42.      * @ORM\Column(
  43.      *     type="datetime",
  44.      *     nullable=true,
  45.      *     name="fecha_envio",
  46.      *     options={"comment":"Cada vez que se modifica la fecha envío se crea un nuevo estado envio en promoción."}
  47.      * )
  48.      */
  49.     private $fechaEnvio;
  50.     /**
  51.      * @ORM\Column(type="float", nullable=true, precision=2)
  52.      */
  53.     protected $recompra;
  54.     /**
  55.      * @ORM\Column(type="string", nullable=true)
  56.      */
  57.     protected $garantia;
  58.     /**
  59.      * @ORM\ManyToOne(targetEntity=\App\Entity\Venta::class, inversedBy="detalleVentas")
  60.      * @ORM\JoinColumn(name="venta_id", referencedColumnName="id")
  61.      */
  62.     protected $venta;
  63.     /*
  64.      * @ORM\JoinColumn(name="reloj_venta_id", referencedColumnName="id")
  65.      * @ORM\OneToOne(targetEntity=\App\Entity\Reloj::class, inversedBy="detalleVenta")
  66.      */
  67. //    private $reloj;
  68.     /**
  69.      * @ORM\ManyToOne(targetEntity="App\Entity\Reloj", inversedBy="detalleVenta")
  70.      * @ORM\JoinColumn(name="reloj_venta_id", referencedColumnName="id")
  71.      */
  72.     protected $reloj;
  73.     /*public function __toString(): string
  74.     {
  75.         return $this->getVenta()->__toString() . ' - ' . $this->getReloj() ?? '---';
  76.     }*/
  77.     public function getVenta(): ?Venta
  78.     {
  79.         return $this->venta;
  80.     }
  81.     public function setVenta(?Venta $venta): self
  82.     {
  83.         $this->venta $venta;
  84.         return $this;
  85.     }
  86.     public function getPrecioCosteTotal(): ?float
  87.     {
  88.         return $this->precioCosteTotal;
  89.     }
  90.     public function setPrecioCosteTotal(?float $precioCosteTotal): self
  91.     {
  92.         $this->precioCosteTotal $precioCosteTotal;
  93.         return $this;
  94.     }
  95.     public function getPrecioVenta(): ?float
  96.     {
  97.         return $this->precioVenta;
  98.     }
  99.     public function setPrecioVenta(?float $precioVenta): self
  100.     {
  101.         $this->precioVenta $precioVenta;
  102.         return $this;
  103.     }
  104.     public function getMargenBeneficio(): ?float
  105.     {
  106.         return $this->margenBeneficio;
  107.     }
  108.     public function setMargenBeneficio(?float $margenBeneficio): self
  109.     {
  110.         $this->margenBeneficio $margenBeneficio;
  111.         return $this;
  112.     }
  113.     public function getDescuento(): ?float
  114.     {
  115.         return $this->descuento;
  116.     }
  117.     public function setDescuento(?float $descuento): self
  118.     {
  119.         $this->descuento $descuento;
  120.         return $this;
  121.     }
  122.     public function getReloj(): ?Reloj
  123.     {
  124.         return $this->reloj;
  125.     }
  126.     public function setReloj(?Reloj $reloj): static
  127.     {
  128.         $this->reloj $reloj;
  129.         return $this;
  130.     }
  131.     public function getFechaEnvio(): ?DateTimeInterface
  132.     {
  133.         return $this->fechaEnvio;
  134.     }
  135.     public function setFechaEnvio(?DateTimeInterface $fechaEnvio): static
  136.     {
  137.         $this->fechaEnvio $fechaEnvio;
  138.         return $this;
  139.     }
  140.     public function getRecompra(): ?float
  141.     {
  142.         return $this->recompra;
  143.     }
  144.     public function setRecompra(?float $recompra): static
  145.     {
  146.         $this->recompra $recompra;
  147.         return $this;
  148.     }
  149.     public function getGarantia(): ?string
  150.     {
  151.         return $this->garantia;
  152.     }
  153.     public function setGarantia(?string $garantia): static
  154.     {
  155.         $this->garantia $garantia;
  156.         return $this;
  157.     }
  158.     public function getGarantiaStr(): ?string
  159.     {
  160.         switch ($this->getVenta()->getOperacion()->getIdioma())
  161.         {
  162.             case IdiomaEnum::IDIOMA_ES:
  163.                 $garantia $this->getGarantia() === TipoGarantiaEnum::GARANTIA_SIN null 'Sobre el calibre';
  164.                 break;
  165.             case IdiomaEnum::IDIOMA_EN:
  166.                 $garantia $this->getGarantia() === TipoGarantiaEnum::GARANTIA_SIN null 'Over the movement';
  167.                 break;
  168.             default:
  169.                 $garantia null;
  170.                 break;
  171.         }
  172.         return $garantia;
  173.     }
  174.     public function getGarantiaFecha(): ?DateTimeInterface
  175.     {
  176.         switch ($this->getGarantia())
  177.         {
  178.             case TipoGarantiaEnum::GARANTIA_6:
  179.                 $fechaGarantia $this->getFechaEnvio()->add(new DateInterval('P' 365*6/12 'D'));
  180.                 break;
  181.             case TipoGarantiaEnum::GARANTIA_12:
  182.                 $fechaGarantia $this->getFechaEnvio()->add(new DateInterval('P' 365*12/12 'D'));
  183.                 break;
  184.             default:
  185.                 $fechaGarantia null;
  186.                 break;
  187.         }
  188.         return $fechaGarantia;
  189.     }
  190.     public function getRecompraStr(): ?string
  191.     {
  192.         if(!$this->getGarantiaStr()) return null;
  193.         switch ($this->getVenta()->getOperacion()->getIdioma())
  194.         {
  195.             case IdiomaEnum::IDIOMA_ES:
  196.                 $recompra 'Recompra:';
  197.                 break;
  198.             case IdiomaEnum::IDIOMA_EN:
  199.                 $recompra 'Buy-back:';
  200.                 break;
  201.             default:
  202.                 $recompra null;
  203.                 break;
  204.         }
  205.         return $recompra;
  206.     }
  207.     public function getRecompraIndice(): ?string
  208.     {
  209.         if(!$this->getRecompra()) return null;
  210.         $recompra number_format($this->getRecompra(), 2',');
  211.         switch ($this->getVenta()->getOperacion()->getIdioma())
  212.         {
  213.             case IdiomaEnum::IDIOMA_ES:
  214.                 $indice "Sí, $recompra%";
  215.                 break;
  216.             case IdiomaEnum::IDIOMA_EN:
  217.                 $indice "Yes, $recompra%";
  218.                 break;
  219.             default:
  220.                 $indice null;
  221.                 break;
  222.         }
  223.         return $indice;
  224.     }
  225.     public function getRecompraFechaStr(): ?string
  226.     {
  227.         if(!$this->getRecompraFecha()) return null;
  228.         switch ($this->getVenta()->getOperacion()->getIdioma())
  229.         {
  230.             case IdiomaEnum::IDIOMA_ES:
  231.                 $recompraFechaStr 'Activa hasta: ';
  232.                 break;
  233.             case IdiomaEnum::IDIOMA_EN:
  234.                 $recompraFechaStr 'Term: ';
  235.                 break;
  236.             default:
  237.                 $recompraFechaStr null;
  238.                 break;
  239.         }
  240.         return $recompraFechaStr;
  241.     }
  242.     public function getRecompraFecha(): ?DateTimeInterface
  243.     {
  244.         return $this->getGarantiaFecha();
  245.     }
  246. }