|
|
|
|
|
|
|
|
namespace Lc\ShopBundle\Price\Services; |
|
|
namespace Lc\ShopBundle\Price\Services; |
|
|
|
|
|
|
|
|
use Lc\ShopBundle\Context\OrderProductInterface; |
|
|
use Lc\ShopBundle\Context\OrderProductInterface; |
|
|
|
|
|
use Lc\ShopBundle\Context\OrderShopInterface; |
|
|
use Lc\ShopBundle\Context\ProductPropertyInterface; |
|
|
use Lc\ShopBundle\Context\ProductPropertyInterface; |
|
|
|
|
|
|
|
|
trait PriceUtilsTrait |
|
|
trait PriceUtilsTrait |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $this->round($priceReturn); |
|
|
return $this->round($priceReturn); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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() |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |