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.

43 lines
994B

  1. <?php
  2. namespace Lc\ShopBundle\Model;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Lc\ShopBundle\Context\StatusInterface;
  6. class Price
  7. {
  8. public function withTax()
  9. {
  10. return self::getPriceWithTax(
  11. $this->price,
  12. $this->taxRate
  13. ) ;
  14. }
  15. public function withoutTax()
  16. {
  17. return $this->price ;
  18. }
  19. /* Static */
  20. public static function priceTwoDecimals($number)
  21. {
  22. return number_format(( ($number * 100)) / 100, 2) ;
  23. }
  24. public static function getPriceWithoutTax($priceWithTax, $taxRate)
  25. {
  26. return floatval($priceWithTax) / ($taxRate + 1);
  27. }
  28. public static function getPriceWithTax($priceWithoutTax, $taxRate)
  29. {
  30. return self::priceTwoDecimals(floatval($priceWithoutTax) * ($taxRate + 1)) ;
  31. }
  32. }