|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- <?php
-
- namespace Lc\CaracoleBundle\Solver\Price;
-
- use Lc\CaracoleBundle\Doctrine\Extension\ProductPropertyInterface;
-
- class ProductPriceSolver
- {
- use PriceSolverTrait;
-
- 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());
- } else {
- return 0;
- }
- }
- }
-
- public function getPriceWithTax(ProductPropertyInterface $product)
- {
- return $this->applyTax(
- $this->getPrice($product),
- $product->getTaxRateInherited()->getValue()
- );
- }
-
-
- public function getPriceByRefUnit(ProductPropertyInterface $product)
- {
- if ($product->getBehaviorPriceInherited() == 'by-piece') {
- return ($this->getPrice($product) * $product->getUnitInherited()->getCoefficient(
- )) / $product->getQuantityInherited();
- } elseif ($product->getBehaviorPriceInherited() == 'by-reference-unit') {
- return $product->getPriceByRefUnitInherited();
- }
- }
-
- public function getPriceByRefUnitWithTax(ProductPropertyInterface $product)
- {
- return $this->applyTax(
- $this->getPriceByRefUnit($product),
- $product->getTaxRateInherited()->getValue()
- );
- }
-
-
- public function getPriceWithTaxAndReduction(ProductPropertyInterface $product)
- {
- return $this->applyReductionCatalog(
- $product,
- $this->getPrice($product),
- $this->getPriceWithTax($product)
- );
- }
-
- public function getPriceByRefUnitWithTaxAndReduction(ProductPropertyInterface $product)
- {
- return ($this->getPriceByRefUnitWithTax($product) * $this->getPriceWithTaxAndReduction($product))
- / $this->getPriceWithTax($product);
- }
-
-
- public function getBuyingPrice(ProductPropertyInterface $product)
- {
- if ($product->getBehaviorPriceInherited() == 'by-piece') {
- return $product->getBuyingPriceInherited();
- } elseif ($product->getBehaviorPriceInherited() == 'by-reference-unit') {
- if ($product->getQuantityInherited() > 0) {
- return $product->getBuyingPriceByRefUnitInherited() * ($product->getQuantityInherited(
- ) / $product->getUnitInherited()->getCoefficient());
- } else {
- return 0;
- }
- }
- }
-
- public function getBuyingPriceWithTax(ProductPropertyInterface $product)
- {
- return $this->applyTax(
- $this->getBuyingPrice($product),
- $product->getTaxRateInherited()->getValue()
- );
- }
-
- public function getBuyingPriceByRefUnit(ProductPropertyInterface $product)
- {
- return $product->getBuyingPriceByRefUnitInherited();
- }
-
- public function getBuyingPriceByRefUnitWithTax(ProductPropertyInterface $product)
- {
- return $this->applyTax(
- $this->getBuyingPriceByRefUnit($product),
- $product->getTaxRateInherited()->getValue()
- );
- }
-
- public function getMultiplyingFactor(ProductPropertyInterface $product)
- {
- return $this->round($this->getPriceWithTax($product) / $this->getBuyingPrice($product));
- }
-
- }
-
|