src/Entity/Delete/Invoice.php line 44

  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 ApiPlatform\Metadata\Delete;
  8. use ApiPlatform\Metadata\Get;
  9. use ApiPlatform\Metadata\GetCollection;
  10. use ApiPlatform\Metadata\Link;
  11. use ApiPlatform\Metadata\Patch;
  12. use ApiPlatform\Metadata\Post;
  13. use App\Entity\Common as Common;
  14. use DateTimeInterface;
  15. use Doctrine\DBAL\Types\Types;
  16. use Doctrine\ORM\Mapping as ORM;
  17. use Gedmo\Mapping\Annotation as Gedmo;
  18. use Symfony\Component\Validator\Constraints as Assert;
  19. #[ORM\Table(name'invoicing_invoice')]
  20. #[ORM\Entity]
  21. #[ApiResource(
  22.     operations: [
  23.         new Get(),
  24.         new Delete(),
  25.         new Patch(inputFormats: ['json' => ['application/merge-patch+json']]),
  26.     ],
  27. )]
  28. #[ApiResource(
  29.     uriTemplate'/invoicing/consolidations/{consolidation}/invoices',
  30.     operations: [
  31.         new Post(),
  32.         new GetCollection(),
  33.     ],
  34.     uriVariables: [
  35.         'consolidation' => new Link(fromProperty'invoices'fromClassConsolidation::class)
  36.     ],
  37. )]
  38. #[ApiFilter(SearchFilter::class, properties: [
  39.     'reference' => 'ipartial',
  40. ])]
  41. class Invoice extends Invoiceable
  42. {
  43.     use Common\Blameable;
  44.     use Common\Trackable;
  45.     #[ORM\Id]
  46.     #[ORM\GeneratedValue(strategy'IDENTITY')]
  47.     #[ORM\SequenceGenerator(sequenceName'invoicing_invoice_id_seq')]
  48.     #[ORM\Column(typeTypes::INTEGER)]
  49.     #[ApiProperty(identifierfalse)]
  50.     private int $id;
  51.     #[ORM\ManyToOne(targetEntityConsolidation::class, inversedBy'invoices')]
  52.     #[ORM\JoinColumn(name'batch_id'nullablefalse)]
  53.     #[ApiProperty(readableLinktrue)]
  54.     private ?Consolidation $consolidation null;
  55.     #[Gedmo\Slug(fields: ['reference'])]
  56.     #[ORM\Column(typeTypes::STRING)]
  57.     #[ApiProperty(identifiertrue)]
  58.     private string $slug;
  59.     #[Assert\NotNull]
  60.     #[Assert\Type(typeTypes::BOOLEAN)]
  61.     #[ORM\Column(typeTypes::BOOLEAN)]
  62.     private ?bool $combined null;
  63.     #[Assert\NotNull]
  64.     #[Assert\Type(typeTypes::BOOLEAN)]
  65.     #[ORM\Column(typeTypes::BOOLEAN)]
  66.     private ?bool $invoiced null;
  67.     #[Assert\Type(typeDateTimeInterface::class)]
  68.     #[ORM\Column(typeTypes::DATE_MUTABLEnullabletrue)]
  69.     private ?DateTimeInterface $atc null;
  70.     #[Assert\NotNull]
  71.     #[ORM\Column(typeTypes::JSON)]
  72.     private ?array $data = [];
  73.     public function getId(): ?int
  74.     {
  75.         return $this->id;
  76.     }
  77.     public function getSlug(): ?string
  78.     {
  79.         return $this->slug;
  80.     }
  81.     public function setSlug(string $slug): self
  82.     {
  83.         $this->slug $slug;
  84.         return $this;
  85.     }
  86.     public function isCombined(): ?bool
  87.     {
  88.         return $this->combined;
  89.     }
  90.     public function setCombined(bool $combined): self
  91.     {
  92.         $this->combined $combined;
  93.         return $this;
  94.     }
  95.     public function isInvoiced(): ?bool
  96.     {
  97.         return $this->invoiced;
  98.     }
  99.     public function setInvoiced(bool $invoiced): self
  100.     {
  101.         $this->invoiced $invoiced;
  102.         return $this;
  103.     }
  104.     public function getAtc(): ?DateTimeInterface
  105.     {
  106.         return $this->atc;
  107.     }
  108.     public function setAtc(?DateTimeInterface $atc): self
  109.     {
  110.         $this->atc $atc;
  111.         return $this;
  112.     }
  113.     public function getConsolidation(): ?Consolidation
  114.     {
  115.         return $this->consolidation;
  116.     }
  117.     public function setConsolidation(?Consolidation $consolidation): self
  118.     {
  119.         $this->consolidation $consolidation;
  120.         return $this;
  121.     }
  122.     public function getData(): array
  123.     {
  124.         return $this->data;
  125.     }
  126.     public function setData(?array $data): self
  127.     {
  128.         $this->data $data;
  129.         return $this;
  130.     }
  131. }