export function toCents(amount: number): number { return Math.round(amount * 100); } export function fromCents(cents: number): number { return cents / 100; } const LOCALE_BY_CURRENCY: Record = { EUR: 'de-DE', USD: 'en-US', GBP: 'en-GB', CHF: 'fr-CH', }; export function formatCurrency(cents: number, currency: string): string { const locale = LOCALE_BY_CURRENCY[currency] ?? 'de-DE'; return new Intl.NumberFormat(locale, { style: 'currency', currency, }).format(fromCents(cents)); }