src/Entity/GeneralInvoice.php line 41
<?php
namespace App\Entity;
use App\Repository\GeneralInvoiceRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Delete;
use ApiPlatform\Metadata\Post;
use ApiPlatform\Metadata\Patch;
use ApiPlatform\Metadata\Put;
use Symfony\Component\Serializer\Annotation\Groups;
use App\Controller\Api\GeneralInvoiceController;
#[ORM\Entity(repositoryClass: GeneralInvoiceRepository::class)]
#[ApiResource(
security: 'is_granted("ROLE_SUPER_ADMIN") or is_granted("ROLE_ADMIN")',
normalizationContext: ['groups' => ['generalInvoice:read']],
denormalizationContext: ['groups' => ['generalInvoice:write']],
operations: [
new Get(),
new Put(),
new Patch(),
new Delete(),
new Delete(
name: 'multi_delete',
routeName: 'api_general_invoices_delete',
controller: GeneralInvoiceController::class,
),
new GetCollection(),
new Post()
],
paginationEnabled: false
)]
class GeneralInvoice
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(['generalInvoice:read', 'company:read', 'generalInvoiceDetail:read'])]
private ?int $id = null;
#[ORM\ManyToOne(inversedBy: 'generalInvoices')]
#[ORM\JoinColumn(nullable: false)]
#[Groups(['generalInvoice:read', 'generalInvoice:write', 'company:read', 'generalInvoiceDetail:read'])]
private ?Company $biller = null;
#[ORM\Column]
#[Groups(['generalInvoice:read', 'generalInvoice:write', 'company:read', 'generalInvoiceDetail:read'])]
private ?int $number = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
#[Groups(['generalInvoice:read', 'generalInvoice:write', 'company:read', 'generalInvoiceDetail:read'])]
private ?\DateTimeInterface $date = null;
#[ORM\Column(nullable: true)]
#[Groups(['generalInvoice:read', 'generalInvoice:write', 'company:read', 'generalInvoiceDetail:read'])]
private ?float $total = null;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(['generalInvoice:read', 'generalInvoice:write', 'company:read', 'generalInvoiceDetail:read'])]
private ?string $period = null;
#[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]
#[Groups(['generalInvoice:read', 'generalInvoice:write', 'company:read', 'generalInvoiceDetail:read'])]
#[ApiProperty(readable: true, writable: true)]
private ?\DateTimeInterface $period_date = null;
#[ORM\Column(nullable: true)]
#[Groups(['generalInvoice:read', 'generalInvoice:write', 'company:read', 'generalInvoiceDetail:read'])]
private ?float $rate = null;
#[ORM\OneToMany(mappedBy: 'generalInvoice', targetEntity: GeneralInvoiceDetail::class)]
#[Groups(['generalInvoice:read', 'company:read'])]
private Collection $generalInvoiceDetails;
public function __construct()
{
$this->generalInvoiceDetails = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getBiller(): ?Company
{
return $this->biller;
}
public function setBiller(?Company $biller): self
{
$this->biller = $biller;
return $this;
}
public function getNumber(): ?int
{
return $this->number;
}
public function setNumber(int $number): self
{
$this->number = $number;
return $this;
}
public function getDate(): ?\DateTimeInterface
{
return $this->date;
}
public function setDate(\DateTimeInterface $date): self
{
$this->date = $date;
return $this;
}
public function getTotal(): ?float
{
return $this->total;
}
public function setTotal(?float $total): self
{
$this->total = $total;
return $this;
}
public function getPeriod(): ?string
{
return $this->period;
}
public function setPeriod(string $period): self
{
$this->period = $period;
return $this;
}
public function getPeriodDate(): ?\DateTimeInterface
{
return $this->period_date;
}
public function setPeriodDate(?\DateTimeInterface $period_date): self
{
$this->period_date = $period_date;
return $this;
}
public function getRate(): ?float
{
return $this->rate;
}
public function setRate(?float $rate): self
{
$this->rate = $rate;
return $this;
}
/**
* @return Collection<int, GeneralInvoiceDetail>
*/
public function getGeneralInvoiceDetails(): Collection
{
return $this->generalInvoiceDetails;
}
public function addGeneralInvoiceDetail(GeneralInvoiceDetail $generalInvoiceDetail): self
{
if (!$this->generalInvoiceDetails->contains($generalInvoiceDetail)) {
$this->generalInvoiceDetails->add($generalInvoiceDetail);
$generalInvoiceDetail->setGeneralInvoice($this);
}
return $this;
}
public function removeGeneralInvoiceDetail(GeneralInvoiceDetail $generalInvoiceDetail): self
{
if ($this->generalInvoiceDetails->removeElement($generalInvoiceDetail)) {
// set the owning side to null (unless already changed)
if ($generalInvoiceDetail->getGeneralInvoice() === $this) {
$generalInvoiceDetail->setGeneralInvoice(null);
}
}
return $this;
}
}