Pārlūkot izejas kodu

Nouveau système PriceUtils

feature/export_comptable
Guillaume pirms 4 gadiem
vecāks
revīzija
865d454616
4 mainītis faili ar 248 papildinājumiem un 0 dzēšanām
  1. +94
    -0
      ShopBundle/Services/Price/OrderProductPriceUtils.php
  2. +64
    -0
      ShopBundle/Services/Price/OrderShopPriceUtils.php
  3. +36
    -0
      ShopBundle/Services/Price/PriceUtilsTrait.php
  4. +54
    -0
      ShopBundle/Services/Price/ProductPriceUtils.php

+ 94
- 0
ShopBundle/Services/Price/OrderProductPriceUtils.php Parādīt failu

@@ -0,0 +1,94 @@
<?php

namespace Lc\ShopBundle\Price\Services;

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)
{

}

public function getPriceWithTax(OrderProductInterface $orderProduct)
{

}

public function getPriceWithTaxAndReduction(OrderProductInterface $orderProduct)
{

}

public function getPriceByRefUnit(OrderProductInterface $orderProduct)
{

}

public function getPriceByRefUnitWithTax(OrderProductInterface $orderProduct)
{

}

public function getPriceByRefUnitWithTaxAndReduction(OrderProductInterface $orderProduct)
{

}

public function getTotal(OrderProductInterface $orderProduct)
{

}

public function getTotalWithReductionCatalog(OrderProductInterface $orderProduct)
{

}

public function getTotalWithReductionCart(OrderProductInterface $orderProduct)
{

}

public function getTotalWithReductions(OrderProductInterface $orderProduct)
{

}

public function getTotalWithTax(OrderProductInterface $orderProduct)
{

}

public function getTotalWithTaxAndReductionCatalog(OrderProductInterface $orderProduct)
{

}

public function getTotalWithTaxAndReductionCart(OrderProductInterface $orderProduct)
{

}

public function getTotalWithTaxAndReductions(OrderProductInterface $orderProduct)
{

}
}


+ 64
- 0
ShopBundle/Services/Price/OrderShopPriceUtils.php Parādīt failu

@@ -0,0 +1,64 @@
<?php

namespace Lc\ShopBundle\Price\Services;

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 OrderShopPriceUtils
{
use PriceUtilsTrait ;

protected $orderProductPriceUtils ;

public function __construct(OrderProductPriceUtils $orderProductPriceUtils)
{
$this->orderProductPriceUtils = $orderProductPriceUtils ;
}

public function getTotal(OrderShopInterface $orderShop)
{

}

public function getTotalWithReductionCatalog(OrderShopInterface $orderShop)
{

}

public function getTotalWithReductionCart(OrderShopInterface $orderShop)
{

}

public function getTotalWithReductions(OrderShopInterface $orderShop)
{

}

public function getTotalWithTax(OrderShopInterface $orderShop)
{

}

public function getTotalWithTaxAndReductionCatalog(OrderShopInterface $orderShop)
{

}

public function getTotalWithTaxAndReductionCart(OrderShopInterface $orderShop)
{

}

public function getTotalWithTaxAndReductions(OrderShopInterface $orderShop)
{

}
}


+ 36
- 0
ShopBundle/Services/Price/PriceUtilsTrait.php Parādīt failu

@@ -0,0 +1,36 @@
<?php

namespace Lc\ShopBundle\Price\Services;

trait PriceUtilsTrait
{
public function applyTax($price, $taxRateValue)
{
return $this->round($this->applyPercent($price, $taxRateValue));
}

public function applyReductionPercent($price, $percentage)
{
return $this->applyPercent($price, -$percentage);
}

public function applyReductionAmount($price, $amount)
{
return $price - $amount;
}

public function applyPercent($price, $percentage)
{
return $price * ($percentage / 100 + 1);
}

public function applyPercentNegative($price, $percentage)
{
return $price / ($percentage / 100 + 1);
}

public function round($price)
{
return round((($price * 100)) / 100, 2);
}
}

+ 54
- 0
ShopBundle/Services/Price/ProductPriceUtils.php Parādīt failu

@@ -0,0 +1,54 @@
<?php

namespace Lc\ShopBundle\Price\Services;

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 ProductPriceUtils
{
use PriceUtilsTrait ;

public function getPrice(ProductPropertyInterface $product)
{
if ($product->getBehaviorPriceInherited() == 'by-piece') {
return $product->getPriceInherited();
}
elseif ($product->getBehaviorPriceInherited() == 'by-reference-unit') {
if ($product->getQuantityInherited() > 0) {
return $product->getPriceByRefUnitInherited() * ($product->getQuantityInherited() / $product->getUnitInherited()->getCoefficient());
}
}
}

public function getPriceWithTax(ProductPropertyInterface $product)
{

}

public function getPriceWithTaxAndReduction(ProductPropertyInterface $product)
{

}

public function getPriceByRefUnit(ProductPropertyInterface $product)
{

}

public function getPriceByRefUnitWithTax(ProductPropertyInterface $product)
{

}

public function getPriceByRefUnitWithTaxAndReduction(ProductPropertyInterface $product)
{

}
}


Notiek ielāde…
Atcelt
Saglabāt