Parcourir la source

PriceUtils : getMarginOrderProductsWithReductions

feature/export_comptable
Guillaume il y a 4 ans
Parent
révision
fdb39f5535
1 fichiers modifiés avec 27 ajouts et 23 suppressions
  1. +27
    -23
      ShopBundle/Services/Price/OrderShopPriceUtils.php

+ 27
- 23
ShopBundle/Services/Price/OrderShopPriceUtils.php Voir le fichier

@@ -30,7 +30,6 @@ class OrderShopPriceUtils implements OrderShopPriceUtilsInterface
return $total;
}


//Inclus les ReductionCatalog des OrderProducts
public function getMarginOrderProducts(OrderShopInterface $orderShop): float
{
@@ -41,16 +40,41 @@ class OrderShopPriceUtils implements OrderShopPriceUtilsInterface
return $total;
}

public function getMarginOrderProductsWithReductions(OrderShopInterface $orderShop): float
{
$total = $this->getMarginOrderProducts($orderShop);

$totalReductionAmount = 0;
foreach ($orderShop->getOrderReductionCarts() as $orderReductionCart) {
$totalReductionAmount += $this->getOrderProductsReductionCartAmountWithoutTax($orderShop, $orderReductionCart);
}

foreach ($orderShop->getOrderReductionCredits() as $orderReductionCredit) {
$totalReductionAmount += $this->getOrderProductsReductionCreditAmountWithoutTax($orderShop, $orderReductionCredit);
}

$total -= $totalReductionAmount;

return $total;
}

public function getMarginOrderProductsPercent(OrderShopInterface $orderShop): float
{
if ($this->getTotalOrderProducts($orderShop)) {
return $this->round($this->getMarginOrderProducts($orderShop) / $this->getTotalOrderProducts($orderShop) * 100);
return $this->round($this->getMarginOrderProductsWithReductions($orderShop) / $this->getTotalOrderProductsWithReductions($orderShop) * 100);
} else {
return 0;
}

}

public function getMarginOrderProductsWithReductionsPercent(OrderShopInterface $orderShop): float
{
if ($this->getTotalOrderProducts($orderShop)) {
return $this->round($this->getMarginOrderProducts($orderShop) / $this->getTotalOrderProducts($orderShop) * 100);
} else {
return 0;
}
}

public function getTotalOrderProductsWithTax(OrderShopInterface $orderShop): float
{
@@ -162,26 +186,6 @@ class OrderShopPriceUtils implements OrderShopPriceUtilsInterface
return $total;
}


public function getMarginOrderProductsWithReductions(OrderShopInterface $orderShop): float
{
$total = $this->getMarginOrderProducts($orderShop);

$totalReductionAmount = 0;
foreach ($orderShop->getOrderReductionCarts() as $orderReductionCart) {
$totalReductionAmount += $this->getOrderProductsReductionCartAmountWithoutTax($orderShop, $orderReductionCart);
}

foreach ($orderShop->getOrderReductionCredits() as $orderReductionCredit) {
$totalReductionAmount += $this->getOrderProductsReductionCreditAmountWithoutTax($orderShop, $orderReductionCredit);
}

$total -= $totalReductionAmount;

return $total;
}


public function getTotalOrderProductsWithTaxAndReductionCarts(OrderShopInterface $orderShop)
{
$total = $this->getTotalOrderProductsWithTax($orderShop);

Chargement…
Annuler
Enregistrer