|
|
@@ -3,6 +3,7 @@ |
|
|
|
namespace Lc\ShopBundle\Services ; |
|
|
|
|
|
|
|
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; |
|
|
@@ -88,6 +89,13 @@ class PriceUtils |
|
|
|
if($entity instanceof OrderProductInterface) { |
|
|
|
return $entity->getQuantityOrder() * $this->getPrice($entity) ; |
|
|
|
} |
|
|
|
if($entity instanceof OrderShopInterface) { |
|
|
|
$total = 0 ; |
|
|
|
foreach($entity->getOrderProducts() as $orderProduct) { |
|
|
|
$total += $this->getTotal($orderProduct) ; |
|
|
|
} |
|
|
|
return $total ; |
|
|
|
} |
|
|
|
return null ; |
|
|
|
} |
|
|
|
|
|
|
@@ -99,6 +107,16 @@ class PriceUtils |
|
|
|
$entity->getTaxRateInherited()->getValue() |
|
|
|
) ; |
|
|
|
} |
|
|
|
if($entity instanceof OrderShopInterface) { |
|
|
|
$total = 0 ; |
|
|
|
foreach($entity->getOrderProducts() as $orderProduct) { |
|
|
|
$total += $this->getTotalWithTax($orderProduct) ; |
|
|
|
} |
|
|
|
return $total ; |
|
|
|
} |
|
|
|
if($entity instanceof OrderShopInterface) { |
|
|
|
return $this->getTotalWithTaxByOrderProducts($entity->getOrderProducts()) ; |
|
|
|
} |
|
|
|
return null ; |
|
|
|
} |
|
|
|
|
|
|
@@ -111,6 +129,32 @@ class PriceUtils |
|
|
|
$this->getTotalWithTax($entity) |
|
|
|
) ; |
|
|
|
} |
|
|
|
|
|
|
|
if($entity instanceof OrderShopInterface) { |
|
|
|
return $this->getTotalWithTaxAndReductionByOrderProducts($entity->getOrderProducts()) ; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public function getTotalWithTaxByOrderProducts($orderProducts) |
|
|
|
{ |
|
|
|
$totalWithTax = 0; |
|
|
|
|
|
|
|
foreach ($orderProducts as $orderProduct) { |
|
|
|
$totalWithTax += $this->getTotalWithTax($orderProduct); |
|
|
|
} |
|
|
|
|
|
|
|
return $totalWithTax; |
|
|
|
} |
|
|
|
|
|
|
|
public function getTotalWithTaxAndReductionByOrderProducts($orderProducts) |
|
|
|
{ |
|
|
|
$totalWithTax = 0; |
|
|
|
|
|
|
|
foreach ($orderProducts as $orderProduct) { |
|
|
|
$totalWithTax += $this->getTotalWithTaxAndReduction($orderProduct); |
|
|
|
} |
|
|
|
|
|
|
|
return $totalWithTax; |
|
|
|
} |
|
|
|
|
|
|
|
public function getPriceWithTaxAndReductionCatalog($entity, $price, $priceWithTax, $reductionCatalog = null): ?float |
|
|
@@ -132,8 +176,12 @@ class PriceUtils |
|
|
|
} |
|
|
|
|
|
|
|
if($entity instanceof OrderProductInterface) { |
|
|
|
// OrderProductReductionCatalog |
|
|
|
$reductionCatalog = null ; |
|
|
|
$orderProductReductionCatalog = $entity->getOrderProductReductionCatalog() ; |
|
|
|
if($orderProductReductionCatalog) { |
|
|
|
$reductionCatalogValue = $orderProductReductionCatalog->getValue() ; |
|
|
|
$reductionCatalogUnit = $orderProductReductionCatalog->getUnit() ; |
|
|
|
$reductionCatalogBehaviorTaxRate = $orderProductReductionCatalog->getBehaviorTaxRate() ; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@@ -166,7 +214,6 @@ class PriceUtils |
|
|
|
return $priceWithTax ; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function applyTax($price, $taxRateValue) |
|
|
|
{ |
|
|
|
return $this->round($this->applyPercent($price, $taxRateValue)) ; |