feat(booking): Anzahlung mit Konto und Frist in der Auftragsbestätigung
- Migration 015_booking_deposit.sql: bookings.deposit_required + bookings.deposit_account (bestehende Buchungen mit Betrag > 0 werden auf JA gesetzt), schema.sql nachgezogen - Buchungsformular: „Anzahlung fällig: JA/NEIN“ und Kontoauswahl neben dem Betrag (nur Verwaltung; Nicht-Admins behalten die gespeicherten Werte), Pflichtbetrag bei JA, Hinweis in der Zusammenfassung - app/documents.php: deposit_accounts() (Standard Postbank/Michael Schmitz, überschreibbar per app.deposit_accounts) und deposit_due_date() (7 Werktage Mo–Sa ohne NRW-Feiertage, app.deposit_due_working_days) - Auftragsbestätigung: Block „Anzahlung und verbindliche Reservierung“ mit Betrag, Datum, Kontoinhaber, Bank, IBAN, Verwendungszweck und Hinweis, dass der Termin erst nach Zahlungseingang reserviert ist; kompaktere Beträge/ Signatur, damit alles auf eine Seite passt - Buchungsdetail, Kopiertext, AGB (Zahlungsabschnitt), Anleitung, README, config.example.php und ROADMAP (Feature 24) ergänzt
This commit is contained in:
parent
8f0d3d9191
commit
bf85a64a79
12 changed files with 243 additions and 17 deletions
|
|
@ -22,6 +22,13 @@ Die Anforderungen stammen aus
|
|||
(wird beim Scrollen per CSS invertiert). PWA-Icons liegen unter
|
||||
`web/assets/icons/`.
|
||||
|
||||
- **Anzahlung in der Auftragsbestätigung**: Im Buchungsformular wird neben dem Betrag festgelegt, ob eine
|
||||
Anzahlung fällig ist (`bookings.deposit_required`) und auf welches Konto sie geht
|
||||
(`bookings.deposit_account`); die Konten stehen in `deposit_accounts()` (`app/documents.php`, überschreibbar
|
||||
über `app.deposit_accounts`). Die Auftragsbestätigung nennt Betrag, Frist
|
||||
(`app.deposit_due_working_days`, Standard 7 Werktage Mo–Sa ohne NRW-Feiertage) mit Datum, Kontoinhaber/Bank/IBAN,
|
||||
Verwendungszweck und den Hinweis, dass der Termin erst nach Zahlungseingang reserviert ist. Migration
|
||||
`015_booking_deposit.sql`.
|
||||
- **Sicherungen**: Unter **Verwaltung → Sicherungen** legt der Admin mit einem
|
||||
Klick ein Archiv aus Datenbank und allen abgelegten Dateien an, lädt es
|
||||
herunter, spielt einen früheren Stand wieder ein (mit automatischer
|
||||
|
|
|
|||
|
|
@ -82,6 +82,10 @@
|
|||
- **Umsetzung:** `next_booking_start()` liefert die nächste Buchung; `page_dashboard()` gibt `free_until` (Tag vor Mietbeginn) je Anhänger mit, `views/dashboard.php` zeigt „Frei bis <Datum> – neue Buchung möglich“.
|
||||
- **Prüfung:** Anhänger mit Buchung in 10 Tagen zeigt „Frei bis <Datum vor Mietbeginn>“, Anhänger ohne Buchung den bisherigen Text, Anhänger mit heutiger Buchung unverändert.
|
||||
|
||||
- [x] **Feature 24: Anzahlung in der Auftragsbestätigung**
|
||||
- **Umsetzung:** Migration `015_booking_deposit.sql` ergänzt `bookings.deposit_required` und `bookings.deposit_account` (bestehende Buchungen mit Betrag > 0 werden auf „JA“ gesetzt). Im Formular stehen „Anzahlung fällig: JA/NEIN“ und die Kontoauswahl neben dem Betrag (nur Verwaltung); Nicht-Admins können die Werte nicht ändern. `deposit_accounts()`/`deposit_due_date()` in `app/documents.php` liefern Konto und Frist (7 Werktage Mo–Sa, ohne NRW-Feiertage, per `app.deposit_due_working_days` einstellbar). Die Auftragsbestätigung druckt den Block „Anzahlung und verbindliche Reservierung“ mit Betrag, Datum, Kontoinhaber, Bank, IBAN, Verwendungszweck und dem Hinweis, dass der Termin erst nach Zahlungseingang reserviert ist; Beträge und Signatur rücken dafür kompakter zusammen und bleiben auf einer Seite. Buchungsdetail und Kopiertext zeigen Fälligkeit/Konto.
|
||||
- **Prüfung:** Buchung mit „JA“ und 50 € anlegen – Auftragsbestätigung nennt 50,00 €, Fristdatum in 7 Werktagen, Konto und Reservierungshinweis; „NEIN“ erzeugt keine Anzahlungszeile und keinen Absatz (Anzahlung = 0,00 €); „JA“ ohne Betrag meldet einen Fehler; Nicht-Admin sieht die Felder gesperrt; bestehende Buchung mit Anzahlung zeigt nach der Migration „JA“.
|
||||
|
||||
## Rückmeldungen Michael (30.11.2026)
|
||||
|
||||
- [x] **Feature 20: Logo und Namensumbruch im Mietvertrag**
|
||||
|
|
|
|||
|
|
@ -63,6 +63,10 @@ function agb_sections(): array
|
|||
. 'Die Kaution wird bei ordnungsgemäßer Rückgabe selbstverständlich vollständig erstattet.'],
|
||||
['p' => 'Nach Absprache kann auch per Überweisung bezahlt werden – dann jedoch so, dass das '
|
||||
. 'Geld spätestens am Montag der Terminwoche auf dem Konto des Vermieters eingegangen ist.'],
|
||||
['p' => 'Ist in der Auftragsbestätigung eine Anzahlung ausgewiesen, ist diese innerhalb von '
|
||||
. '7 Werktagen nach Erhalt der Auftragsbestätigung auf das dort genannte Konto zu überweisen. '
|
||||
. 'Erst mit Eingang der Anzahlung ist der Termin verbindlich reserviert; bei nicht '
|
||||
. 'fristgerechtem Eingang kann der Termin anderweitig vergeben werden.'],
|
||||
],
|
||||
],
|
||||
[
|
||||
|
|
|
|||
|
|
@ -55,6 +55,17 @@ return [
|
|||
'backup_keep' => 14,
|
||||
// Maximale Größe einer hochgeladenen Sicherung (MB).
|
||||
'backup_max_mb' => 200,
|
||||
// Anzahlung in der Auftragsbestätigung: Frist in Werktagen (Mo–Sa ohne
|
||||
// gesetzliche Feiertage). Die Konten stehen als Standard in
|
||||
// app/documents.php (deposit_accounts()) und lassen sich hier
|
||||
// überschreiben: Schlüssel => ['label', 'holder', 'bank', 'iban'].
|
||||
'deposit_due_working_days' => 7,
|
||||
// 'deposit_accounts' => [
|
||||
// 'postbank' => ['label' => 'Postbank – Michael Schmitz', 'holder' => 'Michael Schmitz',
|
||||
// 'bank' => 'Postbank', 'iban' => 'DE…'],
|
||||
// 'sparkasse' => ['label' => 'Sparkasse – Drink it cold', 'holder' => '…',
|
||||
// 'bank' => '…', 'iban' => 'DE…'],
|
||||
// ],
|
||||
],
|
||||
// Optional: Angaben für Impressum und Datenschutz überschreiben. Die
|
||||
// Standardwerte stehen in app/legal.php. Hinweis: tools/deploy.sh erzeugt
|
||||
|
|
|
|||
34
app/data.php
34
app/data.php
|
|
@ -163,6 +163,8 @@ function booking_note_clean(string $note): string
|
|||
function booking_input(array $source): array
|
||||
{
|
||||
$kind = (string) ($source['kind'] ?? 'pickup');
|
||||
// Anzahlung: Häkchen „Anzahlung vereinbart“ entscheidet, ob der Betrag gilt.
|
||||
$depositRequired = (string) ($source['deposit_required'] ?? '0') === '1' ? 1 : 0;
|
||||
if (array_key_exists('rent_cents', $source) || array_key_exists('delivery_cents', $source)) {
|
||||
$rent = max(0, (int) ($source['rent_cents'] ?? 0));
|
||||
$delivery = max(0, (int) ($source['delivery_cents'] ?? 0));
|
||||
|
|
@ -186,7 +188,9 @@ function booking_input(array $source): array
|
|||
'end_date' => trim((string) ($source['end_date'] ?? '')),
|
||||
'start_time' => normalize_time($source['start_time'] ?? ''),
|
||||
'end_time' => normalize_time($source['end_time'] ?? ''),
|
||||
'deposit_cents' => parse_money((string) ($source['deposit'] ?? '0')),
|
||||
'deposit_cents' => $depositRequired ? parse_money((string) ($source['deposit'] ?? '0')) : 0,
|
||||
'deposit_required' => $depositRequired,
|
||||
'deposit_account' => trim((string) ($source['deposit_account'] ?? '')),
|
||||
'rent_cents' => $rent,
|
||||
'delivery_cents' => $delivery,
|
||||
'total_cents' => $rent + $delivery,
|
||||
|
|
@ -214,6 +218,8 @@ function booking_to_input(array $booking): array
|
|||
'start_time' => normalize_time($booking['start_time'] ?? ''),
|
||||
'end_time' => normalize_time($booking['end_time'] ?? ''),
|
||||
'deposit_cents' => (int) $booking['deposit_cents'],
|
||||
'deposit_required' => (int) ($booking['deposit_required'] ?? 0),
|
||||
'deposit_account' => (string) ($booking['deposit_account'] ?? ''),
|
||||
'rent_cents' => (int) ($booking['rent_cents'] ?? $booking['total_cents']),
|
||||
'delivery_cents' => (int) ($booking['delivery_cents'] ?? 0),
|
||||
'total_cents' => (int) $booking['total_cents'],
|
||||
|
|
@ -317,6 +323,11 @@ function booking_validate(array $data, int $excludeId = 0, int $allowTrailerId =
|
|||
$errors['rent'] = 'Der Betrag ist unrealistisch hoch.';
|
||||
} elseif ($data['deposit_cents'] > $data['total_cents']) {
|
||||
$errors['deposit'] = 'Die Anzahlung darf den Gesamtbetrag nicht übersteigen.';
|
||||
} elseif ((int) ($data['deposit_required'] ?? 0) === 1 && $data['deposit_cents'] <= 0) {
|
||||
$errors['deposit'] = 'Bitte den Betrag der Anzahlung angeben oder „Anzahlung: NEIN“ wählen.';
|
||||
}
|
||||
if ((int) ($data['deposit_required'] ?? 0) === 1 && !deposit_account((string) ($data['deposit_account'] ?? ''))) {
|
||||
$errors['deposit_account'] = 'Bitte das Konto für die Anzahlung auswählen.';
|
||||
}
|
||||
|
||||
if (!$errors && $trailer) {
|
||||
|
|
@ -514,15 +525,17 @@ function booking_create(array $data, int $userId): int
|
|||
$stmt = $pdo->prepare(
|
||||
'INSERT INTO bookings
|
||||
(trailer_id, employee_id, return_employee_id, start_date, end_date, start_time, end_time, deposit_cents,
|
||||
deposit_required, deposit_account,
|
||||
rent_cents, delivery_cents, total_cents, invoice, invoice_no, kind,
|
||||
customer_name, street, city, mobile, email, note, status, created_at, updated_at, created_by, updated_by)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, "active", ?, ?, ?, ?)'
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, "active", ?, ?, ?, ?)'
|
||||
);
|
||||
$stmt->execute([
|
||||
$data['trailer_id'], $data['employee_id'], $data['return_employee_id'] ?: null,
|
||||
$data['start_date'], $data['end_date'],
|
||||
null_if_empty($data['start_time']), null_if_empty($data['end_time']),
|
||||
$data['deposit_cents'], $data['rent_cents'], $data['delivery_cents'], $data['total_cents'],
|
||||
$data['deposit_cents'], (int) ($data['deposit_required'] ?? 0), (string) ($data['deposit_account'] ?? ''),
|
||||
$data['rent_cents'], $data['delivery_cents'], $data['total_cents'],
|
||||
$data['invoice'], null_if_empty($data['invoice_no']), $data['kind'],
|
||||
$data['customer_name'], $data['street'], $data['city'], $data['mobile'], $data['email'],
|
||||
(string) ($data['note'] ?? ''),
|
||||
|
|
@ -554,15 +567,17 @@ function booking_update(int $id, array $data, int $userId): void
|
|||
}
|
||||
$stmt = $pdo->prepare(
|
||||
'UPDATE bookings SET trailer_id = ?, employee_id = ?, return_employee_id = ?, start_date = ?, end_date = ?,
|
||||
start_time = ?, end_time = ?, deposit_cents = ?, rent_cents = ?, delivery_cents = ?,
|
||||
total_cents = ?, invoice = ?, invoice_no = ?, kind = ?, customer_name = ?, street = ?,
|
||||
city = ?, mobile = ?, email = ?, note = ?, updated_at = ?, updated_by = ? WHERE id = ?'
|
||||
start_time = ?, end_time = ?, deposit_cents = ?, deposit_required = ?, deposit_account = ?,
|
||||
rent_cents = ?, delivery_cents = ?, total_cents = ?, invoice = ?, invoice_no = ?, kind = ?,
|
||||
customer_name = ?, street = ?, city = ?, mobile = ?, email = ?, note = ?, updated_at = ?,
|
||||
updated_by = ? WHERE id = ?'
|
||||
);
|
||||
$stmt->execute([
|
||||
$data['trailer_id'], $data['employee_id'], $data['return_employee_id'] ?: null,
|
||||
$data['start_date'], $data['end_date'],
|
||||
null_if_empty($data['start_time']), null_if_empty($data['end_time']),
|
||||
$data['deposit_cents'], $data['rent_cents'], $data['delivery_cents'], $data['total_cents'],
|
||||
$data['deposit_cents'], (int) ($data['deposit_required'] ?? 0), (string) ($data['deposit_account'] ?? ''),
|
||||
$data['rent_cents'], $data['delivery_cents'], $data['total_cents'],
|
||||
$data['invoice'], null_if_empty($data['invoice_no']), $data['kind'],
|
||||
$data['customer_name'], $data['street'], $data['city'], $data['mobile'], $data['email'],
|
||||
(string) ($data['note'] ?? ''),
|
||||
|
|
@ -760,7 +775,10 @@ function booking_invoice_display(array $booking): string
|
|||
function booking_copy_text(array $booking): string
|
||||
{
|
||||
return implode("\n", [
|
||||
'Anzahlung: ' . fmt_money((int) $booking['deposit_cents']),
|
||||
'Anzahlung: ' . fmt_money((int) $booking['deposit_cents'])
|
||||
. ((int) ($booking['deposit_required'] ?? 0) === 1 && (int) $booking['deposit_cents'] > 0
|
||||
? ' (fällig bis ' . fmt_date(deposit_due_date()) . ')'
|
||||
: ''),
|
||||
'Gesamtbetrag: ' . fmt_money((int) $booking['total_cents']),
|
||||
'Noch zu zahlen: ' . fmt_money(due_cents((int) $booking['total_cents'], (int) $booking['deposit_cents'])),
|
||||
'Rechnung: ' . booking_invoice_display($booking),
|
||||
|
|
|
|||
|
|
@ -418,6 +418,91 @@ function document_pdf_rows(PdfDoc $pdf, float $top, array $rows, float $valueX =
|
|||
return $y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Konten, auf die eine Anzahlung überwiesen werden kann.
|
||||
*
|
||||
* Standard steht in dieser Funktion, damit sie auch dann greift, wenn die
|
||||
* app/config.local.php beim Deployment neu erzeugt wird (dort wird kein
|
||||
* `app.deposit_accounts` geschrieben). Weitere Konten lassen sich hier
|
||||
* ergänzen oder per `app.deposit_accounts` in der lokalen Konfiguration
|
||||
* überschreiben (Schlüssel => label/holder/bank/iban).
|
||||
*
|
||||
* @return array<string, array{label: string, holder: string, bank: string, iban: string}>
|
||||
*/
|
||||
function deposit_accounts(): array
|
||||
{
|
||||
$defaults = [
|
||||
'postbank' => [
|
||||
'label' => 'Postbank – Michael Schmitz',
|
||||
'holder' => 'Michael Schmitz',
|
||||
'bank' => 'Postbank',
|
||||
'iban' => 'DE12 1001 0010 0464 1261 30',
|
||||
],
|
||||
];
|
||||
|
||||
$configured = config('app.deposit_accounts', null);
|
||||
if (!is_array($configured) || $configured === []) {
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
$accounts = [];
|
||||
foreach ($configured as $key => $account) {
|
||||
if (!is_array($account)) {
|
||||
continue;
|
||||
}
|
||||
$accounts[(string) $key] = [
|
||||
'label' => (string) ($account['label'] ?? $key),
|
||||
'holder' => (string) ($account['holder'] ?? ''),
|
||||
'bank' => (string) ($account['bank'] ?? ''),
|
||||
'iban' => (string) ($account['iban'] ?? ''),
|
||||
];
|
||||
}
|
||||
return $accounts !== [] ? $accounts : $defaults;
|
||||
}
|
||||
|
||||
/** Konto zur Kennung; ohne gültige Kennung das erste Konto (oder null). */
|
||||
function deposit_account(string $key): ?array
|
||||
{
|
||||
$accounts = deposit_accounts();
|
||||
if ($key !== '' && isset($accounts[$key])) {
|
||||
return $accounts[$key];
|
||||
}
|
||||
$first = reset($accounts);
|
||||
return $first === false ? null : $first;
|
||||
}
|
||||
|
||||
/** Frist für die Anzahlung in Werktagen (Mo–Sa, ohne gesetzliche Feiertage). */
|
||||
function deposit_due_working_days(): int
|
||||
{
|
||||
return max(1, min(60, (int) config('app.deposit_due_working_days', 7)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Fälligkeitsdatum der Anzahlung: n Werktage ab heute (Mo–Sa, NRW-Feiertage
|
||||
* zählen nicht mit).
|
||||
*/
|
||||
function deposit_due_date(?string $fromIso = null): string
|
||||
{
|
||||
$date = $fromIso !== null && valid_date($fromIso) ? $fromIso : today_iso();
|
||||
$remaining = deposit_due_working_days();
|
||||
$guard = 0;
|
||||
$cursor = date_obj($date);
|
||||
while ($remaining > 0 && $guard < 400) {
|
||||
$cursor = $cursor->modify('+1 day');
|
||||
$guard++;
|
||||
$iso = $cursor->format('Y-m-d');
|
||||
$weekday = $cursor->format('N');
|
||||
if ($weekday === '7') {
|
||||
continue; // Sonntag ist kein Werktag
|
||||
}
|
||||
if (holiday_name($iso) !== null) {
|
||||
continue;
|
||||
}
|
||||
$remaining--;
|
||||
}
|
||||
return $cursor->format('Y-m-d');
|
||||
}
|
||||
|
||||
/**
|
||||
* Bezeichnung des Mietgegenstandes, ohne doppelte Wörter
|
||||
* ("Kühlanhänger 1", "Kühltruhe 1", "Kühlanhänger: WM Meyer").
|
||||
|
|
@ -663,26 +748,59 @@ function document_confirmation_pdf(array $booking, string $variant): string
|
|||
if ($deposit > 0) {
|
||||
$priceRows[] = ['Kaution', fmt_money($deposit) . ' (Rückgabe: volle Erstattung)'];
|
||||
}
|
||||
// Anzahlung: vereinbart (Häkchen in der Buchung) und Betrag > 0.
|
||||
$depositRequired = (int) ($booking['deposit_required'] ?? 0) === 1;
|
||||
$account = $depositRequired && $paid > 0 ? deposit_account((string) ($booking['deposit_account'] ?? '')) : null;
|
||||
$dueDate = $account !== null ? deposit_due_date() : null;
|
||||
$workingDays = deposit_due_working_days();
|
||||
if ($paid > 0) {
|
||||
$priceRows[] = ['Anzahlung', '− ' . fmt_money($paid)];
|
||||
$priceRows[] = [
|
||||
$depositRequired ? 'Anzahlung (bis ' . fmt_date((string) $dueDate) . ')' : 'Anzahlung',
|
||||
'− ' . fmt_money($paid),
|
||||
];
|
||||
}
|
||||
$priceRows[] = ['Gesamtbetrag', fmt_money($grand), true];
|
||||
$priceRows[] = ['Bei Übergabe zu zahlen', fmt_money(max(0, $grand - $paid)), true];
|
||||
$priceRows[] = ['Rechnung', booking_invoice_display($booking)];
|
||||
$y = document_pdf_rows($pdf, $y, $priceRows);
|
||||
|
||||
$note = 'Der Gesamtbetrag ist bei der Übergabe in bar zu zahlen. Nach Absprache ist auch eine '
|
||||
. 'Überweisung möglich – das Geld muss dann spätestens am Montag der Terminwoche eingegangen sein. '
|
||||
. 'Die Kaution wird bei ordnungsgemäßer Rückgabe vollständig erstattet.';
|
||||
$y = document_pdf_note($pdf, $y + 8, 'Zahlung', $note);
|
||||
if ($account !== null) {
|
||||
$y = document_pdf_heading($pdf, $y + 6, 'Anzahlung und verbindliche Reservierung');
|
||||
$intro = 'Zur verbindlichen Reservierung ist eine Anzahlung in Höhe von ' . fmt_money($paid)
|
||||
. ' innerhalb von ' . $workingDays . ' Werktagen nach Erhalt dieser Auftragsbestätigung – also bis '
|
||||
. 'spätestens ' . fmt_date((string) $dueDate) . ' – auf folgendes Konto zu überweisen:';
|
||||
$y = $pdf->paragraph(50, $y + 2, $pdf->pageWidth() - 100, 9.5, $intro, false, 13);
|
||||
$y = document_pdf_rows($pdf, $y + 4, [
|
||||
['Kontoinhaber', $account['holder']],
|
||||
['Bank', $account['bank']],
|
||||
['IBAN', $account['iban']],
|
||||
['Verwendungszweck', 'Kühlanhänger ' . fmt_date((string) $booking['start_date']) . ' · '
|
||||
. (string) $booking['customer_name']],
|
||||
], 150.0);
|
||||
$warning = 'Bitte beachten: Erst nach Eingang der Anzahlung auf dem genannten Konto ist der Termin '
|
||||
. 'verbindlich reserviert. Erfolgt innerhalb der Frist kein Zahlungseingang, behalten wir uns vor, '
|
||||
. 'den Termin wieder freizugeben.';
|
||||
$y = $pdf->paragraph(50, $y + 4, $pdf->pageWidth() - 100, 9.5, $warning, false, 13);
|
||||
}
|
||||
|
||||
// Mit Anzahlung steht das Wichtigste schon oben – dann nur noch der Restbetrag.
|
||||
$note = $account !== null
|
||||
? 'Der Restbetrag von ' . fmt_money(max(0, $grand - $paid)) . ' ist bei der Übergabe in bar zu zahlen; '
|
||||
. 'nach Absprache auch per Überweisung. Die Kaution wird bei ordnungsgemäßer Rückgabe vollständig erstattet.'
|
||||
: 'Der Gesamtbetrag ist bei der Übergabe in bar zu zahlen. Nach Absprache ist auch eine '
|
||||
. 'Überweisung möglich – das Geld muss dann spätestens am Montag der Terminwoche eingegangen sein. '
|
||||
. 'Die Kaution wird bei ordnungsgemäßer Rückgabe vollständig erstattet.';
|
||||
$y = document_pdf_note($pdf, $y + 6, 'Zahlung', $note);
|
||||
|
||||
$closing = 'Vielen Dank für die Buchung. Diese Auftragsbestätigung bestätigt den vereinbarten Termin und '
|
||||
. 'die genannten Beträge. Es gelten die Allgemeinen Geschäftsbedingungen des Vermieters. '
|
||||
. 'Bitte prüfen Sie die Angaben und melden Sie sich bei Abweichungen.';
|
||||
$y = $pdf->paragraph(50, $y + 4, $pdf->pageWidth() - 100, 9, $closing, false, 12.5);
|
||||
|
||||
$signatureTop = $y + 50;
|
||||
if ($signatureTop > 720) {
|
||||
// Unterschrift nur dann auf eine neue Seite, wenn sie sonst in den Fußbereich
|
||||
// rutschen würde – mit Anzahlungsblock ist Seite 1 sonst schnell „voll".
|
||||
$signatureTop = $y + 34;
|
||||
if ($signatureTop > 770) {
|
||||
document_pdf_footer($pdf, 'Auftragsbestätigung · Buchung #' . (int) $booking['id']);
|
||||
$pdf->newPage();
|
||||
$signatureTop = 150;
|
||||
|
|
|
|||
|
|
@ -806,6 +806,8 @@ function booking_form_context(array $user, ?array $booking = null, array $values
|
|||
'user' => $user,
|
||||
'isEdit' => $booking !== null,
|
||||
'canEditBilling' => auth_can_manage($user),
|
||||
'depositAccounts' => deposit_accounts(),
|
||||
'depositDueDays' => deposit_due_working_days(),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -820,6 +822,8 @@ function form_values_from_input(array $data): array
|
|||
'start_time' => (string) ($data['start_time'] ?? ''),
|
||||
'end_time' => (string) ($data['end_time'] ?? ''),
|
||||
'deposit' => number_format($data['deposit_cents'] / 100, 2, ',', ''),
|
||||
'deposit_required' => (int) ($data['deposit_required'] ?? 0),
|
||||
'deposit_account' => (string) ($data['deposit_account'] ?? ''),
|
||||
'rent' => number_format($data['rent_cents'] / 100, 2, ',', ''),
|
||||
'delivery' => number_format($data['delivery_cents'] / 100, 2, ',', ''),
|
||||
'invoice' => (int) $data['invoice'],
|
||||
|
|
@ -872,6 +876,8 @@ function page_booking_new(array $user, string $method): void
|
|||
'start_time' => '',
|
||||
'end_time' => '',
|
||||
'deposit' => '',
|
||||
'deposit_required' => 0,
|
||||
'deposit_account' => '',
|
||||
'rent' => '',
|
||||
'delivery' => '',
|
||||
'invoice' => 0,
|
||||
|
|
@ -926,6 +932,8 @@ function page_booking_edit(array $user, int $id, string $method): void
|
|||
'start_time' => (string) ($booking['start_time'] ?? ''),
|
||||
'end_time' => (string) ($booking['end_time'] ?? ''),
|
||||
'deposit' => number_format((int) $booking['deposit_cents'] / 100, 2, ',', ''),
|
||||
'deposit_required' => (int) ($booking['deposit_required'] ?? 0),
|
||||
'deposit_account' => (string) ($booking['deposit_account'] ?? ''),
|
||||
'rent' => number_format((int) $booking['rent_cents'] / 100, 2, ',', ''),
|
||||
'delivery' => number_format((int) $booking['delivery_cents'] / 100, 2, ',', ''),
|
||||
'invoice' => (int) $booking['invoice'],
|
||||
|
|
@ -950,6 +958,8 @@ function page_booking_edit(array $user, int $id, string $method): void
|
|||
$data = booking_input($_POST);
|
||||
if (!$canEditBilling) {
|
||||
$data['deposit_cents'] = (int) $booking['deposit_cents'];
|
||||
$data['deposit_required'] = (int) ($booking['deposit_required'] ?? 0);
|
||||
$data['deposit_account'] = (string) ($booking['deposit_account'] ?? '');
|
||||
$data['rent_cents'] = (int) $booking['rent_cents'];
|
||||
$data['delivery_cents'] = (int) $booking['delivery_cents'];
|
||||
$data['total_cents'] = (int) $booking['total_cents'];
|
||||
|
|
|
|||
12
sql/migrations/015_booking_deposit.sql
Normal file
12
sql/migrations/015_booking_deposit.sql
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
-- Anzahlung in der Auftragsbestätigung: eigene Kennzeichnung und Zielkonto.
|
||||
--
|
||||
-- Bisher war die Anzahlung nur ein Betrag (bookings.deposit_cents). Jetzt lässt
|
||||
-- sich zusätzlich festhalten, ob überhaupt eine Anzahlung vereinbart ist und auf
|
||||
-- welches Konto sie überwiesen werden soll; die Auftragsbestätigung fordert sie
|
||||
-- dann mit Frist (Standard: 7 Werktage) ein.
|
||||
ALTER TABLE bookings
|
||||
ADD COLUMN deposit_required TINYINT(1) NOT NULL DEFAULT 0 AFTER deposit_cents,
|
||||
ADD COLUMN deposit_account VARCHAR(40) NOT NULL DEFAULT '' AFTER deposit_required;
|
||||
|
||||
-- Bestehende Buchungen mit Anzahlung behalten ihr Verhalten.
|
||||
UPDATE bookings SET deposit_required = 1 WHERE deposit_cents > 0;
|
||||
|
|
@ -65,6 +65,9 @@ CREATE TABLE IF NOT EXISTS bookings (
|
|||
start_time TIME NULL DEFAULT NULL,
|
||||
end_time TIME NULL DEFAULT NULL,
|
||||
deposit_cents INT UNSIGNED NOT NULL DEFAULT 0,
|
||||
-- Anzahlung laut Auftragsbestätigung: vereinbart? auf welches Konto?
|
||||
deposit_required TINYINT(1) NOT NULL DEFAULT 0,
|
||||
deposit_account VARCHAR(40) NOT NULL DEFAULT '',
|
||||
rent_cents INT UNSIGNED NOT NULL DEFAULT 0,
|
||||
delivery_cents INT UNSIGNED NOT NULL DEFAULT 0,
|
||||
total_cents INT UNSIGNED NOT NULL DEFAULT 0,
|
||||
|
|
|
|||
|
|
@ -201,7 +201,15 @@ $returnTo = '/bookings/' . (int) $booking['id'];
|
|||
<div><dt>Miete</dt><dd><?= e(fmt_money((int) $booking['rent_cents'])) ?></dd></div>
|
||||
<div><dt>Lieferkosten</dt><dd><?= e(fmt_money((int) $booking['delivery_cents'])) ?></dd></div>
|
||||
<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'])) ?></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'] ?? ''));
|
||||
echo ' · fällig bis ' . e(fmt_date(deposit_due_date()));
|
||||
if ($depositTarget !== null) {
|
||||
echo ' auf ' . e((string) $depositTarget['label']);
|
||||
}
|
||||
}
|
||||
?></dd></div>
|
||||
<div class="is-strong"><dt>Noch zu zahlen</dt><dd><?= e(fmt_money($due)) ?></dd></div>
|
||||
</dl>
|
||||
</section>
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@
|
|||
/** @var array $user */
|
||||
/** @var bool $isEdit */
|
||||
/** @var bool $canEditBilling */
|
||||
/** @var array<string, array{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';
|
||||
$selectedTrailer = null;
|
||||
|
|
@ -227,6 +229,24 @@ $backUrl = $isEdit ? '/bookings/' . (int) $booking['id'] : '/calendar';
|
|||
<?php if ($fieldError('deposit')): ?><em class="field-error"><?= e($fieldError('deposit')) ?></em><?php endif; ?>
|
||||
</label>
|
||||
|
||||
<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>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<span class="segmented-radio segmented-radio--compact">
|
||||
<label><input type="radio" name="deposit_required" value="0"<?= (int) $values['deposit_required'] === 0 ? ' checked' : '' ?><?= empty($canEditBilling) ? ' disabled' : '' ?>><span>NEIN</span></label>
|
||||
<label><input type="radio" name="deposit_required" value="1"<?= (int) $values['deposit_required'] === 1 ? ' checked' : '' ?><?= empty($canEditBilling) ? ' disabled' : '' ?>><span>JA</span></label>
|
||||
</span>
|
||||
</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>
|
||||
</div>
|
||||
|
||||
<div class="field<?= $fieldError('invoice_no') !== '' ? ' has-error' : '' ?>" data-paste-field="invoice_no">
|
||||
<span>Rechnung</span>
|
||||
<div class="field-with-aside">
|
||||
|
|
@ -252,6 +272,8 @@ $backUrl = $isEdit ? '/bookings/' . (int) $booking['id'] : '/calendar';
|
|||
</div>
|
||||
<p class="muted small">
|
||||
Es gilt: Gesamt = Miete + Lieferkosten, „Noch zu zahlen" = Gesamt − Anzahlung.
|
||||
Mit „Anzahlung fällig: JA" steht in der Auftragsbestätigung, bis wann die Anzahlung auf
|
||||
welchem Konto eingehen muss – sonst ist der Termin nicht reserviert.
|
||||
Kunden bitte auf die <a href="<?= e(url('/datenschutz')) ?>">Datenschutzhinweise</a> hinweisen.
|
||||
<?php if (empty($canEditBilling)): ?>
|
||||
<br>Miete, Lieferkosten, Anzahlung und Rechnungsdaten pflegt die Verwaltung.
|
||||
|
|
@ -271,7 +293,10 @@ $backUrl = $isEdit ? '/bookings/' . (int) $booking['id'] : '/calendar';
|
|||
<div><dt>Miete</dt><dd data-summary-rent><?= e(fmt_money(parse_money((string) $values['rent']))) ?></dd></div>
|
||||
<div><dt>Lieferkosten</dt><dd data-summary-delivery><?= e(fmt_money(parse_money((string) $values['delivery']))) ?></dd></div>
|
||||
<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']))) ?></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>
|
||||
<?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>
|
||||
<div class="form-actions">
|
||||
|
|
|
|||
|
|
@ -103,6 +103,12 @@ $admin = !empty($isAdmin);
|
|||
<strong>auch wenn der Kunde schon unterschrieben hat</strong>. Dabei wird neben dem PDF auch die gespeicherte
|
||||
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.
|
||||
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.
|
||||
</p>
|
||||
<p class="manual-note">
|
||||
Unterlagen werden automatisch <strong>einen Monat nach dem Mietende</strong> gelöscht. Innerhalb dieser Frist
|
||||
kann alles nachgesehen, gedruckt oder erneut gemailt werden.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue