You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
2.3KB

  1. <?php
  2. namespace Lc\ShopBundle\Price\Services;
  3. use Doctrine\Common\Collections\Collection;
  4. use Lc\ShopBundle\Context\OrderProductInterface;
  5. use Lc\ShopBundle\Context\OrderShopInterface;
  6. use Lc\ShopBundle\Context\ProductFamilyInterface;
  7. use Lc\ShopBundle\Context\ProductInterface;
  8. use Lc\ShopBundle\Context\ProductPropertyInterface;
  9. use Lc\ShopBundle\Context\ReductionCatalogInterface;
  10. class ProductPriceUtils
  11. {
  12. use PriceUtilsTrait ;
  13. public function getPrice(ProductPropertyInterface $product)
  14. {
  15. if ($product->getBehaviorPriceInherited() == 'by-piece') {
  16. return $product->getPriceInherited();
  17. }
  18. elseif ($product->getBehaviorPriceInherited() == 'by-reference-unit') {
  19. if ($product->getQuantityInherited() > 0) {
  20. return $product->getPriceByRefUnitInherited() * ($product->getQuantityInherited() / $product->getUnitInherited()->getCoefficient());
  21. }
  22. }
  23. }
  24. public function getPriceWithTax(ProductPropertyInterface $product)
  25. {
  26. return $this->applyTax(
  27. $this->getPrice($product),
  28. $product->getTaxRateInherited()->getValue()
  29. );
  30. }
  31. public function getPriceWithTaxAndReduction(ProductPropertyInterface $product)
  32. {
  33. }
  34. public function getPriceByRefUnit(ProductPropertyInterface $product)
  35. {
  36. if ($product->getBehaviorPriceInherited() == 'by-piece') {
  37. return ($this->getPrice($product) * $product->getUnitInherited()->getCoefficient()) / $product->getQuantityInherited();
  38. } elseif ($product->getBehaviorPriceInherited() == 'by-reference-unit') {
  39. return $product->getPriceByRefUnitInherited();
  40. }
  41. }
  42. public function getPriceByRefUnitWithTax(ProductPropertyInterface $product)
  43. {
  44. return $this->applyTax(
  45. $this->getPriceByRefUnit($product),
  46. $product->getTaxRateInherited()->getValue()
  47. );
  48. }
  49. public function getPriceByRefUnitWithTaxAndReduction(ProductPropertyInterface $product)
  50. {
  51. }
  52. }