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.

36 lines
904B

  1. <?php
  2. namespace Lc\ShopBundle\Price\Services;
  3. trait PriceUtilsTrait
  4. {
  5. public function applyTax($price, $taxRateValue)
  6. {
  7. return $this->round($this->applyPercent($price, $taxRateValue));
  8. }
  9. public function applyReductionPercent($price, $percentage)
  10. {
  11. return $this->applyPercent($price, -$percentage);
  12. }
  13. public function applyReductionAmount($price, $amount)
  14. {
  15. return $price - $amount;
  16. }
  17. public function applyPercent($price, $percentage)
  18. {
  19. return $price * ($percentage / 100 + 1);
  20. }
  21. public function applyPercentNegative($price, $percentage)
  22. {
  23. return $price / ($percentage / 100 + 1);
  24. }
  25. public function round($price)
  26. {
  27. return round((($price * 100)) / 100, 2);
  28. }
  29. }