<?php
namespace App\Entity;
use App\Repository\PriceProductRepository;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=PriceProductRepository::class)
*/
class PriceProduct
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=Product::class, inversedBy="priceProducts")
* @ORM\JoinColumn(nullable=false)
*/
private $product;
/**
* @ORM\Column(type="decimal", precision=10, scale=2)
*/
private $priceDealer;
/**
* @ORM\Column(type="decimal", precision=8, scale=2)
*/
private $nbrDealerProd;
/**
* @ORM\Column(type="decimal", precision=10, scale=2)
*/
private $priceCustomer;
/**
* @ORM\Column(type="decimal", precision=10, scale=2)
*/
private $supplierPrice = 0.00;
/**
* @ORM\Column(type="decimal", precision=10, scale=2)
*/
private $priceBulkCustomer;
//Begin promo
/**
* @ORM\Column(type="decimal", precision=10, scale=2, nullable=true)
*/
private $promoPriceDealer;
/**
* @ORM\Column(type="decimal", precision=10, scale=2, nullable=true)
*/
private $promoPriceCustomer;
/**
* @ORM\Column(type="decimal", precision=10, scale=2, nullable=true)
*/
private $promoPriceBulkCustomer;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $promoStartAt;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $promoEndAt;
/**
* @ORM\Column(type="boolean")
*/
private $isPromoActive = false;
//End promo
/**
* @ORM\Column(type="decimal", precision=8, scale=2)
*/
private $nbrBulkProd;
/**
* @ORM\Column(type="decimal", precision=6, scale=2)
*/
private $taxeProduct;
public function getId(): ?int
{
return $this->id;
}
public function getProduct(): ?Product
{
return $this->product;
}
public function setProduct(?Product $product): self
{
$this->product = $product;
return $this;
}
public function getPriceDealer(): ?string
{
return $this->priceDealer;
}
public function setPriceDealer(string $priceDealer): self
{
$this->priceDealer = $priceDealer;
return $this;
}
public function getNbrDealerProd(): ?string
{
return $this->nbrDealerProd;
}
public function setNbrDealerProd(string $nbrDealerProd): self
{
$this->nbrDealerProd = $nbrDealerProd;
return $this;
}
public function getPriceCustomer(): ?string
{
return $this->priceCustomer;
}
public function setPriceCustomer(string $priceCustomer): self
{
$this->priceCustomer = $priceCustomer;
return $this;
}
public function getSupplierPrice(): ?string
{
return $this->supplierPrice;
}
public function setSupplierPrice($supplierPrice): self
{
$this->supplierPrice = $supplierPrice;
return $this;
}
public function getPriceBulkCustomer(): ?string
{
return $this->priceBulkCustomer;
}
public function setPriceBulkCustomer(string $priceBulkCustomer): self
{
$this->priceBulkCustomer = $priceBulkCustomer;
return $this;
}
public function getNbrBulkProd(): ?string
{
return $this->nbrBulkProd;
}
public function setNbrBulkProd(string $nbrBulkProd): self
{
$this->nbrBulkProd = $nbrBulkProd;
return $this;
}
public function getTaxeProduct(): ?string
{
return $this->taxeProduct;
}
public function setTaxeProduct(string $taxeProduct): self
{
$this->taxeProduct = $taxeProduct;
return $this;
}
//Promo
public function isPromotionValid(): bool
{
if (!$this->isPromoActive) {
return false;
}
$now = new \DateTime();
if ($this->promoStartAt && $now < $this->promoStartAt) {
return false;
}
if ($this->promoEndAt && $now > $this->promoEndAt) {
return false;
}
return true;
}
public function getPromoStartAt(): ?\DateTimeInterface
{
return $this->promoStartAt;
}
public function setPromoStartAt(?\DateTimeInterface $promoStartAt): self
{
$this->promoStartAt = $promoStartAt;
return $this;
}
public function getPromoEndAt(): ?\DateTimeInterface
{
return $this->promoEndAt;
}
public function setPromoEndAt(?\DateTimeInterface $promoEndAt): self
{
$this->promoEndAt = $promoEndAt;
return $this;
}
public function isPromoActive(): bool
{
return $this->isPromoActive;
}
public function setIsPromoActive(bool $isPromoActive): self
{
$this->isPromoActive = $isPromoActive;
return $this;
}
public function getPromoPriceDealer(): ?string
{
return $this->promoPriceDealer;
}
public function setPromoPriceDealer(?string $promoPriceDealer): self
{
$this->promoPriceDealer = $promoPriceDealer;
return $this;
}
public function getPromoPriceCustomer(): ?string
{
return $this->promoPriceCustomer;
}
public function setPromoPriceCustomer(?string $promoPriceCustomer): self
{
$this->promoPriceCustomer = $promoPriceCustomer;
return $this;
}
public function getPromoPriceBulkCustomer(): ?string
{
return $this->promoPriceBulkCustomer;
}
public function setPromoPriceBulkCustomer(?string $promoPriceBulkCustomer): self
{
$this->promoPriceBulkCustomer = $promoPriceBulkCustomer;
return $this;
}
}