Browse Source

PriceUtils

feature/export_comptable
Guillaume 4 years ago
parent
commit
47055737ed
2 changed files with 34 additions and 4 deletions
  1. +32
    -2
      ShopBundle/Services/Price/OrderShopPriceUtils.php
  2. +2
    -2
      ShopBundle/Services/Price/PriceUtils.php

+ 32
- 2
ShopBundle/Services/Price/OrderShopPriceUtils.php View File

return $total; return $total;
} }


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


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


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

public function getTotalOrderProductsWithTax(OrderShopInterface $orderShop): float public function getTotalOrderProductsWithTax(OrderShopInterface $orderShop): float
{ {
return $this->getTotalOrderProductsWithTaxByOrderProducts($orderShop->getOrderProducts()); return $this->getTotalOrderProductsWithTaxByOrderProducts($orderShop->getOrderProducts());
} }


public function getTotalBuyingPriceOrderProducts($orderProducts): float
{
$total = 0;

foreach ($orderProducts as $orderProduct) {
$total += $this->orderProductPriceUtils->getTotalBuyingPrice($orderProduct);
}

return $total;
}

public function getTotalBuyingPriceOrderProductsWithTax($orderProducts): float public function getTotalBuyingPriceOrderProductsWithTax($orderProducts): float
{ {
$total = 0; $total = 0;


return $amountWithTax; return $amountWithTax;
} }

public function getTotalReductions()
{

}

public function getTotalReductionsWithTax()
{

}
} }



+ 2
- 2
ShopBundle/Services/Price/PriceUtils.php View File

$service = 'orderProductPriceUtils'; $service = 'orderProductPriceUtils';
} }


if ($entity instanceof OrderShopInterface || is_array($entity)) {
if ($entity instanceof OrderShopInterface || is_iterable($entity) || is_array($entity)) {
$service = 'orderShopPriceUtils'; $service = 'orderShopPriceUtils';
} }


} }
} else { } else {
if (!strlen($service)) { if (!strlen($service)) {
throw new \ErrorException("PriceUtils : le type d'entité n'est pas géré.");
throw new \ErrorException("PriceUtils : le type d'entité n'est pas géré");
} else { } else {
if (!method_exists($this->$service, $name)) { if (!method_exists($this->$service, $name)) {
throw new \ErrorException("PriceUtils : la méthode " . $name . " du service " . $service . " n'existe pas."); throw new \ErrorException("PriceUtils : la méthode " . $name . " du service " . $service . " n'existe pas.");

Loading…
Cancel
Save