src/Entity/InvoiceDetail.php line 20
<?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\Repository\InvoiceDetailRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;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\NotNull;#[ORM\Entity(repositoryClass: InvoiceDetailRepository::class)]classInvoiceDetail{#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]#[Groups(['invoice_detail_out'])]private ?int $id = null;#[ORM\ManyToOne(inversedBy: 'invoiceDetails')]#[ORM\JoinColumn(nullable: true)]private ?Invoice $Invoice = null;#[ORM\ManyToOne(cascade: ['persist'])]#[ORM\JoinColumn(nullable: false)]#[NotNull]#[Groups(['invoice_detail_out', 'invoice_detail_in'])]private ?Product $product = null;#[ORM\Column(type: Types::DECIMAL, precision: 20, scale: 6)]#[GreaterThanOrEqual(0.001)]#[NotNull]#[Groups(['invoice_detail_out', 'invoice_detail_in'])]private ?float $amount = null;#[ORM\Column(type: Types::DECIMAL, precision: 20, scale: 6)]#[GreaterThanOrEqual(0)]#[NotNull]#[Groups(['invoice_detail_out', 'invoice_detail_in'])]private ?float $discount = 0;#[ORM\Column(type: Types::DECIMAL, precision: 20, scale: 6)]private ?float $totalWithoutTax = 0;#[ORM\OneToMany(mappedBy: 'invoiceDetail', targetEntity: InvoiceDetailTaxes::class, cascade: ['persist'], orphanRemoval: true)]private Collection $invoiceDetailTaxes;#[ORM\Column(type: Types::DECIMAL, precision: 20, scale: 6, nullable: true)]#[GreaterThanOrEqual(0)]#[Groups(['invoice_detail_out', 'invoice_detail_in'])]private ?float $price = null;#[ORM\Column(length: 230, nullable: true)]#[Groups(['invoice_detail_out', 'invoice_detail_in'])]private ?string $detail = null;#[ORM\Column(nullable: true)]private ?float $iva = null;#[ORM\Column(type: Types::DECIMAL, precision: 50, scale: 8, nullable: true)]private ?string $basGravIVA = null;#[ORM\Column(type: Types::DECIMAL, precision: 23, scale: 8, nullable: true)]private ?string $liqIVAItem = null;#[ORM\Column(nullable: true)]private ?float $ivaBase = null;#[ORM\Column(nullable: true)]private ?int $discountType = null;public function __construct(){$this->invoiceDetailTaxes = new ArrayCollection();}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 getProduct(): ?Product{return $this->product;}public function setProduct(?Product $product): self{$this->product = $product;return $this;}public function getAmount(): ?float{return $this->amount;}public function setAmount(float $amount): self{$this->amount = $amount;return $this;}public function getDiscount(): ?float{return $this->discount;}public function setDiscount(?float $discount): self{$this->discount = $discount;return $this;}public function getTotalWithoutTax(): float{return $this->totalWithoutTax;}public function setTotalWithoutTax(float $totalWithoutTax): self{$this->totalWithoutTax = $totalWithoutTax;return $this;}/*** @return Collection<int, InvoiceDetailTaxes>*/public function getInvoiceDetailTaxes(): Collection{return $this->invoiceDetailTaxes;}public function addInvoiceDetailTax(InvoiceDetailTaxes $invoiceDetailTax): self{if (!$this->invoiceDetailTaxes->contains($invoiceDetailTax)) {$this->invoiceDetailTaxes->add($invoiceDetailTax);$invoiceDetailTax->setInvoiceDetail($this);}return $this;}public function removeInvoiceDetailTax(InvoiceDetailTaxes $invoiceDetailTax): self{if ($this->invoiceDetailTaxes->removeElement($invoiceDetailTax)) {// set the owning side to null (unless already changed)if ($invoiceDetailTax->getInvoiceDetail() === $this) {$invoiceDetailTax->setInvoiceDetail(null);}}return $this;}public function getPrice(): ?float{return $this->price;}public function setPrice(?float $price): self{$this->price = $price;return $this;}public function getDetail(): ?string{return $this->detail;}public function setDetail(?string $detail): self{$this->detail = $detail;return $this;}public function getIva(): ?float{return $this->iva;}public function setIva(?float $iva): static{$this->iva = $iva;return $this;}public function getBasGravIVA(): ?string{return $this->basGravIVA;}public function setBasGravIVA(?string $basGravIVA): static{$this->basGravIVA = $basGravIVA;return $this;}public function getLiqIVAItem(): ?string{return $this->liqIVAItem;}public function setLiqIVAItem(?string $liqIVAItem): static{$this->liqIVAItem = $liqIVAItem;return $this;}public function getIvaBase(): ?float{return $this->ivaBase;}public function setIvaBase(?float $ivaBase): static{$this->ivaBase = $ivaBase;return $this;}public function getDiscountType(): ?int{return $this->discountType;}public function setDiscountType(?int $discountType): static{$this->discountType = $discountType;return $this;}public function getUnitDesc(){if ($this->getSubProduct()) {return number_format($this->getSubProduct()->getUnitValue()->getUnitValue(), 2) . " " . $this->getSubProduct()->getUnitValue()->getUnit()->getAbreviation() . " (" . $this->getSubProduct()->getUnitValue()->getUnit()->getName() . ")";}return "";}public function getItemName(){$name = $this->getProduct()->getName();if ($this->getSubProduct()) {$name .= " " . number_format($this->getSubProduct()->getUnitValue()->getUnitValue(), 2) . " " . $this->getSubProduct()->getUnitValue()->getUnit()->describe();} elseif ($this->getUnitDetail()) {$name .= " " . number_format($this->getUnitDetail()->getAmount(), 2) . " " . $this->getUnitDetail()->getUnit()->describe();}return $name;}public function copy(){$id = new InvoiceDetail();$id->setIva($this->getIva())->setProduct($this->getProduct())->setPrice($this->getPrice())->setDetail($this->getDetail())->setDiscount($this->getDiscount())->setDiscountType($this->getDiscountType())->setAmount($this->getAmount());return $id;}public function getTotal(){if ($this->getProduct()->getTax()) {return $this->getTotalWithoutTax() + ($this->getTotalWithoutTax() * ($this->getProduct()->getTax()->getAmount() / 100));}return $this->getTotalWithoutTax();}}