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
11
sql/migrations/020_booking_deposit_amount.sql
Normal file
11
sql/migrations/020_booking_deposit_amount.sql
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
-- Kaution je Buchung.
|
||||
--
|
||||
-- Bisher stand die Kaution global in app.document_deposit_cents (100 €) und
|
||||
-- wurde in Auftragsbestätigung, Mietvertrag und Zahlungserinnerung fest
|
||||
-- eingerechnet. Kunden zahlen die Kaution aber nur zum Teil oder gar nicht
|
||||
-- (Vereinbarung vor Ort), und bei Stammkunden wird ganz darauf verzichtet.
|
||||
--
|
||||
-- deposit_amount_cents ist die Kaution (bar bei Übergabe; 0 = keine Kaution).
|
||||
-- deposit_cents bleibt die Anzahlung (Überweisung vor dem Termin).
|
||||
ALTER TABLE bookings
|
||||
ADD COLUMN deposit_amount_cents INT UNSIGNED NOT NULL DEFAULT 10000 AFTER deposit_account_id;
|
||||
31
sql/migrations/021_document_signatures.sql
Normal file
31
sql/migrations/021_document_signatures.sql
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
-- Drei Unterschriften im Mietvertrag.
|
||||
--
|
||||
-- Der Papiervertrag wird an drei Stellen unterschrieben:
|
||||
-- handover – Mitarbeiter bestätigt bei der Übergabe, dass die Zahlung
|
||||
-- eingegangen ist,
|
||||
-- customer – Kunde bestätigt, den Mietgegenstand übernommen zu haben,
|
||||
-- return – Kunde bestätigt bei der Rückgabe, die Kaution zurückerhalten
|
||||
-- zu haben.
|
||||
--
|
||||
-- Bisher gab es nur eine Signatur (booking_documents.signature_file/signed_at)
|
||||
-- – das bleibt die Kundenunterschrift bei der Übernahme und wird hier als
|
||||
-- Rolle 'customer' übernommen.
|
||||
CREATE TABLE IF NOT EXISTS document_signatures (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
document_id BIGINT UNSIGNED NOT NULL,
|
||||
role ENUM('handover', 'customer', 'return') NOT NULL,
|
||||
signature_file VARCHAR(190) NOT NULL,
|
||||
signed_at DATETIME NOT NULL,
|
||||
signed_via VARCHAR(10) NOT NULL DEFAULT 'tablet',
|
||||
signed_by BIGINT UNSIGNED NULL DEFAULT NULL,
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE KEY uq_document_signatures_role (document_id, role),
|
||||
KEY idx_document_signatures_document (document_id),
|
||||
CONSTRAINT fk_document_signatures_document FOREIGN KEY (document_id) REFERENCES booking_documents (id) ON DELETE CASCADE,
|
||||
CONSTRAINT fk_document_signatures_user FOREIGN KEY (signed_by) REFERENCES users (id) ON DELETE SET NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
INSERT IGNORE INTO document_signatures (document_id, role, signature_file, signed_at, signed_via, signed_by)
|
||||
SELECT id, 'customer', signature_file, signed_at, COALESCE(NULLIF(signed_via, ''), 'tablet'), created_by
|
||||
FROM booking_documents
|
||||
WHERE signature_file IS NOT NULL AND signed_at IS NOT NULL;
|
||||
16
sql/migrations/022_review_mail_log.sql
Normal file
16
sql/migrations/022_review_mail_log.sql
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
-- Automatische Bewertungsmail eine Woche nach der Rückgabe.
|
||||
--
|
||||
-- Die Mail („Ihre Meinung ist uns wichtig“ mit Google-Bewertungslink) hat der
|
||||
-- Kunde bisher manuell verschickt. Der tägliche Erinnerungslauf erzeugt sie
|
||||
-- jetzt selbst; dieses Protokoll stellt sicher, dass jeder Kunde genau eine
|
||||
-- Mail bekommt (auch wenn der Cron einen Tag ausfällt).
|
||||
CREATE TABLE IF NOT EXISTS review_mail_log (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
booking_id BIGINT UNSIGNED NOT NULL,
|
||||
sent_to VARCHAR(190) NOT NULL,
|
||||
sent_at DATETIME NOT NULL,
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE KEY uq_review_mail_booking (booking_id),
|
||||
KEY idx_review_mail_sent (sent_at),
|
||||
CONSTRAINT fk_review_mail_booking FOREIGN KEY (booking_id) REFERENCES bookings (id) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
|
@ -81,6 +81,8 @@ CREATE TABLE IF NOT EXISTS bookings (
|
|||
-- Anzahlung laut Auftragsbestätigung: vereinbart? auf welches Konto?
|
||||
deposit_required TINYINT(1) NOT NULL DEFAULT 0,
|
||||
deposit_account_id BIGINT UNSIGNED NULL DEFAULT NULL,
|
||||
-- Kaution (bar bei Übergabe, 0 = keine Kaution); nicht die Anzahlung.
|
||||
deposit_amount_cents INT UNSIGNED NOT NULL DEFAULT 10000,
|
||||
-- Restzahlung: bar bei der Übergabe oder per Überweisung.
|
||||
balance_method ENUM('cash', 'transfer') NOT NULL DEFAULT 'cash',
|
||||
rent_cents INT UNSIGNED NOT NULL DEFAULT 0,
|
||||
|
|
@ -166,6 +168,17 @@ CREATE TABLE IF NOT EXISTS payment_reminder_log (
|
|||
CONSTRAINT fk_payment_reminder_booking FOREIGN KEY (booking_id) REFERENCES bookings (id) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS review_mail_log (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
booking_id BIGINT UNSIGNED NOT NULL,
|
||||
sent_to VARCHAR(190) NOT NULL,
|
||||
sent_at DATETIME NOT NULL,
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE KEY uq_review_mail_booking (booking_id),
|
||||
KEY idx_review_mail_sent (sent_at),
|
||||
CONSTRAINT fk_review_mail_booking FOREIGN KEY (booking_id) REFERENCES bookings (id) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS auth_tokens (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
user_id BIGINT UNSIGNED NOT NULL,
|
||||
|
|
@ -310,6 +323,23 @@ CREATE TABLE IF NOT EXISTS booking_documents (
|
|||
CONSTRAINT fk_booking_documents_user FOREIGN KEY (created_by) REFERENCES users (id) ON DELETE SET NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- Unterschriften je Unterlage: handover (Mitarbeiter, Zahlung erhalten),
|
||||
-- customer (Kunde, Übernahme) und return (Kunde, Kaution zurück).
|
||||
CREATE TABLE IF NOT EXISTS document_signatures (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
document_id BIGINT UNSIGNED NOT NULL,
|
||||
role ENUM('handover', 'customer', 'return') NOT NULL,
|
||||
signature_file VARCHAR(190) NOT NULL,
|
||||
signed_at DATETIME NOT NULL,
|
||||
signed_via VARCHAR(10) NOT NULL DEFAULT 'tablet',
|
||||
signed_by BIGINT UNSIGNED NULL DEFAULT NULL,
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE KEY uq_document_signatures_role (document_id, role),
|
||||
KEY idx_document_signatures_document (document_id),
|
||||
CONSTRAINT fk_document_signatures_document FOREIGN KEY (document_id) REFERENCES booking_documents (id) ON DELETE CASCADE,
|
||||
CONSTRAINT fk_document_signatures_user FOREIGN KEY (signed_by) REFERENCES users (id) ON DELETE SET NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- Kundenrundmail: Sperrliste für Abmeldungen und Versandprotokoll.
|
||||
-- Empfänger werden je Kampagne aus bookings.email gezogen (app/mailing.php).
|
||||
CREATE TABLE IF NOT EXISTS mail_optouts (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue