@@ -43,17 +43,22 @@ class Price | |||
public static function format($number) | |||
{ | |||
return str_replace('.', ',',number_format($number, 2)) . ' €'; | |||
return self::numberTwoDecimals($number).' €'; | |||
} | |||
public static function getPrice($priceWithTax, $taxRate) | |||
{ | |||
return round(floatval($priceWithTax) / ($taxRate + 1), 2); | |||
return floatval($priceWithTax) / ($taxRate + 1); | |||
} | |||
public static function getPriceWithTax($priceWithoutTax, $taxRate) | |||
{ | |||
return round(floatval($priceWithoutTax) * ($taxRate + 1), 2); | |||
return floatval($priceWithoutTax) * ($taxRate + 1) ; | |||
} | |||
public static function numberTwoDecimals($number) | |||
{ | |||
return number_format(((int) ($number * 100)) / 100, 2) ; | |||
} | |||
} |
@@ -10,7 +10,7 @@ | |||
* @returns {string} | |||
*/ | |||
function getPrice(priceWithTax, taxRate) { | |||
return parseFloat(parseFloat(priceWithTax) / (taxRate + 1)).toFixed(2); | |||
return numberTwoDecimals(parseFloat(parseFloat(priceWithTax) / (taxRate + 1))); | |||
} | |||
/** | |||
@@ -21,7 +21,11 @@ function getPrice(priceWithTax, taxRate) { | |||
* @returns {string} | |||
*/ | |||
function getPriceWithTax(priceWithoutTax, taxRate) { | |||
return parseFloat(parseFloat(priceWithoutTax) * (taxRate + 1)).toFixed(2); | |||
return numberTwoDecimals(parseFloat(parseFloat(priceWithoutTax) * (taxRate + 1))); | |||
} | |||
function numberTwoDecimals(num) { | |||
return (parseInt((num * 100)) / 100).toFixed(2) ; | |||
} | |||
/** |