|
|
|
|
|
|
|
|
use Lc\CaracoleBundle\Model\Order\OrderStatusModel; |
|
|
use Lc\CaracoleBundle\Model\Order\OrderStatusModel; |
|
|
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; |
|
|
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; |
|
|
use Lc\CaracoleBundle\Model\Product\ProductFamilyModel; |
|
|
use Lc\CaracoleBundle\Model\Product\ProductFamilyModel; |
|
|
|
|
|
use Lc\CaracoleBundle\Model\Product\ProductInterface; |
|
|
use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface; |
|
|
use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface; |
|
|
use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface; |
|
|
use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface; |
|
|
use Lc\CaracoleBundle\Model\Section\SectionInterface; |
|
|
use Lc\CaracoleBundle\Model\Section\SectionInterface; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($orderShop->getOrderProducts() as $orderProduct) { |
|
|
foreach ($orderShop->getOrderProducts() as $orderProduct) { |
|
|
if ($this->orderProductSolver->compare($orderProduct, $orderProductAdd)) { |
|
|
if ($this->orderProductSolver->compare($orderProduct, $orderProductAdd)) { |
|
|
|
|
|
|
|
|
$orderProduct->setQuantityOrder( |
|
|
$orderProduct->setQuantityOrder( |
|
|
$orderProduct->getQuantityOrder() + $orderProductAdd->getQuantityOrder() |
|
|
$orderProduct->getQuantityOrder() + $orderProductAdd->getQuantityOrder() |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
public function deductAvailabilityProduct(OrderShopInterface $orderShop): void |
|
|
public function deductAvailabilityProduct(OrderShopInterface $orderShop): void |
|
|
{ |
|
|
{ |
|
|
foreach ($orderShop->getOrderProducts() as $orderProduct) { |
|
|
foreach ($orderShop->getOrderProducts() as $orderProduct) { |
|
|
$this->applyDeductAvailabilityProduct($orderShop, $orderProduct); |
|
|
|
|
|
|
|
|
$this->applyDeductAvailabilityProduct($orderShop, $orderProduct->getProduct(), $orderProduct->getQuantityOrder()); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function applyDeductAvailabilityProduct( |
|
|
public function applyDeductAvailabilityProduct( |
|
|
OrderShopInterface $orderShop, |
|
|
OrderShopInterface $orderShop, |
|
|
OrderProductInterface $orderProduct |
|
|
|
|
|
|
|
|
ProductInterface $product, |
|
|
|
|
|
int $quantityOrder |
|
|
): void { |
|
|
): void { |
|
|
switch ($orderProduct->getProduct()->getProductFamily()->getBehaviorCountStock()) { |
|
|
|
|
|
|
|
|
switch ($product->getProductFamily()->getBehaviorCountStock()) { |
|
|
case ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_MEASURE : |
|
|
case ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_MEASURE : |
|
|
|
|
|
|
|
|
//Disponibilité par unité de référence |
|
|
//Disponibilité par unité de référence |
|
|
$oldAvailability = $this->productSolver->getAvailableQuantityInherited($orderProduct->getProduct()); |
|
|
|
|
|
$newAvailability = $oldAvailability - ($orderProduct->getQuantityOrder( |
|
|
|
|
|
) * ($orderProduct->getQuantityProduct() / $orderProduct->getUnit()->getCoefficient())); |
|
|
|
|
|
|
|
|
$oldAvailability = $this->productSolver->getAvailableQuantityInherited($product); |
|
|
|
|
|
$newAvailability = $oldAvailability - ($quantityOrder * ($this->productSolver->getQuantityInherited( |
|
|
|
|
|
$product |
|
|
|
|
|
) / $this->productSolver->getUnitInherited($product)->getCoefficient())); |
|
|
|
|
|
|
|
|
$productFamily = $orderProduct->getProduct()->getProductFamily(); |
|
|
|
|
|
|
|
|
$productFamily = $product->getProductFamily(); |
|
|
$productFamily->setAvailableQuantity($newAvailability); |
|
|
$productFamily->setAvailableQuantity($newAvailability); |
|
|
$productFamily->setUpdatedBy($orderShop->getUser()); |
|
|
$productFamily->setUpdatedBy($orderShop->getUser()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
break; |
|
|
case ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY : |
|
|
case ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY : |
|
|
|
|
|
|
|
|
$oldAvailability = $this->productSolver->getAvailableQuantityInherited($orderProduct->getProduct()); |
|
|
|
|
|
$newAvailability = $oldAvailability - $orderProduct->getQuantityOrder(); |
|
|
|
|
|
|
|
|
$oldAvailability = $this->productSolver->getAvailableQuantityInherited($product); |
|
|
|
|
|
$newAvailability = $oldAvailability - $quantityOrder; |
|
|
|
|
|
|
|
|
$productFamily = $orderProduct->getProduct()->getProductFamily(); |
|
|
|
|
|
|
|
|
$productFamily = $product->getProductFamily(); |
|
|
$productFamily->setAvailableQuantity($newAvailability); |
|
|
$productFamily->setAvailableQuantity($newAvailability); |
|
|
$productFamily->setUpdatedBy($orderShop->getUser()); |
|
|
$productFamily->setUpdatedBy($orderShop->getUser()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
break; |
|
|
case ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT : |
|
|
case ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT : |
|
|
$oldAvailability = $this->productSolver->getAvailableQuantityInherited($orderProduct->getProduct()); |
|
|
|
|
|
$newAvailability = $oldAvailability - $orderProduct->getQuantityOrder(); |
|
|
|
|
|
|
|
|
$oldAvailability = $this->productSolver->getAvailableQuantityInherited($product); |
|
|
|
|
|
$newAvailability = $oldAvailability - $quantityOrder; |
|
|
|
|
|
|
|
|
$product = $orderProduct->getProduct(); |
|
|
|
|
|
$product->setAvailableQuantity($newAvailability); |
|
|
$product->setAvailableQuantity($newAvailability); |
|
|
$product->setUpdatedBy($orderShop->getUser()); |
|
|
$product->setUpdatedBy($orderShop->getUser()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
$this->entityManager->flush(); |
|
|
$this->entityManager->flush(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function updatePriceByProductFamily(ProductFamilyInterface $productFamily) |
|
|
public function updatePriceByProductFamily(ProductFamilyInterface $productFamily) |
|
|
{ |
|
|
{ |
|
|
$debug = ''; |
|
|
$debug = ''; |