|
- <?php
-
- namespace Lc\ShopBundle\Services\Price;
-
-
- use Doctrine\Common\Collections\Collection;
- use Lc\ShopBundle\Context\OrderProductInterface;
- use Lc\ShopBundle\Context\OrderShopInterface;
- use Lc\ShopBundle\Context\ProductFamilyInterface;
- use Lc\ShopBundle\Context\ProductInterface;
- use Lc\ShopBundle\Context\ProductPropertyInterface;
- use Lc\ShopBundle\Context\ReductionCatalogInterface;
-
- class OrderProductPriceUtils
- {
- use PriceUtilsTrait ;
-
- protected $productPriceUtils ;
-
- public function __construct(ProductPriceUtils $productPriceUtils)
- {
- $this->productPriceUtils = $productPriceUtils ;
- }
-
- public function getPrice(OrderProductInterface $orderProduct)
- {
- return $orderProduct->getPrice();
- }
-
- public function getBuyingPrice(OrderProductInterface $orderProduct)
- {
- return $orderProduct->getBuyingPrice();
- }
-
- public function getPriceWithTax(OrderProductInterface $orderProduct)
- {
- return $this->applyTax(
- $this->getPrice($orderProduct),
- $orderProduct->getTaxRate()->getValue()
- );
- }
-
- public function getPriceWithTaxAndReduction(OrderProductInterface $orderProduct)
- {
- return $this->applyReductionCatalog(
- $orderProduct,
- $this->getPrice($orderProduct),
- $this->getPriceWithTax($orderProduct)
- );
-
- }
-
- public function getPriceWithReduction(OrderProductInterface $orderProduct)
- {
- return $this->applyReductionCatalog(
- $orderProduct,
- $this->getPrice($orderProduct),
- $this->getPriceWithTax($orderProduct),
- null,
- false
- );
-
- }
-
- public function getTotal(OrderProductInterface $orderProduct)
- {
- return $orderProduct->getQuantityOrder() * $this->getPrice($orderProduct);
- }
-
-
-
- public function getMargin(OrderProductInterface $orderProduct)
- {
- return $this->getPriceWithReduction($orderProduct) - $this->getBuyingPrice($orderProduct);
- }
-
- public function getMarginPercent(OrderProductInterface $orderProduct)
- {
- if($this->getBuyingPrice($orderProduct)) {
- return ($this->getMargin($orderProduct) / $this->getBuyingPrice($orderProduct)) * 100;
- }else{
- return 0;
- }
- }
-
- public function getTotalMargin(OrderProductInterface $orderProduct)
- {
- return $orderProduct->getQuantityOrder() * $this->getMargin($orderProduct);
- }
-
-
- public function getTotalWithReduction(OrderProductInterface $orderProduct)
- {
- return $this->applyReductionCatalog(
- $orderProduct,
- $this->getTotal($orderProduct),
- $this->getTotalWithTax($orderProduct),
- null,
- false
- );
- }
-
- public function getTotalWithTax(OrderProductInterface $orderProduct)
- {
- return $this->applyTax(
- $this->getTotal($orderProduct),
- $orderProduct->getTaxRateInherited()->getValue()
- );
- }
-
- public function getTotalWithTaxAndReduction(OrderProductInterface $orderProduct)
- {
- return $this->applyReductionCatalog(
- $orderProduct,
- $this->getTotal($orderProduct),
- $this->getTotalWithTax($orderProduct)
- );
- }
-
-
- public function getTotalTaxes(OrderProductInterface $orderProduct){
- return $this->getTotalWithTaxAndReduction($orderProduct) - $this->getTotalWithReduction($orderProduct);
- }
- }
|