Browse Source

TVA : calculs des arrondis

refactoring
Guillaume Bourgeois 4 years ago
parent
commit
c0dc9dc797
2 changed files with 6 additions and 6 deletions
  1. +1
    -1
      backend/web/js/backend.js
  2. +5
    -5
      common/web/js/utils.js

+ 1
- 1
backend/web/js/backend.js View File

@@ -89,7 +89,7 @@ function opendistrib_products_event_price_with_tax() {
}
$('#product-price-with-tax').val(getPriceWithTax($('#product-price').val(), taxRateSelected));
//formattage des prix
$('#product-price').val(parseFloat($('#product-price').val()).toFixed(2));
$('#product-price').val(parseFloat($('#product-price').val()).toFixed(3));
}
function opendistrib_products_event_price(){
taxRateSelected = $('#product-id_tax_rate').find('option:selected').data('tax-rate-value');

+ 5
- 5
common/web/js/utils.js View File

@@ -10,7 +10,7 @@
* @returns {string}
*/
function getPrice(priceWithTax, taxRate) {
return numberTwoDecimals(parseFloat(parseFloat(priceWithTax) / (taxRate + 1)));
return numberDecimals(parseFloat(parseFloat(priceWithTax) / (taxRate + 1)), 3);
}

/**
@@ -21,11 +21,11 @@ function getPrice(priceWithTax, taxRate) {
* @returns {string}
*/
function getPriceWithTax(priceWithoutTax, taxRate) {
return numberTwoDecimals(parseFloat(parseFloat(priceWithoutTax) * (taxRate + 1)));
return numberDecimals(parseFloat(parseFloat(priceWithoutTax) * (taxRate + 1)), 2);
}

function numberTwoDecimals(num) {
return Number(num).toFixed(2) ;
function numberDecimals(num, decimals) {
return Number(num).toFixed(decimals) ;
}

/**
@@ -35,7 +35,7 @@ function numberTwoDecimals(num) {
* @returns {string}
*/
function formatPrice(price) {
return Number(price).toFixed(2).replace('.', ',') + ' €';
return numberTwoDecimals(price).replace('.', ',') + ' €';
}

/**

Loading…
Cancel
Save