src/Entity/GeneralInvoice.php line 41

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\GeneralInvoiceRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use ApiPlatform\Metadata\ApiResource;
  9. use ApiPlatform\Metadata\ApiProperty;
  10. use ApiPlatform\Metadata\Get;
  11. use ApiPlatform\Metadata\GetCollection;
  12. use ApiPlatform\Metadata\Delete;
  13. use ApiPlatform\Metadata\Post;
  14. use ApiPlatform\Metadata\Patch;
  15. use ApiPlatform\Metadata\Put;
  16. use Symfony\Component\Serializer\Annotation\Groups;
  17. use App\Controller\Api\GeneralInvoiceController;
  18. #[ORM\Entity(repositoryClassGeneralInvoiceRepository::class)]
  19. #[ApiResource(
  20.     security'is_granted("ROLE_SUPER_ADMIN") or is_granted("ROLE_ADMIN")',
  21.     normalizationContext: ['groups' => ['generalInvoice:read']],
  22.     denormalizationContext: ['groups' => ['generalInvoice:write']],
  23.     operations: [
  24.         new Get(),
  25.         new Put(),
  26.         new Patch(),
  27.         new Delete(),
  28.         new Delete(
  29.             name'multi_delete',
  30.             routeName'api_general_invoices_delete',
  31.             controllerGeneralInvoiceController::class,
  32.         ),
  33.         new GetCollection(),
  34.         new Post()
  35.     ],
  36.     paginationEnabledfalse
  37. )]
  38. class GeneralInvoice
  39. {
  40.     #[ORM\Id]
  41.     #[ORM\GeneratedValue]
  42.     #[ORM\Column]
  43.     #[Groups(['generalInvoice:read''company:read''generalInvoiceDetail:read'])]
  44.     private ?int $id null;
  45.     #[ORM\ManyToOne(inversedBy'generalInvoices')]
  46.     #[ORM\JoinColumn(nullablefalse)]
  47.     #[Groups(['generalInvoice:read''generalInvoice:write''company:read''generalInvoiceDetail:read'])]
  48.     private ?Company $biller null;
  49.     #[ORM\Column]
  50.     #[Groups(['generalInvoice:read''generalInvoice:write''company:read''generalInvoiceDetail:read'])]
  51.     private ?int $number null;
  52.     #[ORM\Column(typeTypes::DATETIME_MUTABLE)]
  53.     #[Groups(['generalInvoice:read''generalInvoice:write''company:read''generalInvoiceDetail:read'])]
  54.     private ?\DateTimeInterface $date null;
  55.     #[ORM\Column(nullabletrue)]
  56.     #[Groups(['generalInvoice:read''generalInvoice:write''company:read''generalInvoiceDetail:read'])]
  57.     private ?float $total null;
  58.     #[ORM\Column(length255nullabletrue)]
  59.     #[Groups(['generalInvoice:read''generalInvoice:write''company:read''generalInvoiceDetail:read'])]
  60.     private ?string $period null;
  61.     #[ORM\Column(typeTypes::DATE_MUTABLEnullabletrue)]
  62.     #[Groups(['generalInvoice:read''generalInvoice:write''company:read''generalInvoiceDetail:read'])]
  63.     #[ApiProperty(readabletruewritabletrue)]
  64.     private ?\DateTimeInterface $period_date null;
  65.     #[ORM\Column(nullabletrue)]
  66.     #[Groups(['generalInvoice:read''generalInvoice:write''company:read''generalInvoiceDetail:read'])]
  67.     private ?float $rate null;
  68.     #[ORM\OneToMany(mappedBy'generalInvoice'targetEntityGeneralInvoiceDetail::class)]
  69.     #[Groups(['generalInvoice:read''company:read'])]
  70.     private Collection $generalInvoiceDetails;
  71.     public function __construct()
  72.     {
  73.         $this->generalInvoiceDetails = new ArrayCollection();
  74.     }
  75.     public function getId(): ?int
  76.     {
  77.         return $this->id;
  78.     }
  79.     public function getBiller(): ?Company
  80.     {
  81.         return $this->biller;
  82.     }
  83.     public function setBiller(?Company $biller): self
  84.     {
  85.         $this->biller $biller;
  86.         return $this;
  87.     }
  88.     public function getNumber(): ?int
  89.     {
  90.         return $this->number;
  91.     }
  92.     public function setNumber(int $number): self
  93.     {
  94.         $this->number $number;
  95.         return $this;
  96.     }
  97.     public function getDate(): ?\DateTimeInterface
  98.     {
  99.         return $this->date;
  100.     }
  101.     public function setDate(\DateTimeInterface $date): self
  102.     {
  103.         $this->date $date;
  104.         return $this;
  105.     }
  106.     public function getTotal(): ?float
  107.     {
  108.         return $this->total;
  109.     }
  110.     public function setTotal(?float $total): self
  111.     {
  112.         $this->total $total;
  113.         return $this;
  114.     }
  115.     public function getPeriod(): ?string
  116.     {
  117.         return $this->period;
  118.     }
  119.     public function setPeriod(string $period): self
  120.     {
  121.         $this->period $period;
  122.         return $this;
  123.     }
  124.     public function getPeriodDate(): ?\DateTimeInterface
  125.     {
  126.         return $this->period_date;
  127.     }
  128.     public function setPeriodDate(?\DateTimeInterface $period_date): self
  129.     {
  130.         $this->period_date $period_date;
  131.         return $this;
  132.     }
  133.     public function getRate(): ?float
  134.     {
  135.         return $this->rate;
  136.     }
  137.     public function setRate(?float $rate): self
  138.     {
  139.         $this->rate $rate;
  140.         return $this;
  141.     }
  142.     /**
  143.      * @return Collection<int, GeneralInvoiceDetail>
  144.      */
  145.     public function getGeneralInvoiceDetails(): Collection
  146.     {
  147.         return $this->generalInvoiceDetails;
  148.     }
  149.     public function addGeneralInvoiceDetail(GeneralInvoiceDetail $generalInvoiceDetail): self
  150.     {
  151.         if (!$this->generalInvoiceDetails->contains($generalInvoiceDetail)) {
  152.             $this->generalInvoiceDetails->add($generalInvoiceDetail);
  153.             $generalInvoiceDetail->setGeneralInvoice($this);
  154.         }
  155.         return $this;
  156.     }
  157.     public function removeGeneralInvoiceDetail(GeneralInvoiceDetail $generalInvoiceDetail): self
  158.     {
  159.         if ($this->generalInvoiceDetails->removeElement($generalInvoiceDetail)) {
  160.             // set the owning side to null (unless already changed)
  161.             if ($generalInvoiceDetail->getGeneralInvoice() === $this) {
  162.                 $generalInvoiceDetail->setGeneralInvoice(null);
  163.             }
  164.         }
  165.         return $this;
  166.     }
  167. }