Преглед на файлове

ProductPriceSolver : ajout round

packProduct
Guillaume преди 2 години
родител
ревизия
019e931041
променени са 2 файла, в които са добавени 20 реда и са изтрити 20 реда
  1. +16
    -14
      Builder/Order/OrderProductBuilder.php
  2. +4
    -6
      Solver/Price/ProductPriceSolver.php

+ 16
- 14
Builder/Order/OrderProductBuilder.php Целия файл

@@ -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 Целия файл

@@ -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…
Отказ
Запис