Browse Source

[Boutique] Gestion accessoires

feature/rotating_product
Guillaume Bourgeois 5 months ago
parent
commit
06a0a0692f
1 changed files with 9 additions and 17 deletions
  1. +9
    -17
      domain/Order/Order/OrderResolver.php

+ 9
- 17
domain/Order/Order/OrderResolver.php View File

Product $product, Product $product,
Distribution $distribution, Distribution $distribution,
bool $inNumberOfPieces = false, bool $inNumberOfPieces = false,
Order $orderCurrent = null,
bool $ignoreOrderCurrent = false
Order $orderCurrent = null
): float ): float
{ {
if(!isset($this->ordersArrayCachedByDistribution[$distribution->id])) { if(!isset($this->ordersArrayCachedByDistribution[$distribution->id])) {
} }
$ordersArray = $this->ordersArrayCachedByDistribution[$distribution->id]; $ordersArray = $this->ordersArrayCachedByDistribution[$distribution->id];
if($orderCurrent) { if($orderCurrent) {
$ordersArray = $this->orderBuilder->addOrUpdateOrIgnoreOrderFromArray($orderCurrent, $ordersArray, $ignoreOrderCurrent);
$ordersArray = $this->orderBuilder->addOrUpdateOrIgnoreOrderFromArray($orderCurrent, $ordersArray);
} }


$productQuantity = $this->orderSolver->getProductQuantity($product, $ordersArray); $productQuantity = $this->orderSolver->getProductQuantity($product, $ordersArray);
public function getQuantityOfAccessoryAvailableInDistribution( public function getQuantityOfAccessoryAvailableInDistribution(
Accessory $accessory, Accessory $accessory,
Distribution $distribution, Distribution $distribution,
Order $orderCurrent = null,
bool $ignoreOrderCurrent = false
Order $orderCurrent = null
): int ): int
{ {
$quantityOfAccessoryUsed = 0; $quantityOfAccessoryUsed = 0;
$productAccessory->getProduct(), $productAccessory->getProduct(),
$distribution, $distribution,
true, true,
$orderCurrent,
$ignoreOrderCurrent
$orderCurrent
); );
} }


public function getSmallestQuantityAccessoryAvailable( public function getSmallestQuantityAccessoryAvailable(
Product $product, Product $product,
Distribution $distribution, Distribution $distribution,
Order $orderCurrent = null,
bool $ignoreOrderCurrent = false
Order $orderCurrent = null
): ?int ): ?int
{ {
$smallestQuantity = null; $smallestQuantity = null;
$quantityAccessoryAvailableInDistribution = $this->getQuantityOfAccessoryAvailableInDistribution( $quantityAccessoryAvailableInDistribution = $this->getQuantityOfAccessoryAvailableInDistribution(
$productAccessory->getAccessory(), $productAccessory->getAccessory(),
$distribution, $distribution,
$orderCurrent,
$ignoreOrderCurrent
$orderCurrent
); );
$smallestQuantity = is_null($smallestQuantity) ? $quantityAccessoryAvailableInDistribution $smallestQuantity = is_null($smallestQuantity) ? $quantityAccessoryAvailableInDistribution
: min($smallestQuantity, $quantityAccessoryAvailableInDistribution); : min($smallestQuantity, $quantityAccessoryAvailableInDistribution);
public function getProductQuantityRemaining( public function getProductQuantityRemaining(
Product $product, Product $product,
Distribution $distribution, Distribution $distribution,
Order $orderCurrent = null,
bool $ignoreOrderCurrent = false
Order $orderCurrent = null
): ?float ): ?float
{ {
$productDistribution = $this->productDistributionRepository->findOneProductDistribution($distribution, $product); $productDistribution = $this->productDistributionRepository->findOneProductDistribution($distribution, $product);
$product, $product,
$distribution, $distribution,
false, false,
$orderCurrent,
$ignoreOrderCurrent
$orderCurrent
); );
$quantityRemaining = is_null($productDistribution->quantity_max) ? null $quantityRemaining = is_null($productDistribution->quantity_max) ? null
: ($productDistribution->quantity_max - $quantityOrder); : ($productDistribution->quantity_max - $quantityOrder);
$smallestQuantityAccessoryAvailable = $this->getSmallestQuantityAccessoryAvailable( $smallestQuantityAccessoryAvailable = $this->getSmallestQuantityAccessoryAvailable(
$product, $product,
$distribution, $distribution,
$orderCurrent,
$ignoreOrderCurrent
$orderCurrent
); );
if (!is_null($smallestQuantityAccessoryAvailable)) { if (!is_null($smallestQuantityAccessoryAvailable)) {
$smallestQuantityAccessoryAvailable = $this->productSolver->getWeightOrNumberOfPieces($smallestQuantityAccessoryAvailable, $product); $smallestQuantityAccessoryAvailable = $this->productSolver->getWeightOrNumberOfPieces($smallestQuantityAccessoryAvailable, $product);

Loading…
Cancel
Save