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



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


if($product instanceof ProductInterface) {
if ($product instanceof ProductInterface) {
return $this->productSolver; return $this->productSolver;
} }
} }
return $solver->getPriceInherited($product); return $solver->getPriceInherited($product);
} elseif ($solver->getBehaviorPriceInherited($product) == 'by-reference-unit') { } elseif ($solver->getBehaviorPriceInherited($product) == 'by-reference-unit') {
if ($solver->getQuantityInherited($product) > 0) { if ($solver->getQuantityInherited($product) > 0) {
return $solver->getPriceByRefUnitInherited($product) * ($solver->getQuantityInherited($product
return $solver->getPriceByRefUnitInherited($product) * ($solver->getQuantityInherited(
$product
) / $solver->getUnitInherited($product)->getCoefficient()); ) / $solver->getUnitInherited($product)->getCoefficient());
} else { } else {
return 0; return 0;
} }


//Bridge pour applyReductionCatalog qui ne peut pas être appeler à cause du call //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( 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) 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;
} }




return $solver->getBuyingPriceInherited($product); return $solver->getBuyingPriceInherited($product);
} elseif ($solver->getBehaviorPriceInherited($product) == 'by-reference-unit') { } elseif ($solver->getBehaviorPriceInherited($product) == 'by-reference-unit') {
if ($solver->getQuantityInherited($product) > 0) { if ($solver->getQuantityInherited($product) > 0) {
return $solver->getBuyingPriceByRefUnitInherited($product) * ($solver->getQuantityInherited($product
return $solver->getBuyingPriceByRefUnitInherited($product) * ($solver->getQuantityInherited(
$product
) / $solver->getUnitInherited($product)->getCoefficient()); ) / $solver->getUnitInherited($product)->getCoefficient());
} else { } else {
return 0; return 0;

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

} }
} }


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) public function getTitleInherited(ProductInterface $product)
{ {
if ($product->getTitle()) { if ($product->getTitle()) {

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



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

Loading…
Cancel
Save