fixed sale matrrici
This commit is contained in:
@@ -984,16 +984,23 @@ if ($action === 'list' || $action === 'detail') {
|
||||
});
|
||||
const fmtPrice = v => v === null || v === undefined ? '—' : fmtEur(v, Math.abs(v) >= 10 ? 2 : 3);
|
||||
|
||||
// numeri grandi leggibili: 12,5 t · 125 mila m · 1,2 mln m · 85 k€
|
||||
function fmtShort(n, unit) {
|
||||
n = +n || 0;
|
||||
const a = Math.abs(n);
|
||||
if (a >= 1e6) return (n / 1e6).toLocaleString('it-IT', {
|
||||
maximumFractionDigits: 2
|
||||
}) + ' M' + (unit || '');
|
||||
if (a >= 1e4) return (n / 1e3).toLocaleString('it-IT', {
|
||||
maximumFractionDigits: 1
|
||||
}) + ' k' + (unit || '');
|
||||
return fmtNum(n) + (unit ? ' ' + unit : '');
|
||||
const nf = (v, d) => v.toLocaleString('it-IT', {
|
||||
maximumFractionDigits: d
|
||||
});
|
||||
if (unit === '€') {
|
||||
if (a >= 1e6) return nf(n / 1e6, 2) + ' M€';
|
||||
if (a >= 1e4) return nf(n / 1e3, 1) + ' k€';
|
||||
return fmtNum(n) + ' €';
|
||||
}
|
||||
if (unit === 'kg' && a >= 1e4) return nf(n / 1e3, a >= 1e5 ? 0 : 1) + ' t';
|
||||
const u = unit ? ' ' + unit : '';
|
||||
if (a >= 1e6) return nf(n / 1e6, 2) + ' mln' + u;
|
||||
if (a >= 1e4) return nf(n / 1e3, 1) + ' mila' + u;
|
||||
return fmtNum(n) + u;
|
||||
}
|
||||
const fmtEurShort = n => Math.abs(+n || 0) >= 1e4 ? fmtShort(n, '€') : fmtEur(n);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user