Browse Source

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

dev
Guillaume Bourgeois 4 years ago
parent
commit
ca7b3ec425
2 changed files with 14 additions and 5 deletions
  1. +8
    -3
      common/helpers/Price.php
  2. +6
    -2
      common/web/js/utils.js

+ 8
- 3
common/helpers/Price.php View File



public static function format($number) public static function format($number)
{ {
return str_replace('.', ',',number_format($number, 2)) . ' €';
return self::numberTwoDecimals($number).' €';
} }


public static function getPrice($priceWithTax, $taxRate) public static function getPrice($priceWithTax, $taxRate)
{ {
return round(floatval($priceWithTax) / ($taxRate + 1), 2);
return floatval($priceWithTax) / ($taxRate + 1);
} }


public static function getPriceWithTax($priceWithoutTax, $taxRate) 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 View File

* @returns {string} * @returns {string}
*/ */
function getPrice(priceWithTax, taxRate) { function getPrice(priceWithTax, taxRate) {
return parseFloat(parseFloat(priceWithTax) / (taxRate + 1)).toFixed(2);
return numberTwoDecimals(parseFloat(parseFloat(priceWithTax) / (taxRate + 1)));
} }


/** /**
* @returns {string} * @returns {string}
*/ */
function getPriceWithTax(priceWithoutTax, taxRate) { 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) ;
} }


/** /**

Loading…
Cancel
Save