<?php
// src/Acme/UserBundle/Entity/User.php
namespace App\Entity;
use Knp\DoctrineBehaviors\Contract\Entity\SoftDeletableInterface;
use Knp\DoctrineBehaviors\Model\SoftDeletable\SoftDeletableTrait;
use Knp\DoctrineBehaviors\Model\Blameable\BlameableTrait;
use Knp\DoctrineBehaviors\Contract\Entity\BlameableInterface;
use Knp\DoctrineBehaviors\Model\Timestampable\TimestampableTrait;
use Knp\DoctrineBehaviors\Contract\Entity\TimestampableInterface;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @Doctrine\ORM\Mapping\Entity
* @Doctrine\ORM\Mapping\Table(name="product_equipment")
*/
class ProductEquipment implements BlameableInterface, TimestampableInterface, SoftDeletableInterface {
use BlameableTrait;
use TimestampableTrait;
use SoftDeletableTrait;
/**
* @var integer
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, nullable=true)
*/
private $name;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Language")
* @ORM\JoinColumn(name="language_id", referencedColumnName="id")
*/
protected $language;
/**
* @Doctrine\ORM\Mapping\Column(type="decimal", precision=10, scale=2, nullable=true, name="price_net")
*/
protected $priceNet;
/**
* @Doctrine\ORM\Mapping\Column(type="decimal", precision=10, scale=2, nullable=true)
*/
protected $price;
/**
* @Doctrine\ORM\Mapping\Column(type="boolean", nullable=true)
*/
protected $visible = true;
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 getPrice()
{
$vat = 23;
if ($this->getLanguage()->getId() == 1) { //pl
$vat = 23;
}
if ($this->getLanguage()->getId() == 4) { //ro
$vat = 19;
}
if ($this->getLanguage()->getId() == 3) { //sk
$vat = 23;
}
if ($this->getLanguage()->getId() == 2) { //cz
$vat = 21;
}
return round($this->getPriceNet() * ((100+$vat)/100), $this->getLanguage()->getRoundingPrecision());
return $this->price;
}
public function setPrice($price): self
{
$this->price = $price;
return $this;
}
public function getLanguage(): ?Language
{
return $this->language;
}
public function setLanguage(?Language $language): self
{
$this->language = $language;
return $this;
}
/**
* @return mixed
*/
public function getPriceNet()
{
return $this->priceNet;
}
/**
* @param mixed $priceNet
*/
public function setPriceNet($priceNet): void
{
$this->priceNet = $priceNet;
}
/**
* @return bool
*/
public function isVisible()
{
return $this->visible;
}
/**
* @param bool $visible
*/
public function setVisible($visible): void
{
$this->visible = $visible;
}
}