feat(admin): Anzahlungskonten in der Verwaltung pflegen (zwei IBANs)
- Migration 016_deposit_accounts.sql: Tabelle deposit_accounts (label, holder, bank, iban, sort_order), gefüllt mit Postbank (DE12 …1261 30) und Sparkasse (DE83 3206 0362 3303 2140 10); bookings.deposit_account -> deposit_account_id mit Fremdschlüssel (ON DELETE SET NULL), Altbestand wird aufs erste Konto gemappt; schema.sql nachgezogen - Neue Seite Verwaltung → Konten (/admin/accounts): anlegen, ändern, löschen (Löschen nur ohne Buchungsbezug), Anzeige der Verwendung je Konto - Buchungsformular wählt aus dieser Liste (Anzeige mit IBAN-Ende), Validierung prüft IBAN-Format, Auftragsbestätigung druckt das gewählte Konto - deposit_accounts()/deposit_account() lesen aus der DB (Cache wird nach Änderungen verworfen); Konfigurations-Override entfällt - Anleitung (Abschnitt 3 und 15), README, config.example.php und ROADMAP (Feature 25) aktualisiert
This commit is contained in:
parent
bf85a64a79
commit
cc8d7330f8
15 changed files with 478 additions and 76 deletions
|
|
@ -5,6 +5,7 @@ $items = [
|
|||
'/admin/employees' => ['label' => 'Mitarbeiter', 'icon' => 'i-users'],
|
||||
'/admin/trailers' => ['label' => 'Anhänger', 'icon' => 'i-truck'],
|
||||
'/admin/mailings' => ['label' => 'Rundmail', 'icon' => 'i-mail'],
|
||||
'/admin/accounts' => ['label' => 'Konten', 'icon' => 'i-bank'],
|
||||
'/admin/backups' => ['label' => 'Sicherungen', 'icon' => 'i-database'],
|
||||
];
|
||||
?>
|
||||
|
|
|
|||
163
views/admin_accounts.php
Normal file
163
views/admin_accounts.php
Normal file
|
|
@ -0,0 +1,163 @@
|
|||
<?php
|
||||
/** @var list<array{id: int, label: string, holder: string, bank: string, iban: string}> $accounts */
|
||||
/** @var array<int, int> $usage */
|
||||
/** @var array<string, string> $errors */
|
||||
/** @var array<string, string> $createErrors */
|
||||
/** @var array<string, mixed> $createValues */
|
||||
/** @var array<int, array<string, mixed>> $rowValues */
|
||||
$error = static fn (string $key): string => (string) ($errors[$key] ?? '');
|
||||
$createError = static fn (string $key): string => (string) ($createErrors[$key] ?? '');
|
||||
?>
|
||||
<div class="page-head page-head--compact">
|
||||
<div>
|
||||
<p class="eyebrow">Verwaltung</p>
|
||||
<h1>Konten</h1>
|
||||
<p class="page-head__lede">Konten, auf die Kunden die <strong>Anzahlung</strong> überweisen. Im Buchungsformular
|
||||
wird je Buchung eines davon ausgewählt; die Auftragsbestätigung druckt Kontoinhaber, Bank und IBAN.
|
||||
Änderungen gelten für alle <em>neu</em> erzeugten Auftragsbestätigungen.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require __DIR__ . '/_admin_nav.php'; ?>
|
||||
|
||||
<?php if ($error('general') !== ''): ?>
|
||||
<div class="alert alert--error" role="alert">
|
||||
<svg class="ico" aria-hidden="true"><use href="#i-alert"/></svg>
|
||||
<div><strong>Das hat nicht geklappt.</strong><p><?= e($error('general')) ?></p></div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<section class="panel">
|
||||
<div class="panel__head">
|
||||
<div>
|
||||
<h2>Hinterlegte Konten</h2>
|
||||
<p><?= count($accounts) ?> Konto<?= count($accounts) === 1 ? '' : 'en' ?>. Reihenfolge über „Sortierung“
|
||||
(kleinere Zahl zuerst).</p>
|
||||
</div>
|
||||
<div class="panel__actions">
|
||||
<details class="create-trailer"<?= $createErrors ? ' open' : '' ?>>
|
||||
<summary class="btn small create-trailer__summary">
|
||||
<svg class="ico" aria-hidden="true"><use href="#i-plus"/></svg> Konto anlegen
|
||||
</summary>
|
||||
<div class="create-trailer__body">
|
||||
<form method="post" action="<?= e(url('/admin/accounts')) ?>" class="form-grid">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="action" value="create">
|
||||
<label class="field<?= $createError('label') !== '' ? ' has-error' : '' ?>">
|
||||
<span>Bezeichnung</span>
|
||||
<input type="text" name="label" maxlength="80" value="<?= e((string) $createValues['label']) ?>" placeholder="Postbank – Michael Schmitz" required>
|
||||
<?php if ($createError('label')): ?><em class="field-error"><?= e($createError('label')) ?></em><?php endif; ?>
|
||||
</label>
|
||||
<label class="field<?= $createError('holder') !== '' ? ' has-error' : '' ?>">
|
||||
<span>Kontoinhaber</span>
|
||||
<input type="text" name="holder" maxlength="120" value="<?= e((string) $createValues['holder']) ?>" required>
|
||||
<?php if ($createError('holder')): ?><em class="field-error"><?= e($createError('holder')) ?></em><?php endif; ?>
|
||||
</label>
|
||||
<label class="field<?= $createError('bank') !== '' ? ' has-error' : '' ?>">
|
||||
<span>Bank</span>
|
||||
<input type="text" name="bank" maxlength="80" value="<?= e((string) $createValues['bank']) ?>" placeholder="Postbank">
|
||||
<?php if ($createError('bank')): ?><em class="field-error"><?= e($createError('bank')) ?></em><?php endif; ?>
|
||||
</label>
|
||||
<label class="field<?= $createError('iban') !== '' ? ' has-error' : '' ?>">
|
||||
<span>IBAN</span>
|
||||
<input type="text" name="iban" maxlength="34" value="<?= e((string) $createValues['iban']) ?>" placeholder="DE12 1001 0010 0464 1261 30" required>
|
||||
<?php if ($createError('iban')): ?><em class="field-error"><?= e($createError('iban')) ?></em><?php endif; ?>
|
||||
</label>
|
||||
<label class="field">
|
||||
<span>Sortierung</span>
|
||||
<input type="number" name="sort_order" value="<?= e((string) $createValues['sort_order']) ?>" step="1" placeholder="1">
|
||||
</label>
|
||||
<div class="form-actions field--full">
|
||||
<button class="btn primary" type="submit">
|
||||
<svg class="ico" aria-hidden="true"><use href="#i-plus"/></svg> Konto anlegen
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</details>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ($accounts === []): ?>
|
||||
<p class="muted">Noch kein Konto hinterlegt – ohne Konto kann keine Anzahlung in der Auftragsbestätigung genannt werden.</p>
|
||||
<?php else: ?>
|
||||
<div class="table-wrap">
|
||||
<table class="data-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Bezeichnung</th>
|
||||
<th>Kontoinhaber</th>
|
||||
<th>Bank</th>
|
||||
<th>IBAN</th>
|
||||
<th>Sortierung</th>
|
||||
<th>Verwendet in</th>
|
||||
<th class="ta-right">Aktionen</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($accounts as $account): ?>
|
||||
<?php
|
||||
$id = (int) $account['id'];
|
||||
$values = $rowValues[$id] ?? [
|
||||
'label' => $account['label'],
|
||||
'holder' => $account['holder'],
|
||||
'bank' => $account['bank'],
|
||||
'iban' => $account['iban'],
|
||||
'sort_order' => $account['sort_order'] ?? 0,
|
||||
];
|
||||
$used = (int) ($usage[$id] ?? 0);
|
||||
?>
|
||||
<tr>
|
||||
<td colspan="5">
|
||||
<form method="post" action="<?= e(url('/admin/accounts')) ?>" class="form-grid" id="account-<?= $id ?>">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="action" value="update">
|
||||
<input type="hidden" name="id" value="<?= $id ?>">
|
||||
<label class="field">
|
||||
<span>Bezeichnung</span>
|
||||
<input type="text" name="label" maxlength="80" value="<?= e((string) $values['label']) ?>" required>
|
||||
</label>
|
||||
<label class="field">
|
||||
<span>Kontoinhaber</span>
|
||||
<input type="text" name="holder" maxlength="120" value="<?= e((string) $values['holder']) ?>" required>
|
||||
</label>
|
||||
<label class="field">
|
||||
<span>Bank</span>
|
||||
<input type="text" name="bank" maxlength="80" value="<?= e((string) $values['bank']) ?>">
|
||||
</label>
|
||||
<label class="field">
|
||||
<span>IBAN</span>
|
||||
<input type="text" name="iban" maxlength="34" value="<?= e((string) $values['iban']) ?>" required>
|
||||
</label>
|
||||
<label class="field">
|
||||
<span>Sortierung</span>
|
||||
<input type="number" name="sort_order" step="1" value="<?= e((string) $values['sort_order']) ?>">
|
||||
</label>
|
||||
</form>
|
||||
</td>
|
||||
<td><?= $used === 0 ? '<span class="muted small">–</span>' : (int) $used . ' Buchung' . ($used === 1 ? '' : 'en') ?></td>
|
||||
<td class="ta-right">
|
||||
<div class="danger-actions">
|
||||
<button class="btn small" type="submit" form="account-<?= $id ?>">
|
||||
<svg class="ico" aria-hidden="true"><use href="#i-check"/></svg> Speichern
|
||||
</button>
|
||||
<form method="post" action="<?= e(url('/admin/accounts')) ?>"
|
||||
data-confirm="Konto „<?= e((string) $account['label']) ?>“ löschen?">
|
||||
<?= csrf_field() ?>
|
||||
<input type="hidden" name="action" value="delete">
|
||||
<input type="hidden" name="id" value="<?= $id ?>">
|
||||
<button class="btn small danger-ghost" type="submit"<?= $used > 0 ? ' disabled title="Wird in Buchungen verwendet"' : '' ?>>
|
||||
<svg class="ico" aria-hidden="true"><use href="#i-trash"/></svg> Löschen
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<p class="muted small">Konten, die bereits in Buchungen verwendet werden, lassen sich nur ändern, nicht löschen –
|
||||
sonst ginge die Zuordnung in alten Auftragsbestätigungen verloren.</p>
|
||||
<?php endif; ?>
|
||||
</section>
|
||||
|
|
@ -203,10 +203,10 @@ $returnTo = '/bookings/' . (int) $booking['id'];
|
|||
<div><dt>Gesamtbetrag</dt><dd><?= e(fmt_money((int) $booking['total_cents'])) ?></dd></div>
|
||||
<div><dt>Anzahlung</dt><dd><?= e(fmt_money((int) $booking['deposit_cents'])) ?><?php
|
||||
if ((int) ($booking['deposit_required'] ?? 0) === 1 && (int) $booking['deposit_cents'] > 0) {
|
||||
$depositTarget = deposit_account((string) ($booking['deposit_account'] ?? ''));
|
||||
$depositTarget = deposit_account((int) ($booking['deposit_account_id'] ?? 0));
|
||||
echo ' · fällig bis ' . e(fmt_date(deposit_due_date()));
|
||||
if ($depositTarget !== null) {
|
||||
echo ' auf ' . e((string) $depositTarget['label']);
|
||||
echo ' auf ' . e(deposit_account_label($depositTarget));
|
||||
}
|
||||
}
|
||||
?></dd></div>
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
/** @var array $user */
|
||||
/** @var bool $isEdit */
|
||||
/** @var bool $canEditBilling */
|
||||
/** @var array<string, array{label: string, holder: string, bank: string, iban: string}> $depositAccounts */
|
||||
/** @var list<array{id: int, label: string, holder: string, bank: string, iban: string}> $depositAccounts */
|
||||
/** @var int $depositDueDays */
|
||||
$fieldError = static fn (string $key): string => (string) ($errors[$key] ?? '');
|
||||
$cancelled = $isEdit && ($booking['status'] ?? '') === 'cancelled';
|
||||
|
|
@ -232,9 +232,9 @@ $backUrl = $isEdit ? '/bookings/' . (int) $booking['id'] : '/calendar';
|
|||
<div class="field<?= $fieldError('deposit_account') !== '' ? ' has-error' : '' ?>">
|
||||
<span>Anzahlung fällig · Konto</span>
|
||||
<div class="field-with-aside">
|
||||
<select name="deposit_account" aria-label="Konto für die Anzahlung"<?= empty($canEditBilling) ? ' disabled' : '' ?>>
|
||||
<?php foreach ($depositAccounts as $accountKey => $accountRow): ?>
|
||||
<option value="<?= e_attr((string) $accountKey) ?>"<?= (string) $values['deposit_account'] === (string) $accountKey ? ' selected' : '' ?>><?= e((string) $accountRow['label']) ?></option>
|
||||
<select name="deposit_account_id" aria-label="Konto für die Anzahlung"<?= empty($canEditBilling) ? ' disabled' : '' ?>>
|
||||
<?php foreach ($depositAccounts as $accountRow): ?>
|
||||
<option value="<?= (int) $accountRow['id'] ?>"<?= (int) $values['deposit_account_id'] === (int) $accountRow['id'] ? ' selected' : '' ?>><?= e(deposit_account_label($accountRow)) ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<span class="segmented-radio segmented-radio--compact">
|
||||
|
|
@ -244,7 +244,8 @@ $backUrl = $isEdit ? '/bookings/' . (int) $booking['id'] : '/calendar';
|
|||
</div>
|
||||
<?php if ($fieldError('deposit_account')): ?><em class="field-error"><?= e($fieldError('deposit_account')) ?></em><?php endif; ?>
|
||||
<em class="muted small">Bei „JA“ fordert die Auftragsbestätigung die Anzahlung mit
|
||||
Frist (<?= (int) $depositDueDays ?> Werktage) und nennt das Konto.</em>
|
||||
Frist (<?= (int) $depositDueDays ?> Werktage) und nennt das Konto. Konten pflegt die
|
||||
Verwaltung unter „Konten“.</em>
|
||||
</div>
|
||||
|
||||
<div class="field<?= $fieldError('invoice_no') !== '' ? ' has-error' : '' ?>" data-paste-field="invoice_no">
|
||||
|
|
@ -295,7 +296,10 @@ $backUrl = $isEdit ? '/bookings/' . (int) $booking['id'] : '/calendar';
|
|||
<div><dt>Gesamtbetrag</dt><dd data-summary-total><?= e(fmt_money(parse_money((string) $values['rent']) + parse_money((string) $values['delivery']))) ?></dd></div>
|
||||
<div><dt>Anzahlung</dt><dd data-summary-deposit><?= e(fmt_money(parse_money((string) $values['deposit']))) ?><?= (int) $values['deposit_required'] === 1 ? ' · fällig' : '' ?></dd></div>
|
||||
<?php if ((int) $values['deposit_required'] === 1): ?>
|
||||
<div><dt>Konto</dt><dd><?= e((string) ($depositAccounts[(string) $values['deposit_account']]['label'] ?? '')) ?></dd></div>
|
||||
<div><dt>Konto</dt><dd><?php
|
||||
$currentAccount = deposit_account((int) $values['deposit_account_id']);
|
||||
echo e($currentAccount !== null ? deposit_account_label($currentAccount) : '–');
|
||||
?></dd></div>
|
||||
<?php endif; ?>
|
||||
<div class="is-strong"><dt>Noch zu zahlen</dt><dd data-summary-due><?= e(fmt_money(due_cents(parse_money((string) $values['rent']) + parse_money((string) $values['delivery']), parse_money((string) $values['deposit'])))) ?></dd></div>
|
||||
</dl>
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@ $navActive = static function (string $area) use ($path): string {
|
|||
<symbol id="i-snow" viewBox="0 0 24 24"><path d="M12 2v20M4.5 6.8l15 10.4M19.5 6.8 4.5 17.2M12 6.4 9.6 4M12 6.4 14.4 4M12 17.6 9.6 20M12 17.6l2.4 2.4"/></symbol>
|
||||
<symbol id="i-sun" viewBox="0 0 24 24"><circle cx="12" cy="12" r="4"/><path d="M12 2v3M12 19v3M2 12h3M19 12h3M4.9 4.9 7 7M17 17l2.1 2.1M19.1 4.9 17 7M7 17l-2.1 2.1"/></symbol>
|
||||
<symbol id="i-download" viewBox="0 0 24 24"><path d="M12 3v12M7 10l5 5 5-5"/><path d="M5 20h14"/></symbol>
|
||||
<symbol id="i-bank" viewBox="0 0 24 24"><path d="M3 9.5 12 4l9 5.5"/><path d="M5 10v9M9.5 10v9M14.5 10v9M19 10v9"/><path d="M3 21h18"/></symbol>
|
||||
<symbol id="i-database" viewBox="0 0 24 24"><ellipse cx="12" cy="5.5" rx="8" ry="3"/><path d="M4 5.5v13c0 1.7 3.6 3 8 3s8-1.3 8-3v-13"/><path d="M4 12c0 1.7 3.6 3 8 3s8-1.3 8-3"/></symbol>
|
||||
</defs>
|
||||
</svg>
|
||||
|
|
|
|||
|
|
@ -104,7 +104,8 @@ $admin = !empty($isAdmin);
|
|||
Unterschrift entfernt; danach lässt sich die passende Variante neu erzeugen. Ein bereits an den Kunden
|
||||
gemailtes PDF bleibt natürlich in dessen Postfach.</p>
|
||||
<p><strong>Anzahlung:</strong> Im Buchungsformular lässt sich bei den Beträgen einstellen, ob eine Anzahlung
|
||||
fällig ist („Anzahlung fällig: JA/NEIN“) und auf <strong>welches Konto</strong> sie überwiesen werden soll.
|
||||
fällig ist („Anzahlung fällig: JA/NEIN“) und auf <strong>welches Konto</strong> sie überwiesen werden soll
|
||||
(die Konten pflegt der Administrator unter <strong>Verwaltung → Konten</strong>).
|
||||
Bei „JA“ nennt die Auftragsbestätigung den Betrag, die <strong>Frist von 7 Werktagen</strong> mit
|
||||
konkretem Datum, das Konto mit IBAN und den Verwendungszweck – verbunden mit dem Hinweis, dass der Termin
|
||||
erst nach Zahlungseingang verbindlich reserviert ist. Ohne Anzahlung erscheint der Absatz nicht.
|
||||
|
|
@ -303,6 +304,9 @@ $admin = !empty($isAdmin);
|
|||
erscheinen nicht mehr in neuen Buchungen, bleiben historisch erhalten.</li>
|
||||
<li><strong>Benutzer</strong>: Konten anlegen und einladen, Mitarbeiterkonto zuordnen (steuert Erinnerungen und Push).</li>
|
||||
<li><strong>Rundmail</strong>: Empfänger aus Buchungen, Testmail, Versand in Häppchen, Protokoll je Empfänger.</li>
|
||||
<li><strong>Konten</strong>: Konten für die Anzahlung (Bezeichnung, Inhaber, Bank, IBAN, Sortierung) anlegen
|
||||
und ändern. Sie erscheinen im Buchungsformular und in der Auftragsbestätigung; Konten, die bereits in
|
||||
Buchungen verwendet werden, lassen sich nicht löschen.</li>
|
||||
<li><strong>Konfiguration</strong> (<code>app/config.local.php</code>): Mailversand, Kaution, Aufbewahrung
|
||||
(<code>app.document_retention_days</code>), Vertragstexte je Variante (<code>documents.delivery|pickup|chest</code>).</li>
|
||||
</ul>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue