Steuerkram/src/Views/tax/ustva_show.php

176 lines
8.9 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
use Steuerkram\View;
$h = fn($v) => View::h($v);
$fmt = fn($v) => View::formatMoney($v);
$fmtKz = fn($v) => $v !== null ? number_format((float)$v, 2, ',', '.') . ' €' : '–';
?>
<div style="display:grid;grid-template-columns:1fr 340px;gap:1.5rem;align-items:start">
<!-- Linke Seite: Kennzahlen-Tabelle -->
<div class="card">
<div class="card-header">
<div class="card-title">Kennzahlen – <?= $h($months[$month-1]) ?> <?= $h($year) ?></div>
<?php if (!empty($settings['ustva_steuernummer'])): ?>
<span class="text-muted text-sm">StNr: <?= $h($settings['ustva_steuernummer']) ?></span>
<?php else: ?>
<a href="/settings" class="badge badge-red">⚠ Steuernummer fehlt in Einstellungen</a>
<?php endif; ?>
</div>
<div class="table-wrap">
<table>
<thead>
<tr>
<th>Kz</th>
<th>Bezeichnung</th>
<th class="td-right">Bemessungsgrundlage</th>
<th class="td-right">Steuer</th>
</tr>
</thead>
<tbody>
<?php
$sections = [
'Umsätze' => ['81', 'ust81', '89', 'ust89'],
'Vorsteuer' => ['66', '61'],
'Ergebnis' => ['83'],
];
foreach ($sections as $sectionTitle => $kzNrs):
?>
<tr style="background:#f8fafc">
<td colspan="4" style="font-size:.75rem;font-weight:700;text-transform:uppercase;letter-spacing:.05em;color:var(--color-muted);padding:.4rem 1rem">
<?= $h($sectionTitle) ?>
</td>
</tr>
<?php foreach ($kzNrs as $nr):
if (!isset($kz[$nr])) continue;
$field = $kz[$nr];
$isResult = ($nr === '83');
$isDisplay = !($field['xml'] ?? true);
$isNegative = $isResult && ($field['steuer'] ?? 0) < 0;
?>
<tr style="<?= $isResult ? 'font-weight:700;background:#f0f4ff' : '' ?>">
<td class="td-mono" style="color:var(--color-muted);width:50px"><?= $isDisplay ? '' : $h($nr) ?></td>
<td><?= $h($field['name']) ?></td>
<td class="td-right td-mono">
<?php if ($field['betrag'] !== null): ?>
<?php if (!$isDisplay): ?>
<a href="/tax/ustva/<?= $year ?>/<?= $month ?>/kz/<?= $nr ?>" style="text-decoration:none;color:inherit"><?= $fmtKz($field['betrag']) ?></a>
<?php else: ?>
<?= $fmtKz($field['betrag']) ?>
<?php endif; ?>
<?php else: ?>
<?= $isResult ? '' : '–' ?>
<?php endif; ?>
</td>
<td class="td-right td-mono" style="<?= $isNegative ? 'color:var(--color-success)' : ($isResult ? 'color:var(--color-danger)' : '') ?>">
<?php if ($field['steuer'] !== null): ?>
<?php if (!$isDisplay): ?>
<a href="/tax/ustva/<?= $year ?>/<?= $month ?>/kz/<?= $nr ?>" style="text-decoration:none;color:inherit"><?= $fmtKz($field['steuer']) ?></a>
<?php else: ?>
<?= $fmtKz($field['steuer']) ?>
<?php endif; ?>
<?php else: ?>
–
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
<!-- Rechte Seite: Aktionen -->
<div>
<div class="card mb-2">
<div class="card-header"><div class="card-title">Aktionen</div></div>
<div class="card-body">
<div style="display:flex;flex-direction:column;gap:.75rem">
<a href="/tax/ustva/<?= $h($year) ?>/<?= $h($month) ?>/xml" class="btn btn-primary">
⬇ ELSTER XML herunterladen
</a>
<form method="post" action="/tax/ustva/<?= $h($year) ?>/<?= $h($month) ?>/save">
<button type="submit" class="btn btn-secondary w-full">Voranmeldung speichern</button>
</form>
<?php if (!empty($saved)): ?>
<div class="flash flash-info" style="margin:0">
Gespeichert am <?= $h($saved['created_at']) ?>
</div>
<?php endif; ?>
</div>
</div>
</div>
<div class="card mb-2">
<div class="card-header"><div class="card-title">Zusammenfassung</div></div>
<div class="card-body">
<?php
$kz81val = (float)($kz['81']['betrag'] ?? 0);
$kz89val = (float)($kz['89']['betrag'] ?? 0);
$ust81val = (float)($kz['ust81']['steuer'] ?? 0);
$ust89val = (float)($kz['ust89']['steuer'] ?? 0);
$vst66val = (float)($kz['66']['steuer'] ?? 0);
$vst61val = (float)($kz['61']['steuer'] ?? 0);
$zahllast = (float)($kz['83']['steuer'] ?? 0);
?>
<table style="width:100%;font-size:.9rem">
<tr>
<td style="padding:.35rem 0;color:var(--color-muted)">Umsatz 19 % (Kz 81)</td>
<td class="td-right td-mono"><?= $fmtKz($kz81val) ?></td>
</tr>
<?php if ($kz89val != 0.0): ?>
<tr>
<td style="padding:.35rem 0;color:var(--color-muted)">ig. Erwerb 19 % (Kz 89)</td>
<td class="td-right td-mono"><?= $fmtKz($kz89val) ?></td>
</tr>
<?php endif; ?>
<tr>
<td style="padding:.35rem 0;color:var(--color-muted)">USt aus Kz 81</td>
<td class="td-right td-mono"><?= $fmtKz($ust81val) ?></td>
</tr>
<?php if ($ust89val != 0.0): ?>
<tr>
<td style="padding:.35rem 0;color:var(--color-muted)">USt aus Kz 89</td>
<td class="td-right td-mono"><?= $fmtKz($ust89val) ?></td>
</tr>
<?php endif; ?>
<tr style="border-top:1px solid #e2e8f0">
<td style="padding:.35rem 0;color:var(--color-muted)">Vorsteuer (Kz 66)</td>
<td class="td-right td-mono" style="color:var(--color-success)">– <?= $fmtKz($vst66val) ?></td>
</tr>
<?php if ($vst61val != 0.0): ?>
<tr>
<td style="padding:.35rem 0;color:var(--color-muted)">i.g. Erwerb VSt (Kz 61)</td>
<td class="td-right td-mono" style="color:var(--color-success)">– <?= $fmtKz($vst61val) ?></td>
</tr>
<?php endif; ?>
<tr style="border-top:2px solid #000;font-weight:700">
<td style="padding:.5rem 0"><?= $zahllast >= 0 ? 'Vorauszahlung' : 'Erstattung' ?></td>
<td class="td-right td-mono" style="color:<?= $zahllast >= 0 ? 'var(--color-danger)' : 'var(--color-success)' ?>">
<?= $fmtKz($zahllast) ?>
</td>
</tr>
</table>
</div>
</div>
<div class="card">
<div class="card-header"><div class="card-title">Navigation</div></div>
<div class="card-body">
<?php
$prevMonth = $month - 1;
$prevYear = $year;
if ($prevMonth < 1) { $prevMonth = 12; $prevYear--; }
$nextMonth = $month + 1;
$nextYear = $year;
if ($nextMonth > 12) { $nextMonth = 1; $nextYear++; }
?>
<div style="display:flex;justify-content:space-between">
<a href="/tax/ustva/<?= $prevYear ?>/<?= $prevMonth ?>" class="btn btn-secondary btn-sm">‹ <?= $h($months[$prevMonth-1]) ?></a>
<a href="/tax/ustva/<?= $nextYear ?>/<?= $nextMonth ?>" class="btn btn-secondary btn-sm"><?= $h($months[$nextMonth-1]) ?> ›</a>
</div>
</div>
</div>
</div>
</div>