51 lines
1.3 KiB
PHP
51 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace KupShop\KupShopBundle\Util\Price;
|
|
|
|
use KupShop\I18nBundle\Entity\Currency;
|
|
|
|
class TotalPrice
|
|
{
|
|
private $priceWithVat;
|
|
private $priceWithoutVat;
|
|
private $currency;
|
|
|
|
public function __construct(\Decimal $priceWithVat, \Decimal $priceWithoutVat, Currency $currency)
|
|
{
|
|
$this->priceWithVat = $priceWithVat;
|
|
$this->priceWithoutVat = $priceWithoutVat;
|
|
$this->currency = $currency;
|
|
}
|
|
|
|
public function getPriceWithVat(): \Decimal
|
|
{
|
|
return $this->priceWithVat;
|
|
}
|
|
|
|
public function getPriceWithoutVat(): \Decimal
|
|
{
|
|
return $this->priceWithoutVat;
|
|
}
|
|
|
|
public function getCurrency(): Currency
|
|
{
|
|
return $this->currency;
|
|
}
|
|
|
|
// Jestli chceš přičítat TotalPrice, udělej si na to metodu a nezapomeň konvertovat měnu
|
|
public function add(Price $price): self
|
|
{
|
|
$price = PriceCalculator::convert($price, $this->currency);
|
|
|
|
$this->priceWithVat = $this->priceWithVat->add($price->getPriceWithVat());
|
|
$this->priceWithoutVat = $this->priceWithoutVat->add($price->getPriceWithoutVat());
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function round()
|
|
{
|
|
$this->priceWithVat = roundPrice($this->priceWithVat, $this->currency->getPriceRoundOrder(), bata: false);
|
|
}
|
|
}
|