|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace Lc\ShopBundle\Price\Services; |
|
|
namespace Lc\ShopBundle\Price\Services; |
|
|
|
|
|
|
|
|
|
|
|
use Lc\ShopBundle\Context\OrderReductionCreditInterface; |
|
|
use Lc\ShopBundle\Context\OrderShopInterface; |
|
|
use Lc\ShopBundle\Context\OrderShopInterface; |
|
|
use Lc\ShopBundle\Context\OrderShopPriceUtilsInterface; |
|
|
use Lc\ShopBundle\Context\OrderShopPriceUtilsInterface; |
|
|
use Lc\ShopBundle\Model\ReductionCart; |
|
|
use Lc\ShopBundle\Model\ReductionCart; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function amountOrderProductsReductionCart(OrderShopInterface $order, $orderReductionCart) |
|
|
|
|
|
|
|
|
public function getOrderProductsReductionCartAmountWithoutTax(OrderShopInterface $order, $orderReductionCart) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
if($orderReductionCart->getAppliedTo() === ReductionCart::APPLIED_TO_ORDER_PRODUCTS) { |
|
|
if($orderReductionCart->getAppliedTo() === ReductionCart::APPLIED_TO_ORDER_PRODUCTS) { |
|
|
if ($orderReductionCart->getUnit() == 'percent') { |
|
|
if ($orderReductionCart->getUnit() == 'percent') { |
|
|
|
|
|
|
|
|
$priceWithTax = $this->applyReductionPercent( |
|
|
|
|
|
$this->getTotalOrderProductsWithTax($order), |
|
|
|
|
|
$orderReductionCart->getValue |
|
|
|
|
|
|
|
|
$price = $this->applyReductionPercent( |
|
|
|
|
|
$this->getTotalOrderProducts($order), |
|
|
|
|
|
$orderReductionCart->getValue() |
|
|
); |
|
|
); |
|
|
} else if ($orderReductionCart->getUnit() == 'amount') { |
|
|
} else if ($orderReductionCart->getUnit() == 'amount') { |
|
|
if ($orderReductionCart->getBehaviorTaxRate() == 'tax-excluded') { |
|
|
if ($orderReductionCart->getBehaviorTaxRate() == 'tax-excluded') { |
|
|
$priceWithTax = $this->applyTax( |
|
|
|
|
|
$this->applyReductionAmount( |
|
|
|
|
|
$this->getTotalOrderProducts($order), |
|
|
|
|
|
$orderReductionCart->getValue() |
|
|
|
|
|
), |
|
|
|
|
|
$this->getTaxRateAverage($order) |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
$price = $orderReductionCart->getValue(); |
|
|
} else if ($orderReductionCart->getBehaviorTaxRate() == 'tax-included') { |
|
|
} else if ($orderReductionCart->getBehaviorTaxRate() == 'tax-included') { |
|
|
$priceWithTax = |
|
|
|
|
|
$this->applyReductionAmount( |
|
|
|
|
|
$this->getTotalOrderProductsWithTax($order), |
|
|
|
|
|
$orderReductionCart->getValue() |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$price = $orderReductionCart->getValue() / $this->getTaxRateAverage(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function amountOrderProductsReductionCredit(OrderShopInterface $order, $orderReductionCart) |
|
|
|
|
|
|
|
|
public function getOrderProductsReductionCartAmountWithTax(OrderShopInterface $order, $orderReductionCart) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if($orderReductionCart->getAppliedTo() === ReductionCart::APPLIED_TO_ORDER_PRODUCTS) { |
|
|
if ($orderReductionCart->getUnit() == 'percent') { |
|
|
if ($orderReductionCart->getUnit() == 'percent') { |
|
|
|
|
|
|
|
|
$priceWithTax = $this->applyReductionPercent( |
|
|
|
|
|
|
|
|
$price = $this->applyReductionPercent( |
|
|
$this->getTotalOrderProductsWithTax($order), |
|
|
$this->getTotalOrderProductsWithTax($order), |
|
|
$orderReductionCart->getValue |
|
|
|
|
|
|
|
|
$orderReductionCart->getValue() |
|
|
); |
|
|
); |
|
|
} else if ($orderReductionCart->getUnit() == 'amount') { |
|
|
} else if ($orderReductionCart->getUnit() == 'amount') { |
|
|
if ($orderReductionCart->getBehaviorTaxRate() == 'tax-excluded') { |
|
|
if ($orderReductionCart->getBehaviorTaxRate() == 'tax-excluded') { |
|
|
$priceWithTax = $this->applyTax( |
|
|
|
|
|
$this->applyReductionAmount( |
|
|
|
|
|
$this->getTotalOrderProducts($order), |
|
|
|
|
|
$orderReductionCart->getValue() |
|
|
|
|
|
), |
|
|
|
|
|
$this->getTaxRateAverage($order) |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
$price = $orderReductionCart->getValue() * $this->getTaxRateAverage(); |
|
|
} else if ($orderReductionCart->getBehaviorTaxRate() == 'tax-included') { |
|
|
} else if ($orderReductionCart->getBehaviorTaxRate() == 'tax-included') { |
|
|
$priceWithTax = |
|
|
|
|
|
$this->applyReductionAmount( |
|
|
|
|
|
$this->getTotalOrderProductsWithTax($order), |
|
|
|
|
|
$orderReductionCart->getValue() |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$price = $orderReductionCart->getValue() ; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function getOrderProductsReductionCreditAmountWithoutTax(OrderShopInterface $order, OrderReductionCreditInterface $orderReductionCredit) |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
if ($orderReductionCredit->getBehaviorTaxRate() == 'tax-excluded') { |
|
|
|
|
|
$amount = $orderReductionCredit->getValue(); |
|
|
|
|
|
} else if ($orderReductionCredit->getBehaviorTaxRate() == 'tax-included') { |
|
|
|
|
|
$amount = $orderReductionCredit->getValue() / $this->getTaxRateAverage(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return $amount; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function getOrderProductsReductionCreditAmountWithTax(OrderShopInterface $order, OrderReductionCreditInterface $orderReductionCredit) |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
if ($orderReductionCredit->getBehaviorTaxRate() == 'tax-excluded') { |
|
|
|
|
|
$amountWithTax = $orderReductionCredit->getValue() * $this->getTaxRateAverage(); |
|
|
|
|
|
} else if ($orderReductionCredit->getBehaviorTaxRate() == 'tax-included') { |
|
|
|
|
|
$amountWithTax = $orderReductionCredit->getValue(); |
|
|
|
|
|
} |
|
|
|
|
|
return $amountWithTax; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|