Sales Dashboard Widget

This commit is contained in:
2025-11-25 13:46:45 +01:00
parent 0a98d71037
commit 914613e3ea
5 changed files with 257 additions and 57 deletions
+12
View File
@@ -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))
}