<?php
namespace App\Entity;
use App\Repository\ProductoRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use DateTime;
/**
* @ORM\Entity(repositoryClass=ProductoRepository::class)
* @ORM\HasLifecycleCallbacks
*/
class Producto
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=50)
*/
private $codigo;
/**
* @ORM\Column(type="string", length=255)
*/
private $nombre;
/**
* @ORM\Column(type="boolean")
*/
private $estado;
/**
* @ORM\Column(type="string", length=50)
*/
private $ip_crea;
/**
* @ORM\Column(type="string", length=50)
*/
private $ip_modifica;
/**
* @ORM\Column(type="integer")
*/
private $user_crea;
/**
* @ORM\Column(type="integer")
*/
private $user_modifica;
/**
* @ORM\Column(type="datetime")
*/
private $created_at;
/**
* @ORM\Column(type="datetime")
*/
private $updated_at;
/**
* @ORM\OneToMany(targetEntity=OrdenVentaDetalle::class, mappedBy="producto")
*/
private $ordenVentaDetalles;
/**
* @ORM\Column(type="integer")
*/
private $cantidad;
/**
* @ORM\Column(type="decimal", precision=10, scale=4)
*/
private $precio;
/**
* @ORM\Column(type="decimal", precision=10, scale=4)
*/
private $iva;
/**
* @ORM\Column(type="string", length=50, nullable=true)
*/
private $tipo;
/**
* @ORM\OneToMany(targetEntity=MovimientosProductos::class, mappedBy="producto")
*/
private $movimientosProductos;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $log;
public function __construct()
{
$this->ordenVentaDetalles = new ArrayCollection();
$this->movimientosProductos = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getCodigo(): ?string
{
return $this->codigo;
}
public function setCodigo(string $codigo): self
{
$this->codigo = $codigo;
return $this;
}
public function getNombre(): ?string
{
return $this->nombre;
}
public function setNombre(string $nombre): self
{
$this->nombre = $nombre;
return $this;
}
public function getEstado(): ?bool
{
return $this->estado;
}
public function setEstado(bool $estado): self
{
$this->estado = $estado;
return $this;
}
public function getIpCrea(): ?string
{
return $this->ip_crea;
}
public function setIpCrea(string $ip_crea): self
{
$this->ip_crea = $ip_crea;
return $this;
}
public function getIpModifica(): ?string
{
return $this->ip_modifica;
}
public function setIpModifica(string $ip_modifica): self
{
$this->ip_modifica = $ip_modifica;
return $this;
}
public function getUserCrea(): ?int
{
return $this->user_crea;
}
public function setUserCrea(int $user_crea): self
{
$this->user_crea = $user_crea;
return $this;
}
public function getUserModifica(): ?int
{
return $this->user_modifica;
}
public function setUserModifica(int $user_modifica): self
{
$this->user_modifica = $user_modifica;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->created_at;
}
public function setCreatedAt(\DateTimeInterface $created_at): self
{
$this->created_at = $created_at;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updated_at;
}
public function setUpdatedAt(\DateTimeInterface $updated_at): self
{
$this->updated_at = $updated_at;
return $this;
}
/**
* @ORM\PrePersist
* @ORM\PreUpdate
*/
public function updatedTimestamps(): void
{
$dateTimeNow = new DateTime('now');
$this->setUpdatedAt($dateTimeNow);
if ($this->getCreatedAt() === null) {
$this->setCreatedAt($dateTimeNow);
}
}
/**
* @return Collection|OrdenVentaDetalle[]
*/
public function getOrdenVentaDetalles(): Collection
{
return $this->ordenVentaDetalles;
}
public function addOrdenVentaDetalle(OrdenVentaDetalle $ordenVentaDetalle): self
{
if (!$this->ordenVentaDetalles->contains($ordenVentaDetalle)) {
$this->ordenVentaDetalles[] = $ordenVentaDetalle;
$ordenVentaDetalle->setProducto($this);
}
return $this;
}
public function removeOrdenVentaDetalle(OrdenVentaDetalle $ordenVentaDetalle): self
{
if ($this->ordenVentaDetalles->removeElement($ordenVentaDetalle)) {
// set the owning side to null (unless already changed)
if ($ordenVentaDetalle->getProducto() === $this) {
$ordenVentaDetalle->setProducto(null);
}
}
return $this;
}
public function getCantidad(): ?int
{
return $this->cantidad;
}
public function setCantidad(int $cantidad): self
{
$this->cantidad = $cantidad;
return $this;
}
public function getPrecio(): ?string
{
return $this->precio;
}
public function setPrecio(string $precio): self
{
$this->precio = $precio;
return $this;
}
public function getIva(): ?string
{
return $this->iva;
}
public function setIva(string $iva): self
{
$this->iva = $iva;
return $this;
}
public function getTipo(): ?string
{
return $this->tipo;
}
public function setTipo(?string $tipo): self
{
$this->tipo = $tipo;
return $this;
}
/**
* @return Collection|MovimientosProductos[]
*/
public function getMovimientosProductos(): Collection
{
return $this->movimientosProductos;
}
public function addMovimientosProducto(MovimientosProductos $movimientosProducto): self
{
if (!$this->movimientosProductos->contains($movimientosProducto)) {
$this->movimientosProductos[] = $movimientosProducto;
$movimientosProducto->setProducto($this);
}
return $this;
}
public function removeMovimientosProducto(MovimientosProductos $movimientosProducto): self
{
if ($this->movimientosProductos->removeElement($movimientosProducto)) {
// set the owning side to null (unless already changed)
if ($movimientosProducto->getProducto() === $this) {
$movimientosProducto->setProducto(null);
}
}
return $this;
}
public function getTotalSum()
{
$total = 0;
foreach ($this->getMovimientosProductos() AS $item) {
$total += $item->getCantidad();
}
return $total;
}
public function getLog(): ?string
{
return $this->log;
}
public function setLog(?string $log): self
{
$this->log = $log;
return $this;
}
}