src/Entity/InvoiceTaxes.php line 16
<?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 App\Enums\IvaPurposeEnum;use App\Repository\InvoiceTaxesRepository;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;#[ORM\Entity(repositoryClass: InvoiceTaxesRepository::class)]class InvoiceTaxes{#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]private ?int $id = null;#[ORM\ManyToOne(inversedBy: 'invoiceTaxes')]#[ORM\JoinColumn(nullable: true)]private ?Invoice $invoice = null;#[ORM\Column]private ?int $code = null;#[ORM\Column]private ?int $percentage = null;#[ORM\Column(type: Types::DECIMAL, precision: 23, scale: 8)]private ?string $base = null;#[ORM\Column(type: Types::DECIMAL, precision: 23, scale: 8)]private ?string $fare = null;#[ORM\Column(type: Types::DECIMAL, precision: 23, scale: 8)]private ?string $taxAmount = null;#[ORM\Column(type: Types::DECIMAL, precision: 23, scale: 8, nullable: true)]private ?string $baseGravada = null;#[ORM\Column(length: 3, nullable: true)]private ?string $purpose = null;public function getId(): ?int{return $this->id;}public function getInvoice(): ?Invoice{return $this->invoice;}public function setInvoice(?Invoice $invoice): self{$this->invoice = $invoice;return $this;}public function getCode(): ?int{return $this->code;}public function setCode(int $code): self{$this->code = $code;return $this;}public function getPercentage(): ?int{return $this->percentage;}public function setPercentage(int $percentage): self{$this->percentage = $percentage;return $this;}public function getBase(): ?string{return $this->base;}public function setBase(string $base): self{$this->base = $base;return $this;}public function getFare(): ?string{return $this->fare;}public function setFare(string $fare): self{$this->fare = $fare;return $this;}public function getTaxAmount(): ?string{return $this->taxAmount;}public function setTaxAmount(string $taxAmount): self{$this->taxAmount = $taxAmount;return $this;}public function getBaseGravada(): ?string{return $this->baseGravada;}public function setBaseGravada(?string $baseGravada): static{$this->baseGravada = $baseGravada;return $this;}public function getPurpose(): ?string{return $this->purpose;}public function setPurpose(?string $purpose): static{$this->purpose = $purpose;return $this;}public function copy(): InvoiceTaxes{$invoiceTax = new InvoiceTaxes();$invoiceTax->setTaxAmount($this->getTaxAmount())->setCode($this->getCode())->setFare($this->getFare())->setBase($this->getBase())->setPercentage($this->getPercentage());$invoiceTax->setPurpose(self::computePurpose($invoiceTax)->value);return $invoiceTax;}/*** @param InvoiceTaxes $invoiceTax* @return IvaPurposeEnum*/public static function computePurpose(InvoiceTaxes $invoiceTax): IvaPurposeEnum{if ($invoiceTax->getCode() === 2) {if ($invoiceTax->getPercentage() === 6) {return IvaPurposeEnum::NoObjetoIva;} elseif ($invoiceTax->getPercentage() === 0) {return IvaPurposeEnum::Base0;} else {return IvaPurposeEnum::Iva;}}}}