Procházet zdrojové kódy

ProductPriceSolver : ajout round

packProduct
Guillaume před 2 roky
rodič
revize
019e931041
2 změnil soubory, kde provedl 20 přidání a 20 odebrání
  1. +16
    -14
      Builder/Order/OrderProductBuilder.php
  2. +4
    -6
      Solver/Price/ProductPriceSolver.php

+ 16
- 14
Builder/Order/OrderProductBuilder.php Zobrazit soubor

@@ -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 Zobrazit soubor

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

}


Načítá se…
Zrušit
Uložit