Files
fewo-stommer/app/Console/Commands/AdvanceWaitingCases.php
T
LarsandClaude Sonnet 5.5 8442d0a3d8 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>
2026-11-05 07:54:11 +01:00

48 lines
1.9 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace App\Console\Commands;
use App\Models\Booking;
use App\Models\Tenant;
use App\Process\ProcessRunner;
use App\Tenancy\TenantRunner;
use Illuminate\Console\Attributes\Description;
use Illuminate\Console\Attributes\Signature;
use Illuminate\Console\Command;
use Throwable;
/**
* Evaluates binding bookings that wait for an event again (V2.1, docs/Prozessarchitektur/V2.1/02 §5): the portal's
* confirmation mail did not come in time (escalate once), came meanwhile (close the escalation, go on) – without this nothing
* would resume or time out, because no scheduler looks at binding cases. Only cases whose channel makes them wait are
* touched; once per landlord.
*/
#[Signature('bookings:advance-waiting')]
#[Description('Re-evaluate binding bookings that wait for a portal confirmation (deadline, escalation, resume) – once per landlord')]
class AdvanceWaitingCases extends Command
{
public function handle(TenantRunner $tenants, ProcessRunner $runner): int
{
$tenants->each(function (Tenant $tenant) use ($runner): void {
$evaluated = 0;
Booking::query()->occupying()->where('intake', 'booking')->where('created_at', '>', now()->subDays(90))
->with(['property', 'guest', 'importChannel', 'originChannel'])
->each(function (Booking $booking) use ($runner, &$evaluated): void {
if (! $booking->process()->awaitsPortalConfirmation()) {
return;
}
try {
$runner->advance($booking, 'schedule:waiting');
$evaluated++;
} catch (Throwable $exception) {
report($exception);
}
});
$this->info("{$tenant->name}: {$evaluated} wartende Vorgang/Vorgänge bewertet.");
});
return self::SUCCESS;
}
}