|
|
|
|
|
|
|
|
* @returns {string} |
|
|
* @returns {string} |
|
|
*/ |
|
|
*/ |
|
|
function getPrice(priceWithTax, taxRate) { |
|
|
function getPrice(priceWithTax, taxRate) { |
|
|
return numberTwoDecimals(parseFloat(parseFloat(priceWithTax) / (taxRate + 1))); |
|
|
|
|
|
|
|
|
return numberDecimals(parseFloat(parseFloat(priceWithTax) / (taxRate + 1)), 3); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
|
|
|
|
|
|
* @returns {string} |
|
|
* @returns {string} |
|
|
*/ |
|
|
*/ |
|
|
function getPriceWithTax(priceWithoutTax, taxRate) { |
|
|
function getPriceWithTax(priceWithoutTax, taxRate) { |
|
|
return numberTwoDecimals(parseFloat(parseFloat(priceWithoutTax) * (taxRate + 1))); |
|
|
|
|
|
|
|
|
return numberDecimals(parseFloat(parseFloat(priceWithoutTax) * (taxRate + 1)), 2); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function numberTwoDecimals(num) { |
|
|
|
|
|
return (parseInt((num * 100)) / 100).toFixed(2) ; |
|
|
|
|
|
|
|
|
function numberDecimals(num, decimals) { |
|
|
|
|
|
return Number(num).toFixed(decimals) ; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
|
|
|
|
|
|
* @returns {string} |
|
|
* @returns {string} |
|
|
*/ |
|
|
*/ |
|
|
function formatPrice(price) { |
|
|
function formatPrice(price) { |
|
|
return Number(price).toFixed(2).replace('.', ',') + ' €'; |
|
|
|
|
|
|
|
|
return numberTwoDecimals(price).replace('.', ',') + ' €'; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |