src/Entity/PreOrder.php line 42

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