Browse Source

Prix

feature/export_comptable
Guillaume 4 years ago
parent
commit
7735728fed
3 changed files with 34 additions and 17 deletions
  1. +2
    -2
      ShopBundle/Services/Order/OrderUtils.php
  2. +22
    -15
      ShopBundle/Services/Price/OrderShopPriceUtils.php
  3. +10
    -0
      ShopBundle/Services/Price/PriceUtils.php

+ 2
- 2
ShopBundle/Services/Order/OrderUtils.php View File

@@ -275,7 +275,7 @@ class OrderUtils

if ($order) {
$data['count'] = $this->countQuantities($order);
$data['total_with_tax'] = $this->priceUtils->getTotalWithTaxAndReduction($order);
$data['total_with_tax'] = $this->priceUtils->getTotalWithTax($order);
$data['order_products_by_category'] = $this->getOrderProductsByParentCategory($order);
}
return $data;
@@ -402,7 +402,7 @@ class OrderUtils

public function isOrderPaid($order)
{
if ($this->getTotalOrderPayments($order) >= $this->priceUtils->getTotalWithTaxAndReduction($order)) {
if ($this->getTotalOrderPayments($order) >= $this->priceUtils->getTotalWithTax($order)) {
return true;
} else {
$order->editError[] = 'field.error.orderStatus.noPayment';

+ 22
- 15
ShopBundle/Services/Price/OrderShopPriceUtils.php View File

@@ -41,7 +41,9 @@ class OrderShopPriceUtils implements OrderShopPriceUtilsInterface
}


public function getTotalOrderProductsTaxes(OrderShopInterface $orderShop):float {
public function getTotalOrderProductsTaxes(OrderShopInterface $orderShop):float
{
return 0 ;
}

public function getOrderProductsTaxesAsArray(OrderShopInterface $orderShop):array
@@ -71,9 +73,9 @@ class OrderShopPriceUtils implements OrderShopPriceUtilsInterface
return $this->getTotalOrderProducts($orderShop) / $this->getTotalOrderProductsWithReductions($orderShop);
}

private function getTaxRateAverage(OrderShopInterface $order):float
private function getTaxRateAverage(OrderShopInterface $orderShop):float
{
return $this->getTotalOrderProductsWithTax() / $this->getTotalOrderProducts();
return $this->getTotalOrderProductsWithTax($orderShop) / $this->getTotalOrderProducts($orderShop);
}

public function getTotalOrderProductsWithReductions(OrderShopInterface $orderShop)
@@ -126,7 +128,7 @@ class OrderShopPriceUtils implements OrderShopPriceUtilsInterface
if ($orderReductionCart->getBehaviorTaxRate() == 'tax-excluded') {
$price = $orderReductionCart->getValue();
} else if ($orderReductionCart->getBehaviorTaxRate() == 'tax-included') {
$price = $orderReductionCart->getValue() / $this->getTaxRateAverage();
$price = $orderReductionCart->getValue() / $this->getTaxRateAverage($order);
}

}
@@ -137,34 +139,37 @@ class OrderShopPriceUtils implements OrderShopPriceUtilsInterface

public function getOrderProductsReductionCartAmountWithTax(OrderShopInterface $order, $orderReductionCart)
{
$amount = 0;

$amount =0;
if($orderReductionCart->getAppliedTo() === ReductionCart::APPLIED_TO_ORDER_PRODUCTS) {
if ($orderReductionCart->getUnit() == 'percent') {

$amount = $this->amountReductionByPercentValue(
$this->getTotalOrderProductsWithTax($order),
$orderReductionCart->getValue()
);
} else if ($orderReductionCart->getUnit() == 'amount') {
}
elseif ($orderReductionCart->getUnit() == 'amount') {
if ($orderReductionCart->getBehaviorTaxRate() == 'tax-excluded') {
$amount = $orderReductionCart->getValue() * $this->getTaxRateAverage();
} else if ($orderReductionCart->getBehaviorTaxRate() == 'tax-included') {
$amount = $orderReductionCart->getValue() * $this->getTaxRateAverage($order);
}
elseif ($orderReductionCart->getBehaviorTaxRate() == 'tax-included') {
$amount = $orderReductionCart->getValue() ;
}

}
}

return $amount ;
}

public function getOrderProductsReductionCreditAmountWithoutTax(OrderShopInterface $order, OrderReductionCreditInterface $orderReductionCredit)
{
$amount =0;
$amount = 0;
if ($orderReductionCredit->getBehaviorTaxRate() == 'tax-excluded') {
$amount = $orderReductionCredit->getValue();
} else if ($orderReductionCredit->getBehaviorTaxRate() == 'tax-included') {
$amount = $orderReductionCredit->getValue() / $this->getTaxRateAverage();
}
else if ($orderReductionCredit->getBehaviorTaxRate() == 'tax-included') {
$amount = $orderReductionCredit->getValue() / $this->getTaxRateAverage($order);
}

return $amount;
@@ -172,12 +177,14 @@ class OrderShopPriceUtils implements OrderShopPriceUtilsInterface

public function getOrderProductsReductionCreditAmountWithTax(OrderShopInterface $order, OrderReductionCreditInterface $orderReductionCredit)
{
$amount =0;
$amountWithTax = 0;
if ($orderReductionCredit->getBehaviorTaxRate() == 'tax-excluded') {
$amountWithTax = $orderReductionCredit->getValue() * $this->getTaxRateAverage();
} else if ($orderReductionCredit->getBehaviorTaxRate() == 'tax-included') {
$amountWithTax = $orderReductionCredit->getValue() * $this->getTaxRateAverage($order);
}
elseif ($orderReductionCredit->getBehaviorTaxRate() == 'tax-included') {
$amountWithTax = $orderReductionCredit->getValue();
}

return $amountWithTax;
}
}

+ 10
- 0
ShopBundle/Services/Price/PriceUtils.php View File

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

return false ;
}

Loading…
Cancel
Save