|
- <?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);
- }
- }
|