mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-01 03:00:54 +00:00
Decimal rendering - support "minimum places" setting (#4527)
* Add configurable setting for "minimum" decimal places * Specify minimum decimal places to 'render_currency' * Fix for rendering currency in tables
This commit is contained in:
@ -45,24 +45,22 @@ function formatCurrency(value, options={}) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var digits = options.digits || global_settings.PRICING_DECIMAL_PLACES || 6;
|
||||
|
||||
// Strip out any trailing zeros, etc
|
||||
value = formatDecimal(value, digits);
|
||||
let maxDigits = options.digits || global_settings.PRICING_DECIMAL_PLACES || 6;
|
||||
let minDigits = options.minDigits || global_settings.PRICING_DECIMAL_PLACES_MIN || 0;
|
||||
|
||||
// Extract default currency information
|
||||
var currency = options.currency || global_settings.INVENTREE_DEFAULT_CURRENCY || 'USD';
|
||||
let currency = options.currency || global_settings.INVENTREE_DEFAULT_CURRENCY || 'USD';
|
||||
|
||||
// Exctract locale information
|
||||
var locale = options.locale || navigator.language || 'en-US';
|
||||
let locale = options.locale || navigator.language || 'en-US';
|
||||
|
||||
|
||||
var formatter = new Intl.NumberFormat(
|
||||
let formatter = new Intl.NumberFormat(
|
||||
locale,
|
||||
{
|
||||
style: 'currency',
|
||||
currency: currency,
|
||||
maximumSignificantDigits: digits,
|
||||
maximumFractionDigits: maxDigits,
|
||||
minimumFractionDigits: minDigits,
|
||||
}
|
||||
);
|
||||
|
||||
|
Reference in New Issue
Block a user