@@ -61,9 +61,7 @@ class OrderProductBuilder | |||
{ | |||
if(!$orderProduct->getOrderProductReductionCatalog()) { | |||
if (is_null($productFamily)) { | |||
$productFamily = $this->productFamilyStore->setSection($section)->getOneBySlug( | |||
$orderProduct->getProduct()->getProductFamily()->getSlug() | |||
); | |||
$productFamily = $orderProduct->getProduct()->getProductFamily(); | |||
} | |||
$reductionCatalog = $productFamily->getReductionCatalog(); |
@@ -102,24 +102,26 @@ class OrderProductPriceSolver | |||
} | |||
public function getTotalWithReduction(OrderProductInterface $orderProduct) | |||
public function getTotalWithReduction(OrderProductInterface $orderProduct, bool $round = true) | |||
{ | |||
return $this->applyReductionCatalog( | |||
$orderProduct, | |||
$this->getTotal($orderProduct), | |||
$this->getTotalWithTax($orderProduct), | |||
$this->getTotalWithTax($orderProduct, $round), | |||
$orderProduct->getQuantityOrder(), | |||
null, | |||
false | |||
false, | |||
$round | |||
); | |||
} | |||
public function getTotalWithTax(OrderProductInterface $orderProduct) | |||
public function getTotalWithTax(OrderProductInterface $orderProduct, $round = true) | |||
{ | |||
return $this->applyTax( | |||
$this->getTotal($orderProduct), | |||
$orderProduct->getTaxRate()->getValue() | |||
$orderProduct->getTaxRate()->getValue(), | |||
$round | |||
); | |||
} | |||
@@ -128,7 +130,7 @@ class OrderProductPriceSolver | |||
return $this->applyReductionCatalog( | |||
$orderProduct, | |||
$this->getTotal($orderProduct), | |||
$this->getTotalWithTax($orderProduct), | |||
$this->getTotalWithTax($orderProduct, $round), | |||
$orderProduct->getQuantityOrder(), | |||
null, | |||
true, |
@@ -34,7 +34,7 @@ class OrderShopPriceSolver | |||
$total = 0; | |||
foreach ($orderShop->getOrderProducts() as $orderProduct) { | |||
$total += $this->orderProductPriceResolver->getTotalWithReduction($orderProduct); | |||
$total += $this->orderProductPriceResolver->getTotalWithReduction($orderProduct, false); | |||
} | |||
return $this->round($total); | |||
} | |||
@@ -145,7 +145,7 @@ class OrderShopPriceSolver | |||
{ | |||
$total = 0; | |||
foreach ($orderProducts as $orderProduct) { | |||
$total += $this->orderProductPriceResolver->getTotalWithTaxAndReduction($orderProduct); | |||
$total += $this->orderProductPriceResolver->getTotalWithTaxAndReduction($orderProduct, false); | |||
} | |||
return $this->round($total); |
@@ -9,9 +9,15 @@ use Lc\CaracoleBundle\Model\Product\ProductInterface; | |||
trait PriceSolverTrait | |||
{ | |||
public function applyTax($price, $taxRateValue) | |||
public function applyTax($price, $taxRateValue, $round = true) | |||
{ | |||
return $this->round($this->applyPercent($price, $taxRateValue)); | |||
$price = $this->applyPercent($price, $taxRateValue); | |||
if($round) { | |||
return $this->round($price); | |||
} | |||
return $price; | |||
} | |||
public function applyReductionPercent($price, $percentage) |