Browse Source

Pack produit : prendre en compte prix avec réduction de chaque produit

develop
Guillaume Bourgeois 2 years ago
parent
commit
fd2b5fabf8
2 changed files with 41 additions and 29 deletions
  1. +1
    -1
      Resolver/SectionResolver.php
  2. +40
    -28
      Solver/Price/ProductPriceSolver.php

+ 1
- 1
Resolver/SectionResolver.php View File

@@ -77,7 +77,7 @@ class SectionResolver
}

return null;
} // front
else {


+ 40
- 28
Solver/Price/ProductPriceSolver.php View File

@@ -42,19 +42,31 @@ class ProductPriceSolver
} elseif ($solver->getBehaviorPriceInherited($product) == 'by-reference-unit') {
if ($solver->getQuantityInherited($product) > 0) {
return $solver->getPriceByRefUnitInherited($product) * ($solver->getQuantityInherited(
$product
) / $solver->getUnitInherited($product)->getCoefficient());
$product
) / $solver->getUnitInherited($product)->getCoefficient());
} else {
return 0;
}
}
}

public function getPriceWithReduction(ProductPropertyInterface $product)
{
return $this->applyReductionCatalog(
$product,
$this->getPrice($product),
$this->getPriceWithTax($product),
1,
null,
false
);
}

public function getPriceWithTax(ProductPropertyInterface $product)
{
return $this->applyTax(
$this->getPrice($product),
$this->productFamilySolver->getTaxRateInherited($product)->getValue()
$this->getPrice($product),
$this->productFamilySolver->getTaxRateInherited($product)->getValue()
);
}

@@ -63,8 +75,7 @@ class ProductPriceSolver
$solver = $this->getSolver($product);

if ($solver->getBehaviorPriceInherited($product) == 'by-piece') {
return ($this->getPrice($product) * $solver->getUnitInherited($product)->getCoefficient(
)) / $solver->getQuantityInherited($product);
return ($this->getPrice($product) * $solver->getUnitInherited($product)->getCoefficient()) / $solver->getQuantityInherited($product);
} elseif ($solver->getBehaviorPriceInherited($product) == 'by-reference-unit') {
return $solver->getPriceByRefUnitInherited($product);
}
@@ -73,8 +84,8 @@ class ProductPriceSolver
public function getPriceByRefUnitWithTax(ProductPropertyInterface $product)
{
return $this->applyTax(
$this->getPriceByRefUnit($product),
$this->productFamilySolver->getTaxRateInherited($product)->getValue()
$this->getPriceByRefUnit($product),
$this->productFamilySolver->getTaxRateInherited($product)->getValue()
);
}

@@ -82,23 +93,24 @@ class ProductPriceSolver
{
//TODO voir différence entre prix ici et dans tableau décli
return $this->applyReductionCatalog(
$product,
$this->getPrice($product),
$this->getPriceWithTax($product)
$product,
$this->getPrice($product),
$this->getPriceWithTax($product)
);
}

//Bridge pour applyReductionCatalog qui ne peut pas être appeler à cause du call
public function getPriceWithTaxByReduction(
ProductPropertyInterface $product,
ReductionCatalogInterface $reductionCatalog
) {
ProductPropertyInterface $product,
ReductionCatalogInterface $reductionCatalog
)
{
return $this->applyReductionCatalog(
$product,
$this->getPrice($product),
$this->getPriceWithTax($product),
1,
$reductionCatalog
$product,
$this->getPrice($product),
$this->getPriceWithTax($product),
1,
$reductionCatalog
);
}

@@ -108,9 +120,9 @@ class ProductPriceSolver

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

return 0;
@@ -125,8 +137,8 @@ class ProductPriceSolver
} elseif ($solver->getBehaviorPriceInherited($product) == 'by-reference-unit') {
if ($solver->getQuantityInherited($product) > 0) {
return $solver->getBuyingPriceByRefUnitInherited($product) * ($solver->getQuantityInherited(
$product
) / $solver->getUnitInherited($product)->getCoefficient());
$product
) / $solver->getUnitInherited($product)->getCoefficient());
} else {
return 0;
}
@@ -136,8 +148,8 @@ class ProductPriceSolver
public function getBuyingPriceWithTax(ProductPropertyInterface $product)
{
return $this->applyTax(
$this->getBuyingPrice($product),
$this->productFamilySolver->getTaxRateInherited($product)->getValue()
$this->getBuyingPrice($product),
$this->productFamilySolver->getTaxRateInherited($product)->getValue()
);
}

@@ -149,8 +161,8 @@ class ProductPriceSolver
public function getBuyingPriceByRefUnitWithTax(ProductPropertyInterface $product)
{
return $this->applyTax(
$this->getBuyingPriceByRefUnit($product),
$this->productFamilySolver->getTaxRateInherited($product)->getValue()
$this->getBuyingPriceByRefUnit($product),
$this->productFamilySolver->getTaxRateInherited($product)->getValue()
);
}


Loading…
Cancel
Save