src/Entity/DetalleCompra.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use DateTime;
  4. use DateTimeInterface;
  5. use Doctrine\DBAL\Types\Types;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use JMS\Serializer\Annotation as JMS;
  8. /**
  9.  * @ORM\Entity(repositoryClass="App\Repository\DetalleCompraRepository")
  10.  * @ORM\Table(name="detalle_compra")
  11.  * @ORM\EntityListeners({
  12.  *     "App\EntityListener\DetalleCompra\ControlRelojesOperacionListener",
  13.  *     "App\EntityListener\DetalleCompra\CrearAccionEstadoGestionCanceladaListener"
  14.  * })
  15.  */
  16. class DetalleCompra extends DetalleOperacion
  17. {
  18.     /**
  19.      * @ORM\Column(type="float", nullable=true, name="precio_pagar", precision=2, options={"default":"0.0"})
  20.      */
  21.     protected $precioPagar;
  22.     /**
  23.      * @ORM\Column(type="float", nullable=true, name="coste_importacion_iva", precision=2)
  24.      */
  25.     private $costeImportacionIva;
  26.     /**
  27.      * @ORM\Column(type="float", nullable=true, name="coste_importacion_otros", precision=2)
  28.      */
  29.     private $costeImportacionOtros;
  30.     /**
  31.      * @ORM\Column(
  32.      *     type="datetime",
  33.      *     nullable=true,
  34.      *     name="fecha_verificacion",
  35.      *     options={"comment":"Será la fecha del estado de recepción en promoción, que se crea automáticamente cuando está en confirmada"}
  36.      * )
  37.      * @JMS\Groups({
  38.      *       "api_v1_operacion_show_serialize"
  39.      *   })
  40.      */
  41.     private $fechaVerificacion;
  42.     /**
  43.      * @ORM\Column(
  44.      *     type="datetime",
  45.      *     nullable=true,
  46.      *     name="fecha_cancelacion",
  47.      *     options={"comment":"Será la fecha del estado de cancelada en promoción, que se crea automáticamente cuando se cancela el reloj"}
  48.      * )
  49.      */
  50.     private $fechaCancelacion;
  51.     /**
  52.      * @ORM\ManyToOne(targetEntity=\App\Entity\Compra::class, inversedBy="detalle")
  53.      * @ORM\JoinColumn(name="compra_id", referencedColumnName="id")
  54.      */
  55.     protected $compra;
  56.     /*
  57.      * @ORM\OneToOne(targetEntity=\App\Entity\Reloj::class, inversedBy="detalleCompra")
  58.      * @ORM\JoinColumn(name="reloj_compra_id", referencedColumnName="id", unique=true)
  59.      */
  60.     /**
  61.      * @ORM\JoinColumn(name="reloj_compra_id", referencedColumnName="id")
  62.      * @ORM\ManyToOne(targetEntity=\App\Entity\Reloj::class, inversedBy="detalleCompra")
  63.      * @JMS\Type(CCAA::class)
  64.      * @JMS\Groups({
  65.      *        "api_v1_operacion_show_serialize"
  66.      *    })
  67.      */
  68.     private $reloj;
  69.     /**
  70.      * @ORM\ManyToOne(targetEntity=\App\Entity\Reloj::class, inversedBy="relojesDerivadosDetalleCompra")
  71.      * @ORM\JoinColumn(name="reloj_base_id", referencedColumnName="id")
  72.      */
  73.     private $relojBase;
  74.     /**
  75.      * @ORM\JoinColumn(name="valoracion_reloj_id", referencedColumnName="id", unique=true)
  76.      * @ORM\OneToOne(targetEntity=\App\Entity\ValoracionesRelojesSinStock::class, inversedBy="detalleCompra")
  77.      */
  78.     private $valoracionReloj;
  79.     /*public function __toString(): string
  80.     {
  81.         return $this->getCompra()->__toString() . ' - ' . $this->getRelojMarca() . ' - ' .  $this->getRelojModelo1() . ' - ' .  $this->getRelojRef1() ?? '---';
  82.     }*/
  83.     public function __clone(): void
  84.     {
  85.         $this->setCompra(null);
  86.         $this->setActividad(null);
  87.         $this->setFechaVerificacion(null);
  88.         $this->setCreatedAt(new DateTime());
  89.         $this->setUpdatedAt(new DateTime());
  90.     }
  91.     public function getCompra(): ?Compra
  92.     {
  93.         return $this->compra;
  94.     }
  95.     public function setCompra(?Compra $compra): self
  96.     {
  97.         $this->compra $compra;
  98.         return $this;
  99.     }
  100.     public function getFechaVerificacion(): ?DateTimeInterface
  101.     {
  102.         return $this->fechaVerificacion;
  103.     }
  104.     public function setFechaVerificacion(?DateTimeInterface $fechaVerificacion): static
  105.     {
  106.         $this->fechaVerificacion $fechaVerificacion;
  107.         return $this;
  108.     }
  109.     public function getFechaCancelacion(): ?\DateTimeInterface
  110.     {
  111.         return $this->fechaCancelacion;
  112.     }
  113.     public function setFechaCancelacion(?\DateTimeInterface $fechaCancelacion): static
  114.     {
  115.         $this->fechaCancelacion $fechaCancelacion;
  116.         return $this;
  117.     }
  118.     public function getReloj(): ?Reloj
  119.     {
  120.         return $this->reloj;
  121.     }
  122.     public function setReloj(?Reloj $reloj): static
  123.     {
  124.         $this->reloj $reloj;
  125.         return $this;
  126.     }
  127.     public function getPrecioPagar(): ?float
  128.     {
  129.         return $this->precioPagar;
  130.     }
  131.     public function setPrecioPagar(?float $precioPagar): static
  132.     {
  133.         $this->precioPagar $precioPagar;
  134.         return $this;
  135.     }
  136.     public function getValoracionReloj(): ?ValoracionesRelojesSinStock
  137.     {
  138.         return $this->valoracionReloj;
  139.     }
  140.     public function setValoracionReloj(?ValoracionesRelojesSinStock $valoracionReloj): static
  141.     {
  142.         $this->valoracionReloj $valoracionReloj;
  143.         return $this;
  144.     }
  145.     public function getRelojBase(): ?Reloj
  146.     {
  147.         return $this->relojBase;
  148.     }
  149.     public function setRelojBase(?Reloj $relojBase): static
  150.     {
  151.         $this->relojBase $relojBase;
  152.         return $this;
  153.     }
  154.     public function getRelojGestion(): ?Reloj
  155.     {
  156.         if (!$relojBase $this->getRelojBase()) return null;
  157.         if(!$operacionGestion $relojBase->getOperacionGestion()) return null;
  158.         $cancelRelojBase $operacionGestion
  159.             ->getCompra()
  160.             ->getDetalle()
  161.             ->findFirst(
  162.                 fn($key$detalle) => $detalle->getReloj()?->getId() === $relojBase->getId()
  163.             )
  164.             ?->getFechaCancelacion();
  165.         return (!$cancelRelojBase && !$relojBase->getFechaVenta() && !$relojBase->getFechaCompra()) ? $relojBase null;
  166.     }
  167.     public function getFechaVerificacionRelojGestion(): ?DateTimeInterface
  168.     {
  169.         if (!$relojBase $this->getRelojBase()) return null;
  170.         if(!$operacionGestion $relojBase->getOperacionGestion()) return null;
  171.         $detalleRelojBase $operacionGestion
  172.             ->getCompra()
  173.             ->getDetalle()
  174.             ->findFirst(
  175.                 fn($key$detalle) => $detalle->getReloj()?->getId() === $relojBase->getId()
  176.             )
  177.         ;
  178.         $cancelRelojBase $detalleRelojBase?->getFechaCancelacion();
  179.         return (!$cancelRelojBase && !$relojBase->getFechaVenta() && !$relojBase->getFechaCompra()) ? $detalleRelojBase->getFechaVerificacion() : null;
  180.     }
  181.     public function getCosteImportacionIva(): ?float
  182.     {
  183.         return $this->costeImportacionIva;
  184.     }
  185.     public function setCosteImportacionIva(?float $costeImportacionIva): static
  186.     {
  187.         $this->costeImportacionIva $costeImportacionIva;
  188.         return $this;
  189.     }
  190.     public function getCosteImportacionOtros(): ?float
  191.     {
  192.         return $this->costeImportacionOtros;
  193.     }
  194.     public function setCosteImportacionOtros(?float $costeImportacionOtros): static
  195.     {
  196.         $this->costeImportacionOtros $costeImportacionOtros;
  197.         return $this;
  198.     }
  199. }