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.      */
  151.     protected $createdAt;
  152.     /**
  153.      * @ORM\OneToOne(targetEntity=\App\Entity\ActividadAbstract::class, mappedBy="detalleOperacion")
  154.      */
  155.     private $actividad;
  156.     /**
  157.      * @ORM\ManyToOne(targetEntity="App\Entity\EstadoAspecto", inversedBy="detalleCompras")
  158.      * @ORM\JoinColumn(name="reloj_aspecto_id", referencedColumnName="id")
  159.      * @JMS\Type(EstadoAspecto::class)
  160.      * @JMS\Groups({
  161.      *      "api_v1_operacion_show_serialize"
  162.      *  })
  163.      */
  164.     protected $relojAspecto;
  165.     /**
  166.      * @ORM\ManyToOne(targetEntity="App\Entity\Marca", inversedBy="detalleCompras")
  167.      * @ORM\JoinColumn(name="reloj_marca_id", referencedColumnName="id")
  168.      * @JMS\Type(Marca::class)
  169.      * @JMS\Groups({
  170.      *       "api_v1_operacion_show_serialize"
  171.      *   })
  172.      */
  173.     protected $relojMarca;
  174.     protected $relojFechaStr;
  175.     public function __construct()
  176.     {
  177.         $this->relojCaja false;
  178.         $this->relojPapeles false;
  179.     }
  180.     public function getId(): ?int
  181.     {
  182.         return $this->id;
  183.     }
  184.     public function getPrecioCoste(): ?float
  185.     {
  186.         return $this->precioCoste;
  187.     }
  188.     public function setPrecioCoste(?float $precioCoste): self
  189.     {
  190.         $this->precioCoste $precioCoste;
  191.         return $this;
  192.     }
  193.     public function getRelojFoto(): ?string
  194.     {
  195.         return $this->relojFoto;
  196.     }
  197.     public function setRelojFoto(?string $relojFoto): self
  198.     {
  199.         $this->relojFoto $relojFoto;
  200.         return $this;
  201.     }
  202.     public function getRelojFotoFile(): ?File
  203.     {
  204.         return $this->relojFotoFile;
  205.     }
  206.     public function setRelojFotoFile(?File $relojFotoFile): self
  207.     {
  208.         $this->relojFotoFile $relojFotoFile;
  209.         if ($relojFotoFile) {
  210.             // if 'updatedAt' is not defined in your entity, use another property
  211.             $this->setUpdatedAt(new DateTime('now'));
  212.         }
  213.         return $this;
  214.     }
  215.     public function getRelojModelo1(): ?string
  216.     {
  217.         return $this->relojModelo1;
  218.     }
  219.     public function setRelojModelo1(?string $relojModelo1): self
  220.     {
  221.         $this->relojModelo1 $relojModelo1;
  222.         return $this;
  223.     }
  224.     public function getRelojRef1(): ?string
  225.     {
  226.         return $this->relojRef1;
  227.     }
  228.     public function setRelojRef1(?string $relojRef1): self
  229.     {
  230.         $this->relojRef1 $relojRef1;
  231.         return $this;
  232.     }
  233.     public function getRelojSerie(): ?string
  234.     {
  235.         return $this->relojSerie;
  236.     }
  237.     public function setRelojSerie(?string $relojSerie): self
  238.     {
  239.         $this->relojSerie $relojSerie;
  240.         return $this;
  241.     }
  242.     public function getRelojFecha(): ?\DateTimeInterface
  243.     {
  244.         return $this->relojFecha;
  245.     }
  246.     public function setRelojFecha(?\DateTimeInterface $relojFecha): self
  247.     {
  248.         $this->relojFecha $relojFecha;
  249.         return $this;
  250.     }
  251.     public function isRelojCaja(): ?bool
  252.     {
  253.         return $this->relojCaja;
  254.     }
  255.     public function setRelojCaja(bool $relojCaja): self
  256.     {
  257.         $this->relojCaja $relojCaja;
  258.         return $this;
  259.     }
  260.     public function isRelojPapeles(): ?bool
  261.     {
  262.         return $this->relojPapeles;
  263.     }
  264.     public function setRelojPapeles(bool $relojPapeles): self
  265.     {
  266.         $this->relojPapeles $relojPapeles;
  267.         return $this;
  268.     }
  269.     public function getDeletedAt(): ?\DateTimeInterface
  270.     {
  271.         return $this->deletedAt;
  272.     }
  273.     public function setDeletedAt(?\DateTimeInterface $deletedAt): self
  274.     {
  275.         $this->deletedAt $deletedAt;
  276.         return $this;
  277.     }
  278.     public function getUpdatedAt(): ?\DateTimeInterface
  279.     {
  280.         return $this->updatedAt;
  281.     }
  282.     public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  283.     {
  284.         $this->updatedAt $updatedAt;
  285.         return $this;
  286.     }
  287.     public function getCreatedAt(): ?\DateTimeInterface
  288.     {
  289.         return $this->createdAt;
  290.     }
  291.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  292.     {
  293.         $this->createdAt $createdAt;
  294.         return $this;
  295.     }
  296.     public function getRelojMarca(): ?Marca
  297.     {
  298.         return $this->relojMarca;
  299.     }
  300.     public function setRelojMarca(?Marca $relojMarca): self
  301.     {
  302.         $this->relojMarca $relojMarca;
  303.         return $this;
  304.     }
  305.     public function getRelojAspecto(): ?EstadoAspecto
  306.     {
  307.         return $this->relojAspecto;
  308.     }
  309.     public function setRelojAspecto(?EstadoAspecto $relojAspecto): self
  310.     {
  311.         $this->relojAspecto $relojAspecto;
  312.         return $this;
  313.     }
  314.     public function getRelojModelo2(): ?string
  315.     {
  316.         return $this->relojModelo2;
  317.     }
  318.     public function setRelojModelo2(?string $relojModelo2): self
  319.     {
  320.         $this->relojModelo2 $relojModelo2;
  321.         return $this;
  322.     }
  323.     public function getRelojRef2(): ?string
  324.     {
  325.         return $this->relojRef2;
  326.     }
  327.     public function setRelojRef2(?string $relojRef2): self
  328.     {
  329.         $this->relojRef2 $relojRef2;
  330.         return $this;
  331.     }
  332.     public function getRelojRegimen(): ?string
  333.     {
  334.         return $this->relojRegimen;
  335.     }
  336.     public function setRelojRegimen(?string $relojRegimen): self
  337.     {
  338.         $this->relojRegimen $relojRegimen;
  339.         return $this;
  340.     }
  341.     public function getComentario(): ?string
  342.     {
  343.         return $this->comentario;
  344.     }
  345.     public function setComentario(?string $comentario): self
  346.     {
  347.         $this->comentario $comentario;
  348.         return $this;
  349.     }
  350.     public function getPrecioPromocion(): ?float
  351.     {
  352.         return $this->precioPromocion;
  353.     }
  354.     public function setPrecioPromocion(?float $precioPromocion): static
  355.     {
  356.         $this->precioPromocion $precioPromocion;
  357.         return $this;
  358.     }
  359.     public function getActividad(): ?ActividadAbstract
  360.     {
  361.         return $this->actividad;
  362.     }
  363.     public function setActividad(?ActividadAbstract $actividad): static
  364.     {
  365.         // unset the owning side of the relation if necessary
  366.         if ($actividad === null && $this->actividad !== null) {
  367.             $this->actividad->setDetalleOperacion(null);
  368.         }
  369.         // set the owning side of the relation if necessary
  370.         if ($actividad !== null && $actividad->getDetalleOperacion() !== $this) {
  371.             $actividad->setDetalleOperacion($this);
  372.         }
  373.         $this->actividad $actividad;
  374.         return $this;
  375.     }
  376.     public function getType(): ?string
  377.     {
  378.         $type null;
  379.         if($this instanceof DetalleCompra$type TipoOperacionEnum::OPERACION_COMPRA;
  380.         if($this instanceof DetalleVenta$type TipoOperacionEnum::OPERACION_VENTA;
  381.         return $type;
  382.     }
  383.     public function getOperacion(): ?Operacion
  384.     {
  385.         $operacion null;
  386.         if($this instanceof DetalleCompra$operacion $this->getCompra()->getOperacion();
  387.         if($this instanceof DetalleVenta$operacion $this->getVenta()->getOperacion();
  388.         return $operacion;
  389.     }
  390.     public function getRelojFechaStr(): ?string
  391.     {
  392.         return $this->relojFecha?->format("d/m/Y");
  393.     }
  394. }