@@ -19,7 +19,7 @@ trait OrderUtilsStockTrait | |||
//Disponibilité par unité de référence | |||
$oldAvailability = $orderProduct->getProduct()->getAvailableQuantityInherited(); | |||
$newAvailability = $oldAvailability - ($orderProduct->getQuantityProduct() / $orderProduct->getUnit()->getCoefficient()); | |||
$newAvailability = $oldAvailability - ($orderProduct->getQuantityOrder() * ($orderProduct->getQuantityProduct() / $orderProduct->getUnit()->getCoefficient())); | |||
$orderProduct->getProduct()->getProductFamily()->setAvailableQuantity($newAvailability); | |||
$this->em->persist($orderProduct->getProduct()->getProductFamily()); |
@@ -56,6 +56,7 @@ class OrderProductPriceUtils | |||
$orderProduct, | |||
$this->getPrice($orderProduct), | |||
$this->getPriceWithTax($orderProduct), | |||
1, | |||
null, | |||
false | |||
); | |||
@@ -95,6 +96,7 @@ class OrderProductPriceUtils | |||
$orderProduct, | |||
$this->getTotal($orderProduct), | |||
$this->getTotalWithTax($orderProduct), | |||
$orderProduct->getQuantityOrder(), | |||
null, | |||
false | |||
); | |||
@@ -113,7 +115,8 @@ class OrderProductPriceUtils | |||
return $this->applyReductionCatalog( | |||
$orderProduct, | |||
$this->getTotal($orderProduct), | |||
$this->getTotalWithTax($orderProduct) | |||
$this->getTotalWithTax($orderProduct), | |||
$orderProduct->getQuantityOrder() | |||
); | |||
} | |||
@@ -42,8 +42,9 @@ trait PriceUtilsTrait | |||
return round((($price * $percent)) / 100, 2); | |||
} | |||
public function applyReductionCatalog($entity, $price, $priceWithTax, $reductionCatalog = null, $withTax = true): ?float | |||
public function applyReductionCatalog($entity, $price, $priceWithTax, $quantity = 1, $reductionCatalog = null, $withTax = true): ?float | |||
{ | |||
if ($reductionCatalog) { | |||
$reductionCatalogValue = $reductionCatalog->getValue(); | |||
$reductionCatalogUnit = $reductionCatalog->getUnit(); | |||
@@ -80,14 +81,14 @@ trait PriceUtilsTrait | |||
$priceWithTax = $this->applyTax( | |||
$this->applyReductionAmount( | |||
$price, | |||
$reductionCatalogValue | |||
$reductionCatalogValue * $quantity | |||
), | |||
$entity->getTaxRateInherited()->getValue() | |||
); | |||
} elseif ($reductionCatalogBehaviorTaxRate == 'tax-included') { | |||
$priceWithTax = $this->applyReductionAmount( | |||
$priceWithTax, | |||
$reductionCatalogValue | |||
$reductionCatalogValue * $quantity | |||
); | |||
} | |||
} |