Browse Source

Processus de commande

feature/export_comptable
Fab 4 years ago
parent
commit
6b50dbada2
4 changed files with 46 additions and 32 deletions
  1. +5
    -0
      ShopBundle/Model/ReductionCart.php
  2. +1
    -0
      ShopBundle/Model/ReductionCartPropertyTrait.php
  3. +40
    -1
      ShopBundle/Services/Price/OrderShopPriceUtils.php
  4. +0
    -31
      ShopBundle/Services/Price/PriceUtilsTrait.php

+ 5
- 0
ShopBundle/Model/ReductionCart.php View File

@@ -17,6 +17,11 @@ use Lc\ShopBundle\Context\StatusInterface;
*/
abstract class ReductionCart extends AbstractEntity implements ReductionPropertyInterface, ReductionInterface, ReductionCartPropertyInterface, FilterMerchantInterface, OrderAmountMinInterface, StatusInterface
{

const APPLIED_TO_DELIVERY = 'delivery';
const APPLIED_TO_ORDER_PRODUCTS = 'order-products';


use StatusTrait;
use OrderAmountMin;
use ReductionTrait;

+ 1
- 0
ShopBundle/Model/ReductionCartPropertyTrait.php View File

@@ -6,6 +6,7 @@ use Doctrine\ORM\Mapping as ORM;

trait ReductionCartPropertyTrait
{

/**
* @ORM\Column(type="boolean", nullable=true)
*/

+ 40
- 1
ShopBundle/Services/Price/OrderShopPriceUtils.php View File

@@ -4,6 +4,7 @@ namespace Lc\ShopBundle\Price\Services;

use Lc\ShopBundle\Context\OrderShopInterface;
use Lc\ShopBundle\Context\OrderShopPriceUtilsInterface;
use Lc\ShopBundle\Model\ReductionCart;

class OrderShopPriceUtils implements OrderShopPriceUtilsInterface
{
@@ -69,7 +70,10 @@ class OrderShopPriceUtils implements OrderShopPriceUtilsInterface
return $this->getTotalOrderProducts($orderShop) / $this->getTotalOrderProductsWithReductions($orderShop);
}


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

public function getTotalOrderProductsWithReductions(OrderShopInterface $orderShop)
{
@@ -81,5 +85,40 @@ class OrderShopPriceUtils implements OrderShopPriceUtilsInterface
{

}

public function applyOrderProductsReductionCart(OrderShopInterface $order, $withTax = true)
{

foreach ($order->getOrderReductionCarts() as $orderReductionCart) {
if($orderReductionCart->getAppliedTo() == ReductionCart::APPLIED_TO_ORDER_PRODUCTS) {
if ($orderReductionCart->getUnit() == 'percent') {

$priceWithTax = $this->applyReductionPercent(
$this->getTotalOrderProductsWithTax($order),
$orderReductionCart->getValue
);
} else if ($orderReductionCart->getUnit() == 'amount') {
if ($orderReductionCart->getBehaviorTaxRate() == 'tax-excluded') {
$priceWithTax = $this->applyTax(
$this->applyReductionAmount(
$this->getTotalOrderProducts($order),
$orderReductionCart->getValue()
),
$order->getTaxRateAverage()
);
} else if ($orderReductionCart->getBehaviorTaxRate() == 'tax-included') {
$priceWithTax =
$this->applyReductionAmount(
$this->getTotalOrderProductsWithTax($order),
$orderReductionCart->getValue()
);

}
}
}
}

}

}


+ 0
- 31
ShopBundle/Services/Price/PriceUtilsTrait.php View File

@@ -99,37 +99,6 @@ trait PriceUtilsTrait
}


public function applyReductionCart(OrderShopInterface $order, $withTax = true)
{

foreach ($order->getOrderReductionCarts() as $orderReductionCart) {
if ($orderReductionCart->getUnit() == 'percent') {

$priceWithTax = $this->applyReductionPercent(
$this->getTotalOrderProductsWithTax($order),
$orderReductionCart->getValue
);
} else if ($orderReductionCart->getUnit() == 'amount') {
if ($orderReductionCart->getBehaviorTaxRate() == 'tax-excluded') {
$priceWithTax = $this->applyTax(
$this->applyReductionAmount(
$this->getTotalOrderProducts($order),
$orderReductionCart->getValue()
),
$order->getTaxRateInherited()->getValue()
);
if ($orderReductionCart->getBehaviorTaxRate() == 'tax-inlcluded') {
$priceWithTax =
$this->applyReductionAmount(
$this->getTotalOrderProductsWithTax($order),
$orderReductionCart->getValue()
);
}
}
}
}

}


}

Loading…
Cancel
Save