V2.1: Kanalfähigkeiten, Ausführungsvarianten, Dokumentenentkopplung, Portalbestätigung
Modellwahl über Kanalfähigkeiten mit erklärten Einschränkungen, Abgleich alter Werte, Ausführungsvarianten je Modul, getrennte Vertrags-/Buchungsinformation, Warten auf die Portalbestätigung mit Eskalation und Wiederaufnahme (Fälle C und D getestet). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ef1635e59a
commit
8442d0a3d8
62 files changed
+1818
-69
No files matched your search
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Process;
|
||||
|
||||
use App\Enums\PortalEmailType;
|
||||
use App\Models\Booking;
|
||||
use App\Models\PortalEmail;
|
||||
use Carbon\CarbonImmutable;
|
||||
|
||||
/**
|
||||
* The evidence that a portal confirmed a binding booking (docs/Prozessarchitektur/V2.1/02 §5): a booking mail of the portal
|
||||
* that is assigned to the case deterministically – by the portal's booking reference or by the calendar entry that belongs
|
||||
* to the case, both of the same channel (CH-13) – or the landlord's explicit confirmation in the case. The evidence level is
|
||||
* „laut Portal“ (mail) or „nachgewiesen durch den Vermieter“; it never creates or changes a binding, the booking was
|
||||
* binding from the start (E-036). Pure reading; `confirm` records the landlord's confirmation.
|
||||
*/
|
||||
final class PortalConfirmation
|
||||
{
|
||||
public const EVENT = 'portal_confirmation';
|
||||
|
||||
/**
|
||||
* @return array{source: 'mail'|'landlord', at: CarbonImmutable, label: string}|null
|
||||
*/
|
||||
public static function evidence(Booking $booking): ?array
|
||||
{
|
||||
$landlord = $booking->events()->where('type', self::EVENT)->orderBy('occurred_at')->first();
|
||||
if ($landlord !== null) {
|
||||
return ['source' => 'landlord', 'at' => CarbonImmutable::parse($landlord->occurred_at), 'label' => 'vom Vermieter bestätigt ('.$landlord->actor.')'];
|
||||
}
|
||||
|
||||
$channelId = $booking->processChannel()?->id;
|
||||
if ($channelId === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$mail = PortalEmail::query()->where('channel_id', $channelId)->where('type', PortalEmailType::Booking)
|
||||
->where(fn ($query) => $query
|
||||
->when(filled($booking->portal_reference), fn ($by) => $by->orWhere('reference', $booking->portal_reference))
|
||||
->orWhereHas('blockedPeriod', fn ($block) => $block->withTrashed()->where('linked_booking_id', $booking->id)))
|
||||
->orderBy('received_at')->first();
|
||||
|
||||
return $mail === null ? null : ['source' => 'mail', 'at' => CarbonImmutable::parse($mail->received_at), 'label' => 'Bestätigungsmail des Portals vom '.CarbonImmutable::parse($mail->received_at)->format('d.m.Y, H:i').' Uhr (laut Portal)'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Until when the confirmation is awaited (counted from the case's arrival in the system).
|
||||
*/
|
||||
public static function deadline(Booking $booking): CarbonImmutable
|
||||
{
|
||||
return CarbonImmutable::parse($booking->created_at)->addHours($booking->process()->portalConfirmationWaitHours());
|
||||
}
|
||||
|
||||
public static function isOverdue(Booking $booking): bool
|
||||
{
|
||||
return self::deadline($booking)->isPast();
|
||||
}
|
||||
|
||||
/**
|
||||
* The landlord states that the portal confirmed (e.g. checked in the portal's own interface). Recorded once.
|
||||
*/
|
||||
public static function confirm(Booking $booking, string $by, ?string $note = null): void
|
||||
{
|
||||
if ($booking->events()->where('type', self::EVENT)->exists()) {
|
||||
return;
|
||||
}
|
||||
CaseLog::record($booking, self::EVENT, 'Bestätigung des Portals vom Vermieter festgehalten', reason: $note, data: ['module' => 'portal.confirmation', 'level' => 'confirmed_by_landlord'], actor: $by);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user