Parcourir la source

Correctif prix

packProduct
Guillaume il y a 2 ans
Parent
révision
ca5f5b2e86
4 fichiers modifiés avec 19 ajouts et 13 suppressions
  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 Voir le fichier

{ {
if(!$orderProduct->getOrderProductReductionCatalog()) { if(!$orderProduct->getOrderProductReductionCatalog()) {
if (is_null($productFamily)) { if (is_null($productFamily)) {
$productFamily = $this->productFamilyStore->setSection($section)->getOneBySlug(
$orderProduct->getProduct()->getProductFamily()->getSlug()
);
$productFamily = $orderProduct->getProduct()->getProductFamily();
} }


$reductionCatalog = $productFamily->getReductionCatalog(); $reductionCatalog = $productFamily->getReductionCatalog();

+ 8
- 6
Solver/Price/OrderProductPriceSolver.php Voir le fichier

} }




public function getTotalWithReduction(OrderProductInterface $orderProduct)
public function getTotalWithReduction(OrderProductInterface $orderProduct, bool $round = true)
{ {
return $this->applyReductionCatalog( return $this->applyReductionCatalog(
$orderProduct, $orderProduct,
$this->getTotal($orderProduct), $this->getTotal($orderProduct),
$this->getTotalWithTax($orderProduct),
$this->getTotalWithTax($orderProduct, $round),
$orderProduct->getQuantityOrder(), $orderProduct->getQuantityOrder(),
null, null,
false
false,
$round
); );
} }


public function getTotalWithTax(OrderProductInterface $orderProduct)
public function getTotalWithTax(OrderProductInterface $orderProduct, $round = true)
{ {


return $this->applyTax( return $this->applyTax(
$this->getTotal($orderProduct), $this->getTotal($orderProduct),
$orderProduct->getTaxRate()->getValue()
$orderProduct->getTaxRate()->getValue(),
$round
); );
} }


return $this->applyReductionCatalog( return $this->applyReductionCatalog(
$orderProduct, $orderProduct,
$this->getTotal($orderProduct), $this->getTotal($orderProduct),
$this->getTotalWithTax($orderProduct),
$this->getTotalWithTax($orderProduct, $round),
$orderProduct->getQuantityOrder(), $orderProduct->getQuantityOrder(),
null, null,
true, true,

+ 2
- 2
Solver/Price/OrderShopPriceSolver.php Voir le fichier



$total = 0; $total = 0;
foreach ($orderShop->getOrderProducts() as $orderProduct) { foreach ($orderShop->getOrderProducts() as $orderProduct) {
$total += $this->orderProductPriceResolver->getTotalWithReduction($orderProduct);
$total += $this->orderProductPriceResolver->getTotalWithReduction($orderProduct, false);
} }
return $this->round($total); return $this->round($total);
} }
{ {
$total = 0; $total = 0;
foreach ($orderProducts as $orderProduct) { foreach ($orderProducts as $orderProduct) {
$total += $this->orderProductPriceResolver->getTotalWithTaxAndReduction($orderProduct);
$total += $this->orderProductPriceResolver->getTotalWithTaxAndReduction($orderProduct, false);
} }


return $this->round($total); return $this->round($total);

+ 8
- 2
Solver/Price/PriceSolverTrait.php Voir le fichier



trait PriceSolverTrait 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) public function applyReductionPercent($price, $percentage)

Chargement…
Annuler
Enregistrer