source; } public function setSource($source): self { $this->source = $source; return $this; } public function __construct(\Decimal $value, Currency $currency, $vat) { $this->value = $value; $this->currency = $currency; $this->vat = toDecimal($vat); } public function setValue(\Decimal $value): void { $this->value = $value; } public function getValue(): \Decimal { return $this->value; } public function getCurrency(): Currency { return $this->currency; } public function getVat(): \Decimal { return $this->vat; } public function getPriceWithVat($round = true): \Decimal { $price = $this->value->addVat($this->vat); if ($round) { return $this->round($price); } return $price; } public function getPriceWithoutVat($round = true): \Decimal { $price = $this->getPriceWithVat($round); return $price->removeVat($this->vat); } protected function round(\Decimal $price): \Decimal { return roundPrice($price, null, null, null, $this->currency, source: $this->getSource()); } public function getVatValue(): \Decimal { return $this->getPriceWithVat()->sub($this->getPriceWithoutVat()); } public function getVatPrice(): Price { return new Price($this->getVatValue(), $this->getCurrency(), \DecimalConstants::zero()); } }