src/Entity/PriceProduct.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PriceProductRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. /**
  6.  * @ORM\Entity(repositoryClass=PriceProductRepository::class)
  7.  */
  8. class PriceProduct
  9. {
  10.     /**
  11.      * @ORM\Id
  12.      * @ORM\GeneratedValue
  13.      * @ORM\Column(type="integer")
  14.      */
  15.     private $id;
  16.     /**
  17.      * @ORM\ManyToOne(targetEntity=Product::class, inversedBy="priceProducts")
  18.      * @ORM\JoinColumn(nullable=false)
  19.      */
  20.     private $product;
  21.     /**
  22.      * @ORM\Column(type="decimal", precision=10, scale=2)
  23.      */
  24.     private $priceDealer;
  25.     /**
  26.      * @ORM\Column(type="decimal", precision=8, scale=2)
  27.      */
  28.     private $nbrDealerProd;
  29.     /**
  30.      * @ORM\Column(type="decimal", precision=10, scale=2)
  31.      */
  32.     private $priceCustomer;
  33.     /**
  34.      * @ORM\Column(type="decimal", precision=10, scale=2)
  35.      */
  36.     private $supplierPrice = 0.00;
  37.     /**
  38.      * @ORM\Column(type="decimal", precision=10, scale=2)
  39.      */
  40.     private $priceBulkCustomer;
  41.     //Begin promo
  42.     /**
  43.      * @ORM\Column(type="decimal", precision=10, scale=2, nullable=true)
  44.      */
  45.     private $promoPriceDealer;
  46.     /**
  47.      * @ORM\Column(type="decimal", precision=10, scale=2, nullable=true)
  48.      */
  49.     private $promoPriceCustomer;
  50.     /**
  51.      * @ORM\Column(type="decimal", precision=10, scale=2, nullable=true)
  52.      */
  53.     private $promoPriceBulkCustomer;
  54.     /**
  55.      * @ORM\Column(type="datetime", nullable=true)
  56.      */
  57.     private $promoStartAt;
  58.     /**
  59.      * @ORM\Column(type="datetime", nullable=true)
  60.      */
  61.     private $promoEndAt;
  62.     /**
  63.      * @ORM\Column(type="boolean")
  64.      */
  65.     private $isPromoActive = false;
  66.     //End promo
  67.     /**
  68.      * @ORM\Column(type="decimal", precision=8, scale=2)
  69.      */
  70.     private $nbrBulkProd;
  71.     /**
  72.      * @ORM\Column(type="decimal", precision=6, scale=2)
  73.      */
  74.     private $taxeProduct;
  75.     public function getId(): ?int
  76.     {
  77.         return $this->id;
  78.     }
  79.     public function getProduct(): ?Product
  80.     {
  81.         return $this->product;
  82.     }
  83.     public function setProduct(?Product $product): self
  84.     {
  85.         $this->product = $product;
  86.         return $this;
  87.     }
  88.     public function getPriceDealer(): ?string
  89.     {
  90.         return $this->priceDealer;
  91.     }
  92.     public function setPriceDealer(string $priceDealer): self
  93.     {
  94.         $this->priceDealer = $priceDealer;
  95.         return $this;
  96.     }
  97.     public function getNbrDealerProd(): ?string
  98.     {
  99.         return $this->nbrDealerProd;
  100.     }
  101.     public function setNbrDealerProd(string $nbrDealerProd): self
  102.     {
  103.         $this->nbrDealerProd = $nbrDealerProd;
  104.         return $this;
  105.     }
  106.     public function getPriceCustomer(): ?string
  107.     {
  108.         return $this->priceCustomer;
  109.     }
  110.     public function setPriceCustomer(string $priceCustomer): self
  111.     {
  112.         $this->priceCustomer = $priceCustomer;
  113.         return $this;
  114.     }
  115.     public function getSupplierPrice(): ?string
  116.     {
  117.         return $this->supplierPrice;
  118.     }
  119.     public function setSupplierPrice($supplierPrice): self
  120.     {
  121.         $this->supplierPrice = $supplierPrice;
  122.         return $this;
  123.     }
  124.     public function getPriceBulkCustomer(): ?string
  125.     {
  126.         return $this->priceBulkCustomer;
  127.     }
  128.     public function setPriceBulkCustomer(string $priceBulkCustomer): self
  129.     {
  130.         $this->priceBulkCustomer = $priceBulkCustomer;
  131.         return $this;
  132.     }
  133.     public function getNbrBulkProd(): ?string
  134.     {
  135.         return $this->nbrBulkProd;
  136.     }
  137.     public function setNbrBulkProd(string $nbrBulkProd): self
  138.     {
  139.         $this->nbrBulkProd = $nbrBulkProd;
  140.         return $this;
  141.     }
  142.     public function getTaxeProduct(): ?string
  143.     {
  144.         return $this->taxeProduct;
  145.     }
  146.     public function setTaxeProduct(string $taxeProduct): self
  147.     {
  148.         $this->taxeProduct = $taxeProduct;
  149.         return $this;
  150.     }
  151.     //Promo
  152.     public function isPromotionValid(): bool
  153.     {
  154.         if (!$this->isPromoActive) {
  155.             return false;
  156.         }
  157.         $now = new \DateTime();
  158.         if ($this->promoStartAt && $now < $this->promoStartAt) {
  159.             return false;
  160.         }
  161.         if ($this->promoEndAt && $now > $this->promoEndAt) {
  162.             return false;
  163.         }
  164.         return true;
  165.     }
  166.     public function getPromoStartAt(): ?\DateTimeInterface
  167.     {
  168.         return $this->promoStartAt;
  169.     }
  170.     public function setPromoStartAt(?\DateTimeInterface $promoStartAt): self
  171.     {
  172.         $this->promoStartAt = $promoStartAt;
  173.         return $this;
  174.     }
  175.     public function getPromoEndAt(): ?\DateTimeInterface
  176.     {
  177.         return $this->promoEndAt;
  178.     }
  179.     public function setPromoEndAt(?\DateTimeInterface $promoEndAt): self
  180.     {
  181.         $this->promoEndAt = $promoEndAt;
  182.         return $this;
  183.     }
  184.     public function isPromoActive(): bool
  185.     {
  186.         return $this->isPromoActive;
  187.     }
  188.     public function setIsPromoActive(bool $isPromoActive): self
  189.     {
  190.         $this->isPromoActive = $isPromoActive;
  191.         return $this;
  192.     }
  193.     public function getPromoPriceDealer(): ?string
  194.     {
  195.         return $this->promoPriceDealer;
  196.     }
  197.     public function setPromoPriceDealer(?string $promoPriceDealer): self
  198.     {
  199.         $this->promoPriceDealer = $promoPriceDealer;
  200.         return $this;
  201.     }
  202.     public function getPromoPriceCustomer(): ?string
  203.     {
  204.         return $this->promoPriceCustomer;
  205.     }
  206.     public function setPromoPriceCustomer(?string $promoPriceCustomer): self
  207.     {
  208.         $this->promoPriceCustomer = $promoPriceCustomer;
  209.         return $this;
  210.     }
  211.     public function getPromoPriceBulkCustomer(): ?string
  212.     {
  213.         return $this->promoPriceBulkCustomer;
  214.     }
  215.     public function setPromoPriceBulkCustomer(?string $promoPriceBulkCustomer): self
  216.     {
  217.         $this->promoPriceBulkCustomer = $promoPriceBulkCustomer;
  218.         return $this;
  219.     }
  220. }