|
|
@@ -36,12 +36,10 @@ class OrderResolver extends AbstractResolver |
|
|
|
{ |
|
|
|
$smallestQuantity = null; |
|
|
|
|
|
|
|
if($this->featureChecker->isEnabled(Feature::ALIAS_PRODUCT_ACCESSORY)) { |
|
|
|
foreach ($product->getProductAccessories() as $productAccessory) { |
|
|
|
$quantityAccessory = $productAccessory->getAccessory()->getQuantity(); |
|
|
|
$smallestQuantity = is_null($smallestQuantity) ? $quantityAccessory |
|
|
|
: min($smallestQuantity, $quantityAccessory); |
|
|
|
} |
|
|
|
foreach ($product->getProductAccessories() as $productAccessory) { |
|
|
|
$quantityAccessory = $productAccessory->getAccessory()->getQuantity(); |
|
|
|
$smallestQuantity = is_null($smallestQuantity) ? $quantityAccessory |
|
|
|
: min($smallestQuantity, $quantityAccessory); |
|
|
|
} |
|
|
|
|
|
|
|
return $smallestQuantity; |
|
|
@@ -50,15 +48,18 @@ class OrderResolver extends AbstractResolver |
|
|
|
public function getProductQuantityMax(Product $product, Distribution $distribution): ?float |
|
|
|
{ |
|
|
|
$productDistribution = $this->productDistributionRepository->findOneProductDistribution($distribution, $product); |
|
|
|
// @TODO : gérer via une exception |
|
|
|
if(!$productDistribution) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
$quantityMax = $productDistribution->quantity_max; |
|
|
|
$smallestQuantityAccessory = $this->getSmallestQuantityAccessory($product); |
|
|
|
|
|
|
|
if(!is_null($smallestQuantityAccessory)) { |
|
|
|
$quantityMax = is_null($quantityMax) ? $smallestQuantityAccessory : min($quantityMax, $smallestQuantityAccessory); |
|
|
|
if($this->featureChecker->isEnabled(Feature::ALIAS_PRODUCT_ACCESSORY)) { |
|
|
|
$smallestQuantityAccessory = $this->getSmallestQuantityAccessory($product); |
|
|
|
if (!is_null($smallestQuantityAccessory)) { |
|
|
|
$quantityMax = is_null($quantityMax) ? $smallestQuantityAccessory : min($quantityMax, $smallestQuantityAccessory); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return $quantityMax; |
|
|
@@ -105,10 +106,12 @@ class OrderResolver extends AbstractResolver |
|
|
|
: ($productDistribution->quantity_max - $quantityOrder); |
|
|
|
|
|
|
|
// Limitation par nombre d'accessoires disponibles |
|
|
|
$smallestQuantityAccessoryAvailable = $this->getSmallestQuantityAccessoryAvailable($product, $distribution); |
|
|
|
if(!is_null($smallestQuantityAccessoryAvailable)) { |
|
|
|
$quantityRemaining = is_null($quantityRemaining) ? $smallestQuantityAccessoryAvailable |
|
|
|
: min($quantityRemaining, $smallestQuantityAccessoryAvailable); |
|
|
|
if($this->featureChecker->isEnabled(Feature::ALIAS_PRODUCT_ACCESSORY)) { |
|
|
|
$smallestQuantityAccessoryAvailable = $this->getSmallestQuantityAccessoryAvailable($product, $distribution); |
|
|
|
if (!is_null($smallestQuantityAccessoryAvailable)) { |
|
|
|
$quantityRemaining = is_null($quantityRemaining) ? $smallestQuantityAccessoryAvailable |
|
|
|
: min($quantityRemaining, $smallestQuantityAccessoryAvailable); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return $quantityRemaining; |