feat(budget): configurable currency in settings (#20)
Add household-wide currency preference for the budget section. Users can select from 13 currencies (EUR, USD, GBP, SEK, NOK, DKK, CHF, PLN, CZK, HUF, JPY, AUD, CAD) in Settings → Budget. - preferences API (GET/PUT) now includes currency field - budget page loads currency from preferences on render - formatAmount() uses locale-aware Intl.NumberFormat with chosen currency - settings page gains a Budget section with a currency select - all three locales (de, en, it) updated with new i18n keys
This commit is contained in:
@@ -47,6 +47,7 @@ let state = {
|
||||
entries: [],
|
||||
summary: null,
|
||||
prevSummary: null, // Vormonat für Monatsvergleich
|
||||
currency: 'EUR',
|
||||
};
|
||||
let _container = null;
|
||||
|
||||
@@ -55,7 +56,7 @@ let _container = null;
|
||||
// --------------------------------------------------------
|
||||
|
||||
function formatAmount(n) {
|
||||
return new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(n);
|
||||
return new Intl.NumberFormat(getLocale(), { style: 'currency', currency: state.currency }).format(n);
|
||||
}
|
||||
|
||||
function formatMonthLabel(ym) {
|
||||
@@ -104,6 +105,11 @@ export async function render(container, { user }) {
|
||||
const today = new Date();
|
||||
state.month = `${today.getFullYear()}-${String(today.getMonth() + 1).padStart(2, '0')}`;
|
||||
|
||||
try {
|
||||
const prefsRes = await api.get('/preferences');
|
||||
state.currency = prefsRes.data?.currency ?? 'EUR';
|
||||
} catch (_) { /* Fallback auf EUR */ }
|
||||
|
||||
container.innerHTML = `
|
||||
<div class="budget-page">
|
||||
<h1 class="sr-only">${t('budget.title')}</h1>
|
||||
|
||||
Reference in New Issue
Block a user