Guillaume 2 лет назад
Родитель
Сommit
ca5f5b2e86
4 измененных файлов: 19 добавлений и 13 удалений
  1. +1
    -3
      Builder/Order/OrderProductBuilder.php
  2. +8
    -6
      Solver/Price/OrderProductPriceSolver.php
  3. +2
    -2
      Solver/Price/OrderShopPriceSolver.php
  4. +8
    -2
      Solver/Price/PriceSolverTrait.php

+ 1
- 3
Builder/Order/OrderProductBuilder.php Просмотреть файл

@@ -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();

+ 8
- 6
Solver/Price/OrderProductPriceSolver.php Просмотреть файл

@@ -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,

+ 2
- 2
Solver/Price/OrderShopPriceSolver.php Просмотреть файл

@@ -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);

+ 8
- 2
Solver/Price/PriceSolverTrait.php Просмотреть файл

@@ -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)

Загрузка…
Отмена
Сохранить