src/Entity/LoadInvoice.php line 34

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