Bläddra i källkod

[global] Prix : corrections liées aux calculs HT et TTC

dev
Guillaume Bourgeois 4 år sedan
förälder
incheckning
ca7b3ec425
2 ändrade filer med 14 tillägg och 5 borttagningar
  1. +8
    -3
      common/helpers/Price.php
  2. +6
    -2
      common/web/js/utils.js

+ 8
- 3
common/helpers/Price.php Visa fil

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

}

+ 6
- 2
common/web/js/utils.js Visa fil

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

/**

Laddar…
Avbryt
Spara