src/Entity/OrderProduct.php line 31

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