|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace Lc\ShopBundle\Model ; |
|
|
namespace Lc\ShopBundle\Model ; |
|
|
|
|
|
|
|
|
|
|
|
use Lc\ShopBundle\Context\ReductionCatalogInterface; |
|
|
use Lc\ShopBundle\Context\UnitInterface; |
|
|
use Lc\ShopBundle\Context\UnitInterface; |
|
|
|
|
|
|
|
|
trait PriceTrait |
|
|
trait PriceTrait |
|
|
|
|
|
|
|
|
return $this->calculatePriceByUnitRef($this->getPriceWithTax()) ; |
|
|
return $this->calculatePriceByUnitRef($this->getPriceWithTax()) ; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function getTheReductionCatalog() |
|
|
|
|
|
{ |
|
|
|
|
|
$reductionCatalog = false; |
|
|
|
|
|
|
|
|
|
|
|
if($this instanceof ProductFamily) { |
|
|
|
|
|
$reductionCatalog = $this->getReductionCatalog() ; |
|
|
|
|
|
} |
|
|
|
|
|
if($this instanceof Product) { |
|
|
|
|
|
$reductionCatalog = $this->getProductFamily()->getReductionCatalog() ; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return $reductionCatalog ; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function getPriceByUnitRefWithTaxAndReduction(): ?float |
|
|
|
|
|
{ |
|
|
|
|
|
$reductionCatalog = $this->getTheReductionCatalog() ; |
|
|
|
|
|
|
|
|
|
|
|
if (isset($reductionCatalog) && $reductionCatalog) { |
|
|
|
|
|
return $this->calculatePriceByUnitRef($this->getPriceWithTaxAndReductionCatalog($reductionCatalog)) ; |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
return $this->calculatePriceByUnitRef($this->getPriceWithTax()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public function getPriceWithTaxAndReduction(): ?float |
|
|
public function getPriceWithTaxAndReduction(): ?float |
|
|
{ |
|
|
{ |
|
|
if ($this->reductionCatalog) { |
|
|
|
|
|
return $this->getPriceWithTaxAndReductionCatalog($this->reductionCatalog); |
|
|
|
|
|
} else { |
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
|
$reductionCatalog = $this->getTheReductionCatalog() ; |
|
|
|
|
|
|
|
|
|
|
|
if (isset($reductionCatalog) && $reductionCatalog) { |
|
|
|
|
|
return $this->getPriceWithTaxAndReductionCatalog($reductionCatalog); |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
return $this->getPriceWithTax(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function getPriceWithTaxAndReductionCatalog(ReductionInterface $reductionCatalog): ?float |
|
|
|
|
|
|
|
|
public function getPriceWithTaxAndReductionCatalog(ReductionCatalogInterface $reductionCatalog): ?float |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
if ($reductionCatalog->getUnit() == 'percent') { |
|
|
if ($reductionCatalog->getUnit() == 'percent') { |