<?php
namespace App\Entity;
use ApiPlatform\Metadata\ApiResource;
use App\Repository\LoadInvoiceRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
use Symfony\Component\Serializer\Annotation\MaxDepth;
#[ORM\Entity(repositoryClass: LoadInvoiceRepository::class)]
#[ApiResource(
normalizationContext: ['groups' => ['load_invoice:read']],
denormalizationContext: ['groups' => ['load_invoice:write']],
order: ['id' => 'DESC'],
)]
#[ApiFilter(
SearchFilter::class,
properties: [
'code1c' => 'exact',
'orders.account.user' => 'exact',
'orders.account.manager' => 'exact',
]
)]
class LoadInvoice
{
#[Groups(['load_invoice:read', 'load_invoice:write', 'order:read', 'pre_order:read'])]
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[Groups(['load_invoice:read', 'load_invoice:write'])]
#[ORM\ManyToOne]
private ?User $modified_user = null;
#[Groups(['load_invoice:read', 'load_invoice:write'])]
#[ORM\ManyToOne]
private ?User $created_by = null;
#[Groups(['load_invoice:read', 'load_invoice:write', 'order:read', 'pre_order:read'])]
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $date_entered = null;
#[Groups(['load_invoice:read', 'load_invoice:write'])]
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $date_modified = null;
#[Groups(['load_invoice:read', 'load_invoice:write', 'order:read', 'pre_order:read'])]
#[ORM\Column(length: 255, nullable: true)]
private ?string $name = null;
#[Groups(['load_invoice:read', 'load_invoice:write', 'order:read', 'pre_order:read'])]
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $description = null;
#[Groups(['load_invoice:read', 'load_invoice:write', 'order:read', 'pre_order:read'])]
#[ORM\Column(length: 20, nullable: true)]
private ?string $code_1c = null;
#[MaxDepth(1)]
#[Groups(['load_invoice:read', 'load_invoice:write', 'order:read', 'pre_order:read'])]
#[ORM\ManyToOne]
private ?User $manager = null;
#[MaxDepth(1)]
#[Groups(['load_invoice:read', 'load_invoice:write', 'order:read', 'pre_order:read'])]
#[ORM\ManyToOne(inversedBy: 'loadInvoices')]
private ?User $client = null;
#[Groups(['load_invoice:read', 'load_invoice:write', 'order:read', 'pre_order:read'])]
#[ORM\Column(length: 100, nullable: true)]
private ?string $car = null;
#[Groups(['load_invoice:read', 'load_invoice:write', 'order:read', 'pre_order:read'])]
#[ORM\Column(length: 100, nullable: true)]
private ?string $route = null;
#[Groups(['load_invoice:read', 'load_invoice:write', 'order:read', 'pre_order:read'])]
#[ORM\Column(length: 100, nullable: true)]
private ?string $run = null;
#[Groups(['load_invoice:read', 'load_invoice:write', 'order:read', 'pre_order:read'])]
#[ORM\Column(length: 100, nullable: true)]
private ?string $driver = null;
#[Groups(['load_invoice:read', 'load_invoice:write', 'order:read', 'pre_order:read'])]
#[ORM\Column(length: 100, nullable: true)]
private ?string $forwarder = null;
#[Groups(['load_invoice:read', 'load_invoice:write', 'order:read', 'pre_order:read'])]
#[ORM\Column(nullable: true)]
private ?float $sum_transportation = null;
#[Groups(['load_invoice:read', 'load_invoice:write', 'order:read', 'pre_order:read'])]
#[ORM\Column(nullable: true)]
private ?float $sum_transportation_km = null;
#[Groups(['load_invoice:read', 'load_invoice:write', 'order:read', 'pre_order:read'])]
#[ORM\Column(nullable: true)]
private ?float $total_sum_transportation = null;
#[Groups(['load_invoice:read', 'load_invoice:write', 'order:read', 'pre_order:read'])]
#[ORM\Column(length: 100, nullable: true)]
private ?string $carrier = null;
#[MaxDepth(1)]
#[Groups(['load_invoice:read', 'load_invoice:write'])]
#[ORM\ManyToOne]
private ?User $assigned_user = null;
#[Groups(['load_invoice:read', 'load_invoice:write', 'order:read', 'pre_order:read'])]
#[ORM\Column(nullable: true)]
private ?bool $pickup = null;
#[Groups(['load_invoice:read', 'load_invoice:write', 'order:read', 'pre_order:read'])]
#[ORM\Column(length: 100, nullable: true)]
private ?string $status = null;
#[MaxDepth(4)]
#[Groups(['load_invoice:read', 'load_invoice:write'])]
#[ORM\ManyToOne(inversedBy: 'loadInvoices')]
private ?PreOrder $pre_order = null;
#[Groups(['load_invoice:read', 'load_invoice:write'])]
#[ORM\OneToMany(mappedBy: 'load_invoice', targetEntity: Accepted::class)]
private Collection $accepteds;
#[MaxDepth(4)]
#[Groups(['load_invoice:read', 'load_invoice:write'])]
#[ORM\ManyToMany(targetEntity: Orders::class, mappedBy: 'loadInvoice')]
private Collection $orders;
#[Groups(['load_invoice:read', 'load_invoice:write'])]
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $dateStart = null;
#[Groups(['load_invoice:read', 'load_invoice:write', 'order:read', 'pre_order:read'])]
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $dateEnd = null;
#[MaxDepth(4)]
#[Groups(['load_invoice:read', 'load_invoice:write', 'order:read', 'pre_order:read'])]
#[ORM\OneToMany(mappedBy: 'loadInvoice', targetEntity: LoadInvoiceProduct::class, cascade:['persist'])]
private Collection $loadInvoiceProducts;
#[MaxDepth(1)]
#[Groups(['load_invoice:read', 'load_invoice:write', 'order:read', 'pre_order:read'])]
#[ORM\ManyToOne(inversedBy: 'loadInvoices')]
private ?Accounts $account = null;
public function __construct()
{
$this->orders = new ArrayCollection();
$this->accepteds = new ArrayCollection();
$this->loadInvoiceProducts = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getModifiedUser(): ?User
{
return $this->modified_user;
}
public function setModifiedUser(?User $modified_user): self
{
$this->modified_user = $modified_user;
return $this;
}
public function getCreatedBy(): ?User
{
return $this->created_by;
}
public function setCreatedBy(?User $created_by): self
{
$this->created_by = $created_by;
return $this;
}
public function getDateEntered(): ?\DateTimeInterface
{
return $this->date_entered;
}
public function setDateEntered(?\DateTimeInterface $date_entered): self
{
$this->date_entered = $date_entered;
return $this;
}
public function getDateModified(): ?\DateTimeInterface
{
return $this->date_modified;
}
public function setDateModified(?\DateTimeInterface $date_modified): self
{
$this->date_modified = $date_modified;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): self
{
$this->name = $name;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getCode1c(): ?string
{
return $this->code_1c;
}
public function setCode1c(?string $code_1c): self
{
$this->code_1c = $code_1c;
return $this;
}
public function getManager(): ?User
{
return $this->manager;
}
public function setManager(?User $manager): self
{
$this->manager = $manager;
return $this;
}
public function getClient(): ?User
{
return $this->client;
}
public function setClient(?User $client): self
{
$this->client = $client;
return $this;
}
public function getCar(): ?string
{
return $this->car;
}
public function setCar(?string $car): self
{
$this->car = $car;
return $this;
}
public function getRoute(): ?string
{
return $this->route;
}
public function setRoute(?string $route): self
{
$this->route = $route;
return $this;
}
public function getRun(): ?string
{
return $this->run;
}
public function setRun(?string $run): self
{
$this->run = $run;
return $this;
}
public function getDriver(): ?string
{
return $this->driver;
}
public function setDriver(?string $driver): self
{
$this->driver = $driver;
return $this;
}
public function getForwarder(): ?string
{
return $this->forwarder;
}
public function setForwarder(?string $forwarder): self
{
$this->forwarder = $forwarder;
return $this;
}
public function getSumTransportation(): ?float
{
return $this->sum_transportation;
}
public function setSumTransportation(?float $sum_transportation): self
{
$this->sum_transportation = $sum_transportation;
return $this;
}
public function getSumTransportationKm(): ?float
{
return $this->sum_transportation_km;
}
public function setSumTransportationKm(?float $sum_transportation_km): self
{
$this->sum_transportation_km = $sum_transportation_km;
return $this;
}
public function getTotalSumTransportation(): ?float
{
return $this->total_sum_transportation;
}
public function setTotalSumTransportation(?float $total_sum_transportation): self
{
$this->total_sum_transportation = $total_sum_transportation;
return $this;
}
public function getCarrier(): ?string
{
return $this->carrier;
}
public function setCarrier(?string $carrier): self
{
$this->carrier = $carrier;
return $this;
}
public function getAssignedUser(): ?User
{
return $this->assigned_user;
}
public function setAssignedUser(?User $assigned_user): self
{
$this->assigned_user = $assigned_user;
return $this;
}
public function isPickup(): ?bool
{
return $this->pickup;
}
public function setPickup(?bool $pickup): self
{
$this->pickup = $pickup;
return $this;
}
public function getStatus(): ?string
{
return $this->status;
}
public function setStatus(?string $status): self
{
$this->status = $status;
return $this;
}
/**
* @return Collection<int, Orders>
*/
// public function getOrders(): Collection
// {
// return $this->orders;
// }
// public function addOrder(Orders $order): self
// {
// if (!$this->orders->contains($order)) {
// $this->orders->add($order);
// $order->setLoadInvoice($this);
// }
// return $this;
// }
// public function removeOrder(Orders $order): self
// {
// if ($this->orders->removeElement($order)) {
// // set the owning side to null (unless already changed)
// if ($order->getLoadInvoice() === $this) {
// $order->setLoadInvoice(null);
// }
// }
// return $this;
// }
public function getPreOrder(): ?PreOrder
{
return $this->pre_order;
}
public function setPreOrder(?PreOrder $pre_order): self
{
$this->pre_order = $pre_order;
return $this;
}
// public function getOrder(): ?Orders
// {
// return $this->order;
// }
// public function setOrder(?Orders $order): self
// {
// $this->order = $order;
// return $this;
// }
/**
* @return Collection<int, Accepted>
*/
public function getAccepteds(): Collection
{
return $this->accepteds;
}
public function addAccepted(Accepted $accepted): self
{
if (!$this->accepteds->contains($accepted)) {
$this->accepteds->add($accepted);
$accepted->setLoadInvoice($this);
}
return $this;
}
public function removeAccepted(Accepted $accepted): self
{
if ($this->accepteds->removeElement($accepted)) {
// set the owning side to null (unless already changed)
if ($accepted->getLoadInvoice() === $this) {
$accepted->setLoadInvoice(null);
}
}
return $this;
}
/**
* @return Collection<int, Orders>
*/
public function getOrders(): Collection
{
return $this->orders;
}
public function addOrder(Orders $order): self
{
if (!$this->orders->contains($order)) {
$this->orders->add($order);
$order->addLoadInvoice($this);
}
return $this;
}
public function removeOrder(Orders $order): self
{
if ($this->orders->removeElement($order)) {
$order->removeLoadInvoice($this);
}
return $this;
}
public function getDateStart(): ?\DateTimeInterface
{
return $this->dateStart;
}
public function setDateStart(?\DateTimeInterface $dateStart): self
{
$this->dateStart = $dateStart;
return $this;
}
public function getDateEnd(): ?\DateTimeInterface
{
return $this->dateEnd;
}
public function setDateEnd(?\DateTimeInterface $dateEnd): self
{
$this->dateEnd = $dateEnd;
return $this;
}
/**
* @return Collection<int, LoadInvoiceProduct>
*/
public function getLoadInvoiceProducts(): Collection
{
return $this->loadInvoiceProducts;
}
public function addLoadInvoiceProduct(LoadInvoiceProduct $loadInvoiceProduct): self
{
if (!$this->loadInvoiceProducts->contains($loadInvoiceProduct)) {
$this->loadInvoiceProducts->add($loadInvoiceProduct);
$loadInvoiceProduct->setLoadInvoice($this);
}
return $this;
}
public function removeLoadInvoiceProduct(LoadInvoiceProduct $loadInvoiceProduct): self
{
if ($this->loadInvoiceProducts->removeElement($loadInvoiceProduct)) {
// set the owning side to null (unless already changed)
if ($loadInvoiceProduct->getLoadInvoice() === $this) {
$loadInvoiceProduct->setLoadInvoice(null);
}
}
return $this;
}
public function getAccount(): ?Accounts
{
return $this->account;
}
public function setAccount(?Accounts $account): self
{
$this->account = $account;
return $this;
}
}