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 ?? []; + onchange="showKontoArt('kategorie_konto_id','kategorie_konto_art',this);updateEigenanteilState()"> – Konto wählen – @@ -410,9 +410,9 @@ $suppliers = $suppliers ?? []; - - - + + + 30% Eigenanteil buchen @@ -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(); }