Browse Source

ProductPriceSolver : ajout round

packProduct
Guillaume 2 years ago
parent
commit
019e931041
2 changed files with 20 additions and 20 deletions
  1. +16
    -14
      Builder/Order/OrderProductBuilder.php
  2. +4
    -6
      Solver/Price/ProductPriceSolver.php

+ 16
- 14
Builder/Order/OrderProductBuilder.php View File

@@ -59,22 +59,24 @@ class OrderProductBuilder

public function initReductionCatalog(SectionInterface $section, OrderProductInterface $orderProduct, ProductFamilyInterface $productFamily = null): OrderProductInterface
{
if(is_null($productFamily)) {
$productFamily = $this->productFamilyStore->setSection($section)->getOneBySlug(
$orderProduct->getProduct()->getProductFamily()->getSlug()
);
}
if(!$orderProduct->getOrderProductReductionCatalog()) {
if (is_null($productFamily)) {
$productFamily = $this->productFamilyStore->setSection($section)->getOneBySlug(
$orderProduct->getProduct()->getProductFamily()->getSlug()
);
}

$reductionCatalog = $productFamily->getReductionCatalog();
if ($reductionCatalog && $reductionCatalog->getStatus()) {
$orderProductReductionCatalog = $this->orderProductReductionCatalogFactory->create(
$reductionCatalog->getTitle(),
$reductionCatalog->getValue(),
$reductionCatalog->getUnit(),
$reductionCatalog->getBehaviorTaxRate()
);
$reductionCatalog = $productFamily->getReductionCatalog();
if ($reductionCatalog && $reductionCatalog->getStatus()) {
$orderProductReductionCatalog = $this->orderProductReductionCatalogFactory->create(
$reductionCatalog->getTitle(),
$reductionCatalog->getValue(),
$reductionCatalog->getUnit(),
$reductionCatalog->getBehaviorTaxRate()
);

$orderProduct->setOrderProductReductionCatalog($orderProductReductionCatalog);
$orderProduct->setOrderProductReductionCatalog($orderProductReductionCatalog);
}
}

return $orderProduct;

+ 4
- 6
Solver/Price/ProductPriceSolver.php View File

@@ -58,7 +58,6 @@ class ProductPriceSolver
);
}


public function getPriceByRefUnit(ProductPropertyInterface $product)
{
$solver = $this->getSolver($product);
@@ -79,7 +78,6 @@ class ProductPriceSolver
);
}


public function getPriceWithTaxAndReduction(ProductPropertyInterface $product)
{
return $this->applyReductionCatalog(
@@ -108,14 +106,15 @@ class ProductPriceSolver
$priceWithTax = $this->getPriceWithTax($product);

if ($priceWithTax) {
return ($this->getPriceByRefUnitWithTax($product) * $this->getPriceWithTaxAndReduction($product))
/ $priceWithTax;
return $this->round(
($this->getPriceByRefUnitWithTax($product) * $this->getPriceWithTaxAndReduction($product))
/ $priceWithTax
);
}

return 0;
}


public function getBuyingPrice(ProductPropertyInterface $product)
{
$solver = $this->getSolver($product);
@@ -158,6 +157,5 @@ class ProductPriceSolver
{
return $this->round($this->getPriceWithTax($product) / $this->getBuyingPrice($product));
}

}


Loading…
Cancel
Save