src/Entity/LoadInvoice.php line 31

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\LoadInvoiceRepository;
  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 Symfony\Component\Serializer\Annotation\MaxDepth;
  13. #[ORM\Entity(repositoryClassLoadInvoiceRepository::class)]
  14. #[ApiResource(
  15.     normalizationContext: ['groups' => ['load_invoice:read']],
  16.     denormalizationContext: ['groups' => ['load_invoice:write']],
  17.     order: ['id' => 'DESC'],
  18. )]
  19. #[ApiFilter(
  20.     SearchFilter::class, 
  21.     properties: [
  22.         'code1c' => 'exact'
  23.         'orders.account.user' => 'exact',
  24.         'orders.account.manager' => 'exact',
  25.     ]
  26. )]
  27. class LoadInvoice
  28. {
  29.     #[Groups(['load_invoice:read''load_invoice:write''order:read''pre_order:read'])]
  30.     #[ORM\Id]
  31.     #[ORM\GeneratedValue]
  32.     #[ORM\Column]
  33.     private ?int $id null;
  34.     #[Groups(['load_invoice:read''load_invoice:write'])]
  35.     #[ORM\ManyToOne]
  36.     private ?User $modified_user null;
  37.     #[Groups(['load_invoice:read''load_invoice:write'])]
  38.     #[ORM\ManyToOne]
  39.     private ?User $created_by null;
  40.     #[Groups(['load_invoice:read''load_invoice:write''order:read''pre_order:read'])]
  41.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  42.     private ?\DateTimeInterface $date_entered null;
  43.     #[Groups(['load_invoice:read''load_invoice:write'])]
  44.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  45.     private ?\DateTimeInterface $date_modified null;
  46.     #[Groups(['load_invoice:read''load_invoice:write''order:read''pre_order:read'])]
  47.     #[ORM\Column(length255nullabletrue)]
  48.     private ?string $name null;
  49.     #[Groups(['load_invoice:read''load_invoice:write''order:read''pre_order:read'])]
  50.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  51.     private ?string $description null;
  52.     #[Groups(['load_invoice:read''load_invoice:write''order:read''pre_order:read'])]
  53.     #[ORM\Column(length20nullabletrue)]
  54.     private ?string $code_1c null;
  55.     #[MaxDepth(1)]
  56.     #[Groups(['load_invoice:read''load_invoice:write''order:read''pre_order:read'])]
  57.     #[ORM\ManyToOne]
  58.     private ?User $manager null;
  59.     #[MaxDepth(1)]
  60.     #[Groups(['load_invoice:read''load_invoice:write''order:read''pre_order:read'])]
  61.     #[ORM\ManyToOne(inversedBy'loadInvoices')]
  62.     private ?User $client null;
  63.     #[Groups(['load_invoice:read''load_invoice:write''order:read''pre_order:read'])]
  64.     #[ORM\Column(length100nullabletrue)]
  65.     private ?string $car null;
  66.     #[Groups(['load_invoice:read''load_invoice:write''order:read''pre_order:read'])]
  67.     #[ORM\Column(length100nullabletrue)]
  68.     private ?string $route null;
  69.     #[Groups(['load_invoice:read''load_invoice:write''order:read''pre_order:read'])]
  70.     #[ORM\Column(length100nullabletrue)]
  71.     private ?string $run null;
  72.     #[Groups(['load_invoice:read''load_invoice:write''order:read''pre_order:read'])]
  73.     #[ORM\Column(length100nullabletrue)]
  74.     private ?string $driver null;
  75.     #[Groups(['load_invoice:read''load_invoice:write''order:read''pre_order:read'])]
  76.     #[ORM\Column(length100nullabletrue)]
  77.     private ?string $forwarder null;
  78.     #[Groups(['load_invoice:read''load_invoice:write''order:read''pre_order:read'])]
  79.     #[ORM\Column(nullabletrue)]
  80.     private ?float $sum_transportation null;
  81.     #[Groups(['load_invoice:read''load_invoice:write''order:read''pre_order:read'])]
  82.     #[ORM\Column(nullabletrue)]
  83.     private ?float $sum_transportation_km null;
  84.     #[Groups(['load_invoice:read''load_invoice:write''order:read''pre_order:read'])]
  85.     #[ORM\Column(nullabletrue)]
  86.     private ?float $total_sum_transportation null;
  87.     #[Groups(['load_invoice:read''load_invoice:write''order:read''pre_order:read'])]
  88.     #[ORM\Column(length100nullabletrue)]
  89.     private ?string $carrier null;
  90.     #[MaxDepth(1)]
  91.     #[Groups(['load_invoice:read''load_invoice:write'])]
  92.     #[ORM\ManyToOne]
  93.     private ?User $assigned_user null;
  94.     #[Groups(['load_invoice:read''load_invoice:write''order:read''pre_order:read'])]
  95.     #[ORM\Column(nullabletrue)]
  96.     private ?bool $pickup null;
  97.     #[Groups(['load_invoice:read''load_invoice:write''order:read''pre_order:read'])]
  98.     #[ORM\Column(length100nullabletrue)]
  99.     private ?string $status null;
  100.     #[MaxDepth(4)]
  101.     #[Groups(['load_invoice:read''load_invoice:write'])]
  102.     #[ORM\ManyToOne(inversedBy'loadInvoices')]
  103.     private ?PreOrder $pre_order null;
  104.     #[Groups(['load_invoice:read''load_invoice:write'])]
  105.     #[ORM\OneToMany(mappedBy'load_invoice'targetEntityAccepted::class)]
  106.     private Collection $accepteds;
  107.     #[MaxDepth(4)]
  108.     #[Groups(['load_invoice:read''load_invoice:write'])]
  109.     #[ORM\ManyToMany(targetEntityOrders::class, mappedBy'loadInvoice')]
  110.     private Collection $orders;
  111.     #[Groups(['load_invoice:read''load_invoice:write'])]
  112.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  113.     private ?\DateTimeInterface $dateStart null;
  114.     #[Groups(['load_invoice:read''load_invoice:write''order:read''pre_order:read'])]
  115.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  116.     private ?\DateTimeInterface $dateEnd null;
  117.     #[MaxDepth(4)]
  118.     #[Groups(['load_invoice:read''load_invoice:write''order:read''pre_order:read'])]
  119.     #[ORM\OneToMany(mappedBy'loadInvoice'targetEntityLoadInvoiceProduct::class, cascade:['persist'])]
  120.     private Collection $loadInvoiceProducts;
  121.     #[MaxDepth(1)]
  122.     #[Groups(['load_invoice:read''load_invoice:write''order:read''pre_order:read'])]
  123.     #[ORM\ManyToOne(inversedBy'loadInvoices')]
  124.     private ?Accounts $account null;
  125.     public function __construct()
  126.     {
  127.         $this->orders = new ArrayCollection();
  128.         $this->accepteds = new ArrayCollection();
  129.         $this->loadInvoiceProducts = new ArrayCollection();
  130.     }
  131.     public function getId(): ?int
  132.     {
  133.         return $this->id;
  134.     }
  135.     public function getModifiedUser(): ?User
  136.     {
  137.         return $this->modified_user;
  138.     }
  139.     public function setModifiedUser(?User $modified_user): self
  140.     {
  141.         $this->modified_user $modified_user;
  142.         return $this;
  143.     }
  144.     public function getCreatedBy(): ?User
  145.     {
  146.         return $this->created_by;
  147.     }
  148.     public function setCreatedBy(?User $created_by): self
  149.     {
  150.         $this->created_by $created_by;
  151.         return $this;
  152.     }
  153.     public function getDateEntered(): ?\DateTimeInterface
  154.     {
  155.         return $this->date_entered;
  156.     }
  157.     public function setDateEntered(?\DateTimeInterface $date_entered): self
  158.     {
  159.         $this->date_entered $date_entered;
  160.         return $this;
  161.     }
  162.     public function getDateModified(): ?\DateTimeInterface
  163.     {
  164.         return $this->date_modified;
  165.     }
  166.     public function setDateModified(?\DateTimeInterface $date_modified): self
  167.     {
  168.         $this->date_modified $date_modified;
  169.         return $this;
  170.     }
  171.     public function getName(): ?string
  172.     {
  173.         return $this->name;
  174.     }
  175.     public function setName(?string $name): self
  176.     {
  177.         $this->name $name;
  178.         return $this;
  179.     }
  180.     public function getDescription(): ?string
  181.     {
  182.         return $this->description;
  183.     }
  184.     public function setDescription(?string $description): self
  185.     {
  186.         $this->description $description;
  187.         return $this;
  188.     }
  189.     public function getCode1c(): ?string
  190.     {
  191.         return $this->code_1c;
  192.     }
  193.     public function setCode1c(?string $code_1c): self
  194.     {
  195.         $this->code_1c $code_1c;
  196.         return $this;
  197.     }
  198.     public function getManager(): ?User
  199.     {
  200.         return $this->manager;
  201.     }
  202.     public function setManager(?User $manager): self
  203.     {
  204.         $this->manager $manager;
  205.         return $this;
  206.     }
  207.     public function getClient(): ?User
  208.     {
  209.         return $this->client;
  210.     }
  211.     public function setClient(?User $client): self
  212.     {
  213.         $this->client $client;
  214.         return $this;
  215.     }
  216.     public function getCar(): ?string
  217.     {
  218.         return $this->car;
  219.     }
  220.     public function setCar(?string $car): self
  221.     {
  222.         $this->car $car;
  223.         return $this;
  224.     }
  225.     public function getRoute(): ?string
  226.     {
  227.         return $this->route;
  228.     }
  229.     public function setRoute(?string $route): self
  230.     {
  231.         $this->route $route;
  232.         return $this;
  233.     }
  234.     public function getRun(): ?string
  235.     {
  236.         return $this->run;
  237.     }
  238.     public function setRun(?string $run): self
  239.     {
  240.         $this->run $run;
  241.         return $this;
  242.     }
  243.     public function getDriver(): ?string
  244.     {
  245.         return $this->driver;
  246.     }
  247.     public function setDriver(?string $driver): self
  248.     {
  249.         $this->driver $driver;
  250.         return $this;
  251.     }
  252.     public function getForwarder(): ?string
  253.     {
  254.         return $this->forwarder;
  255.     }
  256.     public function setForwarder(?string $forwarder): self
  257.     {
  258.         $this->forwarder $forwarder;
  259.         return $this;
  260.     }
  261.     public function getSumTransportation(): ?float
  262.     {
  263.         return $this->sum_transportation;
  264.     }
  265.     public function setSumTransportation(?float $sum_transportation): self
  266.     {
  267.         $this->sum_transportation $sum_transportation;
  268.         return $this;
  269.     }
  270.     public function getSumTransportationKm(): ?float
  271.     {
  272.         return $this->sum_transportation_km;
  273.     }
  274.     public function setSumTransportationKm(?float $sum_transportation_km): self
  275.     {
  276.         $this->sum_transportation_km $sum_transportation_km;
  277.         return $this;
  278.     }
  279.     public function getTotalSumTransportation(): ?float
  280.     {
  281.         return $this->total_sum_transportation;
  282.     }
  283.     public function setTotalSumTransportation(?float $total_sum_transportation): self
  284.     {
  285.         $this->total_sum_transportation $total_sum_transportation;
  286.         return $this;
  287.     }
  288.     public function getCarrier(): ?string
  289.     {
  290.         return $this->carrier;
  291.     }
  292.     public function setCarrier(?string $carrier): self
  293.     {
  294.         $this->carrier $carrier;
  295.         return $this;
  296.     }
  297.     public function getAssignedUser(): ?User
  298.     {
  299.         return $this->assigned_user;
  300.     }
  301.     public function setAssignedUser(?User $assigned_user): self
  302.     {
  303.         $this->assigned_user $assigned_user;
  304.         return $this;
  305.     }
  306.     public function isPickup(): ?bool
  307.     {
  308.         return $this->pickup;
  309.     }
  310.     public function setPickup(?bool $pickup): self
  311.     {
  312.         $this->pickup $pickup;
  313.         return $this;
  314.     }
  315.     public function getStatus(): ?string
  316.     {
  317.         return $this->status;
  318.     }
  319.     public function setStatus(?string $status): self
  320.     {
  321.         $this->status $status;
  322.         return $this;
  323.     }
  324.     /**
  325.      * @return Collection<int, Orders>
  326.      */
  327.     // public function getOrders(): Collection
  328.     // {
  329.     //     return $this->orders;
  330.     // }
  331.     // public function addOrder(Orders $order): self
  332.     // {
  333.     //     if (!$this->orders->contains($order)) {
  334.     //         $this->orders->add($order);
  335.     //         $order->setLoadInvoice($this);
  336.     //     }
  337.     //     return $this;
  338.     // }
  339.     // public function removeOrder(Orders $order): self
  340.     // {
  341.     //     if ($this->orders->removeElement($order)) {
  342.     //         // set the owning side to null (unless already changed)
  343.     //         if ($order->getLoadInvoice() === $this) {
  344.     //             $order->setLoadInvoice(null);
  345.     //         }
  346.     //     }
  347.     //     return $this;
  348.     // }
  349.     public function getPreOrder(): ?PreOrder
  350.     {
  351.         return $this->pre_order;
  352.     }
  353.     public function setPreOrder(?PreOrder $pre_order): self
  354.     {
  355.         $this->pre_order $pre_order;
  356.         return $this;
  357.     }
  358.     // public function getOrder(): ?Orders
  359.     // {
  360.     //     return $this->order;
  361.     // }
  362.     // public function setOrder(?Orders $order): self
  363.     // {
  364.     //     $this->order = $order;
  365.     //     return $this;
  366.     // }
  367.     /**
  368.      * @return Collection<int, Accepted>
  369.      */
  370.     public function getAccepteds(): Collection
  371.     {
  372.         return $this->accepteds;
  373.     }
  374.     public function addAccepted(Accepted $accepted): self
  375.     {
  376.         if (!$this->accepteds->contains($accepted)) {
  377.             $this->accepteds->add($accepted);
  378.             $accepted->setLoadInvoice($this);
  379.         }
  380.         return $this;
  381.     }
  382.     public function removeAccepted(Accepted $accepted): self
  383.     {
  384.         if ($this->accepteds->removeElement($accepted)) {
  385.             // set the owning side to null (unless already changed)
  386.             if ($accepted->getLoadInvoice() === $this) {
  387.                 $accepted->setLoadInvoice(null);
  388.             }
  389.         }
  390.         return $this;
  391.     }
  392.     /**
  393.      * @return Collection<int, Orders>
  394.      */
  395.     public function getOrders(): Collection
  396.     {
  397.         return $this->orders;
  398.     }
  399.     public function addOrder(Orders $order): self
  400.     {
  401.         if (!$this->orders->contains($order)) {
  402.             $this->orders->add($order);
  403.             $order->addLoadInvoice($this);
  404.         }
  405.         return $this;
  406.     }
  407.     public function removeOrder(Orders $order): self
  408.     {
  409.         if ($this->orders->removeElement($order)) {
  410.             $order->removeLoadInvoice($this);
  411.         }
  412.         return $this;
  413.     }
  414.     public function getDateStart(): ?\DateTimeInterface
  415.     {
  416.         return $this->dateStart;
  417.     }
  418.     public function setDateStart(?\DateTimeInterface $dateStart): self
  419.     {
  420.         $this->dateStart $dateStart;
  421.         return $this;
  422.     }
  423.     public function getDateEnd(): ?\DateTimeInterface
  424.     {
  425.         return $this->dateEnd;
  426.     }
  427.     public function setDateEnd(?\DateTimeInterface $dateEnd): self
  428.     {
  429.         $this->dateEnd $dateEnd;
  430.         return $this;
  431.     }
  432.     /**
  433.      * @return Collection<int, LoadInvoiceProduct>
  434.      */
  435.     public function getLoadInvoiceProducts(): Collection
  436.     {
  437.         return $this->loadInvoiceProducts;
  438.     }
  439.     public function addLoadInvoiceProduct(LoadInvoiceProduct $loadInvoiceProduct): self
  440.     {
  441.         if (!$this->loadInvoiceProducts->contains($loadInvoiceProduct)) {
  442.             $this->loadInvoiceProducts->add($loadInvoiceProduct);
  443.             $loadInvoiceProduct->setLoadInvoice($this);
  444.         }
  445.         return $this;
  446.     }
  447.     public function removeLoadInvoiceProduct(LoadInvoiceProduct $loadInvoiceProduct): self
  448.     {
  449.         if ($this->loadInvoiceProducts->removeElement($loadInvoiceProduct)) {
  450.             // set the owning side to null (unless already changed)
  451.             if ($loadInvoiceProduct->getLoadInvoice() === $this) {
  452.                 $loadInvoiceProduct->setLoadInvoice(null);
  453.             }
  454.         }
  455.         return $this;
  456.     }
  457.     public function getAccount(): ?Accounts
  458.     {
  459.         return $this->account;
  460.     }
  461.     public function setAccount(?Accounts $account): self
  462.     {
  463.         $this->account $account;
  464.         return $this;
  465.     }
  466. }