CaseActivities/CaseAutomation sind Fassaden über ProcessRunner. Verhaltensvergleich v0.11: 11 Abläufe und 198 Konstellationen gleich, beabsichtigte Abweichungen I-004/I-005 (F-001/F-002). Volle Suite vor U-B: 785/785. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
61 lines
2.3 KiB
PHP
61 lines
2.3 KiB
PHP
<?php
|
||
|
||
namespace App\Process\Modules\Intake;
|
||
|
||
use App\Enums\ActivityState;
|
||
use App\Enums\ChannelTaskStatus;
|
||
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',
|
||
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;
|
||
}
|
||
}
|