Add savings chat analysis feature

This commit is contained in:
Matthias
2026-06-15 18:26:25 +02:00
parent d65e7681ac
commit 4869402d45
26 changed files with 2789 additions and 163 deletions

View File

@@ -29,6 +29,17 @@ export function formatAmount(amount: number): string {
return eur.format(amount);
}
export function formatEurCompact(value: number): string {
const abs = Math.abs(value);
const sign = value < 0 ? "-" : "";
const suffix = (n: number, digits = 1) =>
`${sign}${n.toFixed(digits).replace(".", ",")}`;
if (abs >= 1_000_000) return `${suffix(abs / 1_000_000)} Mio. €`;
if (abs >= 10_000) return `${suffix(abs / 1000)}k €`;
if (abs >= 1000) return `${suffix(abs / 1000, 2)}k €`;
return eur.format(value);
}
export function amountClass(amount: number): string {
if (amount < 0) return "text-red-600 dark:text-red-400";
if (amount > 0) return "text-emerald-600 dark:text-emerald-400";