src/Entity/DetalleOperacion.php line 26

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Enum\TipoOperacionEnum;
  4. use DateTime;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use JMS\Serializer\Annotation as JMS;
  7. use Gedmo\Mapping\Annotation as Gedmo;
  8. use Symfony\Component\HttpFoundation\File\File;
  9. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  10. /**
  11.  * @ORM\Entity(repositoryClass="App\Repository\DetalleOperacionRepository")
  12.  * @ORM\Table(name="detalle_operacion")
  13.  * @ORM\InheritanceType("SINGLE_TABLE")
  14.  * @ORM\DiscriminatorColumn(name="type", type="string")
  15.  * @ORM\DiscriminatorMap({
  16.  *     "operacion":"App\Entity\DetalleOperacion",
  17.  *     "compra":"App\Entity\DetalleCompra",
  18.  *     "venta":"App\Entity\DetalleVenta"
  19.  * })
  20.  * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=true)
  21.  * @Vich\Uploadable
  22.  */
  23. class DetalleOperacion
  24. {
  25.     /**
  26.      * @ORM\Id
  27.      * @ORM\Column(type="bigint")
  28.      * @ORM\GeneratedValue(strategy="AUTO")
  29.      */
  30.     protected $id;
  31.     /**
  32.      * @ORM\Column(type="float", nullable=true, name="precio_coste", options={"default":"0.0","unsigned":true})
  33.      * @JMS\Groups({
  34.      *       "api_v1_operacion_show_serialize"
  35.      *  })
  36.      */
  37.     protected $precioCoste;
  38.     /**
  39.      * @ORM\Column(type="float", nullable=true, precision=2, name="precio_promocion", options={"default":"0.00","unsigned":true})
  40.      * @JMS\Groups({
  41.      *        "api_v1_operacion_show_serialize"
  42.      *   })
  43.      */
  44.     protected $precioPromocion;
  45.     /**
  46.      * @ORM\Column(type="string", nullable=true, name="reloj_foto")
  47.      * @JMS\Groups({
  48.      *     "api_v1_operacion_show_serialize"
  49.      * })
  50.      */
  51.     protected $relojFoto;
  52.     /**
  53.      * @Vich\UploadableField(mapping="reloj", fileNameProperty="relojFoto")
  54.      * @var File
  55.      */
  56.     protected $relojFotoFile;
  57.     /**
  58.      * @ORM\Column(type="string", nullable=true, name="reloj_modelo1")
  59.      * @JMS\Groups({
  60.      *      "api_v1_operacion_show_serialize"
  61.      *  })
  62.      */
  63.     protected $relojModelo1;
  64.     /**
  65.      * @ORM\Column(type="string", nullable=true)
  66.      * @JMS\Groups({
  67.      *      "api_v1_operacion_show_serialize"
  68.      *  })
  69.      */
  70.     private $relojModelo2;
  71.     /**
  72.      * @ORM\Column(type="string", nullable=true, name="reloj_ref1")
  73.      * @JMS\Groups({
  74.      *      "api_v1_operacion_show_serialize"
  75.      *  })
  76.      */
  77.     protected $relojRef1;
  78.     /**
  79.      * @ORM\Column(type="string", nullable=true)
  80.      * @JMS\Groups({
  81.      *      "api_v1_operacion_show_serialize"
  82.      *  })
  83.      */
  84.     private $relojRef2;
  85.     /**
  86.      * @ORM\Column(type="string", nullable=true, name="reloj_serie")
  87.      * @JMS\Groups({
  88.      *      "api_v1_operacion_show_serialize"
  89.      *  })
  90.      */
  91.     protected $relojSerie;
  92.     /**
  93.      * @ORM\Column(
  94.      *     type="datetime",
  95.      *     nullable=true,
  96.      *     name="reloj_fecha",
  97.      *     options={"comment":"Fecha comprado por primera vez"}
  98.      * )
  99.      * @JMS\Groups({
  100.      *      "api_v1_operacion_show_serialize"
  101.      *  })
  102.      */
  103.     protected $relojFecha;
  104.     /**
  105.      * @ORM\Column(type="boolean", nullable=false, name="reloj_caja", options={"default":0})
  106.      * @JMS\Groups({
  107.      *      "api_v1_operacion_show_serialize"
  108.      *  })
  109.      */
  110.     protected $relojCaja;
  111.     /**
  112.      * @ORM\Column(type="boolean", nullable=false, name="reloj_papeles", options={"default":0})
  113.      * @JMS\Groups({
  114.      *      "api_v1_operacion_show_serialize"
  115.      *  })
  116.      */
  117.     protected $relojPapeles;
  118.     /**
  119.      * @ORM\Column(
  120.      *     type="string",
  121.      *     length=4,
  122.      *     nullable=true,
  123.      *     name="reloj_regimen",
  124.      *     options={"comment":"Valores a tomar REBU รณ IVA, por defecto REBU"}
  125.      * )
  126.      * @JMS\Groups({
  127.      *      "api_v1_operacion_show_serialize"
  128.      *  })
  129.      */
  130.     protected $relojRegimen;
  131.     /**
  132.      * @ORM\Column(type="text", nullable=true)
  133.      * @JMS\Groups({
  134.      *      "api_v1_operacion_show_serialize"
  135.      *  })
  136.      */
  137.     private $comentario;
  138.     /**
  139.      * @ORM\Column(type="datetime", nullable=true, name="deleted_at")
  140.      */
  141.     protected $deletedAt;
  142.     /**
  143.      * @ORM\Column(type="datetime", nullable=false, name="updated_at", options={"default":"2022-01-01 00:00:00"})
  144.      * @Gedmo\Timestampable(on="update")
  145.      */
  146.     protected $updatedAt;
  147.     /**
  148.      * @ORM\Column(type="datetime", nullable=false, name="created_at", options={"default":"2022-01-01 00:00:00"})
  149.      * @Gedmo\Timestampable(on="create")
  150.      * @JMS\Groups({
  151.      *       "api_v1_operacion_show_serialize"
  152.      *   })
  153.      */
  154.     protected $createdAt;
  155.     /**
  156.      * @ORM\OneToOne(targetEntity=\App\Entity\ActividadAbstract::class, mappedBy="detalleOperacion")
  157.      */
  158.     private $actividad;
  159.     /**
  160.      * @ORM\ManyToOne(targetEntity="App\Entity\EstadoAspecto", inversedBy="detalleCompras")
  161.      * @ORM\JoinColumn(name="reloj_aspecto_id", referencedColumnName="id")
  162.      * @JMS\Type(EstadoAspecto::class)
  163.      * @JMS\Groups({
  164.      *      "api_v1_operacion_show_serialize"
  165.      *  })
  166.      */
  167.     protected $relojAspecto;
  168.     /**
  169.      * @ORM\ManyToOne(targetEntity="App\Entity\Marca", inversedBy="detalleCompras")
  170.      * @ORM\JoinColumn(name="reloj_marca_id", referencedColumnName="id")
  171.      * @JMS\Type(Marca::class)
  172.      * @JMS\Groups({
  173.      *       "api_v1_operacion_show_serialize"
  174.      *   })
  175.      */
  176.     protected $relojMarca;
  177.     protected $relojFechaStr;
  178.     public function __construct()
  179.     {
  180.         $this->relojCaja false;
  181.         $this->relojPapeles false;
  182.     }
  183.     public function getId(): ?int
  184.     {
  185.         return $this->id;
  186.     }
  187.     public function getPrecioCoste(): ?float
  188.     {
  189.         return $this->precioCoste;
  190.     }
  191.     public function setPrecioCoste(?float $precioCoste): self
  192.     {
  193.         $this->precioCoste $precioCoste;
  194.         return $this;
  195.     }
  196.     public function getRelojFoto(): ?string
  197.     {
  198.         return $this->relojFoto;
  199.     }
  200.     public function setRelojFoto(?string $relojFoto): self
  201.     {
  202.         $this->relojFoto $relojFoto;
  203.         return $this;
  204.     }
  205.     public function getRelojFotoFile(): ?File
  206.     {
  207.         return $this->relojFotoFile;
  208.     }
  209.     public function setRelojFotoFile(?File $relojFotoFile): self
  210.     {
  211.         $this->relojFotoFile $relojFotoFile;
  212.         if ($relojFotoFile) {
  213.             // if 'updatedAt' is not defined in your entity, use another property
  214.             $this->setUpdatedAt(new DateTime('now'));
  215.         }
  216.         return $this;
  217.     }
  218.     public function getRelojModelo1(): ?string
  219.     {
  220.         return $this->relojModelo1;
  221.     }
  222.     public function setRelojModelo1(?string $relojModelo1): self
  223.     {
  224.         $this->relojModelo1 $relojModelo1;
  225.         return $this;
  226.     }
  227.     public function getRelojRef1(): ?string
  228.     {
  229.         return $this->relojRef1;
  230.     }
  231.     public function setRelojRef1(?string $relojRef1): self
  232.     {
  233.         $this->relojRef1 $relojRef1;
  234.         return $this;
  235.     }
  236.     public function getRelojSerie(): ?string
  237.     {
  238.         return $this->relojSerie;
  239.     }
  240.     public function setRelojSerie(?string $relojSerie): self
  241.     {
  242.         $this->relojSerie $relojSerie;
  243.         return $this;
  244.     }
  245.     public function getRelojFecha(): ?\DateTimeInterface
  246.     {
  247.         return $this->relojFecha;
  248.     }
  249.     public function setRelojFecha(?\DateTimeInterface $relojFecha): self
  250.     {
  251.         $this->relojFecha $relojFecha;
  252.         return $this;
  253.     }
  254.     public function isRelojCaja(): ?bool
  255.     {
  256.         return $this->relojCaja;
  257.     }
  258.     public function setRelojCaja(bool $relojCaja): self
  259.     {
  260.         $this->relojCaja $relojCaja;
  261.         return $this;
  262.     }
  263.     public function isRelojPapeles(): ?bool
  264.     {
  265.         return $this->relojPapeles;
  266.     }
  267.     public function setRelojPapeles(bool $relojPapeles): self
  268.     {
  269.         $this->relojPapeles $relojPapeles;
  270.         return $this;
  271.     }
  272.     public function getDeletedAt(): ?\DateTimeInterface
  273.     {
  274.         return $this->deletedAt;
  275.     }
  276.     public function setDeletedAt(?\DateTimeInterface $deletedAt): self
  277.     {
  278.         $this->deletedAt $deletedAt;
  279.         return $this;
  280.     }
  281.     public function getUpdatedAt(): ?\DateTimeInterface
  282.     {
  283.         return $this->updatedAt;
  284.     }
  285.     public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  286.     {
  287.         $this->updatedAt $updatedAt;
  288.         return $this;
  289.     }
  290.     public function getCreatedAt(): ?\DateTimeInterface
  291.     {
  292.         return $this->createdAt;
  293.     }
  294.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  295.     {
  296.         $this->createdAt $createdAt;
  297.         return $this;
  298.     }
  299.     public function getRelojMarca(): ?Marca
  300.     {
  301.         return $this->relojMarca;
  302.     }
  303.     public function setRelojMarca(?Marca $relojMarca): self
  304.     {
  305.         $this->relojMarca $relojMarca;
  306.         return $this;
  307.     }
  308.     public function getRelojAspecto(): ?EstadoAspecto
  309.     {
  310.         return $this->relojAspecto;
  311.     }
  312.     public function setRelojAspecto(?EstadoAspecto $relojAspecto): self
  313.     {
  314.         $this->relojAspecto $relojAspecto;
  315.         return $this;
  316.     }
  317.     public function getRelojModelo2(): ?string
  318.     {
  319.         return $this->relojModelo2;
  320.     }
  321.     public function setRelojModelo2(?string $relojModelo2): self
  322.     {
  323.         $this->relojModelo2 $relojModelo2;
  324.         return $this;
  325.     }
  326.     public function getRelojRef2(): ?string
  327.     {
  328.         return $this->relojRef2;
  329.     }
  330.     public function setRelojRef2(?string $relojRef2): self
  331.     {
  332.         $this->relojRef2 $relojRef2;
  333.         return $this;
  334.     }
  335.     public function getRelojRegimen(): ?string
  336.     {
  337.         return $this->relojRegimen;
  338.     }
  339.     public function setRelojRegimen(?string $relojRegimen): self
  340.     {
  341.         $this->relojRegimen $relojRegimen;
  342.         return $this;
  343.     }
  344.     public function getComentario(): ?string
  345.     {
  346.         return $this->comentario;
  347.     }
  348.     public function setComentario(?string $comentario): self
  349.     {
  350.         $this->comentario $comentario;
  351.         return $this;
  352.     }
  353.     public function getPrecioPromocion(): ?float
  354.     {
  355.         return $this->precioPromocion;
  356.     }
  357.     public function setPrecioPromocion(?float $precioPromocion): static
  358.     {
  359.         $this->precioPromocion $precioPromocion;
  360.         return $this;
  361.     }
  362.     public function getActividad(): ?ActividadAbstract
  363.     {
  364.         return $this->actividad;
  365.     }
  366.     public function setActividad(?ActividadAbstract $actividad): static
  367.     {
  368.         // unset the owning side of the relation if necessary
  369.         if ($actividad === null && $this->actividad !== null) {
  370.             $this->actividad->setDetalleOperacion(null);
  371.         }
  372.         // set the owning side of the relation if necessary
  373.         if ($actividad !== null && $actividad->getDetalleOperacion() !== $this) {
  374.             $actividad->setDetalleOperacion($this);
  375.         }
  376.         $this->actividad $actividad;
  377.         return $this;
  378.     }
  379.     public function getType(): ?string
  380.     {
  381.         $type null;
  382.         if($this instanceof DetalleCompra$type TipoOperacionEnum::OPERACION_COMPRA;
  383.         if($this instanceof DetalleVenta$type TipoOperacionEnum::OPERACION_VENTA;
  384.         return $type;
  385.     }
  386.     public function getOperacion(): ?Operacion
  387.     {
  388.         $operacion null;
  389.         if($this instanceof DetalleCompra$operacion $this->getCompra()->getOperacion();
  390.         if($this instanceof DetalleVenta$operacion $this->getVenta()->getOperacion();
  391.         return $operacion;
  392.     }
  393.     public function getRelojFechaStr(): ?string
  394.     {
  395.         return $this->relojFecha?->format("d/m/Y");
  396.     }
  397. }