Vorgangskern und geführte Vorgangsbearbeitung (Pakete 1 und 2, Prozessarchitektur v0.10)
- Buchung ist der einheitliche Vorgang: Eingangsart, Vorgangsart A1–A6, eingefrorenes Abwicklungsprofil, gespeicherter Verlauf (booking_events); Gast, Personen und Beträge dürfen unbekannt sein, Platzhalter-Gäste werden migriert und nicht mehr angelegt - Einstellungen in Ebenen: Vermieterstandard (So arbeite ich), Abweichung der Wohnung (Experte), Abweichung je Portal und Eingangsart; ersetzt booking_model als Steuergröße - Ein Weg für extern verbindliche Buchungen (TakeOverExternalBooking) statt RecordPortalBooking und "Akte anlegen"; Portalpreis als belegte Gesamtposition - Startseite "Zu erledigen", neue Vorgangsseite mit nächstem Schritt, Automatik-Schalter, "Beenden" mit Storno statt Statusumschaltung; Status von Hand nur im Expertenmodus - Migration übernimmt bisheriges Verhalten unverändert (abweichende Wohnungswerte bleiben als Abweichung), Bericht: php artisan process:settings-report Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9005c12164
commit
3a728c3255
78 files changed
+4296
-1180
No files matched your search
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace App\Process;
|
||||
|
||||
use App\Actions\AutoOffer;
|
||||
use App\Actions\ConfirmBooking;
|
||||
use App\Enums\BookingStatus;
|
||||
use App\Enums\IntakeKind;
|
||||
use App\Enums\ProcessingMode;
|
||||
use App\Enums\Responsibility;
|
||||
use App\Models\Booking;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Carries a case on by itself as far as its data allows – only when the case is handled automatically. What it may do
|
||||
* is what the landlord would do next anyway: send the offer of a request, or send the documents of a booking that is
|
||||
* binding on a portal once the guest's e-mail address and the price are known. Whatever stops it is returned in plain
|
||||
* words; the case then shows it as a task. Never touches a case whose profile was taken over from the old data (the
|
||||
* automation did not exist for those cases before).
|
||||
*/
|
||||
class CaseAutomation
|
||||
{
|
||||
public function __construct(private AutoOffer $autoOffer, private ConfirmBooking $confirm) {}
|
||||
|
||||
/**
|
||||
* @return list<string> what keeps the case from going on automatically (empty: nothing to do or done)
|
||||
*/
|
||||
public function advance(Booking $booking): array
|
||||
{
|
||||
$booking->loadMissing(['guest', 'property']);
|
||||
|
||||
if ($booking->processingMode() !== ProcessingMode::Automatic) {
|
||||
return [];
|
||||
}
|
||||
|
||||
try {
|
||||
return CaseLog::context(fn (): array => $this->step($booking), actor: CaseLog::SYSTEM.' (automatisch)');
|
||||
} catch (Throwable $exception) {
|
||||
report($exception);
|
||||
|
||||
return ['Technischer Fehler beim automatischen Weiterbearbeiten – bitte von Hand fortsetzen.'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<string>
|
||||
*/
|
||||
private function step(Booking $booking): array
|
||||
{
|
||||
if ($booking->status === BookingStatus::Reserved && $booking->offer_version === 0 && $booking->intake !== IntakeKind::Booking) {
|
||||
return $this->autoOffer->handle($booking);
|
||||
}
|
||||
|
||||
if ($booking->isBinding() && $booking->confirmation_sent_at === null && $booking->process()->documents() === Responsibility::Landlord && $booking->process()->origin !== 'migration') {
|
||||
$missing = $this->documentBlockers($booking);
|
||||
if ($missing !== []) {
|
||||
return $missing;
|
||||
}
|
||||
|
||||
return $this->confirm->deliver($booking) ? [] : ['Die Unterlagen konnten nicht versendet werden (siehe Postfach).'];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* What is missing before the documents of a binding case can go to the guest.
|
||||
*
|
||||
* @return list<string>
|
||||
*/
|
||||
public function documentBlockers(Booking $booking): array
|
||||
{
|
||||
return array_values(array_filter([
|
||||
$booking->guest === null ? 'Name und Kontaktdaten des Gastes fehlen.' : null,
|
||||
$booking->guest !== null && blank($booking->guest->email) ? 'Die E-Mail-Adresse des Gastes fehlt.' : null,
|
||||
$booking->total === null ? 'Der Gesamtpreis (laut Portal) fehlt.' : null,
|
||||
]));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user