<?php
namespace App\Entity;
use App\Repository\ProductPriceScaleRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Blameable\Traits\BlameableEntity;
use Gedmo\Timestampable\Traits\TimestampableEntity;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity(repositoryClass: ProductPriceScaleRepository::class)]
class ProductPriceScale
{
use BlameableEntity; //Hook blameable behaviour. Updates createdBy, updatedBy fields
use TimestampableEntity; //Hook timestampable behaviour. Updates createdAt, updatedAt fields
#[ORM\Id]
#[ORM\GeneratedValue(strategy: "IDENTITY")]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column]
#[Assert\NotNull()]
#[Assert\PositiveOrZero()]
private ?float $initialPrice = null;
#[ORM\Column]
#[Assert\NotNull()]
#[Assert\PositiveOrZero()]
private ?float $finalPrice = null;
#[ORM\Column]
#[Assert\NotNull()]
#[Assert\PositiveOrZero()]
private ?int $scaleQuantity = null;
#[ORM\Column(nullable: true)]
#[Assert\PositiveOrZero()]
private ?int $scaleQuantityAvailable = null;
#[ORM\Column]
#[Assert\NotNull()]
#[Assert\PositiveOrZero()]
private ?int $totalMinQuantity = null;
#[ORM\Column]
#[Assert\NotNull()]
#[Assert\PositiveOrZero()]
private ?int $totalMaxQuantity = null;
#[ORM\Column]
#[Assert\NotNull()]
#[Assert\PositiveOrZero()]
private ?float $referredPoints = null;
#[ORM\Column]
#[Assert\NotNull()]
#[Assert\PositiveOrZero()]
private ?float $extraReferredPoints = null;
#[ORM\Column]
#[Assert\NotNull()]
private ?bool $sellProductIfNotComplete = true;
#[ORM\ManyToOne(inversedBy: 'priceScales')]
#[ORM\JoinColumn(nullable: false)]
private ?Product $product = null;
#[ORM\OneToMany(mappedBy: 'productPriceScale', targetEntity: OrderDetail::class)]
private Collection $orderDetails;
public function __construct()
{
$this->orderDetails = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getInitialPrice(): ?float
{
return $this->initialPrice;
}
public function setInitialPrice(float $initialPrice): self
{
$this->initialPrice = $initialPrice;
return $this;
}
public function getFinalPrice(): ?float
{
return $this->finalPrice;
}
public function setFinalPrice(float $finalPrice): self
{
$this->finalPrice = $finalPrice;
return $this;
}
public function getScaleQuantity(): ?int
{
return $this->scaleQuantity;
}
public function setScaleQuantity(int $scaleQuantity): self
{
$this->scaleQuantity = $scaleQuantity;
return $this;
}
public function getScaleQuantityAvailable(): ?int
{
return $this->scaleQuantityAvailable;
}
public function setScaleQuantityAvailable(?int $scaleQuantityAvailable): self
{
$this->scaleQuantityAvailable = $scaleQuantityAvailable;
return $this;
}
public function getTotalMinQuantity(): ?int
{
return $this->totalMinQuantity;
}
public function setTotalMinQuantity(int $totalMinQuantity): self
{
$this->totalMinQuantity = $totalMinQuantity;
return $this;
}
public function getTotalMaxQuantity(): ?int
{
return $this->totalMaxQuantity;
}
public function setTotalMaxQuantity(int $totalMaxQuantity): self
{
$this->totalMaxQuantity = $totalMaxQuantity;
return $this;
}
public function getReferredPoints(): ?float
{
return $this->referredPoints;
}
public function setReferredPoints(float $referredPoints): self
{
$this->referredPoints = $referredPoints;
return $this;
}
public function getExtraReferredPoints(): ?float
{
return $this->extraReferredPoints;
}
public function setExtraReferredPoints(float $extraReferredPoints): self
{
$this->extraReferredPoints = $extraReferredPoints;
return $this;
}
public function isSellProductIfNotComplete(): ?bool
{
return $this->sellProductIfNotComplete;
}
public function setSellProductIfNotComplete(bool $sellProductIfNotComplete): self
{
$this->sellProductIfNotComplete = $sellProductIfNotComplete;
return $this;
}
public function getProduct(): ?Product
{
return $this->product;
}
public function setProduct(?Product $product): self
{
$this->product = $product;
return $this;
}
/**
* @return Collection<int, OrderDetail>
*/
public function getOrderDetails(): Collection
{
return $this->orderDetails;
}
public function addOrderDetail(OrderDetail $orderDetail): self
{
if (!$this->orderDetails->contains($orderDetail)) {
$this->orderDetails->add($orderDetail);
$orderDetail->setProductPriceScale($this);
}
return $this;
}
public function removeOrderDetail(OrderDetail $orderDetail): self
{
if ($this->orderDetails->removeElement($orderDetail)) {
// set the owning side to null (unless already changed)
if ($orderDetail->getProductPriceScale() === $this) {
$orderDetail->setProductPriceScale(null);
}
}
return $this;
}
}