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



public function initReductionCatalog(SectionInterface $section, OrderProductInterface $orderProduct, ProductFamilyInterface $productFamily = null): OrderProductInterface 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; return $orderProduct;

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

); );
} }



public function getPriceByRefUnit(ProductPropertyInterface $product) public function getPriceByRefUnit(ProductPropertyInterface $product)
{ {
$solver = $this->getSolver($product); $solver = $this->getSolver($product);
); );
} }



public function getPriceWithTaxAndReduction(ProductPropertyInterface $product) public function getPriceWithTaxAndReduction(ProductPropertyInterface $product)
{ {
return $this->applyReductionCatalog( return $this->applyReductionCatalog(
$priceWithTax = $this->getPriceWithTax($product); $priceWithTax = $this->getPriceWithTax($product);


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


return 0; return 0;
} }



public function getBuyingPrice(ProductPropertyInterface $product) public function getBuyingPrice(ProductPropertyInterface $product)
{ {
$solver = $this->getSolver($product); $solver = $this->getSolver($product);
{ {
return $this->round($this->getPriceWithTax($product) / $this->getBuyingPrice($product)); return $this->round($this->getPriceWithTax($product) / $this->getBuyingPrice($product));
} }

} }



Loading…
Cancel
Save