|
|
|
|
|
|
|
|
return $this->orderSolver->getProductQuantity($product, $ordersArray); |
|
|
return $this->orderSolver->getProductQuantity($product, $ordersArray); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function getSmallestQuantityAccessory(Product $product): ?int |
|
|
|
|
|
{ |
|
|
|
|
|
$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); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return $smallestQuantity; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function getProductQuantityMax(Product $product, Distribution $distribution): ?float |
|
|
|
|
|
{ |
|
|
|
|
|
$productDistribution = $this->productDistributionRepository->findOneProductDistribution($distribution, $product); |
|
|
|
|
|
if(!$productDistribution) { |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$quantityMax = $productDistribution->quantity_max; |
|
|
|
|
|
$smallestQuantityAccessory = $this->getSmallestQuantityAccessory($product); |
|
|
|
|
|
|
|
|
|
|
|
if(!is_null($smallestQuantityAccessory)) { |
|
|
|
|
|
$quantityMax = is_null($quantityMax) ? $smallestQuantityAccessory : min($quantityMax, $smallestQuantityAccessory); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return $quantityMax; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public function getQuantityOfAccessoryAvailableInDistribution(Accessory $accessory, Distribution $distribution): int |
|
|
public function getQuantityOfAccessoryAvailableInDistribution(Accessory $accessory, Distribution $distribution): int |
|
|
{ |
|
|
{ |
|
|
$quantityOfAccessoryUsed = 0; |
|
|
$quantityOfAccessoryUsed = 0; |
|
|
|
|
|
|
|
|
return $smallestQuantity; |
|
|
return $smallestQuantity; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function getSmallestQuantityAccessory(Product $product, Distribution $distribution): ?int |
|
|
|
|
|
{ |
|
|
|
|
|
$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); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return $smallestQuantity; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function getProductQuantityRemaining(Product $product, Distribution $distribution): ?float |
|
|
public function getProductQuantityRemaining(Product $product, Distribution $distribution): ?float |
|
|
{ |
|
|
{ |
|
|
$productDistribution = $this->productDistributionRepository->findOneProductDistribution($distribution, $product); |
|
|
$productDistribution = $this->productDistributionRepository->findOneProductDistribution($distribution, $product); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $quantityRemaining; |
|
|
return $quantityRemaining; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function getProductQuantityMax(Product $product, Distribution $distribution): ?float |
|
|
|
|
|
{ |
|
|
|
|
|
$productDistribution = $this->productDistributionRepository->findOneProductDistribution($distribution, $product); |
|
|
|
|
|
if(!$productDistribution) { |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$quantityMax = $productDistribution->quantity_max; |
|
|
|
|
|
$smallestQuantityAccessory = $this->getSmallestQuantityAccessory($product, $distribution); |
|
|
|
|
|
|
|
|
|
|
|
if(!is_null($smallestQuantityAccessory)) { |
|
|
|
|
|
$quantityMax = is_null($quantityMax) ? $smallestQuantityAccessory : min($quantityMax, $smallestQuantityAccessory); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return $quantityMax; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |