Akte auch fuer Portal-Reservierungen aus dem Kalender, Ablauf mit Aktivitaeten, Verlauf, Standardprozess je Portal
Deploy FeWo mit PipelineManager / deploy (push) Successful in 3m34s
Deploy FeWo mit PipelineManager / deploy (push) Successful in 3m34s
- Akte anlegen aus einer importierten Portal-Reservierung (Belegung bleibt durchgehend belegt, Kalendereintrag wird Spiegelung) - Akte: Standardprozess (Portal/Vorlage/Storno/Anlagen), Meilensteine mit Aktivitaeten und Aktionshinweis, chronologischer Verlauf - Kanalformular: Abschnitt Standardprozess je Buchungstyp mit Anzeige, was die Vorlage mitbringt - Portalpreis als gemeinsame Logik (PortalPrice) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5ba9ae08ab
commit
81c025f1ee
10 files changed
+450
-75
No files matched your search
@@ -7,6 +7,7 @@
|
||||
use App\Enums\BookingTaskStatus;
|
||||
use App\Enums\ChannelBookingModel;
|
||||
use App\Models\Booking;
|
||||
use App\Models\BookingMessage;
|
||||
use App\Models\BookingTask;
|
||||
use App\Models\Cancellation;
|
||||
use Carbon\CarbonImmutable;
|
||||
@@ -48,7 +49,10 @@ public static function kindLabel(Booking $booking): string
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array{label: string, state: string, detail: ?string}> state: done | current | todo | skipped
|
||||
* The milestones of the process with the activities that belong to each. An activity names the action on the
|
||||
* booking page that does it ("action"), so the landlord sees what was done, what is open and where to do it.
|
||||
*
|
||||
* @return list<array{label: string, state: string, detail: ?string, activities: list<array{label: string, done: bool, action: ?string}>}>
|
||||
*/
|
||||
public static function steps(Booking $booking): array
|
||||
{
|
||||
@@ -56,12 +60,20 @@ public static function steps(Booking $booking): array
|
||||
$kind = self::kind($booking);
|
||||
$closed = in_array($booking->status, [BookingStatus::Cancelled, BookingStatus::Declined, BookingStatus::Expired], true);
|
||||
$binding = in_array($booking->status, BookingStatus::occupying(), true);
|
||||
$hasEmail = filled($booking->guest?->email);
|
||||
$activity = fn (string $label, bool $done, ?string $action = null): array => ['label' => $label, 'done' => $done, 'action' => $done ? null : $action];
|
||||
$steps = [];
|
||||
|
||||
$steps[] = ['label' => 'Anfrage / Eingang', 'state' => 'done', 'detail' => $booking->created_at?->format('d.m.Y')];
|
||||
$steps[] = ['label' => 'Anfrage / Eingang', 'state' => 'done', 'detail' => $booking->created_at?->format('d.m.Y'), 'activities' => [
|
||||
$activity($kind === self::OWN ? 'Anfrage über die Webseite eingegangen' : 'Vorgang angelegt ('.$booking->bookingChannelLabel().')', true),
|
||||
]];
|
||||
|
||||
if (in_array($kind, [self::PORTAL_BOOKING, self::PORTAL_INQUIRY], true)) {
|
||||
$steps[] = ['label' => 'Kontaktdaten des Gastes', 'state' => filled($booking->guest?->email) ? 'done' : ($closed ? 'skipped' : 'current'), 'detail' => filled($booking->guest?->email) ? null : ($booking->contact_requested_at ? 'erfragt am '.$booking->contact_requested_at->format('d.m.Y') : 'fehlen noch')];
|
||||
$asked = $booking->contact_requested_at !== null;
|
||||
$steps[] = ['label' => 'Gast & Kontaktdaten', 'state' => $hasEmail ? 'done' : ($closed ? 'skipped' : 'current'), 'detail' => $hasEmail ? null : ($asked ? 'erfragt am '.$booking->contact_requested_at->format('d.m.Y') : 'fehlen noch'), 'activities' => [
|
||||
$activity('Gast um Kontaktdaten bitten', $hasEmail || $asked, 'Gast um Kontaktdaten bitten'),
|
||||
$activity('Kontaktdaten eintragen (Name, E-Mail, Anschrift)', $hasEmail, 'Kontaktdaten eintragen'),
|
||||
]];
|
||||
}
|
||||
|
||||
$needsOffer = in_array($kind, [self::OWN, self::PORTAL_INQUIRY, self::MANUAL], true);
|
||||
@@ -70,32 +82,85 @@ public static function steps(Booking $booking): array
|
||||
'label' => 'Angebot',
|
||||
'state' => $booking->offer_version > 0 || $binding ? 'done' : ($closed ? 'skipped' : 'current'),
|
||||
'detail' => $booking->offer_version > 0 ? 'Version '.$booking->offer_version.', '.$booking->offer_sent_at?->format('d.m.Y') : null,
|
||||
'activities' => [$activity('Angebot mit Vertragsentwurf an den Gast senden', $booking->offer_version > 0 || $binding, 'Angebot senden')],
|
||||
];
|
||||
}
|
||||
|
||||
$steps[] = [
|
||||
'label' => $needsOffer ? 'Annahme / Vertrag' : 'Vertrag senden',
|
||||
'label' => $needsOffer ? 'Annahme / Vertrag' : 'Bestätigung / Vertrag',
|
||||
'state' => $binding ? ($booking->confirmation_sent_at !== null || $booking->accepted_at !== null || $needsOffer ? 'done' : 'current') : ($closed ? 'skipped' : ($booking->status === BookingStatus::OfferSent ? 'current' : 'todo')),
|
||||
'detail' => $booking->accepted_at ? 'angenommen '.$booking->accepted_at->format('d.m.Y') : ($booking->confirmation_sent_at ? 'Vertrag gesendet '.$booking->confirmation_sent_at->format('d.m.Y') : null),
|
||||
'activities' => array_values(array_filter([
|
||||
$needsOffer ? $activity('Gast nimmt das Angebot an (oder Buchung direkt bestätigen)', $binding, 'Direkt bestätigen') : $activity('Buchung bestätigen (Zeitraum fest belegen)', $binding, 'Direkt bestätigen'),
|
||||
$activity('Mietvertrag mit Anlagen an den Gast senden', $booking->confirmation_sent_at !== null, $binding ? 'Bestätigung erneut senden' : null),
|
||||
$booking->guest_confirmed_at ? $activity('Gast hat die Buchung per E-Mail bestätigt', true) : null,
|
||||
])),
|
||||
];
|
||||
|
||||
if ($booking->wantsPaymentTasks()) {
|
||||
$paid = $booking->paidAmount();
|
||||
$steps[] = ['label' => 'Anzahlung', 'state' => $closed ? 'skipped' : ($paid >= $booking->deposit && $binding ? 'done' : ($binding ? 'current' : 'todo')), 'detail' => $booking->deposit_due_on ? 'fällig '.$booking->deposit_due_on->format('d.m.Y') : null];
|
||||
$steps[] = ['label' => 'Restzahlung', 'state' => $closed ? 'skipped' : ($paid >= $booking->total && $binding ? 'done' : ($binding && $paid >= $booking->deposit ? 'current' : 'todo')), 'detail' => 'fällig '.$booking->balance_due_on?->format('d.m.Y')];
|
||||
$steps[] = ['label' => 'Anzahlung', 'state' => $closed ? 'skipped' : ($paid >= $booking->deposit && $binding ? 'done' : ($binding ? 'current' : 'todo')), 'detail' => $booking->deposit_due_on ? 'fällig '.$booking->deposit_due_on->format('d.m.Y') : null, 'activities' => [
|
||||
$activity('Zahlungseingang erfassen', $paid >= $booking->deposit && $binding, 'Zahlungen (unten)'),
|
||||
]];
|
||||
$steps[] = ['label' => 'Restzahlung', 'state' => $closed ? 'skipped' : ($paid >= $booking->total && $binding ? 'done' : ($binding && $paid >= $booking->deposit ? 'current' : 'todo')), 'detail' => 'fällig '.$booking->balance_due_on?->format('d.m.Y'), 'activities' => [
|
||||
$activity('Restzahlung erfassen', $paid >= $booking->total && $binding, 'Zahlungen (unten)'),
|
||||
]];
|
||||
} else {
|
||||
$steps[] = ['label' => 'Zahlung', 'state' => 'skipped', 'detail' => 'läuft über das Portal'];
|
||||
$steps[] = ['label' => 'Zahlung', 'state' => 'skipped', 'detail' => 'läuft über das Portal', 'activities' => []];
|
||||
}
|
||||
|
||||
$arrived = ! $closed && $binding && $booking->arrival <= $today;
|
||||
$left = ! $closed && $binding && $booking->departure <= $today;
|
||||
$steps[] = ['label' => 'Anreise', 'state' => $closed ? 'skipped' : ($arrived ? 'done' : 'todo'), 'detail' => $booking->arrival->format('d.m.Y')];
|
||||
$steps[] = ['label' => 'Vor Ort', 'state' => $closed ? 'skipped' : ($arrived && ! $left ? 'current' : ($left ? 'done' : 'todo')), 'detail' => null];
|
||||
$steps[] = ['label' => 'Abreise', 'state' => $closed ? 'skipped' : ($left ? 'done' : 'todo'), 'detail' => $booking->departure->format('d.m.Y')];
|
||||
$steps[] = ['label' => 'Anreise', 'state' => $closed ? 'skipped' : ($arrived ? 'done' : 'todo'), 'detail' => $booking->arrival->format('d.m.Y'), 'activities' => [
|
||||
$activity('Anreise-Informationen ('.$booking->property->arrival_info_days_before.' Tage vorher, automatisch)', $booking->arrival_info_sent_at !== null),
|
||||
]];
|
||||
$steps[] = ['label' => 'Vor Ort', 'state' => $closed ? 'skipped' : ($arrived && ! $left ? 'current' : ($left ? 'done' : 'todo')), 'detail' => null, 'activities' => []];
|
||||
$steps[] = ['label' => 'Abreise', 'state' => $closed ? 'skipped' : ($left ? 'done' : 'todo'), 'detail' => $booking->departure->format('d.m.Y'), 'activities' => []];
|
||||
|
||||
return $steps;
|
||||
}
|
||||
|
||||
/**
|
||||
* What has happened so far, oldest first: milestones from the booking's own timestamps, payments and mails.
|
||||
*
|
||||
* @return list<array{at: CarbonImmutable, label: string}>
|
||||
*/
|
||||
public static function history(Booking $booking): array
|
||||
{
|
||||
$events = [];
|
||||
$add = function (mixed $at, string $label) use (&$events): void {
|
||||
if ($at !== null) {
|
||||
$events[] = ['at' => CarbonImmutable::instance($at), 'label' => $label];
|
||||
}
|
||||
};
|
||||
|
||||
$add($booking->created_at, 'Vorgang angelegt ('.$booking->bookingChannelLabel().')');
|
||||
$add($booking->contact_requested_at, 'Gast um Kontaktdaten gebeten');
|
||||
$add($booking->offer_sent_at, 'Angebot Version '.$booking->offer_version.' gesendet');
|
||||
$add($booking->accepted_at, 'Angebot vom Gast angenommen');
|
||||
$add($booking->guest_confirmed_at, 'Gast hat die Buchung per E-Mail bestätigt');
|
||||
$add($booking->confirmed_at, 'Buchung verbindlich bestätigt');
|
||||
$add($booking->confirmation_sent_at, 'Bestätigung mit Mietvertrag an den Gast gesendet');
|
||||
$add($booking->confirmation_failed_at, 'Versand der Bestätigung fehlgeschlagen');
|
||||
$add($booking->arrival_info_sent_at, 'Anreise-Informationen gesendet');
|
||||
$add($booking->cancelled_at, 'Storniert');
|
||||
$add($booking->archived_at, 'Archiviert');
|
||||
|
||||
foreach ($booking->payments()->get() as $payment) {
|
||||
$add($payment->paid_on ?? $payment->created_at, ($payment->amount < 0 ? 'Erstattung ' : 'Zahlung ').Money::format(abs($payment->amount)).' erfasst');
|
||||
}
|
||||
foreach (BookingMessage::query()->where('booking_id', $booking->id)->get() as $message) {
|
||||
$add($message->sent_at, 'E-Mail: '.$message->subject.' ('.$message->audience.')');
|
||||
}
|
||||
foreach (BookingTask::query()->where('booking_id', $booking->id)->where('status', BookingTaskStatus::Done)->get() as $task) {
|
||||
$add($task->completed_at, 'Aufgabe erledigt: '.$task->kind->getLabel());
|
||||
}
|
||||
|
||||
usort($events, fn (array $a, array $b): int => $a['at'] <=> $b['at']);
|
||||
|
||||
return $events;
|
||||
}
|
||||
|
||||
private static function cancelledText(Booking $booking, bool $open): string
|
||||
{
|
||||
$cancellation = Cancellation::query()->where('booking_id', $booking->id)->first();
|
||||
|
||||
Reference in new issue
Block a user