|
|
@@ -36,8 +36,7 @@ class OrderResolver extends AbstractResolver |
|
|
|
Product $product, |
|
|
|
Distribution $distribution, |
|
|
|
bool $inNumberOfPieces = false, |
|
|
|
Order $orderCurrent = null, |
|
|
|
bool $ignoreOrderCurrent = false |
|
|
|
Order $orderCurrent = null |
|
|
|
): float |
|
|
|
{ |
|
|
|
if(!isset($this->ordersArrayCachedByDistribution[$distribution->id])) { |
|
|
@@ -45,7 +44,7 @@ class OrderResolver extends AbstractResolver |
|
|
|
} |
|
|
|
$ordersArray = $this->ordersArrayCachedByDistribution[$distribution->id]; |
|
|
|
if($orderCurrent) { |
|
|
|
$ordersArray = $this->orderBuilder->addOrUpdateOrIgnoreOrderFromArray($orderCurrent, $ordersArray, $ignoreOrderCurrent); |
|
|
|
$ordersArray = $this->orderBuilder->addOrUpdateOrIgnoreOrderFromArray($orderCurrent, $ordersArray); |
|
|
|
} |
|
|
|
|
|
|
|
$productQuantity = $this->orderSolver->getProductQuantity($product, $ordersArray); |
|
|
@@ -105,8 +104,7 @@ class OrderResolver extends AbstractResolver |
|
|
|
public function getQuantityOfAccessoryAvailableInDistribution( |
|
|
|
Accessory $accessory, |
|
|
|
Distribution $distribution, |
|
|
|
Order $orderCurrent = null, |
|
|
|
bool $ignoreOrderCurrent = false |
|
|
|
Order $orderCurrent = null |
|
|
|
): int |
|
|
|
{ |
|
|
|
$quantityOfAccessoryUsed = 0; |
|
|
@@ -116,8 +114,7 @@ class OrderResolver extends AbstractResolver |
|
|
|
$productAccessory->getProduct(), |
|
|
|
$distribution, |
|
|
|
true, |
|
|
|
$orderCurrent, |
|
|
|
$ignoreOrderCurrent |
|
|
|
$orderCurrent |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
@@ -127,8 +124,7 @@ class OrderResolver extends AbstractResolver |
|
|
|
public function getSmallestQuantityAccessoryAvailable( |
|
|
|
Product $product, |
|
|
|
Distribution $distribution, |
|
|
|
Order $orderCurrent = null, |
|
|
|
bool $ignoreOrderCurrent = false |
|
|
|
Order $orderCurrent = null |
|
|
|
): ?int |
|
|
|
{ |
|
|
|
$smallestQuantity = null; |
|
|
@@ -138,8 +134,7 @@ class OrderResolver extends AbstractResolver |
|
|
|
$quantityAccessoryAvailableInDistribution = $this->getQuantityOfAccessoryAvailableInDistribution( |
|
|
|
$productAccessory->getAccessory(), |
|
|
|
$distribution, |
|
|
|
$orderCurrent, |
|
|
|
$ignoreOrderCurrent |
|
|
|
$orderCurrent |
|
|
|
); |
|
|
|
$smallestQuantity = is_null($smallestQuantity) ? $quantityAccessoryAvailableInDistribution |
|
|
|
: min($smallestQuantity, $quantityAccessoryAvailableInDistribution); |
|
|
@@ -152,8 +147,7 @@ class OrderResolver extends AbstractResolver |
|
|
|
public function getProductQuantityRemaining( |
|
|
|
Product $product, |
|
|
|
Distribution $distribution, |
|
|
|
Order $orderCurrent = null, |
|
|
|
bool $ignoreOrderCurrent = false |
|
|
|
Order $orderCurrent = null |
|
|
|
): ?float |
|
|
|
{ |
|
|
|
$productDistribution = $this->productDistributionRepository->findOneProductDistribution($distribution, $product); |
|
|
@@ -165,8 +159,7 @@ class OrderResolver extends AbstractResolver |
|
|
|
$product, |
|
|
|
$distribution, |
|
|
|
false, |
|
|
|
$orderCurrent, |
|
|
|
$ignoreOrderCurrent |
|
|
|
$orderCurrent |
|
|
|
); |
|
|
|
$quantityRemaining = is_null($productDistribution->quantity_max) ? null |
|
|
|
: ($productDistribution->quantity_max - $quantityOrder); |
|
|
@@ -176,8 +169,7 @@ class OrderResolver extends AbstractResolver |
|
|
|
$smallestQuantityAccessoryAvailable = $this->getSmallestQuantityAccessoryAvailable( |
|
|
|
$product, |
|
|
|
$distribution, |
|
|
|
$orderCurrent, |
|
|
|
$ignoreOrderCurrent |
|
|
|
$orderCurrent |
|
|
|
); |
|
|
|
if (!is_null($smallestQuantityAccessoryAvailable)) { |
|
|
|
$smallestQuantityAccessoryAvailable = $this->productSolver->getWeightOrNumberOfPieces($smallestQuantityAccessoryAvailable, $product); |