Browse Source

Correctifs Solver

packProduct
Guillaume 2 years ago
parent
commit
45d154fae2
3 changed files with 36 additions and 15 deletions
  1. +23
    -13
      Solver/Price/ProductPriceSolver.php
  2. +11
    -0
      Solver/Product/ProductSolver.php
  3. +2
    -2
      Solver/Ticket/TicketSolver.php

+ 23
- 13
Solver/Price/ProductPriceSolver.php View File

@@ -24,11 +24,11 @@ class ProductPriceSolver

public function getSolver(ProductPropertyInterface $product)
{
if($product instanceof ProductFamilyInterface) {
if ($product instanceof ProductFamilyInterface) {
return $this->productFamilySolver;
}

if($product instanceof ProductInterface) {
if ($product instanceof ProductInterface) {
return $this->productSolver;
}
}
@@ -41,7 +41,8 @@ class ProductPriceSolver
return $solver->getPriceInherited($product);
} elseif ($solver->getBehaviorPriceInherited($product) == 'by-reference-unit') {
if ($solver->getQuantityInherited($product) > 0) {
return $solver->getPriceByRefUnitInherited($product) * ($solver->getQuantityInherited($product
return $solver->getPriceByRefUnitInherited($product) * ($solver->getQuantityInherited(
$product
) / $solver->getUnitInherited($product)->getCoefficient());
} else {
return 0;
@@ -89,21 +90,29 @@ class ProductPriceSolver
}

//Bridge pour applyReductionCatalog qui ne peut pas être appeler à cause du call
public function getPriceWithTaxByReduction(ProductPropertyInterface $product, ReductionCatalogInterface $reductionCatalog)
{
public function getPriceWithTaxByReduction(
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
);
}

public function getPriceByRefUnitWithTaxAndReduction(ProductPropertyInterface $product)
{
return ($this->getPriceByRefUnitWithTax($product) * $this->getPriceWithTaxAndReduction($product))
/ $this->getPriceWithTax($product);
$priceWithTax = $this->getPriceWithTax($product);

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

return 0;
}


@@ -115,7 +124,8 @@ class ProductPriceSolver
return $solver->getBuyingPriceInherited($product);
} elseif ($solver->getBehaviorPriceInherited($product) == 'by-reference-unit') {
if ($solver->getQuantityInherited($product) > 0) {
return $solver->getBuyingPriceByRefUnitInherited($product) * ($solver->getQuantityInherited($product
return $solver->getBuyingPriceByRefUnitInherited($product) * ($solver->getQuantityInherited(
$product
) / $solver->getUnitInherited($product)->getCoefficient());
} else {
return 0;

+ 11
- 0
Solver/Product/ProductSolver.php View File

@@ -117,6 +117,17 @@ class ProductSolver
}
}

public function getTitle(ProductInterface $product)
{
$title = $product->getProductFamily()->getTitle();

if ($product->getTitle() && strlen($product->getTitle())) {
$title .= ' - ' . $product->getTitle();
}

return $title;
}

public function getTitleInherited(ProductInterface $product)
{
if ($product->getTitle()) {

+ 2
- 2
Solver/Ticket/TicketSolver.php View File

@@ -7,9 +7,9 @@ use Lc\SovBundle\Solver\Ticket\TicketSolver as SovTicketSolver;

class TicketSolver extends SovTicketSolver
{
public static function getTypeChoices(): array
public function getTypeChoices($context = 'backend'): array
{
$choices = parent::getTypeChoices();
$choices = parent::getTypeChoices($context);
$choicesProduct = [
TicketModel::TYPE_PRODUCT_UNAVAILABLE,
TicketModel::TYPE_PRODUCT_ERROR

Loading…
Cancel
Save