src/Entity/Producto.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ProductoRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use DateTime;
  8. /**
  9.  * @ORM\Entity(repositoryClass=ProductoRepository::class)
  10.  * @ORM\HasLifecycleCallbacks
  11.  */
  12. class Producto
  13. {
  14.     /**
  15.      * @ORM\Id
  16.      * @ORM\GeneratedValue
  17.      * @ORM\Column(type="integer")
  18.      */
  19.     private $id;
  20.     /**
  21.      * @ORM\Column(type="string", length=50)
  22.      */
  23.     private $codigo;
  24.     /**
  25.      * @ORM\Column(type="string", length=255)
  26.      */
  27.     private $nombre;
  28.     /**
  29.      * @ORM\Column(type="boolean")
  30.      */
  31.     private $estado;
  32.     /**
  33.      * @ORM\Column(type="string", length=50)
  34.      */
  35.     private $ip_crea;
  36.     /**
  37.      * @ORM\Column(type="string", length=50)
  38.      */
  39.     private $ip_modifica;
  40.     /**
  41.      * @ORM\Column(type="integer")
  42.      */
  43.     private $user_crea;
  44.     /**
  45.      * @ORM\Column(type="integer")
  46.      */
  47.     private $user_modifica;
  48.     /**
  49.      * @ORM\Column(type="datetime")
  50.      */
  51.     private $created_at;
  52.     /**
  53.      * @ORM\Column(type="datetime")
  54.      */
  55.     private $updated_at;
  56.     /**
  57.      * @ORM\OneToMany(targetEntity=OrdenVentaDetalle::class, mappedBy="producto")
  58.      */
  59.     private $ordenVentaDetalles;
  60.     /**
  61.      * @ORM\Column(type="integer")
  62.      */
  63.     private $cantidad;
  64.     /**
  65.      * @ORM\Column(type="decimal", precision=10, scale=4)
  66.      */
  67.     private $precio;
  68.     /**
  69.      * @ORM\Column(type="decimal", precision=10, scale=4)
  70.      */
  71.     private $iva;
  72.     /**
  73.      * @ORM\Column(type="string", length=50, nullable=true)
  74.      */
  75.     private $tipo;
  76.     /**
  77.      * @ORM\OneToMany(targetEntity=MovimientosProductos::class, mappedBy="producto")
  78.      */
  79.     private $movimientosProductos;
  80.     /**
  81.      * @ORM\Column(type="string", length=255, nullable=true)
  82.      */
  83.     private $log;
  84.     public function __construct()
  85.     {
  86.         $this->ordenVentaDetalles = new ArrayCollection();
  87.         $this->movimientosProductos = new ArrayCollection();
  88.     }
  89.     public function getId(): ?int
  90.     {
  91.         return $this->id;
  92.     }
  93.     public function getCodigo(): ?string
  94.     {
  95.         return $this->codigo;
  96.     }
  97.     public function setCodigo(string $codigo): self
  98.     {
  99.         $this->codigo $codigo;
  100.         return $this;
  101.     }
  102.     public function getNombre(): ?string
  103.     {
  104.         return $this->nombre;
  105.     }
  106.     public function setNombre(string $nombre): self
  107.     {
  108.         $this->nombre $nombre;
  109.         return $this;
  110.     }
  111.     public function getEstado(): ?bool
  112.     {
  113.         return $this->estado;
  114.     }
  115.     public function setEstado(bool $estado): self
  116.     {
  117.         $this->estado $estado;
  118.         return $this;
  119.     }
  120.     public function getIpCrea(): ?string
  121.     {
  122.         return $this->ip_crea;
  123.     }
  124.     public function setIpCrea(string $ip_crea): self
  125.     {
  126.         $this->ip_crea $ip_crea;
  127.         return $this;
  128.     }
  129.     public function getIpModifica(): ?string
  130.     {
  131.         return $this->ip_modifica;
  132.     }
  133.     public function setIpModifica(string $ip_modifica): self
  134.     {
  135.         $this->ip_modifica $ip_modifica;
  136.         return $this;
  137.     }
  138.     public function getUserCrea(): ?int
  139.     {
  140.         return $this->user_crea;
  141.     }
  142.     public function setUserCrea(int $user_crea): self
  143.     {
  144.         $this->user_crea $user_crea;
  145.         return $this;
  146.     }
  147.     public function getUserModifica(): ?int
  148.     {
  149.         return $this->user_modifica;
  150.     }
  151.     public function setUserModifica(int $user_modifica): self
  152.     {
  153.         $this->user_modifica $user_modifica;
  154.         return $this;
  155.     }
  156.     public function getCreatedAt(): ?\DateTimeInterface
  157.     {
  158.         return $this->created_at;
  159.     }
  160.     public function setCreatedAt(\DateTimeInterface $created_at): self
  161.     {
  162.         $this->created_at $created_at;
  163.         return $this;
  164.     }
  165.     public function getUpdatedAt(): ?\DateTimeInterface
  166.     {
  167.         return $this->updated_at;
  168.     }
  169.     public function setUpdatedAt(\DateTimeInterface $updated_at): self
  170.     {
  171.         $this->updated_at $updated_at;
  172.         return $this;
  173.     }
  174.     /**
  175.      * @ORM\PrePersist
  176.      * @ORM\PreUpdate
  177.      */
  178.     public function updatedTimestamps(): void
  179.     {
  180.         $dateTimeNow = new DateTime('now');
  181.         $this->setUpdatedAt($dateTimeNow);
  182.         if ($this->getCreatedAt() === null) {
  183.             $this->setCreatedAt($dateTimeNow);
  184.         }
  185.     }
  186.     /**
  187.      * @return Collection|OrdenVentaDetalle[]
  188.      */
  189.     public function getOrdenVentaDetalles(): Collection
  190.     {
  191.         return $this->ordenVentaDetalles;
  192.     }
  193.     public function addOrdenVentaDetalle(OrdenVentaDetalle $ordenVentaDetalle): self
  194.     {
  195.         if (!$this->ordenVentaDetalles->contains($ordenVentaDetalle)) {
  196.             $this->ordenVentaDetalles[] = $ordenVentaDetalle;
  197.             $ordenVentaDetalle->setProducto($this);
  198.         }
  199.         return $this;
  200.     }
  201.     public function removeOrdenVentaDetalle(OrdenVentaDetalle $ordenVentaDetalle): self
  202.     {
  203.         if ($this->ordenVentaDetalles->removeElement($ordenVentaDetalle)) {
  204.             // set the owning side to null (unless already changed)
  205.             if ($ordenVentaDetalle->getProducto() === $this) {
  206.                 $ordenVentaDetalle->setProducto(null);
  207.             }
  208.         }
  209.         return $this;
  210.     }
  211.     public function getCantidad(): ?int
  212.     {
  213.         return $this->cantidad;
  214.     }
  215.     public function setCantidad(int $cantidad): self
  216.     {
  217.         $this->cantidad $cantidad;
  218.         return $this;
  219.     }
  220.     public function getPrecio(): ?string
  221.     {
  222.         return $this->precio;
  223.     }
  224.     public function setPrecio(string $precio): self
  225.     {
  226.         $this->precio $precio;
  227.         return $this;
  228.     }
  229.     public function getIva(): ?string
  230.     {
  231.         return $this->iva;
  232.     }
  233.     public function setIva(string $iva): self
  234.     {
  235.         $this->iva $iva;
  236.         return $this;
  237.     }
  238.     public function getTipo(): ?string
  239.     {
  240.         return $this->tipo;
  241.     }
  242.     public function setTipo(?string $tipo): self
  243.     {
  244.         $this->tipo $tipo;
  245.         return $this;
  246.     }
  247.     /**
  248.      * @return Collection|MovimientosProductos[]
  249.      */
  250.     public function getMovimientosProductos(): Collection
  251.     {
  252.         return $this->movimientosProductos;
  253.     }
  254.     public function addMovimientosProducto(MovimientosProductos $movimientosProducto): self
  255.     {
  256.         if (!$this->movimientosProductos->contains($movimientosProducto)) {
  257.             $this->movimientosProductos[] = $movimientosProducto;
  258.             $movimientosProducto->setProducto($this);
  259.         }
  260.         return $this;
  261.     }
  262.     public function removeMovimientosProducto(MovimientosProductos $movimientosProducto): self
  263.     {
  264.         if ($this->movimientosProductos->removeElement($movimientosProducto)) {
  265.             // set the owning side to null (unless already changed)
  266.             if ($movimientosProducto->getProducto() === $this) {
  267.                 $movimientosProducto->setProducto(null);
  268.             }
  269.         }
  270.         return $this;
  271.     }
  272.     public function getTotalSum()
  273.     {
  274.         $total 0;
  275.         foreach ($this->getMovimientosProductos() AS $item) {
  276.             $total += $item->getCantidad();
  277.         }
  278.         return $total;
  279.     }
  280.     public function getLog(): ?string
  281.     {
  282.         return $this->log;
  283.     }
  284.     public function setLog(?string $log): self
  285.     {
  286.         $this->log $log;
  287.         return $this;
  288.     }
  289.     
  290. }