Use color on the amount of the payment page of TakePOS module

FIX Use pricejs instead of toFixed to be compatible with all currencies
WIP Prepare to be able to enter different payment modes on same invoice
This commit is contained in:
Laurent Destailleur
2019-03-27 12:40:32 +01:00
parent fb30b9bb82
commit ec0733d202
5 changed files with 131 additions and 50 deletions

View File

@@ -1009,6 +1009,25 @@ function getParameterByName(name, valueifnotfound)
function dolroundjs(number, decimals) { return +(Math.round(number + "e+" + decimals) + "e-" + decimals); }
/**
* Function similar to PHP price()
*
* @param {number|string} amount The amount to show
* @param {string} mode 'MT' or 'MU'
* @return {string} The amount with digits
*/
function pricejs(amount, mode) {
var main_max_dec_shown = <?php echo (int) str_replace('.', '', $conf->global->MAIN_MAX_DECIMALS_SHOWN); ?>;
var main_rounding_unit = <?php echo (int) $conf->global->MAIN_MAX_DECIMALS_UNIT; ?>;
var main_rounding_tot = <?php echo (int) $conf->global->MAIN_MAX_DECIMALS_TOT; ?>;
console.log(amount);
if (mode == 'MU') return amount.toFixed(main_rounding_unit);
if (mode == 'MT') return amount.toFixed(main_rounding_tot);
return 'Bad value for parameter mode';
}
/**
* Function similar to PHP price2num()
*