48 lines
2.1 KiB
PHP
48 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace KupShop\FeedsBundle\Wrapper;
|
|
|
|
use KupShop\KupShopBundle\Util\Price\ProductPrice;
|
|
|
|
class PriceWrapper extends PriceVatAwareWrapper
|
|
{
|
|
protected static $objectType = ProductPrice::class;
|
|
|
|
/** @var ProductPrice */
|
|
protected $object;
|
|
|
|
/** Cena s DPH */
|
|
public function field_withVat(): float
|
|
{
|
|
return $this->round($this->convertToActiveCurrency($this->object->getPriceWithVat(false)));
|
|
}
|
|
|
|
/** Cena bez DPH */
|
|
public function field_withoutVat(): float
|
|
{
|
|
// converting to active currency after eshop rounding produced inaccurate results => MUST convert exact price and round afterwards
|
|
// do NOT round final price without vat but calculate it from eshop-rounded vat-included price
|
|
// first convert vat-included price to proper currency then round according to eshop settings
|
|
return roundPrice($this->convertToActiveCurrency($this->object->getPriceWithVat(false)), currency: $this->getCurrency())
|
|
->removeVat($this->object->getVat()) // then remove vat
|
|
->value(4)->asFloat(); // return value without vat and eshop rounding
|
|
}
|
|
|
|
/** Cena s DPH před slevou */
|
|
public function field_withVatWithoutDiscount(): float
|
|
{
|
|
return $this->round($this->convertToActiveCurrency($this->object->getPriceWithVatWithoutDiscount(false)));
|
|
}
|
|
|
|
/** Cena bez DPH před slevou */
|
|
public function field_withoutVatWithoutDiscount(): float
|
|
{
|
|
// converting to active currency after eshop rounding produced inaccurate results => MUST convert exact price and round afterwards
|
|
// do NOT round final non-discounted price without vat but calculate it from eshop-rounded vat-included non-discounted price
|
|
// first convert vat-included non-discount price to proper currency then round according to eshop settings
|
|
return roundPrice($this->convertToActiveCurrency($this->object->getPriceWithVatWithoutDiscount(false)), currency: $this->getCurrency())
|
|
->removeVat($this->object->getVat()) // then remove vat
|
|
->value(4)->asFloat(); // return value without discount|vat|eshop rounding
|
|
}
|
|
}
|