Sales Dashboard Widget
This commit is contained in:
@@ -27,6 +27,18 @@ export function toCurrency(value: number | undefined) {
|
||||
return currencyFormatter.format(value);
|
||||
}
|
||||
|
||||
const roundedCurrencyFormatter = new Intl.NumberFormat('de-DE', {
|
||||
style: 'currency',
|
||||
currency: 'EUR',
|
||||
minimumFractionDigits: 0,
|
||||
maximumFractionDigits: 0
|
||||
})
|
||||
|
||||
export function toRoundedCurrency(value: number | undefined) {
|
||||
if (!value) return roundedCurrencyFormatter.format(0);
|
||||
return roundedCurrencyFormatter.format(toFixedRounded(value, 0));
|
||||
}
|
||||
|
||||
export function toFixedRounded(num: number, precision: number): number {
|
||||
return Number((Math.round(num * Math.pow(10, precision)) / Math.pow(10, precision)).toFixed(precision))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user