Files
fewo-stommer/app/Process/Modules/Intake/ChannelBlocks.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

65 lines
2.6 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\Process\Modules\Intake;
use App\Enums\ActivityState;
use App\Enums\ChannelTaskStatus;
use App\Enums\Execution;
use App\Filament\Resources\ChannelTasks\ChannelTaskResource;
use App\Models\ChannelTask;
use App\Process\Activity;
use App\Process\CaseContext;
use App\Process\Modules\Module;
use App\Process\Modules\ModuleDefinition;
use App\Process\Modules\StepState;
/**
* Blocking and releasing the dates in portals that need it by hand (requires_manual_blocking): the tasks come from the
* observers (CreateChannelTasks) and are proven per portal (ChannelTaskProof). Mandatory, never switched off.
*/
final class ChannelBlocks extends Module
{
public static function key(): string
{
return 'channels.block';
}
public static function definition(): ModuleDefinition
{
return new ModuleDefinition(
label: 'Andere Kanäle sperren',
purpose: 'Sperrt den Zeitraum in Portalen, die nicht automatisch abgleichen, und gibt ihn bei Ende wieder frei – mit Nachweis je Portal.',
phase: 'P02',
executions: [Execution::Automatic, Execution::Manual],
condition: 'sobald ein Vorgang den Zeitraum belegt',
why: 'Die Belegung muss in anderen Portalen nachgezogen werden, sonst droht eine Doppelbuchung.',
effects: ['channel_task', 'landlord_mail', 'network'],
waits: ['landlord', 'portal'],
triggers: ['booking.occupies', 'booking.released'],
performers: ['landlord', 'system'],
);
}
public function activities(CaseContext $case): array
{
$booking = $case->booking;
return ChannelTask::query()
->with('channel')
->whereHas('channel', fn ($query) => $query->where('property_id', $booking->property_id))
->whereDate('starts_on', $booking->arrival)
->whereDate('ends_on', $booking->departure)
->where('status', '!=', ChannelTaskStatus::Dismissed)
->orderBy('id')
->get()
->map(fn (ChannelTask $task): Activity => new Activity('channel_block', ($task->action->value === 'block' ? 'In ' : 'Freigeben in ').$task->channel?->name.($task->action->value === 'block' ? ' sperren' : ''), $task->status === ChannelTaskStatus::Open ? ActivityState::Open : ActivityState::Done, $task->period().' · '.$task->proofLabel(), url: ChannelTaskResource::getUrl()))
->all();
}
/** Listed on its own in the work list; it never holds another step back. */
public function state(CaseContext $case): ?StepState
{
return null;
}
}