From b2ec028137ea0de99afc4cd8f4f0acd7c866eaf8 Mon Sep 17 00:00:00 2001 From: fds2610 Date: Sun, 29 Mar 2026 14:17:00 +0200 Subject: [PATCH] Eigenanteil-Checkbox: aktivierbar nur bei Ausgabe + 4920/4925 + 19% --- src/Views/belege/detail.php | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/src/Views/belege/detail.php b/src/Views/belege/detail.php index 0694118..2ed4330 100644 --- a/src/Views/belege/detail.php +++ b/src/Views/belege/detail.php @@ -346,7 +346,7 @@ $suppliers = $suppliers ?? []; +
+
@@ -448,12 +448,38 @@ function filterKategorieKonten(buchungstyp) { select.selectedIndex = 0; } } + updateEigenanteilState(); } +function updateEigenanteilState() { + const group = document.getElementById('eigenanteil_group'); + const cb = document.getElementById('eigenanteil_30_cb'); + if (!group || !cb) return; + + const buchungstyp = document.querySelector('input[name="buchungstyp"]:checked'); + const kategorieEl = document.getElementById('kategorie_konto_id'); + const ustSatzEl = document.getElementById('ust_satz_select'); + + const istAusgabe = buchungstyp && buchungstyp.value === 'Ausgabe'; + const selectedOpt = kategorieEl && kategorieEl.options[kategorieEl.selectedIndex]; + const kontonummer = selectedOpt ? (selectedOpt.getAttribute('data-search') || '').split(' ')[0] : ''; + const istTelInternet = kontonummer === '4920' || kontonummer === '4925'; + const ist19 = ustSatzEl && ustSatzEl.value === '19'; + + const aktiv = istAusgabe && istTelInternet && ist19; + + group.style.opacity = aktiv ? '1' : '.35'; + group.style.pointerEvents = aktiv ? '' : 'none'; + group.querySelector('label').style.cursor = aktiv ? 'pointer' : 'not-allowed'; + cb.disabled = !aktiv; + if (!aktiv) cb.checked = false; +} + // Initial filtern document.addEventListener('DOMContentLoaded', function() { const checked = document.querySelector('input[name="buchungstyp"]:checked'); if (checked) filterKategorieKonten(checked.value); updateSteuerartVisibility(); + updateEigenanteilState(); }); function updateSteuerartVisibility() { @@ -468,5 +494,6 @@ function updateSteuerartVisibility() { steuerartGroup.style.display = 'none'; if (steuerartSelect) steuerartSelect.value = 'normal'; } + updateEigenanteilState(); }