EÜR: Drill-down auf Buchungen je Konto
This commit is contained in:
parent
37fcf53e8f
commit
f794bc2fa4
5 changed files with 124 additions and 2 deletions
|
|
@ -104,6 +104,7 @@ $router->get('/tax/ustva/{year}/{month}/kz/{kz}', fn($p) => (new UstvaController
|
|||
$router->get('/tax/euer', fn($p) => (new EuerController())->index($p));
|
||||
$router->get('/tax/euer/{year}', fn($p) => (new EuerController())->show($p));
|
||||
$router->get('/tax/euer/{year}/pdf', fn($p) => (new EuerController())->pdf($p));
|
||||
$router->get('/tax/euer/{year}/konto/{konto_id}', fn($p) => (new EuerController())->kontoBookings($p));
|
||||
|
||||
// ── Einstellungen ────────────────────────────────────────────
|
||||
$router->get('/settings', fn($p) => (new SettingsController())->show($p));
|
||||
|
|
|
|||
|
|
@ -41,6 +41,25 @@ class EuerController
|
|||
]);
|
||||
}
|
||||
|
||||
public function kontoBookings(array $params): void
|
||||
{
|
||||
$year = (int)$params['year'];
|
||||
$kontoId = (int)$params['konto_id'];
|
||||
$calc = new EuerCalculator();
|
||||
$bookings = $calc->fetchBookingsForKonto($year, $kontoId);
|
||||
$konto = \Steuerkram\Models\Account::find($kontoId);
|
||||
|
||||
$view = new View();
|
||||
$view->render('layout/base.php', [
|
||||
'pageTitle' => "EÜR {$year} – " . ($konto['bezeichnung'] ?? ''),
|
||||
'content' => $this->renderView('tax/euer_konto_bookings', [
|
||||
'year' => $year,
|
||||
'konto' => $konto,
|
||||
'bookings' => $bookings,
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public function pdf(array $params): void
|
||||
{
|
||||
$year = (int)$params['year'];
|
||||
|
|
|
|||
|
|
@ -68,4 +68,23 @@ class EuerCalculator
|
|||
'gewinn' => $gewinn,
|
||||
];
|
||||
}
|
||||
|
||||
public function fetchBookingsForKonto(int $year, int $kontoId): array
|
||||
{
|
||||
return Database::fetchAll(
|
||||
'SELECT bk.id, bk.buchungs_datum, bk.buchungstyp, bk.ust_satz,
|
||||
bk.betrag_netto, bk.betrag_ust, bk.betrag_brutto, bk.buchungstext,
|
||||
bk.beleg_id, bl.beleg_nr,
|
||||
k.kontonummer AS kategorie_nr, k.bezeichnung AS kategorie_name,
|
||||
z.kontonummer AS zahlungs_nr, z.bezeichnung AS zahlungs_name
|
||||
FROM bookings bk
|
||||
JOIN fiscal_years fy ON bk.fiscal_year_id = fy.id
|
||||
LEFT JOIN belege bl ON bk.beleg_id = bl.id
|
||||
JOIN accounts k ON bk.kategorie_konto_id = k.id
|
||||
JOIN accounts z ON bk.zahlungskonto_id = z.id
|
||||
WHERE fy.year = ? AND bk.kategorie_konto_id = ? AND bk.is_reversal = 0
|
||||
ORDER BY bk.buchungs_datum, bk.id',
|
||||
[$year, $kontoId]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
79
src/Views/tax/euer_konto_bookings.php
Normal file
79
src/Views/tax/euer_konto_bookings.php
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
use Steuerkram\View;
|
||||
$h = fn($v) => View::h($v);
|
||||
$fmt = fn($v) => number_format((float)$v, 2, ',', '.') . ' €';
|
||||
?>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<div>
|
||||
<div class="card-title">
|
||||
<?= $h($konto['kontonummer'] ?? '') ?> – <?= $h($konto['bezeichnung'] ?? '') ?>
|
||||
</div>
|
||||
<div class="text-muted text-sm">EÜR <?= $h($year) ?></div>
|
||||
</div>
|
||||
<a href="/tax/euer/<?= $h($year) ?>" class="btn btn-secondary btn-sm">← Zurück zur EÜR</a>
|
||||
</div>
|
||||
|
||||
<?php if (empty($bookings)): ?>
|
||||
<div class="card-body">
|
||||
<p class="text-muted">Keine Buchungen für dieses Konto in <?= $h($year) ?>.</p>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div class="table-wrap">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Datum</th>
|
||||
<th>Beleg</th>
|
||||
<th>Buchungstext</th>
|
||||
<th>Zahlungskonto</th>
|
||||
<th class="td-right">Netto</th>
|
||||
<th class="td-right">USt</th>
|
||||
<th class="td-right">Brutto</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$sumNetto = 0.0;
|
||||
$sumUst = 0.0;
|
||||
$sumBrutto = 0.0;
|
||||
foreach ($bookings as $b):
|
||||
$netto = (float)$b['betrag_netto'];
|
||||
$ust = (float)$b['betrag_ust'];
|
||||
$brutto = (float)$b['betrag_brutto'];
|
||||
$sumNetto += $netto;
|
||||
$sumUst += $ust;
|
||||
$sumBrutto += $brutto;
|
||||
?>
|
||||
<tr>
|
||||
<td class="td-mono text-sm"><?= $h($b['buchungs_datum']) ?></td>
|
||||
<td>
|
||||
<?php if ($b['beleg_id']): ?>
|
||||
<a href="/belege/<?= (int)$b['beleg_id'] ?>"><?= $h($b['beleg_nr'] ?? '#' . $b['beleg_id']) ?></a>
|
||||
<?php else: ?>
|
||||
<span class="text-muted">–</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td><?= $h($b['buchungstext']) ?></td>
|
||||
<td class="text-sm text-muted">
|
||||
<?= $h($b['zahlungs_nr']) ?> <?= $h($b['zahlungs_name']) ?>
|
||||
</td>
|
||||
<td class="td-right td-mono"><?= $fmt($netto) ?></td>
|
||||
<td class="td-right td-mono"><?= $fmt($ust) ?></td>
|
||||
<td class="td-right td-mono"><?= $fmt($brutto) ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr style="font-weight:700;border-top:2px solid #000">
|
||||
<td colspan="4">Summe (<?= count($bookings) ?> Buchungen)</td>
|
||||
<td class="td-right td-mono"><?= $fmt($sumNetto) ?></td>
|
||||
<td class="td-right td-mono"><?= $fmt($sumUst) ?></td>
|
||||
<td class="td-right td-mono"><?= $fmt($sumBrutto) ?></td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
|
@ -41,7 +41,9 @@ $fmt = fn($v) => View::formatMoney($v);
|
|||
<?php if ($e): ?>
|
||||
<td class="td-mono text-sm" style="color:var(--color-muted)"><?= $h($e['kontonummer']) ?></td>
|
||||
<td><?= $h($e['bezeichnung']) ?></td>
|
||||
<td class="td-right td-mono" style="color:var(--color-success)"><?= $fmt($e['netto']) ?></td>
|
||||
<td class="td-right td-mono" style="color:var(--color-success)">
|
||||
<a href="/tax/euer/<?= $year ?>/konto/<?= (int)$e['id'] ?>" style="text-decoration:none;color:inherit"><?= $fmt($e['netto']) ?></a>
|
||||
</td>
|
||||
<?php else: ?>
|
||||
<td colspan="3"></td>
|
||||
<?php endif; ?>
|
||||
|
|
@ -49,7 +51,9 @@ $fmt = fn($v) => View::formatMoney($v);
|
|||
<?php if ($a): ?>
|
||||
<td class="td-mono text-sm" style="color:var(--color-muted)"><?= $h($a['kontonummer']) ?></td>
|
||||
<td><?= $h($a['bezeichnung']) ?></td>
|
||||
<td class="td-right td-mono" style="color:var(--color-danger)"><?= $fmt($a['netto']) ?></td>
|
||||
<td class="td-right td-mono" style="color:var(--color-danger)">
|
||||
<a href="/tax/euer/<?= $year ?>/konto/<?= (int)$a['id'] ?>" style="text-decoration:none;color:inherit"><?= $fmt($a['netto']) ?></a>
|
||||
</td>
|
||||
<?php else: ?>
|
||||
<td colspan="3"></td>
|
||||
<?php endif; ?>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue