Files
clemensandClaude Opus 4.8 4acd4a2d40 Legacy-Abbau Schritt 3+4: kl_*-Tabellen und legacy_*-Spalten entfernt
Abschluss des Legacy-Abbaus. Die Migration in participants/ledger_entries war
laut Dev-DB vollstaendig (keine legacy_mitarbeiter_id, kein legacy_table), die
kl_*-Tabellen enthielten nur noch Golden-Master-Testfixtures. Da kein echter
Altbestand mehr importiert werden muss (Prod entsteht aus der jetzigen Dev-DB),
kommt die Altwelt komplett raus.

Laufzeit-Code (Schritt 3a):
- ledger.php: Option legacy_mitarbeiter_ids, die Spalten aus allen SELECTs und
  Rueckgaben, ledger_fetch_participant_summary_by_legacy_id sowie das Loeschen
  gespiegelter Legacy-Zeilen in ledger_void_entry/ledger_void_own_self_entry
  entfernt
- imports.php, paypal-inbox.php: legacy_mitarbeiter_id aus Ergebnis und
  Typannotationen entfernt
- ledger-preview.php: Spalte "Legacy" entfernt

Skripte (Schritt 3b/3c):
- die acht reinen Legacy-/Golden-Master-Skripte entfernt (backfill-*,
  seed-golden-master, golden-master-data, check-golden-master, check-m4-*,
  check-m3-saas-basis)
- init-mysql-dev.php legt jetzt einen SaaS-Mandanten mit Owner-Login,
  Teilnehmer, Journalbuchungen und Hinweis an statt kl_*-Zeilen

Schema (Schritt 4, Migration 0024):
- participants.legacy_mitarbeiter_id + uq_participants_tenant_legacy
- ledger_entries.legacy_table/legacy_id + uq_ledger_entries_tenant_legacy
- DROP der Tabellen kl_Einzahlungen, kl_Kaffeeverbrauch, kl_hinweise,
  kl_config, kl_Mitarbeiter

Verifikation unveraendert gruen: http-smoke 33/0, role-matrix 55/0,
tenant-isolation 11/1 (Altfehler), m3-auth/tenant-resolution/billing gruen.
check-m3-settings-flow 7/6 ist vorbestehend (schon bei 3e24910 rot, mit
spaeteren Settings-Feldern nicht synchron) und unabhaengig von diesem Abbau.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-22 08:31:08 +02:00

136 lines
5.2 KiB
PHP

<?php
require_once __DIR__ . '/functions.php';
require_once __DIR__ . '/app/ledger.php';
$pdo = app_db_pdo();
$saasUser = saas_current_user($pdo);
$hasAccess = false;
$tenantId = 0;
$tenantName = '';
$tenantSlug = '';
if ($saasUser !== null && saas_user_has_role(['owner', 'admin', 'treasurer'], $saasUser)) {
$hasAccess = true;
$tenantId = (int)$saasUser['tenant_id'];
$tenantName = (string)$saasUser['tenant_name'];
$tenantSlug = (string)$saasUser['tenant_slug'];
}
$year = ledger_current_year();
$tenantTotals = $hasAccess ? ledger_fetch_tenant_totals($pdo, $tenantId, $year) : ledger_empty_totals();
$participantSummaries = $hasAccess ? ledger_fetch_participant_summaries($pdo, $tenantId, [
'active_only' => true,
'year' => $year,
]) : [];
$recentEntries = $hasAccess ? ledger_fetch_recent_entries($pdo, $tenantId, ['limit' => 25]) : [];
function ledger_preview_money(int $cents): string
{
return saas_format_money_cents($cents) . ' EUR';
}
function ledger_preview_entry_type(string $type): string
{
if ($type === 'payment') {
return 'Einzahlung';
}
if ($type === 'consumption') {
return 'Kaffeeverbrauch';
}
return $type;
}
include 'header.php';
include 'headerline.php';
include 'nav.php';
?>
<section id="banner">
<div class="content">
<h2>Journal-Vorschau</h2>
<?php if (!$hasAccess): ?>
<div class="hint-box error"><p>Kein Zugriff.</p></div>
<?php else: ?>
<p>
Read-only Vorschau aus <code>ledger_entries</code> für
<?php echo saas_html($tenantName); ?>
(<code><?php echo saas_html($tenantSlug); ?></code>).
</p>
<h3>Tenant-Summen</h3>
<table>
<tr>
<th>Gesamteinzahlungen</th>
<th>Gesamtausgaben</th>
<th>Gesamtstriche</th>
<th>Aktueller Saldo</th>
<th>Einzahlungen <?php echo $year; ?></th>
<th>Ausgaben <?php echo $year; ?></th>
<th>Striche <?php echo $year; ?></th>
</tr>
<tr>
<td><?php echo ledger_preview_money($tenantTotals['total_payments_cents']); ?></td>
<td><?php echo ledger_preview_money($tenantTotals['total_costs_cents']); ?></td>
<td><?php echo number_format($tenantTotals['total_marks'], 0, ',', '.'); ?></td>
<td><?php echo ledger_preview_money($tenantTotals['balance_cents']); ?></td>
<td><?php echo ledger_preview_money($tenantTotals['year_payments_cents']); ?></td>
<td><?php echo ledger_preview_money($tenantTotals['year_costs_cents']); ?></td>
<td><?php echo number_format($tenantTotals['year_marks'], 0, ',', '.'); ?></td>
</tr>
</table>
<h3>Aktive Teilnehmer</h3>
<table>
<tr>
<th>Name</th>
<th>E-Mail</th>
<th>Aktueller Stand</th>
<th>Gesamtausgaben</th>
<th>Gesamtstriche</th>
<th>Gesamteinzahlungen</th>
<th>Striche <?php echo $year; ?></th>
</tr>
<?php foreach ($participantSummaries as $summary): ?>
<tr>
<td><?php echo saas_html($summary['display_name']); ?></td>
<td><?php echo saas_html($summary['email'] ?? ''); ?></td>
<td><?php echo ledger_preview_money($summary['balance_cents']); ?></td>
<td><?php echo ledger_preview_money($summary['total_costs_cents']); ?></td>
<td><?php echo number_format($summary['total_marks'], 0, ',', '.'); ?></td>
<td><?php echo ledger_preview_money($summary['total_payments_cents']); ?></td>
<td><?php echo number_format($summary['year_marks'], 0, ',', '.'); ?></td>
</tr>
<?php endforeach; ?>
</table>
<h3>Letzte Ledger-Buchungen</h3>
<table>
<tr>
<th>Datum</th>
<th>Teilnehmer</th>
<th>Typ</th>
<th>Betrag</th>
<th>Striche</th>
<th>Quelle</th>
</tr>
<?php foreach ($recentEntries as $entry): ?>
<tr>
<td><?php echo saas_html($entry['booked_at']); ?></td>
<td><?php echo saas_html($entry['display_name']); ?></td>
<td><?php echo saas_html(ledger_preview_entry_type($entry['type'])); ?></td>
<td><?php echo ledger_preview_money($entry['amount_cents']); ?></td>
<td><?php echo $entry['marks_count'] !== null ? number_format($entry['marks_count'], 0, ',', '.') : ''; ?></td>
<td><?php echo saas_html($entry['source']); ?></td>
</tr>
<?php endforeach; ?>
</table>
<?php endif; ?>
</div>
</section>
<?php include 'footer.php'; ?>