<?php
namespace App\Entity;
use ApiPlatform\Metadata\ApiResource;
use App\Repository\OrderProductRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Serializer\Filter\GroupFilter;
#[ORM\Entity(repositoryClass: OrderProductRepository::class)]
#[ApiResource(
normalizationContext: ['groups' => ['order_product:read']],
denormalizationContext: ['groups' => ['order_product:write']],
order: ['id' => 'DESC'],
)]
#[ApiFilter(SearchFilter::class, properties: [
'order' => 'exact',
'product.id' => 'exact',
'product.userLikeLists.user.id' => 'exact',
'product.userLikeLists.user.is_order' => 'exact',
])]
// #[ApiFilter(GroupFilter::class, arguments: ['parameterName' => 'g', 'overrideDefaultGroups' => true])]
class OrderProduct
{
#[Groups(['order:read', 'order_product:read', 'pre_order_product:read', 'pre_order:read', 'load_invoice:read', 'order:write', 'order_product:write'])]
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[Groups(['order:read', 'order_product:read', 'pre_order_product:read', 'pre_order:read', 'load_invoice:read', 'order:write', 'order_product:write'])]
#[ORM\Column(length: 255, nullable: true)]
private ?string $name = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $date_entered = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $date_modified = null;
#[ORM\Column(nullable: true)]
private ?int $modified_user_id = null;
#[ORM\Column(nullable: true)]
private ?int $created_by = null;
#[Groups(['order_product:read', 'pre_order_product:read', 'pre_order:read', 'order:write', 'order_product:write'])]
#[ORM\ManyToOne(inversedBy: 'orderProducts', cascade:['persist'])]
private ?Orders $order = null;
#[Groups(['order:read', 'order_product:read', 'pre_order_product:read', 'pre_order:read', 'load_invoice:read', 'order:write', 'order_product:write'])]
#[ORM\ManyToOne(inversedBy: 'orderProducts')]
private ?Products $product = null;
#[Groups(['order:read', 'order_product:read', 'pre_order_product:read', 'pre_order:read', 'load_invoice:read', 'order:write', 'order_product:write'])]
#[ORM\Column(length: 100, nullable: true)]
private ?string $status = null;
#[Groups(['order:read', 'order_product:read', 'pre_order_product:read', 'pre_order:read', 'load_invoice:read', 'order:write', 'order_product:write'])]
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $description = null;
#[Groups(['order:read', 'order_product:read', 'pre_order_product:read', 'pre_order:read', 'load_invoice:read', 'order:write', 'order_product:write'])]
#[ORM\Column(nullable: true)]
private ?float $count = 0;
#[Groups(['order:read', 'order_product:read', 'pre_order_product:read', 'pre_order:read', 'order:write', 'order_product:write'])]
#[ORM\ManyToOne]
private ?MeasurmentUnit $measurementUnit = null;
#[Groups(['order:read', 'order_product:read', 'pre_order_product:read', 'pre_order:read', 'load_invoice:read', 'order:write', 'order_product:write'])]
#[ORM\Column(nullable: true)]
private ?float $priceForOne = 0;
#[Groups(['order:read', 'order_product:read', 'pre_order_product:read', 'pre_order:read', 'load_invoice:read', 'order:write', 'order_product:write'])]
#[ORM\Column(nullable: true)]
private ?float $priceIncome = 0;
#[Groups(['order:read', 'order_product:read', 'pre_order_product:read', 'pre_order:read', 'load_invoice:read', 'order:write', 'order_product:write'])]
#[ORM\Column(nullable: true)]
private ?float $markUp = 0;
#[Groups(['order:read', 'order_product:read', 'pre_order_product:read', 'pre_order:read', 'load_invoice:read', 'order:write', 'order_product:write'])]
#[ORM\Column(nullable: true)]
private ?float $sumOrdered = 0;
#[Groups(['order:read', 'order_product:read', 'pre_order_product:read', 'pre_order:read', 'load_invoice:read', 'order:write', 'order_product:write'])]
#[ORM\Column(nullable: true)]
private ?float $discount = 0;
#[Groups(['order:read', 'order_product:read', 'pre_order_product:read', 'pre_order:read', 'load_invoice:read', 'order:write', 'order_product:write'])]
#[ORM\Column(length: 10, nullable: true)]
private ?string $curency = null;
#[Groups(['order:read', 'order_product:read', 'pre_order_product:read', 'pre_order:read', 'load_invoice:read', 'order:write', 'order_product:write'])]
#[ORM\Column(nullable: true)]
private ?float $curencyRate = null;
#[Groups(['order_product:read', 'pre_order_product:read', 'pre_order:read', 'order:write', 'order_product:write'])]
#[ORM\ManyToOne(inversedBy: 'orderProducts')]
private ?PreOrderProduct $preOrderProduct = null;
#[Groups(['order_product:read', 'pre_order_product:read', 'pre_order:read', 'order:write', 'order_product:write'])]
#[ORM\OneToMany(mappedBy: 'order_product', targetEntity: LoadInvoiceProduct::class)]
private Collection $loadInvoiceProducts;
#[Groups(['order_product:read', 'pre_order_product:read', 'pre_order:read', 'order:write', 'order_product:write'])]
#[ORM\OneToMany(mappedBy: 'order_product', targetEntity: AcceptedProduct::class)]
private Collection $acceptedProducts;
#[Groups(['order_product:read', 'pre_order_product:read', 'pre_order:read', 'order:write', 'order_product:write'])]
#[ORM\Column(nullable: true)]
private ?bool $pdv = null;
#[Groups(['order_product:read', 'pre_order_product:read', 'pre_order:read', 'order:write', 'order_product:write'])]
#[ORM\Column(length: 100, nullable: true)]
private ?string $pdvRate = null;
#[Groups(['order_product:read', 'pre_order_product:read', 'pre_order:read', 'order:write', 'order_product:write'])]
#[ORM\Column(nullable: true)]
private ?float $pdvSum = null;
#[Groups(['order_product:read', 'pre_order_product:read', 'pre_order:read', 'order:write', 'order_product:write'])]
#[ORM\Column(length: 100, nullable: true)]
private ?string $pdvDesc = null;
#[Groups(['order_product:read', 'order:read', 'order_product:write'])]
#[ORM\ManyToOne(inversedBy: 'orderProducts')]
private ?Storage $storage = null;
public function __construct()
{
$this->loadInvoiceProducts = new ArrayCollection();
$this->acceptedProducts = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function setId(?string $id): self
{
$this->id = $id;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): self
{
$this->name = $name;
return $this;
}
public function getDateEntered(): ?\DateTimeInterface
{
return $this->date_entered;
}
public function setDateEntered(?\DateTimeInterface $date_entered): self
{
$this->date_entered = $date_entered;
return $this;
}
public function getDateModified(): ?\DateTimeInterface
{
return $this->date_modified;
}
public function setDateModified(?\DateTimeInterface $date_modified): self
{
$this->date_modified = $date_modified;
return $this;
}
public function getModifiedUserId(): ?int
{
return $this->modified_user_id;
}
public function setModifiedUserId(?int $modified_user_id): self
{
$this->modified_user_id = $modified_user_id;
return $this;
}
public function getCreatedBy(): ?int
{
return $this->created_by;
}
public function setCreatedBy(?int $created_by): self
{
$this->created_by = $created_by;
return $this;
}
public function getOrder(): ?Orders
{
return $this->order;
}
public function setOrder(?Orders $order): self
{
$this->order = $order;
return $this;
}
public function getProduct(): ?Products
{
return $this->product;
}
public function setProduct(?Products $product): self
{
$this->product = $product;
return $this;
}
public function getStatus(): ?string
{
return $this->status;
}
public function setStatus(?string $status): self
{
$this->status = $status;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getCount(): ?float
{
return $this->count;
}
public function setCount(?float $count): self
{
$this->count = $count;
return $this;
}
public function getMeasurementUnit(): ?MeasurmentUnit
{
return $this->measurementUnit;
}
public function setMeasurementUnit(?MeasurmentUnit $measurementUnit): self
{
$this->measurementUnit = $measurementUnit;
return $this;
}
public function getPriceForOne(): ?float
{
return $this->priceForOne;
}
public function setPriceForOne(?float $priceForOne): self
{
$this->priceForOne = $priceForOne;
return $this;
}
public function getPriceIncome(): ?float
{
return $this->priceIncome;
}
public function setPriceIncome(?float $priceIncome): self
{
$this->priceIncome = $priceIncome;
return $this;
}
public function getMarkUp(): ?float
{
return $this->markUp;
}
public function setMarkUp(?float $markUp): self
{
$this->markUp = $markUp;
return $this;
}
public function getSumOrdered(): ?float
{
return $this->sumOrdered;
}
public function setSumOrdered(?float $sumOrdered): self
{
$this->sumOrdered = $sumOrdered;
return $this;
}
public function getDiscount(): ?float
{
return $this->discount;
}
public function setDiscount(?float $discount): self
{
$this->discount = $discount;
return $this;
}
public function getCurency(): ?string
{
return $this->curency;
}
public function setCurency(?string $curency): self
{
$this->curency = $curency;
return $this;
}
public function getCurencyRate(): ?float
{
return $this->curencyRate;
}
public function setCurencyRate(?float $curencyRate): self
{
$this->curencyRate = $curencyRate;
return $this;
}
public function getPreOrderProduct(): ?PreOrderProduct
{
return $this->preOrderProduct;
}
public function setPreOrderProduct(?PreOrderProduct $preOrderProduct): self
{
$this->preOrderProduct = $preOrderProduct;
return $this;
}
/**
* @return Collection<int, LoadInvoiceProduct>
*/
public function getLoadInvoiceProducts(): Collection
{
return $this->loadInvoiceProducts;
}
public function addLoadInvoiceProduct(LoadInvoiceProduct $loadInvoiceProduct): self
{
if (!$this->loadInvoiceProducts->contains($loadInvoiceProduct)) {
$this->loadInvoiceProducts->add($loadInvoiceProduct);
$loadInvoiceProduct->setOrderProduct($this);
}
return $this;
}
public function removeLoadInvoiceProduct(LoadInvoiceProduct $loadInvoiceProduct): self
{
if ($this->loadInvoiceProducts->removeElement($loadInvoiceProduct)) {
// set the owning side to null (unless already changed)
if ($loadInvoiceProduct->getOrderProduct() === $this) {
$loadInvoiceProduct->setOrderProduct(null);
}
}
return $this;
}
/**
* @return Collection<int, AcceptedProduct>
*/
public function getAcceptedProducts(): Collection
{
return $this->acceptedProducts;
}
public function addAcceptedProduct(AcceptedProduct $acceptedProduct): self
{
if (!$this->acceptedProducts->contains($acceptedProduct)) {
$this->acceptedProducts->add($acceptedProduct);
$acceptedProduct->setOrderProduct($this);
}
return $this;
}
public function removeAcceptedProduct(AcceptedProduct $acceptedProduct): self
{
if ($this->acceptedProducts->removeElement($acceptedProduct)) {
// set the owning side to null (unless already changed)
if ($acceptedProduct->getOrderProduct() === $this) {
$acceptedProduct->setOrderProduct(null);
}
}
return $this;
}
public function isPdv(): ?bool
{
return $this->pdv;
}
public function setPdv(?bool $pdv): self
{
$this->pdv = $pdv;
return $this;
}
public function getPdvRate(): ?string
{
return $this->pdvRate;
}
public function setPdvRate(?string $pdvRate): self
{
$this->pdvRate = $pdvRate;
return $this;
}
public function getPdvSum(): ?float
{
return $this->pdvSum;
}
public function setPdvSum(?float $pdvSum): self
{
$this->pdvSum = $pdvSum;
return $this;
}
public function getPdvDesc(): ?string
{
return $this->pdvDesc;
}
public function setPdvDesc(?string $pdvDesc): self
{
$this->pdvDesc = $pdvDesc;
return $this;
}
public function getStorage(): ?Storage
{
return $this->storage;
}
public function setStorage(?Storage $storage): static
{
$this->storage = $storage;
return $this;
}
}