src/Entity/Delete/Consolidation.php line 26

  1. <?php
  2. namespace App\Entity\Delete;
  3. use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
  4. use ApiPlatform\Metadata\ApiFilter;
  5. use ApiPlatform\Metadata\ApiProperty;
  6. use ApiPlatform\Metadata\ApiResource;
  7. use App\Entity\Common as Common;
  8. use App\Entity\Identity\User;
  9. use DateTimeInterface;
  10. use Doctrine\Common\Collections\ArrayCollection;
  11. use Doctrine\Common\Collections\Collection;
  12. use Doctrine\DBAL\Types\Types;
  13. use Doctrine\ORM\Mapping as ORM;
  14. use Gedmo\Mapping\Annotation as Gedmo;
  15. use Symfony\Component\Validator\Constraints as Assert;
  16. #[ORM\Table(name'invoicing_batch')]
  17. #[ORM\Entity]
  18. #[ApiResource(routePrefix'/invoicing')]
  19. #[ApiFilter(SearchFilter::class, properties: [
  20.     'reference' => 'ipartial',
  21.     'status' => 'ipartial',
  22. ])]
  23. class Consolidation
  24. {
  25.     use Common\Blameable;
  26.     use Common\Trackable;
  27.     #[ORM\Id]
  28.     #[ORM\GeneratedValue(strategy'IDENTITY')]
  29.     #[ORM\SequenceGenerator(sequenceName'invoicing_batch_id_seq')]
  30.     #[ORM\Column(typeTypes::INTEGER)]
  31.     #[ApiProperty(identifierfalse)]
  32.     private int $id;
  33.     #[Gedmo\Slug(fields: ['reference'])]
  34.     #[ORM\Column(typeTypes::STRING)]
  35.     #[ApiProperty(identifiertrue)]
  36.     private string $slug;
  37.     #[Assert\NotBlank]
  38.     #[Assert\Type(typeTypes::STRING)]
  39.     #[ORM\Column(typeTypes::STRING)]
  40.     private ?string $reference null;
  41.     #[Assert\NotBlank]
  42.     #[Assert\Type(typeTypes::STRING)]
  43.     #[ORM\Column(typeTypes::STRING)]
  44.     private ?string $status null;
  45.     #[Assert\NotBlank]
  46.     #[Assert\Type(typeTypes::STRING)]
  47.     #[ORM\Column(typeTypes::STRINGnullabletrue)]
  48.     private ?string $departureCountryCode null;
  49.     #[Assert\NotBlank]
  50.     #[Assert\Type(typeTypes::STRING)]
  51.     #[ORM\Column(typeTypes::STRINGnullabletrue)]
  52.     private ?string $destination null;
  53.     #[Assert\NotBlank]
  54.     #[Assert\Type(typeTypes::STRING)]
  55.     #[ORM\Column(typeTypes::STRINGnullabletrue)]
  56.     private ?string $transportMode null;
  57.     #[Assert\NotBlank]
  58.     #[Assert\Type(typeTypes::STRING)]
  59.     #[ORM\Column(typeTypes::STRINGnullabletrue)]
  60.     private ?string $billNumber null;
  61.     #[Assert\NotBlank]
  62.     #[Assert\Type(typeTypes::STRING)]
  63.     #[ORM\Column(typeTypes::STRINGnullabletrue)]
  64.     private ?string $vessel null;
  65.     #[ORM\Column(typeTypes::DECIMALprecision18scale5nullabletrue)]
  66.     private ?string $emptyContainersWeight null;
  67.     #[Assert\NotNull]
  68.     #[ORM\Column(typeTypes::JSONnullabletrue)]
  69.     private ?array $containers = [];
  70.     #[Assert\Type(typeTypes::BOOLEAN)]
  71.     #[ORM\Column(typeTypes::BOOLEANnullabletrue)]
  72.     private ?bool $isDg null;
  73.     #[Assert\Type(typeTypes::BOOLEAN)]
  74.     #[ORM\Column(typeTypes::BOOLEANnullabletrue)]
  75.     private ?bool $isBreakBulk null;
  76.     #[Assert\Type(typeTypes::STRING)]
  77.     #[ORM\Column(typeTypes::STRINGnullabletrue)]
  78.     private ?string $tariffZone null;
  79.     #[Assert\Type(typeDateTimeInterface::class)]
  80.     #[ORM\Column(typeTypes::DATE_MUTABLEnullabletrue)]
  81.     private ?DateTimeInterface $atd null;
  82.     #[Assert\Type(typeDateTimeInterface::class)]
  83.     #[ORM\Column(typeTypes::DATE_MUTABLEnullabletrue)]
  84.     private ?DateTimeInterface $ata null;
  85.     /** @var Collection<int, Invoice> */
  86.     #[ORM\OneToMany(mappedBy'consolidation'targetEntityInvoice::class, cascade: ['persist''remove'])]
  87.     private Collection $invoices;
  88.     #[Gedmo\Blameable(on'create')]
  89.     #[ORM\ManyToOne(targetEntityUser::class)]
  90.     #[ORM\JoinColumn(name'created_by'nullabletrue)]
  91.     protected ?User $createdBy null;
  92.     public function __construct()
  93.     {
  94.         $this->invoices = new ArrayCollection();
  95.     }
  96.     public function getId(): ?int
  97.     {
  98.         return $this->id;
  99.     }
  100.     public function getSlug(): ?string
  101.     {
  102.         return $this->slug;
  103.     }
  104.     public function setSlug(string $slug): self
  105.     {
  106.         $this->slug $slug;
  107.         return $this;
  108.     }
  109.     public function getReference(): ?string
  110.     {
  111.         return $this->reference;
  112.     }
  113.     public function setReference(string $reference): self
  114.     {
  115.         $this->reference $reference;
  116.         return $this;
  117.     }
  118.     public function getDepartureCountryCode(): ?string
  119.     {
  120.         return $this->departureCountryCode;
  121.     }
  122.     public function setDepartureCountryCode(string $departureCountryCode): self
  123.     {
  124.         $this->departureCountryCode $departureCountryCode;
  125.         return $this;
  126.     }
  127.     public function getDestination(): ?string
  128.     {
  129.         return $this->destination;
  130.     }
  131.     public function setDestination(string $destination): self
  132.     {
  133.         $this->destination $destination;
  134.         return $this;
  135.     }
  136.     public function getStatus(): ?string
  137.     {
  138.         return $this->status;
  139.     }
  140.     public function setStatus(string $status): self
  141.     {
  142.         $this->status $status;
  143.         return $this;
  144.     }
  145.     public function getTransportMode(): ?string
  146.     {
  147.         return $this->transportMode;
  148.     }
  149.     public function setTransportMode(string $transportMode): self
  150.     {
  151.         $this->transportMode $transportMode;
  152.         return $this;
  153.     }
  154.     public function getBillNumber(): ?string
  155.     {
  156.         return $this->billNumber;
  157.     }
  158.     public function setBillNumber(string $billNumber): self
  159.     {
  160.         $this->billNumber $billNumber;
  161.         return $this;
  162.     }
  163.     public function getVessel(): ?string
  164.     {
  165.         return $this->vessel;
  166.     }
  167.     public function setVessel(string $vessel): self
  168.     {
  169.         $this->vessel $vessel;
  170.         return $this;
  171.     }
  172.     public function getEmptyContainersWeight(): ?string
  173.     {
  174.         return $this->emptyContainersWeight;
  175.     }
  176.     public function setEmptyContainersWeight(?string $emptyContainersWeight): self
  177.     {
  178.         $this->emptyContainersWeight $emptyContainersWeight;
  179.         return $this;
  180.     }
  181.     public function getContainers(): array
  182.     {
  183.         return $this->containers;
  184.     }
  185.     public function setContainers(?array $containers): self
  186.     {
  187.         $this->containers $containers;
  188.         return $this;
  189.     }
  190.     public function isDg(): ?bool
  191.     {
  192.         return $this->isDg;
  193.     }
  194.     public function setIsDg(bool $isDg): self
  195.     {
  196.         $this->isDg $isDg;
  197.         return $this;
  198.     }
  199.     public function isBreakBulk(): ?bool
  200.     {
  201.         return empty($this->containers);
  202.     }
  203.     public function setIsBreakBulk(bool $isBreakBulk): self
  204.     {
  205.         $this->isBreakBulk $isBreakBulk;
  206.         return $this;
  207.     }
  208.     public function getTariffZone(): ?string
  209.     {
  210.         return $this->tariffZone;
  211.     }
  212.     public function setTariffZone(string $tariffZone): self
  213.     {
  214.         $this->tariffZone $tariffZone;
  215.         return $this;
  216.     }
  217.     public function getAtd(): ?DateTimeInterface
  218.     {
  219.         return $this->atd;
  220.     }
  221.     public function setAtd(?DateTimeInterface $atd): self
  222.     {
  223.         $this->atd $atd;
  224.         return $this;
  225.     }
  226.     public function getAta(): ?DateTimeInterface
  227.     {
  228.         return $this->ata;
  229.     }
  230.     public function setAta(?DateTimeInterface $ata): self
  231.     {
  232.         $this->ata $ata;
  233.         return $this;
  234.     }
  235.     /**
  236.      * @return Collection<int, Invoice>
  237.      */
  238.     public function getInvoices(): Collection
  239.     {
  240.         return $this->invoices;
  241.     }
  242.     public function addInvoice(Invoice $invoice): self
  243.     {
  244.         if (!$this->invoices->contains($invoice)) {
  245.             $this->invoices->add($invoice);
  246.             $invoice->setConsolidation($this);
  247.         }
  248.         return $this;
  249.     }
  250.     public function removeInvoice(Invoice $invoice): self
  251.     {
  252.         if ($this->invoices->removeElement($invoice)) {
  253.             // set the owning side to null (unless already changed)
  254.             if ($invoice->getConsolidation() === $this) {
  255.                 $invoice->setConsolidation(null);
  256.             }
  257.         }
  258.         return $this;
  259.     }
  260. }