Merge pull request #55 from baragoon/dev

feat: add income categories to budget management
This commit is contained in:
ulsklyc
2026-04-19 13:07:46 +02:00
committed by GitHub
17 changed files with 119 additions and 5 deletions
+5
View File
@@ -451,6 +451,11 @@
"catHealth": "الصحة", "catHealth": "الصحة",
"catEducation": "التعليم", "catEducation": "التعليم",
"catMisc": "متنوع", "catMisc": "متنوع",
"catEarnedIncome": "دخل العمل",
"catInvestmentIncome": "دخل الاستثمار",
"catTransferGiftIncome": "التحويلات والهدايا",
"catGovernmentBenefits": "المزايا الاجتماعية",
"catOtherIncome": "دخل آخر",
"loadingIndicator": "جارٍ التحميل…" "loadingIndicator": "جارٍ التحميل…"
}, },
"settings": { "settings": {
+5
View File
@@ -451,6 +451,11 @@
"catHealth": "Gesundheit", "catHealth": "Gesundheit",
"catEducation": "Bildung", "catEducation": "Bildung",
"catMisc": "Sonstiges", "catMisc": "Sonstiges",
"catEarnedIncome": "Erwerbseinkommen",
"catInvestmentIncome": "Kapitalerträge",
"catTransferGiftIncome": "Geschenke & Transfers",
"catGovernmentBenefits": "Sozialleistungen",
"catOtherIncome": "Sonstiges Einkommen",
"loadingIndicator": "Lade…" "loadingIndicator": "Lade…"
}, },
"settings": { "settings": {
+5
View File
@@ -451,6 +451,11 @@
"catHealth": "Υγεία", "catHealth": "Υγεία",
"catEducation": "Εκπαίδευση", "catEducation": "Εκπαίδευση",
"catMisc": "Διάφορα", "catMisc": "Διάφορα",
"catEarnedIncome": "Εισόδημα από εργασία",
"catInvestmentIncome": "Επενδυτικό εισόδημα",
"catTransferGiftIncome": "Μεταφορές και δώρα",
"catGovernmentBenefits": "Κοινωνικές παροχές",
"catOtherIncome": "Άλλο εισόδημα",
"loadingIndicator": "Φόρτωση…" "loadingIndicator": "Φόρτωση…"
}, },
"settings": { "settings": {
+5
View File
@@ -451,6 +451,11 @@
"catHealth": "Health", "catHealth": "Health",
"catEducation": "Education", "catEducation": "Education",
"catMisc": "Miscellaneous", "catMisc": "Miscellaneous",
"catEarnedIncome": "Earned Income",
"catInvestmentIncome": "Investment Income",
"catTransferGiftIncome": "Transfer & Gift Income",
"catGovernmentBenefits": "Government & Social Benefits",
"catOtherIncome": "Other Income",
"loadingIndicator": "Loading…" "loadingIndicator": "Loading…"
}, },
"settings": { "settings": {
+5
View File
@@ -451,6 +451,11 @@
"catHealth": "Salud", "catHealth": "Salud",
"catEducation": "Educación", "catEducation": "Educación",
"catMisc": "Otros", "catMisc": "Otros",
"catEarnedIncome": "Ingresos del Trabajo",
"catInvestmentIncome": "Ingresos de Inversión",
"catTransferGiftIncome": "Transferencias y Regalos",
"catGovernmentBenefits": "Prestaciones Sociales",
"catOtherIncome": "Otros Ingresos",
"loadingIndicator": "Cargando…" "loadingIndicator": "Cargando…"
}, },
"settings": { "settings": {
+5
View File
@@ -451,6 +451,11 @@
"catHealth": "Santé", "catHealth": "Santé",
"catEducation": "Éducation", "catEducation": "Éducation",
"catMisc": "Divers", "catMisc": "Divers",
"catEarnedIncome": "Revenus du Travail",
"catInvestmentIncome": "Revenus d'Investissement",
"catTransferGiftIncome": "Transferts et Cadeaux",
"catGovernmentBenefits": "Allocations Sociales",
"catOtherIncome": "Autres Revenus",
"loadingIndicator": "Chargement…" "loadingIndicator": "Chargement…"
}, },
"settings": { "settings": {
+5
View File
@@ -451,6 +451,11 @@
"catHealth": "स्वास्थ्य", "catHealth": "स्वास्थ्य",
"catEducation": "शिक्षा", "catEducation": "शिक्षा",
"catMisc": "विविध", "catMisc": "विविध",
"catEarnedIncome": "कमाई आय",
"catInvestmentIncome": "निवेश आय",
"catTransferGiftIncome": "स्थानांतरण और उपहार",
"catGovernmentBenefits": "सामाजिक लाभ",
"catOtherIncome": "अन्य आय",
"loadingIndicator": "लोड हो रहा है…" "loadingIndicator": "लोड हो रहा है…"
}, },
"settings": { "settings": {
+5
View File
@@ -451,6 +451,11 @@
"catHealth": "Salute", "catHealth": "Salute",
"catEducation": "Istruzione", "catEducation": "Istruzione",
"catMisc": "Varie", "catMisc": "Varie",
"catEarnedIncome": "Reddito da Lavoro",
"catInvestmentIncome": "Reddito da Investimenti",
"catTransferGiftIncome": "Trasferimenti e Regali",
"catGovernmentBenefits": "Prestazioni Sociali",
"catOtherIncome": "Altro Reddito",
"loadingIndicator": "Caricamento…" "loadingIndicator": "Caricamento…"
}, },
"settings": { "settings": {
+5
View File
@@ -451,6 +451,11 @@
"catHealth": "医療", "catHealth": "医療",
"catEducation": "教育", "catEducation": "教育",
"catMisc": "その他", "catMisc": "その他",
"catEarnedIncome": "給与・報酬",
"catInvestmentIncome": "投資収入",
"catTransferGiftIncome": "譲渡・贈与",
"catGovernmentBenefits": "社会保障給付",
"catOtherIncome": "その他の収入",
"loadingIndicator": "読み込み中…" "loadingIndicator": "読み込み中…"
}, },
"settings": { "settings": {
+5
View File
@@ -451,6 +451,11 @@
"catHealth": "Saúde", "catHealth": "Saúde",
"catEducation": "Educação", "catEducation": "Educação",
"catMisc": "Outros", "catMisc": "Outros",
"catEarnedIncome": "Renda do Trabalho",
"catInvestmentIncome": "Renda de Investimento",
"catTransferGiftIncome": "Transferências e Presentes",
"catGovernmentBenefits": "Benefícios Sociais",
"catOtherIncome": "Outras Rendas",
"loadingIndicator": "Carregando…" "loadingIndicator": "Carregando…"
}, },
"settings": { "settings": {
+5
View File
@@ -451,6 +451,11 @@
"catHealth": "Здоровье", "catHealth": "Здоровье",
"catEducation": "Образование", "catEducation": "Образование",
"catMisc": "Разное", "catMisc": "Разное",
"catEarnedIncome": "Трудовой доход",
"catInvestmentIncome": "Инвестиционный доход",
"catTransferGiftIncome": "Переводы и подарки",
"catGovernmentBenefits": "Социальные пособия",
"catOtherIncome": "Прочие доходы",
"loadingIndicator": "Загрузка…" "loadingIndicator": "Загрузка…"
}, },
"settings": { "settings": {
+5
View File
@@ -451,6 +451,11 @@
"catHealth": "Hälsa", "catHealth": "Hälsa",
"catEducation": "Utbildning", "catEducation": "Utbildning",
"catMisc": "Diverse", "catMisc": "Diverse",
"catEarnedIncome": "Arbetsinkomst",
"catInvestmentIncome": "Investeringsinkomst",
"catTransferGiftIncome": "Överföringar och gåvor",
"catGovernmentBenefits": "Socialförmåner",
"catOtherIncome": "Övrig inkomst",
"loadingIndicator": "Laddar…" "loadingIndicator": "Laddar…"
}, },
"settings": { "settings": {
+5
View File
@@ -451,6 +451,11 @@
"catHealth": "Sağlık", "catHealth": "Sağlık",
"catEducation": "Eğitim", "catEducation": "Eğitim",
"catMisc": "Diğer", "catMisc": "Diğer",
"catEarnedIncome": "Kazanç Geliri",
"catInvestmentIncome": "Yatırım Geliri",
"catTransferGiftIncome": "Transferler ve Hediyeler",
"catGovernmentBenefits": "Sosyal Yardımlar",
"catOtherIncome": "Diğer Gelir",
"loadingIndicator": "Yükleniyor…" "loadingIndicator": "Yükleniyor…"
}, },
"settings": { "settings": {
+5 -1
View File
@@ -451,6 +451,11 @@
"catHealth": "Здоров'я", "catHealth": "Здоров'я",
"catEducation": "Освіта", "catEducation": "Освіта",
"catMisc": "Різне", "catMisc": "Різне",
"catEarnedIncome": "Трудовий дохід",
"catInvestmentIncome": "Інвестиційний дохід",
"catTransferGiftIncome": "Переводи та подарунки",
"catGovernmentBenefits": "Соціальні виплати",
"catOtherIncome": "Інші доходи",
"loadingIndicator": "Завантаження…" "loadingIndicator": "Завантаження…"
}, },
"settings": { "settings": {
@@ -620,4 +625,3 @@
"pendingBadgeTitlePlural": "{{count}} нагадувань" "pendingBadgeTitlePlural": "{{count}} нагадувань"
} }
} }
+5
View File
@@ -451,6 +451,11 @@
"catHealth": "健康", "catHealth": "健康",
"catEducation": "教育", "catEducation": "教育",
"catMisc": "其他", "catMisc": "其他",
"catEarnedIncome": "劳动收入",
"catInvestmentIncome": "投资收入",
"catTransferGiftIncome": "转账和礼物",
"catGovernmentBenefits": "社会福利",
"catOtherIncome": "其他收入",
"loadingIndicator": "加载中…" "loadingIndicator": "加载中…"
}, },
"settings": { "settings": {
+36 -3
View File
@@ -15,12 +15,20 @@ import { esc } from '/utils/html.js';
// Konstanten // Konstanten
// -------------------------------------------------------- // --------------------------------------------------------
const CATEGORIES = [ const EXPENSE_CATEGORIES = [
'Lebensmittel', 'Miete', 'Versicherung', 'Mobilität', 'Lebensmittel', 'Miete', 'Versicherung', 'Mobilität',
'Freizeit', 'Kleidung', 'Gesundheit', 'Bildung', 'Sonstiges', 'Freizeit', 'Kleidung', 'Gesundheit', 'Bildung', 'Sonstiges',
]; ];
const INCOME_CATEGORIES = [
'Erwerbseinkommen', 'Kapitalerträge', 'Geschenke & Transfers',
'Sozialleistungen', 'Sonstiges Einkommen',
];
const CATEGORIES = [...EXPENSE_CATEGORIES, ...INCOME_CATEGORIES];
const CATEGORY_LABELS = () => ({ const CATEGORY_LABELS = () => ({
// Expense categories
'Lebensmittel': t('budget.catFood'), 'Lebensmittel': t('budget.catFood'),
'Miete': t('budget.catRent'), 'Miete': t('budget.catRent'),
'Versicherung': t('budget.catInsurance'), 'Versicherung': t('budget.catInsurance'),
@@ -30,6 +38,12 @@ const CATEGORY_LABELS = () => ({
'Gesundheit': t('budget.catHealth'), 'Gesundheit': t('budget.catHealth'),
'Bildung': t('budget.catEducation'), 'Bildung': t('budget.catEducation'),
'Sonstiges': t('budget.catMisc'), 'Sonstiges': t('budget.catMisc'),
// Income categories
'Erwerbseinkommen': t('budget.catEarnedIncome'),
'Kapitalerträge': t('budget.catInvestmentIncome'),
'Geschenke & Transfers': t('budget.catTransferGiftIncome'),
'Sozialleistungen': t('budget.catGovernmentBenefits'),
'Sonstiges Einkommen': t('budget.catOtherIncome'),
}); });
function getMonthName(monthIndex) { function getMonthName(monthIndex) {
@@ -345,8 +359,9 @@ function openBudgetModal({ mode, entry = null }) {
const isExpense = isEdit ? entry.amount < 0 : true; const isExpense = isEdit ? entry.amount < 0 : true;
const absAmount = isEdit ? Math.abs(entry.amount).toFixed(2) : ''; const absAmount = isEdit ? Math.abs(entry.amount).toFixed(2) : '';
const catLabels = CATEGORY_LABELS(); const catLabels = CATEGORY_LABELS();
const catOpts = CATEGORIES.map((c) => const initialCats = isExpense ? EXPENSE_CATEGORIES : INCOME_CATEGORIES;
const catOpts = initialCats.map((c) =>
`<option value="${c}" ${isEdit && entry.category === c ? 'selected' : ''}>${catLabels[c] || c}</option>` `<option value="${c}" ${isEdit && entry.category === c ? 'selected' : ''}>${catLabels[c] || c}</option>`
).join(''); ).join('');
@@ -407,15 +422,33 @@ function openBudgetModal({ mode, entry = null }) {
onSave(panel) { onSave(panel) {
let currentType = isExpense ? 'expense' : 'income'; let currentType = isExpense ? 'expense' : 'income';
const updateCategoryOptions = () => {
const catLabels = CATEGORY_LABELS();
const cats = currentType === 'income' ? INCOME_CATEGORIES : EXPENSE_CATEGORIES;
const catSelect = panel.querySelector('#bm-category');
const currentValue = catSelect.value;
const options = cats.map((c) => {
const opt = document.createElement('option');
opt.value = c;
opt.textContent = catLabels[c] || c;
opt.selected = currentValue === c;
return opt;
});
catSelect.replaceChildren(...options);
};
panel.querySelector('#type-expense').addEventListener('click', () => { panel.querySelector('#type-expense').addEventListener('click', () => {
currentType = 'expense'; currentType = 'expense';
panel.querySelector('#type-expense').classList.add('amount-type-btn--active'); panel.querySelector('#type-expense').classList.add('amount-type-btn--active');
panel.querySelector('#type-income').classList.remove('amount-type-btn--active'); panel.querySelector('#type-income').classList.remove('amount-type-btn--active');
updateCategoryOptions();
}); });
panel.querySelector('#type-income').addEventListener('click', () => { panel.querySelector('#type-income').addEventListener('click', () => {
currentType = 'income'; currentType = 'income';
panel.querySelector('#type-income').classList.add('amount-type-btn--active'); panel.querySelector('#type-income').classList.add('amount-type-btn--active');
panel.querySelector('#type-expense').classList.remove('amount-type-btn--active'); panel.querySelector('#type-expense').classList.remove('amount-type-btn--active');
updateCategoryOptions();
}); });
panel.querySelector('#bm-cancel').addEventListener('click', closeModal); panel.querySelector('#bm-cancel').addEventListener('click', closeModal);
+8 -1
View File
@@ -63,11 +63,18 @@ function generateRecurringInstances(database, month) {
} }
} }
const VALID_CATEGORIES = [ const EXPENSE_CATEGORIES = [
'Lebensmittel', 'Miete', 'Versicherung', 'Mobilität', 'Lebensmittel', 'Miete', 'Versicherung', 'Mobilität',
'Freizeit', 'Kleidung', 'Gesundheit', 'Bildung', 'Sonstiges', 'Freizeit', 'Kleidung', 'Gesundheit', 'Bildung', 'Sonstiges',
]; ];
const INCOME_CATEGORIES = [
'Erwerbseinkommen', 'Kapitalerträge', 'Geschenke & Transfers',
'Sozialleistungen', 'Sonstiges Einkommen',
];
const VALID_CATEGORIES = [...EXPENSE_CATEGORIES, ...INCOME_CATEGORIES];
// -------------------------------------------------------- // --------------------------------------------------------
// Statische Routen vor /:id // Statische Routen vor /:id
// -------------------------------------------------------- // --------------------------------------------------------