|
|
@@ -2,6 +2,7 @@ |
|
|
|
|
|
|
|
namespace Lc\ShopBundle\Services ; |
|
|
|
|
|
|
|
use Doctrine\Common\Collections\Collection; |
|
|
|
use Lc\ShopBundle\Context\OrderProductInterface; |
|
|
|
use Lc\ShopBundle\Context\OrderShopInterface; |
|
|
|
use Lc\ShopBundle\Context\ProductFamilyInterface; |
|
|
@@ -115,7 +116,7 @@ class PriceUtils |
|
|
|
return $total ; |
|
|
|
} |
|
|
|
if($entity instanceof OrderShopInterface) { |
|
|
|
return $this->getTotalWithTaxByOrderProducts($entity->getOrderProducts()) ; |
|
|
|
return $this->getTotalOrderProducts($entity->getOrderProducts(), true) ; |
|
|
|
} |
|
|
|
return null ; |
|
|
|
} |
|
|
@@ -131,30 +132,50 @@ class PriceUtils |
|
|
|
} |
|
|
|
|
|
|
|
if($entity instanceof OrderShopInterface) { |
|
|
|
return $this->getTotalWithTaxAndReductionByOrderProducts($entity->getOrderProducts()) ; |
|
|
|
return $this->getTotalOrderProductsWithTaxAndReduction($entity->getOrderProducts(), true, true) ; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public function getTotalWithTaxByOrderProducts($orderProducts) |
|
|
|
public function getTotalOrderProducts($entity) |
|
|
|
{ |
|
|
|
$totalWithTax = 0; |
|
|
|
|
|
|
|
foreach ($orderProducts as $orderProduct) { |
|
|
|
$totalWithTax += $this->getTotalWithTax($orderProduct); |
|
|
|
} |
|
|
|
return $this->getSumOrderProductsDispatch($entity) ; |
|
|
|
} |
|
|
|
|
|
|
|
return $totalWithTax; |
|
|
|
public function getTotalOrderProductsWithTax($entity) |
|
|
|
{ |
|
|
|
return $this->getSumOrderProductsDispatch($entity, true) ; |
|
|
|
} |
|
|
|
|
|
|
|
public function getTotalWithTaxAndReductionByOrderProducts($orderProducts) |
|
|
|
public function getTotalOrderProductsWithTaxAndReduction($entity) |
|
|
|
{ |
|
|
|
$totalWithTax = 0; |
|
|
|
return $this->getSumOrderProductsDispatch($entity, true, true) ; |
|
|
|
} |
|
|
|
|
|
|
|
foreach ($orderProducts as $orderProduct) { |
|
|
|
$totalWithTax += $this->getTotalWithTaxAndReduction($orderProduct); |
|
|
|
public function getSumOrderProductsDispatch($entity, $withTax = false, $withReduction = false) |
|
|
|
{ |
|
|
|
if($entity instanceof OrderShopInterface) { |
|
|
|
return $this->getSumOrderProducts($entity->getOrderProducts(), $withTax, $withReduction) ; |
|
|
|
} |
|
|
|
if($entity instanceof Collection) { |
|
|
|
return $this->getSumOrderProducts($entity, $withTax, $withReduction) ; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return $totalWithTax; |
|
|
|
public function getSumOrderProducts($orderProducts, $withTax = false, $withReduction = false) |
|
|
|
{ |
|
|
|
$total = 0 ; |
|
|
|
foreach($orderProducts as $orderProduct) { |
|
|
|
if($withTax && $withReduction) { |
|
|
|
$total += $this->getTotalWithTaxAndReduction($orderProduct) ; |
|
|
|
} |
|
|
|
elseif($withTax) { |
|
|
|
$total += $this->getTotalWithTax($orderProduct) ; |
|
|
|
} |
|
|
|
else { |
|
|
|
$total += $this->getTotal($orderProduct) ; |
|
|
|
} |
|
|
|
} |
|
|
|
return $total ; |
|
|
|
} |
|
|
|
|
|
|
|
public function getPriceWithTaxAndReductionCatalog($entity, $price, $priceWithTax, $reductionCatalog = null): ?float |