src/Entity/Tax.php line 32
<?php/** @author Guerby Duval <info@tranzaksyon.com>* @link https://tranzaksyon.com* @copyright You are not allowed to remove this author "Guerby Duval <info@tranzaksyon.com>", the link "https://tranzaksyon.com" neither this copyright.*/namespace App\Entity;use ApiPlatform\Metadata\ApiResource;use ApiPlatform\Metadata\Get;use ApiPlatform\Metadata\GetCollection;use App\Repository\TaxRepository;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;use Symfony\Component\Serializer\Annotation\Groups;use Symfony\Component\Validator\Constraints\GreaterThanOrEqual;use Symfony\Component\Validator\Constraints\NotBlank;use Symfony\Component\Validator\Constraints\NotNull;#[ORM\Entity(repositoryClass: TaxRepository::class)]#[ApiResource(normalizationContext: ['groups' => ['tax_out']], denormalizationContext: ['groups' => ['tax_in']],// security: "is_granted('View', object)"security: "is_granted('ROLE_USER')")]//#[Post(processor: CurrentCompanyStateProcesor::class)]#[Get]#[GetCollection]//#[Put]//#[Delete]class Tax{#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]#[Groups(['tax_out'])]private ?int $id = null;#[ORM\Column(length: 20)]#[NotBlank]#[Groups(['tax_out', 'tax_in'])]private ?string $name = null;#[ORM\Column(type: Types::DECIMAL, precision: 10, scale: 2)]#[NotNull]#[GreaterThanOrEqual(0)]#[Groups(['tax_out', 'tax_in'])]private ?string $amount = null;#[ORM\ManyToOne(inversedBy: 'taxes')]#[ORM\JoinColumn(nullable: true)]private ?SriInfo $sriInfo = null;#[ORM\Column(length: 20, nullable: true)]private ?string $externalId = null;#[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]private ?\DateTimeInterface $validUntil = null;#[ORM\Column(nullable: true)]private ?bool $isDefault = null;#[ORM\Column(length: 3, nullable: true)]private ?string $iAfecIVA = null;#[ORM\Column(nullable: true)]private ?float $dPropIVA = null;public function getId(): ?int{return $this->id;}public function getName(): ?string{return $this->name;}public function setName(string $name): self{$this->name = $name;return $this;}public function getAmount(): ?string{return $this->amount;}public function setAmount(string $amount): self{$this->amount = $amount;return $this;}public function getSriInfo(): ?SriInfo{return $this->sriInfo;}public function setSriInfo(?SriInfo $sriInfo): self{$this->sriInfo = $sriInfo;return $this;}public function getExternalId(): ?string{return $this->externalId;}public function setExternalId(?string $externalId): static{$this->externalId = $externalId;return $this;}public function getValidUntil(): ?\DateTimeInterface{return $this->validUntil;}public function setValidUntil(?\DateTimeInterface $validUntil): static{$this->validUntil = $validUntil;return $this;}public function computeTax(?\DateTime $date): ?string{if ($date == null || $this->validUntil === null || $this->validUntil >= $date) {return $this->getAmount();}foreach ($this->getTaxRanges() as $taxRange) {if ($taxRange->getValidFrom() <= $date && ($taxRange->getValidTo() === null || $date <= $taxRange->getValidTo())) {return $taxRange->getValue();}}return null;}public function isIsDefault(): ?bool{return $this->isDefault;}public function setIsDefault(?bool $isDefault): static{$this->isDefault = $isDefault;return $this;}public function getCode(): ?int{return $this->code;}public function setCode(?int $code): static{$this->code = $code;return $this;}public function getIAfecIVA(): ?string{return $this->iAfecIVA;}public function setIAfecIVA(?string $iAfecIVA): static{$this->iAfecIVA = $iAfecIVA;return $this;}public function getDPropIVA(): ?float{return $this->dPropIVA;}public function setDPropIVA(?float $dPropIVA): static{$this->dPropIVA = $dPropIVA;return $this;}}