src/Entity/PreOrderProduct.php line 27

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