|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <?php
-
- namespace Lc\ShopBundle\Services\Price;
-
- use Doctrine\Common\Collections\Collection;
- use Lc\ShopBundle\Context\OrderProductInterface;
- use Lc\ShopBundle\Context\OrderShopInterface;
- use Lc\ShopBundle\Context\ProductFamilyInterface;
- use Lc\ShopBundle\Context\ProductInterface;
- use Lc\ShopBundle\Context\ProductPropertyInterface;
- use Lc\ShopBundle\Context\ReductionCatalogInterface;
-
- class ProductPriceUtils
- {
- use PriceUtilsTrait ;
-
- public function getPrice(ProductPropertyInterface $product)
- {
- if ($product->getBehaviorPriceInherited() == 'by-piece') {
- return $product->getPriceInherited();
- }
- elseif ($product->getBehaviorPriceInherited() == 'by-reference-unit') {
- if ($product->getQuantityInherited() > 0) {
- return $product->getPriceByRefUnitInherited() * ($product->getQuantityInherited() / $product->getUnitInherited()->getCoefficient());
- }
- }
- }
-
- public function getPriceWithTax(ProductPropertyInterface $product)
- {
- return $this->applyTax(
- $this->getPrice($product),
- $product->getTaxRateInherited()->getValue()
- );
- }
-
-
- public function getPriceByRefUnit(ProductPropertyInterface $product)
- {
- if ($product->getBehaviorPriceInherited() == 'by-piece') {
- return ($this->getPrice($product) * $product->getUnitInherited()->getCoefficient()) / $product->getQuantityInherited();
- } elseif ($product->getBehaviorPriceInherited() == 'by-reference-unit') {
- return $product->getPriceByRefUnitInherited();
- }
- }
-
- public function getPriceByRefUnitWithTax(ProductPropertyInterface $product)
- {
- return $this->applyTax(
- $this->getPriceByRefUnit($product),
- $product->getTaxRateInherited()->getValue()
- );
- }
-
-
- public function getPriceWithTaxAndReduction(ProductPropertyInterface $product)
- {
- return $this->applyReductionCatalog(
- $product,
- $this->getTotal($product),
- $this->getTotalWithTax($product)
- );
- }
-
- public function getPriceByRefUnitWithTaxAndReduction(ProductPropertyInterface $product)
- {
-
- return $this->applyReductionCatalog(
- $product,
- $this->getPriceByRefUnit($product),
- $this->getPriceByRefUnitWithTax($product)
- );
-
- }
-
- }
-
|