src/Entity/OrderProduct.php line 28

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\OrderProductRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\Serializer\Annotation\Groups;
  10. use ApiPlatform\Metadata\ApiFilter;
  11. use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
  12. #[ORM\Entity(repositoryClassOrderProductRepository::class)]
  13. #[ApiResource(
  14.     normalizationContext: ['groups' => ['order_product:read']],
  15.     denormalizationContext: ['groups' => ['order_product:write']],
  16.     order: ['id' => 'DESC'],
  17. )]
  18. #[ApiFilter(SearchFilter::class, properties: [
  19.     'order' => 'exact'
  20.     'product.id' => 'exact',
  21.     'product.userLikeLists.user.id' => 'exact',
  22.     'product.userLikeLists.user.is_order' => 'exact',
  23. ])]
  24. class OrderProduct
  25. {
  26.     #[Groups(['order:read''order_product:read''order_product:read''pre_order_product:read''pre_order:read''load_invoice:read',  'order:write''order_product:write'])]
  27.     #[ORM\Id]
  28.     #[ORM\GeneratedValue]
  29.     #[ORM\Column]
  30.     private ?int $id null;
  31.     #[Groups(['order:read''order_product:read''order_product:read''pre_order_product:read''pre_order:read''load_invoice:read',  'order:write''order_product:write'])]
  32.     #[ORM\Column(length255nullabletrue)]
  33.     private ?string $name null;
  34.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  35.     private ?\DateTimeInterface $date_entered null;
  36.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  37.     private ?\DateTimeInterface $date_modified null;
  38.     #[ORM\Column(nullabletrue)]
  39.     private ?int $modified_user_id null;
  40.     #[ORM\Column(nullabletrue)]
  41.     private ?int $created_by null;
  42.     #[Groups(['order_product:read''pre_order_product:read''pre_order:read''order:write''order_product:write'])]
  43.     #[ORM\ManyToOne(inversedBy'orderProducts'cascade:['persist'])]
  44.     private ?Orders $order null;
  45.     #[Groups(['order:read''order_product:read''order_product:read''pre_order_product:read''pre_order:read''load_invoice:read',  'order:write''order_product:write'])]
  46.     #[ORM\ManyToOne(inversedBy'orderProducts')]
  47.     private ?Products $product null;
  48.     #[Groups(['order:read''order_product:read''order_product:read''pre_order_product:read''pre_order:read''load_invoice:read',  'order:write''order_product:write'])]
  49.     #[ORM\Column(length100nullabletrue)]
  50.     private ?string $status null;
  51.     #[Groups(['order:read''order_product:read''order_product:read''pre_order_product:read''pre_order:read''load_invoice:read',  'order:write''order_product:write'])]
  52.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  53.     private ?string $description null;
  54.     #[Groups(['order:read''order_product:read''order_product:read''pre_order_product:read''pre_order:read''load_invoice:read',  'order:write''order_product:write'])]
  55.     #[ORM\Column(nullabletrue)]
  56.     private ?float $count 0;
  57.     #[Groups(['order:read''order_product:read''order_product:read''pre_order_product:read''pre_order:read''load_invoice:read',  'order:write''order_product:write'])]
  58.     #[ORM\ManyToOne]
  59.     private ?MeasurmentUnit $measurementUnit null;
  60.     #[Groups(['order:read''order_product:read''order_product:read''pre_order_product:read''pre_order:read''load_invoice:read',  'order:write''order_product:write'])]
  61.     #[ORM\Column(nullabletrue)]
  62.     private ?float $priceForOne 0;
  63.     #[Groups(['order:read''order_product:read''order_product:read''pre_order_product:read''pre_order:read''load_invoice:read',  'order:write''order_product:write'])]
  64.     #[ORM\Column(nullabletrue)]
  65.     private ?float $priceIncome 0;
  66.     #[Groups(['order:read''order_product:read''order_product:read''pre_order_product:read''pre_order:read''load_invoice:read',  'order:write''order_product:write'])]
  67.     #[ORM\Column(nullabletrue)]
  68.     private ?float $markUp 0;
  69.     #[Groups(['order:read''order_product:read''order_product:read''pre_order_product:read''pre_order:read''load_invoice:read',  'order:write''order_product:write'])]
  70.     #[ORM\Column(nullabletrue)]
  71.     private ?float $sumOrdered 0;
  72.     #[Groups(['order:read''order_product:read''order_product:read''pre_order_product:read''pre_order:read''load_invoice:read',  'order:write''order_product:write'])]
  73.     #[ORM\Column(nullabletrue)]
  74.     private ?float $discount 0;
  75.     #[Groups(['order:read''order_product:read''order_product:read''pre_order_product:read''pre_order:read''load_invoice:read',  'order:write''order_product:write'])]
  76.     #[ORM\Column(length10nullabletrue)]
  77.     private ?string $curency null;
  78.     #[Groups(['order:read''order_product:read''order_product:read''pre_order_product:read''pre_order:read''load_invoice:read',  'order:write''order_product:write'])]
  79.     #[ORM\Column(nullabletrue)]
  80.     private ?float $curencyRate null;
  81.     #[Groups(['order:read''order_product:read''order_product:read''pre_order_product:read''pre_order:read''load_invoice:read',  'order:write''order_product:write'])]
  82.     #[ORM\ManyToOne(inversedBy'orderProducts')]
  83.     private ?PreOrderProduct $preOrderProduct null;
  84.     #[Groups(['order:read''order_product:read''order_product:read''pre_order_product:read''pre_order:read''load_invoice:read',  'order:write''order_product:write'])]
  85.     #[ORM\OneToMany(mappedBy'order_product'targetEntityLoadInvoiceProduct::class)]
  86.     private Collection $loadInvoiceProducts;
  87.     #[Groups(['order:read''order_product:read''order_product:read''pre_order_product:read''pre_order:read''load_invoice:read',  'order:write''order_product:write'])]
  88.     #[ORM\OneToMany(mappedBy'order_product'targetEntityAcceptedProduct::class)]
  89.     private Collection $acceptedProducts;
  90.     #[Groups(['order_product:read''pre_order_product:read''pre_order:read''order:write''order_product:write'])]
  91.     #[ORM\Column(nullabletrue)]
  92.     private ?bool $pdv null;
  93.     #[Groups(['order_product:read''pre_order_product:read''pre_order:read''order:write''order_product:write'])]
  94.     #[ORM\Column(length100nullabletrue)]
  95.     private ?string $pdvRate null;
  96.     #[Groups(['order_product:read''pre_order_product:read''pre_order:read''order:write''order_product:write'])]
  97.     #[ORM\Column(nullabletrue)]
  98.     private ?float $pdvSum null;
  99.     #[Groups(['order_product:read''pre_order_product:read''pre_order:read''order:write''order_product:write'])]
  100.     #[ORM\Column(length100nullabletrue)]
  101.     private ?string $pdvDesc null;
  102.     public function __construct()
  103.     {
  104.         $this->loadInvoiceProducts = new ArrayCollection();
  105.         $this->acceptedProducts = new ArrayCollection();
  106.     }
  107.     public function getId(): ?int
  108.     {
  109.         return $this->id;
  110.     }
  111.     public function setId(?string $id): self
  112.     {
  113.         $this->id $id;
  114.         return $this;
  115.     }
  116.     public function getName(): ?string
  117.     {
  118.         return $this->name;
  119.     }
  120.     public function setName(?string $name): self
  121.     {
  122.         $this->name $name;
  123.         return $this;
  124.     }
  125.     public function getDateEntered(): ?\DateTimeInterface
  126.     {
  127.         return $this->date_entered;
  128.     }
  129.     public function setDateEntered(?\DateTimeInterface $date_entered): self
  130.     {
  131.         $this->date_entered $date_entered;
  132.         return $this;
  133.     }
  134.     public function getDateModified(): ?\DateTimeInterface
  135.     {
  136.         return $this->date_modified;
  137.     }
  138.     public function setDateModified(?\DateTimeInterface $date_modified): self
  139.     {
  140.         $this->date_modified $date_modified;
  141.         return $this;
  142.     }
  143.     public function getModifiedUserId(): ?int
  144.     {
  145.         return $this->modified_user_id;
  146.     }
  147.     public function setModifiedUserId(?int $modified_user_id): self
  148.     {
  149.         $this->modified_user_id $modified_user_id;
  150.         return $this;
  151.     }
  152.     public function getCreatedBy(): ?int
  153.     {
  154.         return $this->created_by;
  155.     }
  156.     public function setCreatedBy(?int $created_by): self
  157.     {
  158.         $this->created_by $created_by;
  159.         return $this;
  160.     }
  161.     public function getOrder(): ?Orders
  162.     {
  163.         return $this->order;
  164.     }
  165.     public function setOrder(?Orders $order): self
  166.     {
  167.         $this->order $order;
  168.         return $this;
  169.     }
  170.     public function getProduct(): ?Products
  171.     {
  172.         return $this->product;
  173.     }
  174.     public function setProduct(?Products $product): self
  175.     {
  176.         $this->product $product;
  177.         return $this;
  178.     }
  179.     public function getStatus(): ?string
  180.     {
  181.         return $this->status;
  182.     }
  183.     public function setStatus(?string $status): self
  184.     {
  185.         $this->status $status;
  186.         return $this;
  187.     }
  188.     public function getDescription(): ?string
  189.     {
  190.         return $this->description;
  191.     }
  192.     public function setDescription(?string $description): self
  193.     {
  194.         $this->description $description;
  195.         return $this;
  196.     }
  197.     public function getCount(): ?float
  198.     {
  199.         return $this->count;
  200.     }
  201.     public function setCount(?float $count): self
  202.     {
  203.         $this->count $count;
  204.         return $this;
  205.     }
  206.     public function getMeasurementUnit(): ?MeasurmentUnit
  207.     {
  208.         return $this->measurementUnit;
  209.     }
  210.     public function setMeasurementUnit(?MeasurmentUnit $measurementUnit): self
  211.     {
  212.         $this->measurementUnit $measurementUnit;
  213.         return $this;
  214.     }
  215.     public function getPriceForOne(): ?float
  216.     {
  217.         return $this->priceForOne;
  218.     }
  219.     public function setPriceForOne(?float $priceForOne): self
  220.     {
  221.         $this->priceForOne $priceForOne;
  222.         return $this;
  223.     }
  224.     public function getPriceIncome(): ?float
  225.     {
  226.         return $this->priceIncome;
  227.     }
  228.     public function setPriceIncome(?float $priceIncome): self
  229.     {
  230.         $this->priceIncome $priceIncome;
  231.         return $this;
  232.     }
  233.     public function getMarkUp(): ?float
  234.     {
  235.         return $this->markUp;
  236.     }
  237.     public function setMarkUp(?float $markUp): self
  238.     {
  239.         $this->markUp $markUp;
  240.         return $this;
  241.     }
  242.     public function getSumOrdered(): ?float
  243.     {
  244.         return $this->sumOrdered;
  245.     }
  246.     public function setSumOrdered(?float $sumOrdered): self
  247.     {
  248.         $this->sumOrdered $sumOrdered;
  249.         return $this;
  250.     }
  251.     public function getDiscount(): ?float
  252.     {
  253.         return $this->discount;
  254.     }
  255.     public function setDiscount(?float $discount): self
  256.     {
  257.         $this->discount $discount;
  258.         return $this;
  259.     }
  260.     public function getCurency(): ?string
  261.     {
  262.         return $this->curency;
  263.     }
  264.     public function setCurency(?string $curency): self
  265.     {
  266.         $this->curency $curency;
  267.         return $this;
  268.     }
  269.     public function getCurencyRate(): ?float
  270.     {
  271.         return $this->curencyRate;
  272.     }
  273.     public function setCurencyRate(?float $curencyRate): self
  274.     {
  275.         $this->curencyRate $curencyRate;
  276.         return $this;
  277.     }
  278.     public function getPreOrderProduct(): ?PreOrderProduct
  279.     {
  280.         return $this->preOrderProduct;
  281.     }
  282.     public function setPreOrderProduct(?PreOrderProduct $preOrderProduct): self
  283.     {
  284.         $this->preOrderProduct $preOrderProduct;
  285.         return $this;
  286.     }
  287.     /**
  288.      * @return Collection<int, LoadInvoiceProduct>
  289.      */
  290.     public function getLoadInvoiceProducts(): Collection
  291.     {
  292.         return $this->loadInvoiceProducts;
  293.     }
  294.     public function addLoadInvoiceProduct(LoadInvoiceProduct $loadInvoiceProduct): self
  295.     {
  296.         if (!$this->loadInvoiceProducts->contains($loadInvoiceProduct)) {
  297.             $this->loadInvoiceProducts->add($loadInvoiceProduct);
  298.             $loadInvoiceProduct->setOrderProduct($this);
  299.         }
  300.         return $this;
  301.     }
  302.     public function removeLoadInvoiceProduct(LoadInvoiceProduct $loadInvoiceProduct): self
  303.     {
  304.         if ($this->loadInvoiceProducts->removeElement($loadInvoiceProduct)) {
  305.             // set the owning side to null (unless already changed)
  306.             if ($loadInvoiceProduct->getOrderProduct() === $this) {
  307.                 $loadInvoiceProduct->setOrderProduct(null);
  308.             }
  309.         }
  310.         return $this;
  311.     }
  312.     /**
  313.      * @return Collection<int, AcceptedProduct>
  314.      */
  315.     public function getAcceptedProducts(): Collection
  316.     {
  317.         return $this->acceptedProducts;
  318.     }
  319.     public function addAcceptedProduct(AcceptedProduct $acceptedProduct): self
  320.     {
  321.         if (!$this->acceptedProducts->contains($acceptedProduct)) {
  322.             $this->acceptedProducts->add($acceptedProduct);
  323.             $acceptedProduct->setOrderProduct($this);
  324.         }
  325.         return $this;
  326.     }
  327.     public function removeAcceptedProduct(AcceptedProduct $acceptedProduct): self
  328.     {
  329.         if ($this->acceptedProducts->removeElement($acceptedProduct)) {
  330.             // set the owning side to null (unless already changed)
  331.             if ($acceptedProduct->getOrderProduct() === $this) {
  332.                 $acceptedProduct->setOrderProduct(null);
  333.             }
  334.         }
  335.         return $this;
  336.     }
  337.     public function isPdv(): ?bool
  338.     {
  339.         return $this->pdv;
  340.     }
  341.     public function setPdv(?bool $pdv): self
  342.     {
  343.         $this->pdv $pdv;
  344.         return $this;
  345.     }
  346.     public function getPdvRate(): ?string
  347.     {
  348.         return $this->pdvRate;
  349.     }
  350.     public function setPdvRate(?string $pdvRate): self
  351.     {
  352.         $this->pdvRate $pdvRate;
  353.         return $this;
  354.     }
  355.     public function getPdvSum(): ?float
  356.     {
  357.         return $this->pdvSum;
  358.     }
  359.     public function setPdvSum(?float $pdvSum): self
  360.     {
  361.         $this->pdvSum $pdvSum;
  362.         return $this;
  363.     }
  364.     public function getPdvDesc(): ?string
  365.     {
  366.         return $this->pdvDesc;
  367.     }
  368.     public function setPdvDesc(?string $pdvDesc): self
  369.     {
  370.         $this->pdvDesc $pdvDesc;
  371.         return $this;
  372.     }
  373. }