feat(booking): Kaution je Buchung, drei Vertragsunterschriften, Mails und Aufbewahrung nach Kundenwunsch
Kundenwunsch vom 04.12.2026 (docs/auftraege): - Kaution je Buchung (bookings.deposit_amount_cents, Standard 100 €, 0 = keine) statt globaler Konfiguration; Voreinstellungen im Formular angepasst. - Auftragsbestätigung rechnet Kaution nicht mehr in Gesamt/Restbetrag ein, zeigt sie als "in bar"-Hinweis unter dem Zahlungseingang, Verwendungszweck "#Buchungsnummer Name", Hinweis auf Anruf 8–10 Tage vor dem Termin. - Mietvertrag mit drei Unterschriften (Migration 021, document_signatures): Mitarbeiter bestätigt Zahlungseingang, Kunde Übernahme, Kunde Kautionsrückgabe; Zusatzvereinbarungen werden im Vertrag abgedruckt. - Zahlungserinnerung ebenfalls ohne Kaution im Betrag. - Mail-Fuß mit Signaturblock und Antwort-Sperrhinweis, Betreffzeilen mit Buchungsnummer und Mietgegenstand (ohne Anhängernummer), Wochentag in Datumsangaben. - Aufbewahrung: ohne Rechnung 30 Tage, mit Rechnung Mietvertrag 8 Jahre; Jahresarchiv der Mietverträge (app/export.php, Verwaltung → Sicherungen). - Automatische Bewertungsmail eine Woche nach Rückgabe (Migration 022). - Mehrfachvermietung: "Weiterer Anhänger für diesen Kunden" (/bookings/new?from=ID). Migrationen 020–022 sind lokal gelaufen; PDF-Erzeugung, Unterschrifts-Lebenszyklus und Jahresexport getestet.
This commit is contained in:
parent
606237dbda
commit
00b7b7f0e9
33 changed files with 1355 additions and 218 deletions
|
|
@ -886,6 +886,7 @@ function form_values_from_input(array $data): array
|
|||
'deposit' => number_format($data['deposit_cents'] / 100, 2, ',', ''),
|
||||
'deposit_required' => (int) ($data['deposit_required'] ?? 0),
|
||||
'deposit_account_id' => (int) ($data['deposit_account_id'] ?? 0),
|
||||
'deposit_amount' => number_format((int) ($data['deposit_amount_cents'] ?? booking_deposit_default_cents()) / 100, 2, ',', ''),
|
||||
'balance_method' => (string) ($data['balance_method'] ?? 'cash') === 'transfer' ? 'transfer' : 'cash',
|
||||
'rent' => number_format($data['rent_cents'] / 100, 2, ',', ''),
|
||||
'delivery' => number_format($data['delivery_cents'] / 100, 2, ',', ''),
|
||||
|
|
@ -933,6 +934,35 @@ function page_booking_new(array $user, string $method): void
|
|||
$employeeId = (int) $employees[0]['id'];
|
||||
}
|
||||
|
||||
// Weitere Buchung für denselben Kunden/denselben Termin (mehrere Anhänger
|
||||
// oder Anhänger + Truhe): Werte aus der Quellbuchung vorbelegen.
|
||||
$customerName = '';
|
||||
$customerStreet = '';
|
||||
$customerCity = '';
|
||||
$customerMobile = '';
|
||||
$customerEmail = '';
|
||||
$kind = 'pickup';
|
||||
$deliveryStreet = '';
|
||||
$deliveryCity = '';
|
||||
$copyFrom = query_int('from');
|
||||
if ($copyFrom > 0) {
|
||||
$source = booking_find($copyFrom);
|
||||
if ($source !== null) {
|
||||
$customerName = (string) $source['customer_name'];
|
||||
$customerStreet = (string) $source['street'];
|
||||
$customerCity = (string) $source['city'];
|
||||
$customerMobile = (string) $source['mobile'];
|
||||
$customerEmail = (string) $source['email'];
|
||||
$kind = (string) $source['kind'];
|
||||
$deliveryStreet = (string) ($source['delivery_street'] ?? '');
|
||||
$deliveryCity = (string) ($source['delivery_city'] ?? '');
|
||||
if (query_string('start') === '') {
|
||||
$start = (string) $source['start_date'];
|
||||
$end = (string) $source['end_date'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$values = [
|
||||
'trailer_id' => $trailerId,
|
||||
'employee_id' => $employeeId,
|
||||
|
|
@ -944,20 +974,21 @@ function page_booking_new(array $user, string $method): void
|
|||
'deposit' => '',
|
||||
'deposit_required' => 0,
|
||||
'deposit_account_id' => (int) (deposit_accounts()[0]['id'] ?? 0),
|
||||
'deposit_amount' => number_format(booking_deposit_default_cents() / 100, 2, ',', ''),
|
||||
'balance_method' => 'cash',
|
||||
'rent' => '',
|
||||
'delivery' => '',
|
||||
'invoice' => 0,
|
||||
'invoice_no' => '',
|
||||
'kind' => 'pickup',
|
||||
'customer_name' => '',
|
||||
'street' => '',
|
||||
'city' => '',
|
||||
'delivery_street' => '',
|
||||
'delivery_city' => '',
|
||||
'kind' => in_array($kind, ['pickup', 'delivery'], true) ? $kind : 'pickup',
|
||||
'customer_name' => $customerName,
|
||||
'street' => $customerStreet,
|
||||
'city' => $customerCity,
|
||||
'delivery_street' => $deliveryStreet,
|
||||
'delivery_city' => $deliveryCity,
|
||||
'agreements' => '',
|
||||
'mobile' => '',
|
||||
'email' => '',
|
||||
'mobile' => $customerMobile,
|
||||
'email' => $customerEmail,
|
||||
'note' => '',
|
||||
];
|
||||
$errors = [];
|
||||
|
|
@ -1004,6 +1035,7 @@ function page_booking_edit(array $user, int $id, string $method): void
|
|||
'deposit' => number_format((int) $booking['deposit_cents'] / 100, 2, ',', ''),
|
||||
'deposit_required' => (int) ($booking['deposit_required'] ?? 0),
|
||||
'deposit_account_id' => (int) ($booking['deposit_account_id'] ?? 0) ?: (int) (deposit_accounts()[0]['id'] ?? 0),
|
||||
'deposit_amount' => number_format(booking_deposit_amount($booking) / 100, 2, ',', ''),
|
||||
'balance_method' => (string) ($booking['balance_method'] ?? 'cash') === 'transfer' ? 'transfer' : 'cash',
|
||||
'rent' => number_format((int) $booking['rent_cents'] / 100, 2, ',', ''),
|
||||
'delivery' => number_format((int) $booking['delivery_cents'] / 100, 2, ',', ''),
|
||||
|
|
@ -1034,6 +1066,7 @@ function page_booking_edit(array $user, int $id, string $method): void
|
|||
$data['deposit_cents'] = (int) $booking['deposit_cents'];
|
||||
$data['deposit_required'] = (int) ($booking['deposit_required'] ?? 0);
|
||||
$data['deposit_account_id'] = (int) ($booking['deposit_account_id'] ?? 0);
|
||||
$data['deposit_amount_cents'] = booking_deposit_amount($booking);
|
||||
$data['balance_method'] = (string) ($booking['balance_method'] ?? 'cash') === 'transfer' ? 'transfer' : 'cash';
|
||||
$data['rent_cents'] = (int) $booking['rent_cents'];
|
||||
$data['delivery_cents'] = (int) $booking['delivery_cents'];
|
||||
|
|
@ -1087,8 +1120,8 @@ function booking_detail_context(array $booking, array $user): array
|
|||
'documentsMailEnabled' => mail_is_enabled(),
|
||||
'documentsRetention' => array_reduce(
|
||||
array_keys(document_kinds()),
|
||||
static function (array $carry, string $kind): array {
|
||||
$carry[$kind] = document_retention_text($kind);
|
||||
static function (array $carry, string $kind) use ($booking): array {
|
||||
$carry[$kind] = document_retention_text($kind, $booking);
|
||||
return $carry;
|
||||
},
|
||||
[]
|
||||
|
|
@ -1270,24 +1303,33 @@ function page_booking_document_action(array $user, string $method, int $bookingI
|
|||
if (!auth_can_edit_booking($user)) {
|
||||
abort_page(403, 'Dafür fehlt dir die Berechtigung.');
|
||||
}
|
||||
// Drei Unterschriften: Mitarbeiter bestätigt die Zahlung (handover),
|
||||
// Kunde die Übernahme (customer) bzw. die Rückgabe der Kaution (return).
|
||||
$role = post_string('role') !== '' ? post_string('role') : query_string('role');
|
||||
$role = document_sign_role_valid($role) ? $role : DOCUMENT_SIGN_CUSTOMER;
|
||||
if ($method === 'GET') {
|
||||
render_standalone('document_sign', [
|
||||
'booking' => $booking,
|
||||
'doc' => $doc,
|
||||
'role' => $role,
|
||||
'pageTitle' => 'Unterschrift Mietvertrag',
|
||||
], 'Unterschrift · ' . $booking['customer_name']);
|
||||
return;
|
||||
}
|
||||
require_post();
|
||||
try {
|
||||
document_save_signature($booking, $doc, post_string('signature'), (int) $user['id'], 'tablet');
|
||||
document_save_signature($booking, $doc, post_string('signature'), (int) $user['id'], 'tablet', $role);
|
||||
$mailUrl = '';
|
||||
if (mail_is_enabled() && filter_var((string) $booking['email'], FILTER_VALIDATE_EMAIL) !== false) {
|
||||
if ($role === DOCUMENT_SIGN_CUSTOMER
|
||||
&& mail_is_enabled()
|
||||
&& filter_var((string) $booking['email'], FILTER_VALIDATE_EMAIL) !== false
|
||||
) {
|
||||
$mailUrl = '/bookings/' . $bookingId . '/documents/' . $docId . '/mail';
|
||||
}
|
||||
render_standalone('document_sign_done', [
|
||||
'booking' => $booking,
|
||||
'doc' => document_find($docId) ?? $doc,
|
||||
'role' => $role,
|
||||
'mailed' => false,
|
||||
'backUrl' => '/bookings/' . $bookingId . '#unterlagen',
|
||||
'mailUrl' => $mailUrl,
|
||||
|
|
@ -1408,6 +1450,7 @@ function page_signature_public(string $method, string $token): void
|
|||
render_standalone('document_sign_done', [
|
||||
'booking' => $booking,
|
||||
'doc' => $result['doc'],
|
||||
'role' => DOCUMENT_SIGN_CUSTOMER,
|
||||
'mailed' => $result['mailed'],
|
||||
'backUrl' => '',
|
||||
'mailUrl' => '',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue