src/Entity/PreOrder.php line 39

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\PreOrderRepository;
  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. #[ORM\Entity(repositoryClassPreOrderRepository::class)]
  14. #[ApiResource(
  15.     normalizationContext: ['groups' => ['pre_order_product:read''pre_order:read']],
  16.     denormalizationContext: ['groups' => ['pre_order:write']],
  17.     order: ['id' => 'DESC'],
  18. )]
  19. #[ORM\HasLifecycleCallbacks
  20. #[ApiFilter(
  21.     SearchFilter::class, 
  22.     properties: [
  23.         'code1c' => 'exact'
  24.         'account.name' => 'ipartial'
  25.         'account.manager' => 'exact'
  26.         'manager.username' => 'ipartial'
  27.         'manager.firstName' => 'ipartial'
  28.         'manager.lastName' => 'ipartial'
  29.         'synced' => 'exact',  
  30.         'client.id' => 'exact'
  31.     ]
  32. )]
  33. class PreOrder
  34. {
  35.     #[ORM\Id]
  36.     #[ORM\GeneratedValue]
  37.     #[ORM\Column]
  38.     #[Groups(['pre_order_product:read''pre_order:read''pre_order:write''order:read''order_product:read''load_invoice:read'])]
  39.     private ?int $id null;
  40.     #[Groups(['pre_order_product:read''pre_order:read''pre_order:write','order:read''order_product:read''load_invoice:read'])]
  41.     #[ORM\Column(length255nullabletrue)]
  42.     private ?string $name null;
  43.     #[Groups(['pre_order_product:read''pre_order:read''pre_order:write''order:read''order_product:read''load_invoice:read'])]
  44.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  45.     private ?\DateTimeInterface $dateEntered null;
  46.     #[Groups(['pre_order_product:read''pre_order:read''pre_order:write'])]
  47.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  48.     private ?\DateTimeInterface $dateModified null;
  49.     #[Groups(['pre_order_product:read''pre_order:read''pre_order:write''order:read''order_product:read''load_invoice:read'])]
  50.     #[ORM\ManyToOne]
  51.     #[MaxDepth(1)]
  52.     private ?User $createdBy null;
  53.     #[Groups(['pre_order_product:read''pre_order:read''pre_order:write''order:read''order_product:read''load_invoice:read'])]
  54.     #[ORM\ManyToOne]
  55.     #[MaxDepth(1)]
  56.     private ?User $modifiedUser null;
  57.     #[Groups(['pre_order_product:read''pre_order:read''pre_order:write''order:read''order_product:read''load_invoice:read'])]
  58.     #[ORM\Column(typeTypes::DATE_MUTABLEnullabletrue)]
  59.     private ?\DateTimeInterface $dateOrder null;
  60.     #[Groups(['pre_order_product:read''pre_order:read''pre_order:write'])]
  61.     #[ORM\Column(length100nullabletrue)]
  62.     private ?string $status null;
  63.     #[Groups(['pre_order_product:read''pre_order:read''pre_order:write'])]
  64.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  65.     private ?string $description null;
  66.     #[Groups(['pre_order_product:read''pre_order:read''pre_order:write'])]
  67.     #[ORM\Column(length20nullabletrue)]
  68.     private ?string $paymentMethod null;
  69.     #[Groups(['pre_order_product:read''pre_order:read''pre_order:write''order:read''order_product:read''load_invoice:read'])]
  70.     #[ORM\Column(nullabletrue)]
  71.     private ?float $sumOrdered null;
  72.     #[Groups(['pre_order_product:read''pre_order:read''pre_order:write'])]
  73.     #[ORM\Column(length10nullabletrue)]
  74.     private ?string $curency null;
  75.     #[Groups(['pre_order_product:read''pre_order:read''pre_order:write'])]
  76.     #[ORM\Column(nullabletrue)]
  77.     private ?float $curencyRate null;
  78.     #[Groups(['pre_order_product:read''pre_order:read''pre_order:write'])]
  79.     #[ORM\Column(nullabletrue)]
  80.     private ?float $discountTotal null;
  81.     #[Groups(['pre_order_product:read''pre_order:read''pre_order:write'])]
  82.     #[ORM\Column(nullabletrue)]
  83.     private ?int $discountPercent null;
  84.     #[Groups(['pre_order_product:read''pre_order:read''pre_order:write'])]
  85.     #[ORM\Column(length100nullabletrue)]
  86.     private ?string $shippingAddressStreet null;
  87.     #[Groups(['pre_order_product:read''pre_order:read''pre_order:write'])]
  88.     #[ORM\Column(length100nullabletrue)]
  89.     private ?string $shippingAddressCity null;
  90.     #[Groups(['pre_order_product:read''pre_order:read''pre_order:write'])]
  91.     #[ORM\Column(length100nullabletrue)]
  92.     private ?string $shippingAddressBuilding null;
  93.     #[ORM\Column(length100nullabletrue)]
  94.     private ?string $shippingAddressPost null;
  95.     #[Groups(['pre_order_product:read''pre_order:read''pre_order:write'])]
  96.     #[ORM\Column(length100nullabletrue)]
  97.     private ?string $shippingAddressCountry null;
  98.     #[Groups(['pre_order_product:read''pre_order:read''pre_order:write'])]
  99.     #[ORM\Column(length100nullabletrue)]
  100.     private ?string $shippingAddressDate null;
  101.     #[Groups(['pre_order_product:read''pre_order:read''pre_order:write'])]
  102.     #[ORM\Column(nullabletrue)]
  103.     private ?int $copyOrderId null;
  104.     #[MaxDepth(6)]
  105.     #[Groups(['pre_order_product:read''pre_order:read''pre_order:write''order:read''order_product:read''load_invoice:read'])]
  106.     #[ORM\OneToMany(mappedBy'preOrder'targetEntityPreOrderProduct::class, cascade:['persist'])]
  107.     private Collection $preOrderProducts;
  108.     #[MaxDepth(1)]
  109.     #[Groups(['pre_order_product:read''pre_order:read''pre_order:write'])]
  110.     #[ORM\OneToMany(mappedBy'preOrder'targetEntityOrders::class)]
  111.     private Collection $orders;
  112.     #[MaxDepth(1)]
  113.     #[Groups(['pre_order_product:read''pre_order:read''pre_order:write''order:read''order_product:read''load_invoice:read'])]
  114.     #[ORM\OneToMany(mappedBy'pre_order'targetEntityLoadInvoice::class)]
  115.     private Collection $loadInvoices;
  116.     #[MaxDepth(1)]
  117.     #[Groups(['pre_order_product:read''pre_order:read''pre_order:write''order:read''order_product:read''load_invoice:read'])]
  118.     #[ORM\OneToMany(mappedBy'pre_order'targetEntityAccepted::class)]
  119.     private Collection $accepteds;
  120.     #[MaxDepth(1)]
  121.     #[Groups(['pre_order_product:read''pre_order:read''pre_order:write''order:read''order_product:read''load_invoice:read'])]
  122.     #[ORM\OneToMany(mappedBy'pre_order_product'targetEntityLoadInvoiceProduct::class)]
  123.     private Collection $loadInvoiceProducts;
  124.     #[Groups(['pre_order_product:read''pre_order:read''pre_order:write'])]
  125.     #[ORM\ManyToOne(inversedBy'preOrders')]
  126.     #[MaxDepth(1)]
  127.     private ?Accounts $account null;
  128.     #[Groups(['pre_order_product:read''pre_order:read''pre_order:write'])]
  129.     #[ORM\Column(nullabletrue)]
  130.     private ?bool $synced false;
  131.     #[Groups(['pre_order_product:read''pre_order:read''pre_order:write'])]
  132.     #[ORM\ManyToOne(inversedBy'preOrders')]
  133.     private ?User $client null;
  134.     #[Groups(['pre_order_product:read''pre_order:read''pre_order:write'])]
  135.     #[ORM\ManyToOne(inversedBy'ManagerPreOrders')]
  136.     private ?User $manager null;
  137.     #[Groups(['pre_order_product:read''pre_order:read''pre_order:write''order:read''order_product:read''load_invoice:read'])]
  138.     #[ORM\ManyToMany(targetEntityFees::class, mappedBy'pre_orders')]
  139.     private Collection $fees;
  140.     #[Groups(['pre_order_product:read''pre_order:read''pre_order:write''order:read''order_product:read''load_invoice:read'])]
  141.     #[ORM\ManyToOne(inversedBy'pre_orders')]
  142.     private ?Coupons $coupons null;
  143.     #[Groups(['pre_order:read''pre_order:write'])]
  144.     #[ORM\ManyToOne(inversedBy'preOrders')]
  145.     private ?AccountAddress $address null;
  146.     public function __construct()
  147.     {
  148.         $this->preOrderProducts = new ArrayCollection();
  149.         $this->orders = new ArrayCollection();
  150.         $this->loadInvoices = new ArrayCollection();
  151.         $this->accepteds = new ArrayCollection();
  152.         $this->loadInvoiceProducts = new ArrayCollection();
  153.         $this->fees = new ArrayCollection();
  154.     }
  155.     public function getId(): ?int
  156.     {
  157.         return $this->id;
  158.     }
  159.     public function getName(): ?string
  160.     {
  161.         return $this->name;
  162.     }
  163.     public function setName(?string $name): self
  164.     {
  165.         $this->name $name;
  166.         return $this;
  167.     }
  168.     public function getDateEntered(): ?\DateTimeInterface
  169.     {
  170.         return $this->dateEntered;
  171.     }
  172.     public function setDateEntered(?\DateTimeInterface $dateEntered): self
  173.     {
  174.         $this->dateEntered $dateEntered;
  175.         return $this;
  176.     }
  177.     public function getDateModified(): ?\DateTimeInterface
  178.     {
  179.         return $this->dateModified;
  180.     }
  181.     public function setDateModified(?\DateTimeInterface $dateModified): self
  182.     {
  183.         $this->dateModified $dateModified;
  184.         return $this;
  185.     }
  186.     public function getCreatedBy(): ?User
  187.     {
  188.         return $this->createdBy;
  189.     }
  190.     public function setCreatedBy(?User $createdBy): self
  191.     {
  192.         $this->createdBy $createdBy;
  193.         return $this;
  194.     }
  195.     public function getModifiedUser(): ?User
  196.     {
  197.         return $this->modifiedUser;
  198.     }
  199.     public function setModifiedUser(?User $modifiedUser): self
  200.     {
  201.         $this->modifiedUser $modifiedUser;
  202.         return $this;
  203.     }
  204.     public function getDateOrder(): ?\DateTimeInterface
  205.     {
  206.         return $this->dateOrder;
  207.     }
  208.     public function setDateOrder(?\DateTimeInterface $dateOrder): self
  209.     {
  210.         $this->dateOrder $dateOrder;
  211.         return $this;
  212.     }
  213.     public function getStatus(): ?string
  214.     {
  215.         return $this->status;
  216.     }
  217.     public function setStatus(?string $status): self
  218.     {
  219.         $this->status $status;
  220.         return $this;
  221.     }
  222.     public function getDescription(): ?string
  223.     {
  224.         return $this->description;
  225.     }
  226.     public function setDescription(?string $description): self
  227.     {
  228.         $this->description $description;
  229.         return $this;
  230.     }
  231.     public function getPaymentMethod(): ?string
  232.     {
  233.         return $this->paymentMethod;
  234.     }
  235.     public function setPaymentMethod(?string $paymentMethod): self
  236.     {
  237.         $this->paymentMethod $paymentMethod;
  238.         return $this;
  239.     }
  240.     public function getSumOrdered(): ?float
  241.     {
  242.         return $this->sumOrdered;
  243.     }
  244.     public function setSumOrdered(?float $sumOrdered): self
  245.     {
  246.         $this->sumOrdered $sumOrdered;
  247.         return $this;
  248.     }
  249.     public function getCurency(): ?string
  250.     {
  251.         return $this->curency;
  252.     }
  253.     public function setCurency(?string $curency): self
  254.     {
  255.         $this->curency $curency;
  256.         return $this;
  257.     }
  258.     public function getCurencyRate(): ?float
  259.     {
  260.         return $this->curencyRate;
  261.     }
  262.     public function setCurencyRate(?float $curencyRate): self
  263.     {
  264.         $this->curencyRate $curencyRate;
  265.         return $this;
  266.     }
  267.     public function getDiscountTotal(): ?float
  268.     {
  269.         return $this->discountTotal;
  270.     }
  271.     public function setDiscountTotal(?float $discountTotal): self
  272.     {
  273.         $this->discountTotal $discountTotal;
  274.         return $this;
  275.     }
  276.     public function getDiscountPercent(): ?int
  277.     {
  278.         return $this->discountPercent;
  279.     }
  280.     public function setDiscountPercent(?int $discountPercent): self
  281.     {
  282.         $this->discountPercent $discountPercent;
  283.         return $this;
  284.     }
  285.     public function getShippingAddressStreet(): ?string
  286.     {
  287.         return $this->shippingAddressStreet;
  288.     }
  289.     public function setShippingAddressStreet(?string $shippingAddressStreet): self
  290.     {
  291.         $this->shippingAddressStreet $shippingAddressStreet;
  292.         return $this;
  293.     }
  294.     public function getShippingAddressCity(): ?string
  295.     {
  296.         return $this->shippingAddressCity;
  297.     }
  298.     public function setShippingAddressCity(?string $shippingAddressCity): self
  299.     {
  300.         $this->shippingAddressCity $shippingAddressCity;
  301.         return $this;
  302.     }
  303.     public function getShippingAddressBuilding(): ?string
  304.     {
  305.         return $this->shippingAddressBuilding;
  306.     }
  307.     public function setShippingAddressBuilding(?string $shippingAddressBuilding): self
  308.     {
  309.         $this->shippingAddressBuilding $shippingAddressBuilding;
  310.         return $this;
  311.     }
  312.     public function getShippingAddressPost(): ?string
  313.     {
  314.         return $this->shippingAddressPost;
  315.     }
  316.     public function setShippingAddressPost(?string $shippingAddressPost): self
  317.     {
  318.         $this->shippingAddressPost $shippingAddressPost;
  319.         return $this;
  320.     }
  321.     public function getShippingAddressCountry(): ?string
  322.     {
  323.         return $this->shippingAddressCountry;
  324.     }
  325.     public function setShippingAddressCountry(?string $shippingAddressCountry): self
  326.     {
  327.         $this->shippingAddressCountry $shippingAddressCountry;
  328.         return $this;
  329.     }
  330.     public function getShippingAddressDate(): ?string
  331.     {
  332.         return $this->shippingAddressDate;
  333.     }
  334.     public function setShippingAddressDate(?string $shippingAddressDate): self
  335.     {
  336.         $this->shippingAddressDate $shippingAddressDate;
  337.         return $this;
  338.     }
  339.     public function getCopyOrderId(): ?int
  340.     {
  341.         return $this->copyOrderId;
  342.     }
  343.     public function setCopyOrderId(?int $copyOrderId): self
  344.     {
  345.         $this->copyOrderId $copyOrderId;
  346.         return $this;
  347.     }
  348.     /**
  349.      * @return Collection<int, PreOrderProduct>
  350.      */
  351.     public function getPreOrderProducts(): Collection
  352.     {
  353.         return $this->preOrderProducts;
  354.     }
  355.     public function addPreOrderProduct(PreOrderProduct $preOrderProduct): self
  356.     {
  357.         if (!$this->preOrderProducts->contains($preOrderProduct)) {
  358.             $this->preOrderProducts->add($preOrderProduct);
  359.             $preOrderProduct->setPreOrder($this);
  360.         }
  361.         return $this;
  362.     }
  363.     public function removePreOrderProduct(PreOrderProduct $preOrderProduct): self
  364.     {
  365.         if ($this->preOrderProducts->removeElement($preOrderProduct)) {
  366.             // set the owning side to null (unless already changed)
  367.             if ($preOrderProduct->getPreOrder() === $this) {
  368.                 $preOrderProduct->setPreOrder(null);
  369.             }
  370.         }
  371.         return $this;
  372.     }
  373.     /**
  374.      * @return Collection<int, Orders>
  375.      */
  376.     public function getOrders(): Collection
  377.     {
  378.         return $this->orders;
  379.     }
  380.     public function addOrder(Orders $order): self
  381.     {
  382.         if (!$this->orders->contains($order)) {
  383.             $this->orders->add($order);
  384.             $order->setPreOrder($this);
  385.         }
  386.         return $this;
  387.     }
  388.     public function removeOrder(Orders $order): self
  389.     {
  390.         if ($this->orders->removeElement($order)) {
  391.             // set the owning side to null (unless already changed)
  392.             if ($order->getPreOrder() === $this) {
  393.                 $order->setPreOrder(null);
  394.             }
  395.         }
  396.         return $this;
  397.     }
  398.     /**
  399.      * @return Collection<int, LoadInvoice>
  400.      */
  401.     public function getLoadInvoices(): Collection
  402.     {
  403.         return $this->loadInvoices;
  404.     }
  405.     public function addLoadInvoice(LoadInvoice $loadInvoice): self
  406.     {
  407.         if (!$this->loadInvoices->contains($loadInvoice)) {
  408.             $this->loadInvoices->add($loadInvoice);
  409.             $loadInvoice->setPreOrder($this);
  410.         }
  411.         return $this;
  412.     }
  413.     public function removeLoadInvoice(LoadInvoice $loadInvoice): self
  414.     {
  415.         if ($this->loadInvoices->removeElement($loadInvoice)) {
  416.             // set the owning side to null (unless already changed)
  417.             if ($loadInvoice->getPreOrder() === $this) {
  418.                 $loadInvoice->setPreOrder(null);
  419.             }
  420.         }
  421.         return $this;
  422.     }
  423.     /**
  424.      * @return Collection<int, Accepted>
  425.      */
  426.     public function getAccepteds(): Collection
  427.     {
  428.         return $this->accepteds;
  429.     }
  430.     public function addAccepted(Accepted $accepted): self
  431.     {
  432.         if (!$this->accepteds->contains($accepted)) {
  433.             $this->accepteds->add($accepted);
  434.             $accepted->setPreOrder($this);
  435.         }
  436.         return $this;
  437.     }
  438.     public function removeAccepted(Accepted $accepted): self
  439.     {
  440.         if ($this->accepteds->removeElement($accepted)) {
  441.             // set the owning side to null (unless already changed)
  442.             if ($accepted->getPreOrder() === $this) {
  443.                 $accepted->setPreOrder(null);
  444.             }
  445.         }
  446.         return $this;
  447.     }
  448.     /**
  449.      * @return Collection<int, LoadInvoiceProduct>
  450.      */
  451.     public function getLoadInvoiceProducts(): Collection
  452.     {
  453.         return $this->loadInvoiceProducts;
  454.     }
  455.     public function addLoadInvoiceProduct(LoadInvoiceProduct $loadInvoiceProduct): self
  456.     {
  457.         if (!$this->loadInvoiceProducts->contains($loadInvoiceProduct)) {
  458.             $this->loadInvoiceProducts->add($loadInvoiceProduct);
  459.             $loadInvoiceProduct->setPreOrderProduct($this);
  460.         }
  461.         return $this;
  462.     }
  463.     public function removeLoadInvoiceProduct(LoadInvoiceProduct $loadInvoiceProduct): self
  464.     {
  465.         if ($this->loadInvoiceProducts->removeElement($loadInvoiceProduct)) {
  466.             // set the owning side to null (unless already changed)
  467.             if ($loadInvoiceProduct->getPreOrderProduct() === $this) {
  468.                 $loadInvoiceProduct->setPreOrderProduct(null);
  469.             }
  470.         }
  471.         return $this;
  472.     }
  473.     public function getAccount(): ?Accounts
  474.     {
  475.         return $this->account;
  476.     }
  477.     public function setAccount(?Accounts $account): self
  478.     {
  479.         $this->account $account;
  480.         return $this;
  481.     }
  482.     public function isSynced(): ?bool
  483.     {
  484.         return $this->synced;
  485.     }
  486.     public function setSynced(?bool $synced): self
  487.     {
  488.         $this->synced $synced;
  489.         return $this;
  490.     }
  491.     #[ORM\PrePersist]
  492.     public function setCreatedAtValue(): void
  493.     {
  494.         $this->dateEntered = new \DateTime();
  495.     }
  496.     // #[ORM\PrePersist]
  497.     #[ORM\PreUpdate]
  498.     public function setUpdatedAtValue(): void
  499.     {
  500.         $this->dateModified = new \DateTime();
  501.     }
  502.     public function getClient(): ?User
  503.     {
  504.         return $this->client;
  505.     }
  506.     public function setClient(?User $client): self
  507.     {
  508.         $this->client $client;
  509.         return $this;
  510.     }
  511.     public function getManager(): ?User
  512.     {
  513.         return $this->manager;
  514.     }
  515.     public function setManager(?User $manager): self
  516.     {
  517.         $this->manager $manager;
  518.         return $this;
  519.     }
  520.     /**
  521.      * @return Collection<int, Fees>
  522.      */
  523.     public function getFees(): Collection
  524.     {
  525.         return $this->fees;
  526.     }
  527.     public function addFee(Fees $fee): self
  528.     {
  529.         if (!$this->fees->contains($fee)) {
  530.             $this->fees->add($fee);
  531.             $fee->addPreOrder($this);
  532.         }
  533.         return $this;
  534.     }
  535.     public function removeFee(Fees $fee): self
  536.     {
  537.         if ($this->fees->removeElement($fee)) {
  538.             $fee->removePreOrder($this);
  539.         }
  540.         return $this;
  541.     }
  542.     public function getCoupons(): ?Coupons
  543.     {
  544.         return $this->coupons;
  545.     }
  546.     public function setCoupons(?Coupons $coupons): self
  547.     {
  548.         $this->coupons $coupons;
  549.         return $this;
  550.     }
  551.     public function getAddress(): ?AccountAddress
  552.     {
  553.         return $this->address;
  554.     }
  555.     public function setAddress(?AccountAddress $address): self
  556.     {
  557.         $this->address $address;
  558.         return $this;
  559.     }
  560. }