|
- <?php
-
- namespace Lc\ShopBundle\Model;
-
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\ORM\Mapping as ORM;
- use Lc\ShopBundle\Context\StatusInterface;
-
- class Price
- {
-
- public function withTax()
- {
- return self::getPriceWithTax(
- $this->price,
- $this->taxRate
- ) ;
- }
-
- public function withoutTax()
- {
- return $this->price ;
- }
-
- /* Static */
-
- public static function priceTwoDecimals($number)
- {
- return number_format(( ($number * 100)) / 100, 2) ;
- }
-
- public static function getPriceWithoutTax($priceWithTax, $taxRate)
- {
- return floatval($priceWithTax) / ($taxRate + 1);
- }
-
- public static function getPriceWithTax($priceWithoutTax, $taxRate)
- {
- return self::priceTwoDecimals(floatval($priceWithoutTax) * ($taxRate + 1)) ;
- }
-
- }
|