Ein Eingang fuer alle Kanaele (Paket 4, Prozessarchitektur v0.10)
Portalbuchungen und -anfragen aus Kalender und Mail werden ueber PortalIntake zum Vorgang (nur bei sicherer Erkennung), Dubletten ueber Buchungsnummer, gleiches Portal mit gleichen Naechten und Spiegelung; Unsicheres wird geklaert. Portalstorno und -aenderung als Aufgabe am Vorgang ohne stille Stornierung. Schalter je Kanal (Aus als Standard, Beobachten, Anlegen, Anlegen + weiter), Eingangsprotokoll, Bestandsuebernahme mit Vorschau/Bericht/Ruecknahme, Sperrnachweis in drei Stufen. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
cf11c8a474
commit
ac9d20b812
29 files changed
+1952
-16
No files matched your search
@@ -3,6 +3,7 @@
|
||||
namespace App\Actions;
|
||||
|
||||
use App\Channels\ConflictDetector;
|
||||
use App\Channels\Intake\PortalIntake;
|
||||
use App\Channels\Mail\ParsedPortalMail;
|
||||
use App\Channels\Mail\PortalMail;
|
||||
use App\Channels\Mail\PortalMailParser;
|
||||
@@ -12,6 +13,7 @@
|
||||
use App\Mail\PortalMailNotification;
|
||||
use App\Models\BlockedPeriod;
|
||||
use App\Models\Channel;
|
||||
use App\Models\IntakeObservation;
|
||||
use App\Models\PortalEmail;
|
||||
use App\Support\Settings;
|
||||
use App\Tenancy\TenantFeatures;
|
||||
@@ -75,6 +77,9 @@ public function handle(PortalMail $mail): ?PortalEmail
|
||||
]);
|
||||
});
|
||||
|
||||
// One intake for all channels (package 4): bookings, requests and cancellations reach their case.
|
||||
rescue(fn () => $this->intake($channel, $parsed, $record));
|
||||
|
||||
if (in_array($record->status, [PortalEmailStatus::Blocked, PortalEmailStatus::Released, PortalEmailStatus::NeedsReview], true)) {
|
||||
rescue(fn () => Mail::to(Settings::notificationRecipients())->send(new PortalMailNotification($record)));
|
||||
}
|
||||
@@ -86,6 +91,17 @@ public function handle(PortalMail $mail): ?PortalEmail
|
||||
return $record;
|
||||
}
|
||||
|
||||
private function intake(Channel $channel, ParsedPortalMail $parsed, PortalEmail $record): void
|
||||
{
|
||||
$intake = app(PortalIntake::class);
|
||||
match ($parsed->type) {
|
||||
PortalEmailType::Booking => $record->blocked_period_id !== null ? $intake->process(BlockedPeriod::query()->findOrFail($record->blocked_period_id), IntakeObservation::SOURCE_MAIL) : null,
|
||||
PortalEmailType::Cancellation => $intake->cancellationMail($channel, $parsed, $record),
|
||||
PortalEmailType::Inquiry => $intake->inquiryMail($channel, $parsed, $record),
|
||||
PortalEmailType::Unknown => null,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Channels list the sender addresses or domains of their notification e-mails in settings.email_senders.
|
||||
*/
|
||||
@@ -177,6 +193,11 @@ private function release(Channel $channel, ParsedPortalMail $parsed): array
|
||||
default => null,
|
||||
};
|
||||
|
||||
// A block that belongs to a case is never released by a mail: the case leads, the landlord decides (E-019).
|
||||
if ($block && $block->linked_booking_id !== null) {
|
||||
return [PortalEmailStatus::NeedsReview, $block, 'Stornierung zu einem gebuchten Vorgang gemeldet – nichts automatisch freigegeben; Aufgabe am Vorgang prüfen.'];
|
||||
}
|
||||
|
||||
if ($block) {
|
||||
$block->delete();
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
use App\Channels\ChannelSyncException;
|
||||
use App\Channels\ConflictDetector;
|
||||
use App\Channels\ExternalPeriod;
|
||||
use App\Channels\Intake\PortalIntake;
|
||||
use App\Enums\ChannelEchoBehavior;
|
||||
use App\Models\BlockedPeriod;
|
||||
use App\Models\Booking;
|
||||
@@ -135,6 +136,8 @@ public function handle(Channel $channel): ChannelSyncLog
|
||||
'alerted_at' => null, 'last_import_events' => count($periods), 'sync_warnings' => $warnings])->save();
|
||||
});
|
||||
app(ReportChannelConflicts::class)->handle($channel, $conflicts);
|
||||
// One intake for all channels (package 4); a failure there never fails the sync itself.
|
||||
rescue(fn () => app(PortalIntake::class)->afterSync($channel->fresh()));
|
||||
|
||||
return $channel->syncLogs()->create(['successful' => true, 'events' => count($periods), ...$counts,
|
||||
'conflicts' => count($conflicts), 'warnings' => $warnings,
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
use App\Enums\BookingStatus;
|
||||
use App\Enums\IntakeKind;
|
||||
use App\Enums\OccupationKind;
|
||||
use App\Enums\ProcessingMode;
|
||||
use App\Exceptions\ReservationException;
|
||||
use App\Models\BlockedPeriod;
|
||||
use App\Models\Booking;
|
||||
@@ -31,7 +32,7 @@ class TakeOverExternalBooking
|
||||
public function __construct(private ConfirmBooking $confirm, private PortalPrice $price) {}
|
||||
|
||||
/**
|
||||
* @param array{guest?: ?array<string, ?string>, guests?: ?int, portal_reference?: ?string, portal_total?: ?int, notes?: ?string, guest_confirmed?: bool} $facts
|
||||
* @param array{guest?: ?array<string, ?string>, guests?: ?int, portal_reference?: ?string, portal_total?: ?int, notes?: ?string, guest_confirmed?: bool, processing_mode?: ?ProcessingMode} $facts
|
||||
*
|
||||
* @throws ReservationException
|
||||
*/
|
||||
@@ -73,6 +74,7 @@ public function handle(Property $property, Channel $channel, CarbonImmutable $ar
|
||||
'hold_expires_at' => null,
|
||||
'guest_confirmed_at' => ($facts['guest_confirmed'] ?? false) ? now() : null,
|
||||
'internal_notes' => filled($facts['notes'] ?? null) ? trim((string) $facts['notes']) : null,
|
||||
'processing_mode' => $facts['processing_mode'] ?? null,
|
||||
...$this->price->columns($property, $arrival, $departure, $guests, $portalTotal, $channel->name),
|
||||
]);
|
||||
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions;
|
||||
|
||||
use App\Availability\AvailabilityChecker;
|
||||
use App\Enums\BookingStatus;
|
||||
use App\Enums\IntakeKind;
|
||||
use App\Enums\ProcessingMode;
|
||||
use App\Exceptions\ReservationException;
|
||||
use App\Models\Booking;
|
||||
use App\Models\Channel;
|
||||
use App\Process\CaseAutomation;
|
||||
use App\Process\ProcessSettings;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
/**
|
||||
* A non-binding request through a portal (case type A2) as it arrives: dates and the portal's reference, nothing
|
||||
* invented. Guest, number of guests and price stay unknown until the landlord enters them; the case then asks for
|
||||
* exactly that and continues like a request of the own website. Whether the dates are reserved follows the channel's
|
||||
* settings for requests.
|
||||
*/
|
||||
class TakeOverPortalInquiry
|
||||
{
|
||||
public function __construct(private AvailabilityChecker $availability, private ProcessSettings $settings) {}
|
||||
|
||||
/**
|
||||
* @throws ReservationException
|
||||
*/
|
||||
public function handle(Channel $channel, CarbonImmutable $arrival, CarbonImmutable $departure, ?string $reference = null, ?string $notes = null, ?ProcessingMode $processingMode = null): Booking
|
||||
{
|
||||
$property = $channel->property;
|
||||
if ($departure->lessThanOrEqualTo($arrival)) {
|
||||
throw new ReservationException('Die Abreise muss nach der Anreise liegen.');
|
||||
}
|
||||
|
||||
$booking = DB::transaction(function () use ($property, $channel, $arrival, $departure, $reference, $notes, $processingMode): Booking {
|
||||
$property->newQuery()->whereKey($property->id)->lockForUpdate()->firstOrFail();
|
||||
if (! $this->availability->isAvailable($property, $arrival, $departure)) {
|
||||
throw ReservationException::notAvailable();
|
||||
}
|
||||
|
||||
$profile = $this->settings->resolve($property, $channel, IntakeKind::Inquiry);
|
||||
|
||||
return $property->bookings()->create([
|
||||
'status' => BookingStatus::Reserved,
|
||||
'source' => 'portal',
|
||||
'intake' => IntakeKind::Inquiry,
|
||||
'origin_channel_id' => $channel->id,
|
||||
'portal_reference' => $reference,
|
||||
'arrival' => $arrival->toDateString(),
|
||||
'departure' => $departure->toDateString(),
|
||||
'hold_expires_at' => $profile->preReservation() ? now()->addHours($profile->holdHours()) : null,
|
||||
'processing_mode' => $processingMode,
|
||||
'internal_notes' => $notes,
|
||||
]);
|
||||
});
|
||||
|
||||
app(CaseAutomation::class)->advance($booking);
|
||||
|
||||
return $booking->refresh();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Channels\Intake;
|
||||
|
||||
use App\Enums\CaseType;
|
||||
use App\Enums\IntakeOutcome;
|
||||
use App\Models\Booking;
|
||||
|
||||
/**
|
||||
* What the intake recognised in one incoming portal event, with its reasons in plain words.
|
||||
*/
|
||||
final class IntakeDecision
|
||||
{
|
||||
/**
|
||||
* @param list<string> $reasons why the intake decided so
|
||||
* @param list<string> $missing what the new case will not know yet
|
||||
*/
|
||||
public function __construct(
|
||||
public readonly IntakeOutcome $outcome,
|
||||
public readonly array $reasons = [],
|
||||
public readonly ?Booking $booking = null,
|
||||
public readonly ?CaseType $caseType = null,
|
||||
public readonly array $missing = [],
|
||||
public readonly ?string $reference = null,
|
||||
) {}
|
||||
|
||||
public function withBooking(Booking $booking): self
|
||||
{
|
||||
return new self($this->outcome, $this->reasons, $booking, $this->caseType ?? $booking->case_type, $this->missing, $this->reference);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<string> $reasons
|
||||
*/
|
||||
public function as(IntakeOutcome $outcome, array $reasons): self
|
||||
{
|
||||
return new self($outcome, $reasons, $this->booking, $this->caseType, $this->missing, $this->reference);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,489 @@
|
||||
<?php
|
||||
|
||||
namespace App\Channels\Intake;
|
||||
|
||||
use App\Actions\ReconcileChannelRepresentations;
|
||||
use App\Actions\TakeOverExternalBooking;
|
||||
use App\Actions\TakeOverPortalInquiry;
|
||||
use App\Channels\Mail\ParsedPortalMail;
|
||||
use App\Enums\BookingStatus;
|
||||
use App\Enums\BookingTaskKind;
|
||||
use App\Enums\BookingTaskStatus;
|
||||
use App\Enums\CaseIntakeMode;
|
||||
use App\Enums\ChannelBookingModel;
|
||||
use App\Enums\IntakeKind;
|
||||
use App\Enums\IntakeOutcome;
|
||||
use App\Enums\OccupationKind;
|
||||
use App\Enums\ProcessingMode;
|
||||
use App\Exceptions\ReservationException;
|
||||
use App\Models\BlockedPeriod;
|
||||
use App\Models\Booking;
|
||||
use App\Models\BookingTask;
|
||||
use App\Models\Channel;
|
||||
use App\Models\IntakeObservation;
|
||||
use App\Models\PortalEmail;
|
||||
use App\Pricing\QuoteException;
|
||||
use App\Process\CaseLog;
|
||||
use App\Process\ProcessSettings;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Illuminate\Support\Collection;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* The one intake for bookings and requests from portals (UMSETZUNGSPLAN_v0.10 §5.5, package 4). Every incoming event –
|
||||
* an entry of a portal calendar, a booking, request or cancellation e-mail – is judged the same way:
|
||||
*
|
||||
* - **Same case first** (no duplicates): an entry already linked to a case; the portal's booking reference; the same
|
||||
* portal with exactly the same nights; the calendar mirror of an entry that belongs to a case. Different references
|
||||
* or overlapping but different dates are never merged – they are clarified.
|
||||
* - **New case only when certain**: a booking e-mail of the portal with dates and reference, or a calendar entry that
|
||||
* the channel's rules recognise as a reservation booked at this portal (or that the landlord classified so). Blocks,
|
||||
* mirrors of other portals, own use and unrecognised entries never become cases by themselves.
|
||||
* - **Reports about known cases** (cancellation e-mail, entry gone from the calendar, other dates) become a task on the
|
||||
* case and an entry in its history – the case itself is never cancelled, released or changed here (E-019).
|
||||
*
|
||||
* What happens then depends on the channel ({@see CaseIntakeMode}): nothing (off), only a record (observe), or the
|
||||
* cases and tasks are created (create; continue additionally lets the new cases follow the automatic handling).
|
||||
* Creating a case never sends anything the landlord did not release (package 3).
|
||||
*/
|
||||
class PortalIntake
|
||||
{
|
||||
public const LINK_NOTE = 'Automatisch dem Vorgang zugeordnet; der Vorgang führt diese Belegung.';
|
||||
|
||||
public function __construct(
|
||||
private TakeOverExternalBooking $takeOver,
|
||||
private TakeOverPortalInquiry $inquiry,
|
||||
private ProcessSettings $settings,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Judges one portal calendar entry or e-mail block without changing anything.
|
||||
*/
|
||||
public function evaluate(BlockedPeriod $block): IntakeDecision
|
||||
{
|
||||
$block->loadMissing(['channel', 'property', 'canonicalBlock', 'linkedBooking']);
|
||||
$channel = $block->channel;
|
||||
$reference = self::reference($block);
|
||||
|
||||
if ($channel === null || ! in_array($block->source, ['channel', 'email'], true)) {
|
||||
return new IntakeDecision(IntakeOutcome::Ignore, ['Kein importierter Portaleintrag.'], reference: $reference);
|
||||
}
|
||||
if ($block->trashed()) {
|
||||
return new IntakeDecision(IntakeOutcome::Ignore, ['Nicht mehr im Kalender des Portals.'], reference: $reference);
|
||||
}
|
||||
if ($block->linked_booking_id !== null && $block->linkedBooking !== null) {
|
||||
return new IntakeDecision(IntakeOutcome::Link, ['Bereits dem Vorgang zugeordnet.'], $block->linkedBooking, reference: $reference);
|
||||
}
|
||||
if ($block->is_representation) {
|
||||
$leaderCase = $block->canonicalBlock?->linkedBooking;
|
||||
|
||||
return $leaderCase !== null
|
||||
? new IntakeDecision(IntakeOutcome::Link, ['Spiegelung einer Belegung, die zu diesem Vorgang gehört.'], $leaderCase, reference: $reference)
|
||||
: new IntakeDecision(IntakeOutcome::Ignore, ['Spiegelung einer anderen Belegung, keine eigene Buchung.'], reference: $reference);
|
||||
}
|
||||
|
||||
if ($reference !== null && ($case = $this->caseByReference($channel, $reference)) !== null) {
|
||||
return new IntakeDecision(IntakeOutcome::Link, ['Gleiche Buchungsnummer '.$reference.' wie der Vorgang.'], $case, reference: $reference);
|
||||
}
|
||||
|
||||
if ($block->ends_on->lessThanOrEqualTo(CarbonImmutable::today())) {
|
||||
return new IntakeDecision(IntakeOutcome::Ignore, ['Liegt in der Vergangenheit.'], reference: $reference);
|
||||
}
|
||||
if ($block->occupationKind() === OccupationKind::Block) {
|
||||
return new IntakeDecision(IntakeOutcome::Ignore, ['Als Sperrzeit eingeordnet (z. B. Spiegelung, eigene Nutzung oder Wartung).'], reference: $reference);
|
||||
}
|
||||
if ($block->is_private) {
|
||||
return new IntakeDecision(IntakeOutcome::Ignore, ['Als private Belegung eingeordnet.'], reference: $reference);
|
||||
}
|
||||
|
||||
$origin = $block->origin_channel_id;
|
||||
if ($origin !== null && $origin !== $channel->id) {
|
||||
$case = $this->caseWithSameNights($block, $origin);
|
||||
|
||||
return $case !== null
|
||||
? new IntakeDecision(IntakeOutcome::Link, ['Laut Kalender über ein anderes Portal gebucht; dort gibt es den Vorgang mit genau diesen Nächten.'], $case, reference: $reference)
|
||||
: new IntakeDecision(IntakeOutcome::Clarify, ['Laut Kalender über ein anderes Portal gebucht – der Vorgang entsteht dort, nicht hier.'], reference: $reference);
|
||||
}
|
||||
|
||||
$case = $this->caseWithSameNights($block, $channel->id);
|
||||
if ($case !== null) {
|
||||
return filled($case->portal_reference) && $reference !== null && $case->portal_reference !== $reference
|
||||
? new IntakeDecision(IntakeOutcome::Clarify, ['Gleiche Nächte wie Vorgang '.$case->reference.', aber andere Buchungsnummer ('.$reference.' / '.$case->portal_reference.').'], reference: $reference)
|
||||
: new IntakeDecision(IntakeOutcome::Link, ['Dasselbe Portal mit genau denselben Nächten wie Vorgang '.$case->reference.'.'], $case, reference: $reference);
|
||||
}
|
||||
|
||||
$overlap = Booking::query()->occupying()->where('property_id', $block->property_id)->overlapping($block->starts_on, $block->ends_on)->first();
|
||||
if ($overlap !== null) {
|
||||
return new IntakeDecision(IntakeOutcome::Clarify, ['Überschneidet sich mit Vorgang '.$overlap->reference.' ('.$overlap->arrival->format('d.m.').'–'.$overlap->departure->format('d.m.Y').'), ohne dieselbe Buchung zu sein.'], reference: $reference);
|
||||
}
|
||||
$sameChannelOverlap = $channel->blockedPeriods()->occupying()->whereKeyNot($block->id)->overlapping($block->starts_on, $block->ends_on)->exists();
|
||||
if ($sameChannelOverlap) {
|
||||
return new IntakeDecision(IntakeOutcome::Clarify, ['Weitere Einträge desselben Portals überschneiden sich – keine Zusammenführung nach Terminen.'], reference: $reference);
|
||||
}
|
||||
|
||||
$certainty = $this->certainty($block, $reference);
|
||||
if ($certainty !== null) {
|
||||
return new IntakeDecision(IntakeOutcome::Clarify, [$certainty], reference: $reference);
|
||||
}
|
||||
if ($channel->booking_model === ChannelBookingModel::Inquiry) {
|
||||
return new IntakeDecision(IntakeOutcome::Clarify, ['Über dieses Portal kommen laut Einstellung nur Anfragen – eine feste Buchung bitte bestätigen.'], reference: $reference);
|
||||
}
|
||||
|
||||
$profile = $this->settings->resolve($block->property, $channel, IntakeKind::Booking);
|
||||
$fields = (array) ($block->ical_interpretation['fields'] ?? []);
|
||||
|
||||
return new IntakeDecision(
|
||||
IntakeOutcome::Create,
|
||||
[$block->source === 'email' ? 'Buchungsmail von '.$channel->name.' mit Zeitraum und Buchungsnummer.' : 'Kalendereintrag nach Regel „'.($block->ical_interpretation['rule'] ?? 'persönlich eingeordnet').'“ als Buchung bei '.$channel->name.' erkannt.'],
|
||||
caseType: $profile->caseType,
|
||||
missing: array_values(array_filter([
|
||||
blank($fields['guest_full_name'] ?? null) ? 'Name des Gastes' : 'Name des Gastes (nur als Hinweis aus dem Kalender)',
|
||||
'E-Mail-Adresse des Gastes',
|
||||
'Personenzahl',
|
||||
'Gesamtpreis laut Portal',
|
||||
$reference === null ? 'Buchungsnummer' : null,
|
||||
])),
|
||||
reference: $reference,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Judges an entry and acts as the channel allows: records what was recognised and – only when the channel creates
|
||||
* cases – creates the case, links the entry to its case or marks it for clarification.
|
||||
*/
|
||||
public function process(BlockedPeriod $block, string $source): IntakeDecision
|
||||
{
|
||||
$channel = $block->channel;
|
||||
$mode = $channel?->case_intake ?? CaseIntakeMode::Off;
|
||||
if (! $mode->records()) {
|
||||
return new IntakeDecision(IntakeOutcome::Ignore, ['Automatische Übernahme ist für dieses Portal aus.']);
|
||||
}
|
||||
|
||||
$decision = $this->evaluate($block);
|
||||
$applied = false;
|
||||
|
||||
if ($mode->creates()) {
|
||||
[$decision, $applied] = match ($decision->outcome) {
|
||||
IntakeOutcome::Create => $this->create($block, $decision, $mode, $source),
|
||||
IntakeOutcome::Link => [$decision, $this->link($block, $decision->booking, $decision->reasons[0] ?? '')],
|
||||
IntakeOutcome::Clarify => [$decision, $this->flag($block, $decision->reasons[0] ?? '')],
|
||||
default => [$decision, false],
|
||||
};
|
||||
}
|
||||
|
||||
$this->record($channel, $mode, $source, $decision, $applied, $block, null, $block->starts_on, $block->ends_on);
|
||||
|
||||
return $decision;
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes over an existing portal entry by an explicit run of the landlord or operator (stock adoption), whatever the
|
||||
* channel's switch says: certain bookings become cases (released by hand, never automatic), entries of known cases
|
||||
* are linked, everything else is only reported.
|
||||
*/
|
||||
public function adopt(BlockedPeriod $block): IntakeDecision
|
||||
{
|
||||
$decision = $this->evaluate($block);
|
||||
$applied = false;
|
||||
|
||||
if ($decision->outcome === IntakeOutcome::Create) {
|
||||
[$decision, $applied] = $this->create($block, $decision, CaseIntakeMode::Create, IntakeObservation::SOURCE_ADOPTION);
|
||||
} elseif ($decision->outcome === IntakeOutcome::Link) {
|
||||
$applied = $this->link($block, $decision->booking, $decision->reasons[0] ?? '');
|
||||
}
|
||||
|
||||
$this->record($block->channel, CaseIntakeMode::Create, IntakeObservation::SOURCE_ADOPTION, $decision, $applied, $block, null, $block->starts_on, $block->ends_on);
|
||||
|
||||
return $decision;
|
||||
}
|
||||
|
||||
/**
|
||||
* After a calendar sync: new or changed entries of the channel go through the intake; entries of known cases that
|
||||
* disappeared or show other nights become reports on the case.
|
||||
*/
|
||||
public function afterSync(Channel $channel): void
|
||||
{
|
||||
$mode = $channel->case_intake ?? CaseIntakeMode::Off;
|
||||
if (! $mode->records()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$open = $channel->blockedPeriods()->whereIn('source', ['channel', 'email'])->whereNull('linked_booking_id')
|
||||
->where('is_representation', false)->whereDate('ends_on', '>', CarbonImmutable::today())->orderBy('starts_on')->get();
|
||||
foreach ($open as $block) {
|
||||
$this->process($block, IntakeObservation::SOURCE_CALENDAR);
|
||||
}
|
||||
|
||||
$linked = $channel->blockedPeriods()->withTrashed()->with('linkedBooking')->where('source', 'channel')->whereNotNull('linked_booking_id')
|
||||
->whereHas('linkedBooking', fn ($query) => $query->whereIn('status', BookingStatus::occupying())->whereDate('departure', '>', CarbonImmutable::today()))->get();
|
||||
foreach ($linked as $block) {
|
||||
$case = $block->linkedBooking;
|
||||
if ($block->trashed()) {
|
||||
$this->report($channel, $mode, $case, IntakeOutcome::CancellationSignal, 'Der Eintrag '.$block->starts_on->format('d.m.').'–'.$block->ends_on->format('d.m.Y').' ist aus dem Kalender von '.$channel->name.' verschwunden. Das kann eine Stornierung sein, ist aber kein Nachweis – bitte im Portal prüfen.', 'gone:'.$block->id, IntakeObservation::SOURCE_CALENDAR, $block);
|
||||
} elseif (! $block->starts_on->equalTo($case->arrival) || ! $block->ends_on->equalTo($case->departure)) {
|
||||
$this->report($channel, $mode, $case, IntakeOutcome::ChangeSignal, 'Der Kalender von '.$channel->name.' meldet '.$block->starts_on->format('d.m.').'–'.$block->ends_on->format('d.m.Y').', der Vorgang hat '.$case->arrival->format('d.m.').'–'.$case->departure->format('d.m.Y').'. Bitte prüfen, ob die Buchung im Portal geändert wurde.', 'dates:'.$block->id.':'.$block->starts_on->toDateString().':'.$block->ends_on->toDateString(), IntakeObservation::SOURCE_CALENDAR, $block);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A portal e-mail reporting a cancellation: the case learns about it as a task; nothing is cancelled.
|
||||
*
|
||||
* @return Booking|null the case the report belongs to
|
||||
*/
|
||||
public function cancellationMail(Channel $channel, ParsedPortalMail $parsed, PortalEmail $mail): ?Booking
|
||||
{
|
||||
$case = $parsed->reference !== null ? $this->caseByReference($channel, $parsed->reference) : null;
|
||||
$mode = $channel->case_intake ?? CaseIntakeMode::Off;
|
||||
if ($case === null || ! $case->isBinding()) {
|
||||
$this->record($channel, $mode, IntakeObservation::SOURCE_MAIL, new IntakeDecision(IntakeOutcome::Clarify, [$parsed->reference === null ? 'Stornierungsmail ohne Buchungsnummer – keinem Vorgang sicher zuzuordnen.' : 'Kein gebuchter Vorgang mit der Buchungsnummer '.$parsed->reference.'.'], reference: $parsed->reference), false, null, $mail, $parsed->startsOn, $parsed->endsOn);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->report($channel, $mode, $case, IntakeOutcome::CancellationSignal, $channel->name.' meldet eine Stornierung (E-Mail „'.$mail->subject.'“). Bitte prüfen Sie die Buchung und die nächsten Schritte.', 'mail:'.$mail->message_id, IntakeObservation::SOURCE_MAIL, null, $mail);
|
||||
|
||||
return $case;
|
||||
}
|
||||
|
||||
/**
|
||||
* A request e-mail of a portal: a request case with the dates and the reference (A2), when the channel creates
|
||||
* cases; otherwise only recorded.
|
||||
*/
|
||||
public function inquiryMail(Channel $channel, ParsedPortalMail $parsed, PortalEmail $mail): IntakeDecision
|
||||
{
|
||||
$mode = $channel->case_intake ?? CaseIntakeMode::Off;
|
||||
if (! $mode->records()) {
|
||||
return new IntakeDecision(IntakeOutcome::Ignore, ['Automatische Übernahme ist für dieses Portal aus.']);
|
||||
}
|
||||
|
||||
$profile = $this->settings->resolve($channel->property, $channel, IntakeKind::Inquiry);
|
||||
$decision = match (true) {
|
||||
! $parsed->hasPeriod() => new IntakeDecision(IntakeOutcome::Clarify, ['Anfrage erkannt, aber An- und Abreise nicht sicher lesbar.'], reference: $parsed->reference),
|
||||
$parsed->reference !== null && ($case = $this->caseByReference($channel, $parsed->reference)) !== null => new IntakeDecision(IntakeOutcome::Link, ['Gleiche Anfragenummer '.$parsed->reference.' wie der Vorgang.'], $case, reference: $parsed->reference),
|
||||
$parsed->endsOn->lessThanOrEqualTo(CarbonImmutable::today()) => new IntakeDecision(IntakeOutcome::Ignore, ['Liegt in der Vergangenheit.'], reference: $parsed->reference),
|
||||
default => new IntakeDecision(IntakeOutcome::Inquiry, ['Anfrage-Mail von '.$channel->name.' mit Zeitraum.'], caseType: $profile->caseType, missing: ['Name und E-Mail-Adresse des Gastes', 'Personenzahl'], reference: $parsed->reference),
|
||||
};
|
||||
|
||||
$applied = false;
|
||||
if ($mode->creates() && $decision->outcome === IntakeOutcome::Inquiry) {
|
||||
try {
|
||||
$case = $this->inquiry->handle($channel, $parsed->startsOn, $parsed->endsOn, $parsed->reference, 'Automatisch aus der Anfrage-Mail von '.$channel->name.' übernommen („'.$mail->subject.'“).', $mode === CaseIntakeMode::Create ? ProcessingMode::Manual : null);
|
||||
CaseLog::record($case, 'intake', 'Automatisch aus der Anfrage-Mail von '.$channel->name.' angelegt', actor: CaseLog::SYSTEM, data: ['source' => IntakeObservation::SOURCE_MAIL, 'message_id' => $mail->message_id]);
|
||||
$decision = $decision->withBooking($case);
|
||||
$applied = true;
|
||||
} catch (ReservationException|QuoteException $exception) {
|
||||
$decision = $decision->as(IntakeOutcome::Clarify, ['Anfrage nicht automatisch übernommen: '.$exception->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
$this->record($channel, $mode, IntakeObservation::SOURCE_MAIL, $decision, $applied, null, $mail, $parsed->startsOn, $parsed->endsOn);
|
||||
|
||||
return $decision;
|
||||
}
|
||||
|
||||
/**
|
||||
* The portal's booking reference of an entry: extracted by the calendar rules, or the one of a booking e-mail.
|
||||
*/
|
||||
public static function reference(BlockedPeriod $block): ?string
|
||||
{
|
||||
$fromRules = $block->ical_interpretation['fields']['booking_reference'] ?? null;
|
||||
if (filled($fromRules)) {
|
||||
return trim((string) $fromRules);
|
||||
}
|
||||
|
||||
if ($block->source === 'email' && str_starts_with((string) $block->external_uid, 'email:')) {
|
||||
$reference = substr((string) $block->external_uid, 6);
|
||||
|
||||
// Mails without a reference got a random identifier, which is no booking reference.
|
||||
return preg_match('/^[0-9a-f]{32}$/', $reference) === 1 ? null : $reference;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The case of a portal booking with this reference: on the case itself or on an entry that belongs to a case.
|
||||
*/
|
||||
public function caseByReference(Channel $channel, string $reference): ?Booking
|
||||
{
|
||||
$case = Booking::query()->where('portal_reference', $reference)
|
||||
->where(fn ($query) => $query->where('origin_channel_id', $channel->id)->orWhere('import_channel_id', $channel->id))
|
||||
->orderBy('id')->first();
|
||||
if ($case !== null) {
|
||||
return $case;
|
||||
}
|
||||
|
||||
$linked = $channel->blockedPeriods()->withTrashed()->whereNotNull('linked_booking_id')
|
||||
->whereIn('external_uid', [$reference, 'email:'.$reference])->value('linked_booking_id');
|
||||
|
||||
return $linked !== null ? Booking::query()->find($linked) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The one occupying case of this portal with exactly these nights (more than one: none – that is for a person).
|
||||
*/
|
||||
private function caseWithSameNights(BlockedPeriod $block, int $channelId): ?Booking
|
||||
{
|
||||
/** @var Collection<int, Booking> $cases */
|
||||
$cases = Booking::query()->occupying()->where('property_id', $block->property_id)
|
||||
->whereDate('arrival', $block->starts_on)->whereDate('departure', $block->ends_on)
|
||||
->where(fn ($query) => $query->where('origin_channel_id', $channelId)->orWhere('import_channel_id', $channelId))
|
||||
->get();
|
||||
|
||||
return $cases->count() === 1 ? $cases->first() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Null when the entry is certainly a booking of its portal, otherwise why not.
|
||||
*/
|
||||
private function certainty(BlockedPeriod $block, ?string $reference): ?string
|
||||
{
|
||||
if ($block->needs_review && ! in_array($block->review_note, [ReconcileChannelRepresentations::OVERLAP_NOTE], true)) {
|
||||
return 'Prüfhinweis am Eintrag: '.($block->review_note ?? 'bitte prüfen').'.';
|
||||
}
|
||||
|
||||
if ($block->source === 'email') {
|
||||
return $reference === null ? 'Buchungsmail ohne Buchungsnummer – ohne Nummer lässt sich ein späterer Kalendereintrag nicht sicher zuordnen.' : null;
|
||||
}
|
||||
|
||||
// Classified by the landlord as a reservation booked at this portal.
|
||||
if ($block->occupation_kind === OccupationKind::Reservation && $block->reviewed_at !== null && $block->origin_channel_id === $block->channel_id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$interpretation = (array) ($block->ical_interpretation ?? []);
|
||||
if (! ($interpretation['matched'] ?? false)) {
|
||||
return 'Kein Kalendermerkmal erkannt – eine reine Belegt-Meldung ist kein Nachweis einer Buchung.';
|
||||
}
|
||||
if (($interpretation['event_type'] ?? null) !== 'portal_reservation') {
|
||||
return 'Die Regel „'.($interpretation['rule'] ?? '').'“ ordnet den Eintrag nicht als Buchung ein.';
|
||||
}
|
||||
if (($interpretation['representation'] ?? null) !== 'leading_candidate' || $block->origin_channel_id !== $block->channel_id) {
|
||||
return 'Die Regel erkennt eine Reservierung, aber nicht sicher als Buchung bei diesem Portal.';
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{IntakeDecision, bool}
|
||||
*/
|
||||
private function create(BlockedPeriod $block, IntakeDecision $decision, CaseIntakeMode $mode, string $source): array
|
||||
{
|
||||
$channel = $block->channel;
|
||||
$fields = (array) ($block->ical_interpretation['fields'] ?? []);
|
||||
$name = trim((string) ($fields['guest_full_name'] ?? $fields['guest_first_name'] ?? ''));
|
||||
$origin = match ($source) {
|
||||
IntakeObservation::SOURCE_MAIL => 'der Buchungsmail',
|
||||
IntakeObservation::SOURCE_ADOPTION => 'dem Bestand der Portalbelegungen',
|
||||
default => 'dem Kalender',
|
||||
};
|
||||
|
||||
try {
|
||||
$case = $this->takeOver->handle($block->property, $channel, CarbonImmutable::parse($block->starts_on), CarbonImmutable::parse($block->ends_on), [
|
||||
'portal_reference' => $decision->reference,
|
||||
'notes' => 'Automatisch aus '.$origin.' von '.$channel->name.' übernommen.'.($name !== '' ? ' Name laut Portal: '.$name.'.' : ''),
|
||||
'processing_mode' => $mode === CaseIntakeMode::Create ? ProcessingMode::Manual : null,
|
||||
], $block);
|
||||
} catch (ReservationException $exception) {
|
||||
$this->flag($block, 'Nicht automatisch übernommen: '.$exception->getMessage());
|
||||
|
||||
return [$decision->as(IntakeOutcome::Clarify, ['Nicht automatisch übernommen: '.$exception->getMessage()]), false];
|
||||
}
|
||||
|
||||
CaseLog::record($case, 'intake', 'Automatisch aus '.$origin.' von '.$channel->name.' angelegt', actor: CaseLog::SYSTEM, data: ['source' => $source, 'blocked_period_id' => $block->id, 'reference' => $decision->reference]);
|
||||
|
||||
return [$decision->withBooking($case), true];
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the entry a mirror of its case (the case leads availability and export).
|
||||
*/
|
||||
private function link(BlockedPeriod $block, ?Booking $case, string $reason): bool
|
||||
{
|
||||
if ($case === null || $block->linked_booking_id === $case->id || $block->is_representation) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$block->forceFill([
|
||||
'is_representation' => true, 'representation_automatic' => false, 'canonical_block_id' => null,
|
||||
'linked_booking_id' => $case->id, 'export_approved' => false, 'needs_review' => false, 'reviewed_at' => now(),
|
||||
'occupation_kind' => OccupationKind::Reservation, 'review_note' => self::LINK_NOTE,
|
||||
])->save();
|
||||
app(ReconcileChannelRepresentations::class)->handle($block->property);
|
||||
CaseLog::record($case, 'intake', 'Weitere Quelle zugeordnet: '.($block->source === 'email' ? 'E-Mail' : 'Kalender').' von '.$block->channel?->name.' ('.$block->starts_on->format('d.m.').'–'.$block->ends_on->format('d.m.Y').')', $reason, actor: CaseLog::SYSTEM, data: ['blocked_period_id' => $block->id]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts an uncertain entry in front of the landlord ("Zu erledigen") with the reason.
|
||||
*/
|
||||
private function flag(BlockedPeriod $block, string $reason): bool
|
||||
{
|
||||
if ($block->needs_review || $block->reviewed_at !== null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$block->forceFill(['needs_review' => true, 'review_note' => mb_substr($reason, 0, 250)])->saveQuietly();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* A report of the portal about a known case: a task and an entry in the history – once per report.
|
||||
*/
|
||||
private function report(Channel $channel, CaseIntakeMode $mode, Booking $case, IntakeOutcome $outcome, string $message, string $key, string $source, ?BlockedPeriod $block = null, ?PortalEmail $mail = null): void
|
||||
{
|
||||
$fingerprint = hash('sha256', $channel->id.'|signal|'.$key);
|
||||
$known = $case->events()->where('type', 'portal_signal')->get()->contains(fn ($event): bool => ($event->data['fingerprint'] ?? null) === $fingerprint);
|
||||
$applied = false;
|
||||
|
||||
if ($mode->creates() && ! $known) {
|
||||
$kind = $outcome === IntakeOutcome::CancellationSignal ? BookingTaskKind::PortalCancellationReported : BookingTaskKind::PortalChangeReported;
|
||||
$task = BookingTask::query()->firstOrNew(['booking_id' => $case->id, 'kind' => $kind]);
|
||||
$task->forceFill(['tenant_id' => $case->tenant_id, 'status' => BookingTaskStatus::Open, 'due_on' => today(), 'note' => mb_substr($message, 0, 1000), 'completed_by' => null, 'completed_at' => null])->save();
|
||||
CaseLog::record($case, 'portal_signal', $message, actor: $channel->name, data: ['fingerprint' => $fingerprint, 'source' => $source]);
|
||||
$applied = true;
|
||||
}
|
||||
|
||||
$this->record($channel, $mode, $source, new IntakeDecision($outcome, [$message], $case, $case->case_type), $applied, $block, $mail, $block?->starts_on ?? $case->arrival, $block?->ends_on ?? $case->departure, $key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Records the decision once per event and result (repeated syncs and mails add nothing).
|
||||
*/
|
||||
private function record(?Channel $channel, CaseIntakeMode $mode, string $source, IntakeDecision $decision, bool $applied, ?BlockedPeriod $block, ?PortalEmail $mail, mixed $startsOn, mixed $endsOn, ?string $key = null): void
|
||||
{
|
||||
if ($channel === null || ! $mode->records()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$fingerprint = hash('sha256', implode('|', [
|
||||
$channel->id, $mode->value, $decision->outcome->value, $key ?? '',
|
||||
$block?->id ?? '', $mail?->message_id ?? '', $decision->booking?->id ?? '',
|
||||
$startsOn instanceof \DateTimeInterface ? $startsOn->format('Y-m-d') : (string) $startsOn,
|
||||
$endsOn instanceof \DateTimeInterface ? $endsOn->format('Y-m-d') : (string) $endsOn,
|
||||
]));
|
||||
|
||||
try {
|
||||
$observation = IntakeObservation::query()->firstOrNew(['fingerprint' => $fingerprint]);
|
||||
if ($observation->exists) {
|
||||
return;
|
||||
}
|
||||
$observation->fill([
|
||||
'channel_id' => $channel->id, 'blocked_period_id' => $block?->id, 'portal_email_id' => $mail?->id,
|
||||
'booking_id' => $decision->booking?->id, 'source' => $source, 'mode' => $mode, 'outcome' => $decision->outcome,
|
||||
'applied' => $applied, 'case_type' => $decision->caseType?->value, 'reference' => $decision->reference,
|
||||
'starts_on' => $startsOn, 'ends_on' => $endsOn, 'reasons' => $decision->reasons, 'missing' => $decision->missing,
|
||||
'occurred_at' => now(),
|
||||
]);
|
||||
$observation->tenant_id = $channel->tenant_id;
|
||||
$observation->save();
|
||||
} catch (Throwable $exception) {
|
||||
// The record must never stop the intake itself.
|
||||
report($exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Channels\Intake\PortalIntake;
|
||||
use App\Enums\ChannelTaskStatus;
|
||||
use App\Enums\IntakeOutcome;
|
||||
use App\Models\BlockedPeriod;
|
||||
use App\Models\Booking;
|
||||
use App\Models\Channel;
|
||||
use App\Models\ChannelTask;
|
||||
use App\Models\Tenant;
|
||||
use App\Tenancy\TenantRunner;
|
||||
use Illuminate\Console\Attributes\Description;
|
||||
use Illuminate\Console\Attributes\Signature;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
#[Signature('channels:adopt-occupations
|
||||
{--channel=* : Nur diese Kanal-IDs}
|
||||
{--apply : Wirklich übernehmen (ohne: nur Vorschau)}
|
||||
{--revert= : Eine frühere Übernahme anhand ihres Berichts zurücknehmen}')]
|
||||
#[Description('Bestehende Portalbelegungen ohne Vorgang prüfen und – nur mit --apply – als Vorgang übernehmen bzw. dem vorhandenen Vorgang zuordnen (Bericht, wiederholbar, rücknehmbar)')]
|
||||
class AdoptPortalOccupations extends Command
|
||||
{
|
||||
private const DIRECTORY = 'intake-adoptions';
|
||||
|
||||
/** Attributes of an entry that an adoption changes and a revert restores. */
|
||||
private const RESTORED = ['is_representation', 'representation_automatic', 'canonical_block_id', 'linked_booking_id', 'export_approved', 'needs_review', 'reviewed_at', 'occupation_kind', 'guest_id', 'review_note'];
|
||||
|
||||
public function handle(TenantRunner $runner, PortalIntake $intake): int
|
||||
{
|
||||
if (filled($this->option('revert'))) {
|
||||
return $this->revert((string) $this->option('revert'));
|
||||
}
|
||||
|
||||
$apply = (bool) $this->option('apply');
|
||||
$report = ['run' => now()->format('Ymd-His'), 'apply' => $apply, 'entries' => [], 'channel_task_ids' => []];
|
||||
$firstTask = (int) ChannelTask::query()->withoutGlobalScopes()->max('id');
|
||||
|
||||
$runner->each(function (Tenant $tenant) use ($intake, $apply, &$report): void {
|
||||
$channels = Channel::query()->when($this->option('channel'), fn ($query, $ids) => $query->whereKey($ids))->orderBy('id')->get();
|
||||
foreach ($channels as $channel) {
|
||||
$entries = $channel->blockedPeriods()->whereIn('source', ['channel', 'email'])->whereNull('linked_booking_id')
|
||||
->where('is_representation', false)->whereDate('ends_on', '>', today())->orderBy('starts_on')->get();
|
||||
foreach ($entries as $entry) {
|
||||
$before = collect(self::RESTORED)->mapWithKeys(fn (string $field): array => [$field => $entry->getRawOriginal($field)])->all();
|
||||
$decision = $apply ? $intake->adopt($entry) : $intake->evaluate($entry);
|
||||
$created = $apply && $decision->outcome === IntakeOutcome::Create && $decision->booking !== null;
|
||||
$report['entries'][] = [
|
||||
'tenant' => $tenant->id, 'channel' => $channel->name, 'blocked_period_id' => $entry->id,
|
||||
'period' => $entry->starts_on->format('d.m.Y').'–'.$entry->ends_on->format('d.m.Y'),
|
||||
'outcome' => $decision->outcome->value, 'case_type' => $decision->caseType?->value, 'reference' => $decision->reference,
|
||||
'booking_id' => $decision->booking?->id, 'created' => $created, 'reasons' => $decision->reasons, 'before' => $before,
|
||||
];
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if ($apply) {
|
||||
$report['channel_task_ids'] = ChannelTask::query()->withoutGlobalScopes()->where('id', '>', $firstTask)->pluck('id')->all();
|
||||
}
|
||||
|
||||
$this->table(['Kanal', 'Zeitraum', 'Ergebnis', 'Art', 'Nr.', 'Vorgang', 'Begründung'], array_map(fn (array $entry): array => [
|
||||
$entry['channel'], $entry['period'], IntakeOutcome::from($entry['outcome'])->getLabel(), strtoupper((string) $entry['case_type']), $entry['reference'] ?? '–',
|
||||
$entry['booking_id'] ? '#'.$entry['booking_id'].($entry['created'] ? ' (neu)' : '') : '–', implode(' ', $entry['reasons']),
|
||||
], $report['entries']));
|
||||
|
||||
$path = self::DIRECTORY.'/'.$report['run'].($apply ? '' : '-vorschau').'.json';
|
||||
for ($number = 2; Storage::disk('local')->exists($path); $number++) {
|
||||
$path = self::DIRECTORY.'/'.$report['run'].($apply ? '' : '-vorschau').'-'.$number.'.json';
|
||||
}
|
||||
Storage::disk('local')->put($path, json_encode($report, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
|
||||
$counts = collect($report['entries'])->countBy('outcome');
|
||||
$this->info(($apply ? 'Übernommen' : 'Vorschau – nichts geändert').': '.$counts->map(fn (int $count, string $outcome): string => IntakeOutcome::from($outcome)->getLabel().' '.$count)->implode(', '));
|
||||
$this->line('Bericht: storage/app/private/'.$path.($apply ? ' (Rücknahme: --revert='.$path.')' : ''));
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes an adoption back: cases created by it are removed again as long as nothing has happened with them (no
|
||||
* document, no payment), and every entry gets its former state. Cases with activity are reported, not touched.
|
||||
*/
|
||||
private function revert(string $path): int
|
||||
{
|
||||
if (! Storage::disk('local')->exists($path)) {
|
||||
$this->error('Bericht nicht gefunden: '.$path);
|
||||
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
$report = json_decode((string) Storage::disk('local')->get($path), true);
|
||||
if (! ($report['apply'] ?? false)) {
|
||||
$this->info('Das war eine Vorschau – es gibt nichts zurückzunehmen.');
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
$kept = [];
|
||||
foreach ((array) $report['entries'] as $entry) {
|
||||
$block = BlockedPeriod::query()->withoutGlobalScopes()->withTrashed()->find($entry['blocked_period_id']);
|
||||
$case = ($entry['created'] ?? false) ? Booking::query()->withoutGlobalScopes()->find($entry['booking_id']) : null;
|
||||
if ($case !== null && ($case->contract_path !== null || $case->confirmation_sent_at !== null || $case->payments()->withoutGlobalScopes()->exists())) {
|
||||
$kept[] = $case->reference;
|
||||
|
||||
continue;
|
||||
}
|
||||
// The entry first gets its former state (it may point to the case), then the case created by the run goes.
|
||||
if ($block !== null && in_array($entry['outcome'], [IntakeOutcome::Create->value, IntakeOutcome::Link->value], true)) {
|
||||
$block->forceFill((array) $entry['before'])->saveQuietly();
|
||||
}
|
||||
$case?->delete();
|
||||
}
|
||||
|
||||
ChannelTask::query()->withoutGlobalScopes()->whereKey((array) ($report['channel_task_ids'] ?? []))->where('status', ChannelTaskStatus::Open)
|
||||
->update(['status' => ChannelTaskStatus::Dismissed, 'automation_error' => 'Bestandsübernahme zurückgenommen.']);
|
||||
|
||||
$this->info('Zurückgenommen.'.($kept === [] ? '' : ' Nicht entfernt, weil schon bearbeitet: '.implode(', ', $kept)));
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Enums\IntakeOutcome;
|
||||
use App\Models\IntakeObservation;
|
||||
use App\Models\Tenant;
|
||||
use App\Tenancy\TenantRunner;
|
||||
use Illuminate\Console\Attributes\Description;
|
||||
use Illuminate\Console\Attributes\Signature;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
#[Signature('channels:intake-report {--days=14 : Zeitraum in Tagen}')]
|
||||
#[Description('Bericht des Eingangsprotokolls: was über die Portale hereinkam und welche Vorgänge entstanden sind oder entstanden wären')]
|
||||
class IntakeReport extends Command
|
||||
{
|
||||
public function handle(TenantRunner $runner): int
|
||||
{
|
||||
$runner->each(function (Tenant $tenant): void {
|
||||
$observations = IntakeObservation::query()->with(['channel', 'booking'])
|
||||
->where('occurred_at', '>=', now()->subDays((int) $this->option('days')))->orderBy('occurred_at')->get();
|
||||
|
||||
$this->line("<options=bold>{$tenant->name}</>: ".$observations->count().' Einträge');
|
||||
$this->table(['Wann', 'Portal', 'Quelle', 'Zeitraum', 'Ergebnis', 'Ausgeführt', 'Vorgang', 'Begründung'], $observations->map(fn (IntakeObservation $observation): array => [
|
||||
$observation->occurred_at->format('d.m. H:i'),
|
||||
$observation->channel?->name,
|
||||
$observation->sourceLabel(),
|
||||
$observation->starts_on ? $observation->starts_on->format('d.m.').'–'.$observation->ends_on?->format('d.m.Y') : '–',
|
||||
$observation->outcome->getLabel(),
|
||||
$observation->applied ? 'ja' : 'nur protokolliert',
|
||||
$observation->booking?->reference ?? '–',
|
||||
implode(' ', (array) $observation->reasons),
|
||||
])->all());
|
||||
|
||||
$wouldCreate = $observations->filter(fn (IntakeObservation $observation): bool => ! $observation->applied && in_array($observation->outcome, [IntakeOutcome::Create, IntakeOutcome::Inquiry], true))->count();
|
||||
$this->info("Wären entstanden (Beobachten): {$wouldCreate}");
|
||||
});
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,8 @@ enum BookingTaskKind: string implements HasLabel
|
||||
case CancellationRequest = 'cancellation_request';
|
||||
case CancellationFee = 'cancellation_fee';
|
||||
case PortalCancellation = 'portal_cancellation';
|
||||
case PortalCancellationReported = 'portal_cancel_reported';
|
||||
case PortalChangeReported = 'portal_change_reported';
|
||||
|
||||
public function getLabel(): string
|
||||
{
|
||||
@@ -27,12 +29,14 @@ public function getLabel(): string
|
||||
self::CancellationRequest => 'Stornierungswunsch des Gastes',
|
||||
self::CancellationFee => 'Stornokosten prüfen und abrechnen',
|
||||
self::PortalCancellation => 'Stornierung im Portal veranlassen bzw. prüfen',
|
||||
self::PortalCancellationReported => 'Das Portal meldet eine Stornierung – bitte prüfen',
|
||||
self::PortalChangeReported => 'Das Portal meldet eine Änderung – bitte prüfen',
|
||||
};
|
||||
}
|
||||
|
||||
public function isPayment(): bool
|
||||
{
|
||||
return ! in_array($this, [self::CancellationRequest, self::CancellationFee, self::PortalCancellation], true);
|
||||
return ! in_array($this, [self::CancellationRequest, self::CancellationFee, self::PortalCancellation, self::PortalCancellationReported, self::PortalChangeReported], true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,7 +50,7 @@ public function reminder(): ?array
|
||||
self::DepositReminder => [PaymentReminder::DEPOSIT_OVERDUE, 'deposit_reminded_at'],
|
||||
self::BalanceRequest => [PaymentReminder::BALANCE_REQUEST, 'balance_requested_at'],
|
||||
self::BalanceReminder => [PaymentReminder::BALANCE_OVERDUE, 'balance_reminded_at'],
|
||||
self::CancellationRequest, self::CancellationFee, self::PortalCancellation => null,
|
||||
self::CancellationRequest, self::CancellationFee, self::PortalCancellation, self::PortalCancellationReported, self::PortalChangeReported => null,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use Filament\Support\Contracts\HasDescription;
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
|
||||
/**
|
||||
* Whether bookings and requests recognised on a channel become cases by themselves (UMSETZUNGSPLAN_v0.10 §5.5). Every
|
||||
* channel starts switched off; observing only records what would happen. Creating cases never sends anything that the
|
||||
* landlord has not released (documents need their release, package 3); only the last mode lets the new cases follow
|
||||
* the automatic handling of the settings.
|
||||
*/
|
||||
enum CaseIntakeMode: string implements HasDescription, HasLabel
|
||||
{
|
||||
case Off = 'off';
|
||||
case Observe = 'observe';
|
||||
case Create = 'create';
|
||||
case Continue = 'continue';
|
||||
|
||||
public function getLabel(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Off => 'Aus – Sie übernehmen Buchungen selbst',
|
||||
self::Observe => 'Beobachten – nur protokollieren, was entstehen würde',
|
||||
self::Create => 'Vorgänge anlegen – die nächsten Schritte geben Sie frei',
|
||||
self::Continue => 'Vorgänge anlegen und nach Ihren Einstellungen weiterbearbeiten',
|
||||
};
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Off => 'Erkannte Buchungen erscheinen als Klärungsfall; nichts entsteht automatisch.',
|
||||
self::Observe => 'Es entsteht nichts. Das Eingangsprotokoll zeigt, welche Vorgänge entstanden wären und warum.',
|
||||
self::Create => 'Sicher erkannte Buchungen werden zum Vorgang; Sie geben jeden weiteren Schritt frei.',
|
||||
self::Continue => 'Wie „anlegen“; danach laufen die Vorgänge automatisch oder mit Freigabe – wie unter „So arbeite ich“ eingestellt.',
|
||||
};
|
||||
}
|
||||
|
||||
public function records(): bool
|
||||
{
|
||||
return $this !== self::Off;
|
||||
}
|
||||
|
||||
public function creates(): bool
|
||||
{
|
||||
return in_array($this, [self::Create, self::Continue], true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use Filament\Support\Contracts\HasColor;
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
|
||||
/**
|
||||
* How far a block (or release) on a portal is proven (E-018). The three steps are different statements: entering the
|
||||
* block does not show that the portal took it over, and a calendar feed we provide proves nothing about the portal.
|
||||
*/
|
||||
enum ChannelTaskProof: string implements HasColor, HasLabel
|
||||
{
|
||||
/** The change was made or started (by hand or by an automation). */
|
||||
case Initiated = 'initiated';
|
||||
|
||||
/** The block was seen in the portal's own calendar. */
|
||||
case Observed = 'observed';
|
||||
|
||||
/** The portal confirmed it (e.g. its own confirmation or a test booking was refused). */
|
||||
case Confirmed = 'confirmed';
|
||||
|
||||
public function getLabel(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Initiated => 'veranlasst',
|
||||
self::Observed => 'im Portal gesehen',
|
||||
self::Confirmed => 'Wirksamkeit bestätigt',
|
||||
};
|
||||
}
|
||||
|
||||
public function getColor(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Initiated => 'warning',
|
||||
self::Observed => 'info',
|
||||
self::Confirmed => 'success',
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* The choice the landlord reads when completing a task.
|
||||
*/
|
||||
public function question(bool $block = true): string
|
||||
{
|
||||
$what = $block ? 'gesperrt' : 'freigegeben';
|
||||
|
||||
return match ($this) {
|
||||
self::Initiated => "Ich habe den Zeitraum im Portal {$what}.",
|
||||
self::Observed => "… und im Kalender des Portals gesehen, dass er {$what} ist.",
|
||||
self::Confirmed => 'Das Portal hat es bestätigt (z. B. Bestätigung oder Testanfrage abgelehnt).',
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use Filament\Support\Contracts\HasColor;
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
|
||||
/**
|
||||
* What the intake made of one incoming event (portal calendar entry or portal e-mail).
|
||||
*/
|
||||
enum IntakeOutcome: string implements HasColor, HasLabel
|
||||
{
|
||||
/** A booking binding on the portal, recognised with confidence: a new case (A3–A5). */
|
||||
case Create = 'create';
|
||||
|
||||
/** A non-binding request through the portal: a new request case (A2). */
|
||||
case Inquiry = 'inquiry';
|
||||
|
||||
/** The same booking as an existing case (reference, same portal and dates, or its calendar mirror). */
|
||||
case Link = 'link';
|
||||
|
||||
/** Not certain enough: the landlord clarifies. */
|
||||
case Clarify = 'clarify';
|
||||
|
||||
/** No booking of this portal (block, mirror of another portal, own use, already clarified). */
|
||||
case Ignore = 'ignore';
|
||||
|
||||
/** The portal reports a cancellation of a known case. */
|
||||
case CancellationSignal = 'cancellation';
|
||||
|
||||
/** The portal reports other dates for a known case, or its calendar entry disappeared. */
|
||||
case ChangeSignal = 'change';
|
||||
|
||||
public function getLabel(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Create => 'Neuer Vorgang (Buchung)',
|
||||
self::Inquiry => 'Neuer Vorgang (Anfrage)',
|
||||
self::Link => 'Gehört zu vorhandenem Vorgang',
|
||||
self::Clarify => 'Klärung nötig',
|
||||
self::Ignore => 'Keine Buchung',
|
||||
self::CancellationSignal => 'Portal meldet Stornierung',
|
||||
self::ChangeSignal => 'Portal meldet Änderung',
|
||||
};
|
||||
}
|
||||
|
||||
public function getColor(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Create, self::Inquiry => 'success',
|
||||
self::Link, self::Ignore => 'gray',
|
||||
self::Clarify => 'warning',
|
||||
self::CancellationSignal, self::ChangeSignal => 'danger',
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,9 @@
|
||||
use App\Enums\ProcessingMode;
|
||||
use App\Enums\ProcessSetting;
|
||||
use App\Enums\Responsibility;
|
||||
use App\Models\BlockedPeriod;
|
||||
use App\Models\Booking;
|
||||
use App\Models\IntakeObservation;
|
||||
use App\Models\User;
|
||||
use App\Process\CaseActivities;
|
||||
use App\Process\CaseAutomation;
|
||||
@@ -123,6 +125,7 @@ public static function configure(Schema $schema): Schema
|
||||
TextEntry::make('status')->label('Status')->badge(),
|
||||
TextEntry::make('case_type')->label('Vorgangsart')->state(fn (Booking $record): string => strtoupper($record->caseType()->value).' – '.$record->caseType()->getLabel()),
|
||||
TextEntry::make('intake')->label('Eingangsart')->state(fn (Booking $record): string => $record->intake?->getLabel() ?? '–'),
|
||||
TextEntry::make('sources')->label('Quellen und Kalenderdarstellungen')->state(fn (Booking $record): HtmlString => self::sources($record))->html()->columnSpanFull(),
|
||||
TextEntry::make('profile')->label('Abwicklungsprofil (eingefroren)')->state(fn (Booking $record): HtmlString => self::profile($record))->html()->columnSpanFull(),
|
||||
TextEntry::make('hold_expires_at')->label('Reserviert bis')->dateTime('d.m.Y, H:i')->placeholder('–'),
|
||||
TextEntry::make('offer_hash')->label('Angebot (Prüfsumme)')->state(fn (Booking $record): ?string => $record->offer_version > 0 ? 'Version '.$record->offer_version.' · '.substr((string) $record->offer_hash, 0, 16) : null)->placeholder('–'),
|
||||
@@ -161,6 +164,22 @@ private static function nextStep(Booking $booking): HtmlString
|
||||
.'<div style="margin-top:.5rem;color:#6b7280;font-size:.9rem">'.$mode.'</div>');
|
||||
}
|
||||
|
||||
/**
|
||||
* Every portal entry (calendar or e-mail) that belongs to the case, and what the intake recorded about it.
|
||||
*/
|
||||
private static function sources(Booking $booking): HtmlString
|
||||
{
|
||||
$lines = BlockedPeriod::query()->withTrashed()->with('channel')->where('linked_booking_id', $booking->id)->orderBy('id')->get()
|
||||
->map(fn (BlockedPeriod $entry): string => e(($entry->source === 'email' ? 'E-Mail' : 'Kalender').' von '.($entry->channel?->name ?? '–').': '.$entry->starts_on->format('d.m.').'–'.$entry->ends_on->format('d.m.Y')
|
||||
.($entry->trashed() ? ' · nicht mehr im Kalender' : '').($entry->starts_on->equalTo($booking->arrival) && $entry->ends_on->equalTo($booking->departure) ? '' : ' · abweichende Termine').' · Kennung '.$entry->external_uid));
|
||||
$observations = IntakeObservation::query()->with('channel')->where('booking_id', $booking->id)->orderBy('occurred_at')->get()
|
||||
->map(fn (IntakeObservation $observation): string => e($observation->occurred_at->format('d.m.Y H:i').' · '.$observation->sourceLabel().' '.$observation->channel?->name.' · '.$observation->outcome->getLabel().($observation->applied ? '' : ' (nur protokolliert)')));
|
||||
|
||||
$html = $lines->isEmpty() ? 'Keine Portaleinträge zugeordnet.' : $lines->implode('<br>');
|
||||
|
||||
return new HtmlString($observations->isEmpty() ? $html : $html.'<br><span style="color:#6b7280">Eingang: '.$observations->implode('<br>').'</span>');
|
||||
}
|
||||
|
||||
/**
|
||||
* The documents made for the case, as recorded when they were created (kind, template, date).
|
||||
*/
|
||||
|
||||
@@ -2,9 +2,13 @@
|
||||
|
||||
namespace App\Filament\Resources\ChannelTasks\Tables;
|
||||
|
||||
use App\Enums\ChannelTaskAction;
|
||||
use App\Enums\ChannelTaskProof;
|
||||
use App\Enums\ChannelTaskStatus;
|
||||
use App\Models\ChannelTask;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\Radio;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
@@ -24,6 +28,8 @@ public static function configure(Table $table): Table
|
||||
TextColumn::make('reason')->label('Anlass')->wrap(),
|
||||
TextColumn::make('status')->label('Status')->badge()
|
||||
->description(fn (ChannelTask $record): ?string => $record->completed_by ? "{$record->completed_by}, {$record->completed_at?->format('d.m. H:i')}" : null),
|
||||
TextColumn::make('proof')->label('Nachweis')->state(fn (ChannelTask $record): string => $record->proofLabel())
|
||||
->description(fn (ChannelTask $record): ?string => $record->proof_by ? "{$record->proof_by}, {$record->proof_at?->format('d.m. H:i')}" : null)->wrap(),
|
||||
TextColumn::make('created_at')->label('Seit')->since(),
|
||||
TextColumn::make('automation_error')->label('Automatisierung')->placeholder('–')->limit(40)->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
@@ -45,7 +51,26 @@ public static function configure(Table $table): Table
|
||||
->icon(Heroicon::OutlinedCheck)
|
||||
->color('success')
|
||||
->visible(fn (ChannelTask $record): bool => $record->status === ChannelTaskStatus::Open)
|
||||
->action(fn (ChannelTask $record) => $record->complete(auth()->user()->name)),
|
||||
->modalHeading(fn (ChannelTask $record): string => ($record->action === ChannelTaskAction::Block ? 'Sperre in ' : 'Freigabe in ').$record->channel->name.' erledigt')
|
||||
->modalDescription('Was können Sie sagen? Ein bereitgestellter Kalender beweist nicht, dass das Portal ihn schon übernommen hat.')
|
||||
->fillForm(['proof' => ChannelTaskProof::Initiated->value])
|
||||
->schema(fn (ChannelTask $record): array => [
|
||||
Radio::make('proof')->hiddenLabel()->required()
|
||||
->options(collect(ChannelTaskProof::cases())->mapWithKeys(fn (ChannelTaskProof $proof): array => [$proof->value => $proof->question($record->action === ChannelTaskAction::Block)])->all()),
|
||||
Textarea::make('note')->label('Notiz (optional)')->placeholder('z. B. „im Vermieterkalender rot markiert“')->rows(2),
|
||||
])
|
||||
->action(fn (ChannelTask $record, array $data) => $record->complete(auth()->user()->name, ChannelTaskProof::from($data['proof']), $data['note'] ?? null)),
|
||||
Action::make('prove')
|
||||
->label('Nachweis ergänzen')
|
||||
->icon(Heroicon::OutlinedShieldCheck)
|
||||
->color('gray')
|
||||
->visible(fn (ChannelTask $record): bool => $record->status === ChannelTaskStatus::Done && $record->proof !== ChannelTaskProof::Confirmed)
|
||||
->schema(fn (ChannelTask $record): array => [
|
||||
Radio::make('proof')->hiddenLabel()->required()
|
||||
->options(collect([ChannelTaskProof::Observed, ChannelTaskProof::Confirmed])->mapWithKeys(fn (ChannelTaskProof $proof): array => [$proof->value => $proof->question($record->action === ChannelTaskAction::Block)])->all()),
|
||||
Textarea::make('note')->label('Notiz (optional)')->rows(2),
|
||||
])
|
||||
->action(fn (ChannelTask $record, array $data) => $record->prove(ChannelTaskProof::from($data['proof']), auth()->user()->name, $data['note'] ?? null)),
|
||||
Action::make('dismiss')
|
||||
->label('Verwerfen')
|
||||
->icon(Heroicon::OutlinedXMark)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Resources\Channels\Schemas;
|
||||
|
||||
use App\Channels\ChannelRegistry;
|
||||
use App\Enums\CaseIntakeMode;
|
||||
use App\Enums\ChannelBookingModel;
|
||||
use App\Enums\ChannelEchoBehavior;
|
||||
use App\Enums\ChannelExportMode;
|
||||
@@ -55,6 +56,13 @@ public static function configure(Schema $schema, bool $selectProperty = false):
|
||||
Select::make('status')->label('Kanalstatus')->options(ChannelStatus::class)->default(ChannelStatus::Setup)->required(),
|
||||
Select::make('booking_model')->label('Was kommt über dieses Portal?')->options(ChannelBookingModel::class)->default(ChannelBookingModel::Mixed)->required()
|
||||
->helperText('„Portalbuchung“ und „Gemischt“ gelten als Sofortbuchung: automatische Angebote für diese Wohnung warten, bis das Portal unseren Kalender abgerufen hat. „Vermittlung / Anfrage“: keine Sofortbuchung.'),
|
||||
Select::make('case_intake')
|
||||
->label('Erkannte Buchungen automatisch als Vorgang übernehmen?')
|
||||
->options(CaseIntakeMode::class)
|
||||
->default(CaseIntakeMode::Off)
|
||||
->required()
|
||||
->helperText('Zuerst „Beobachten“: Dann entsteht nichts, aber das Eingangsprotokoll (Expertenansicht) zeigt, welche Vorgänge entstanden wären. Unklare Belegungen und Meldungen zu gebuchten Vorgängen erscheinen unter „Zu erledigen“. Unterlagen gehen nie ohne Ihre Freigabe hinaus.')
|
||||
->columnSpanFull(),
|
||||
...self::processSections(),
|
||||
Select::make('connector')
|
||||
->label('Kalenderanbindung')
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\IntakeObservations;
|
||||
|
||||
use App\Enums\CaseIntakeMode;
|
||||
use App\Enums\IntakeOutcome;
|
||||
use App\Filament\Concerns\FollowsAdminMode;
|
||||
use App\Filament\Resources\Bookings\BookingResource;
|
||||
use App\Filament\Resources\IntakeObservations\Pages\ListIntakeObservations;
|
||||
use App\Models\Channel;
|
||||
use App\Models\IntakeObservation;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Table;
|
||||
use UnitEnum;
|
||||
|
||||
/**
|
||||
* The intake record (expert view): what came in over each portal, what the intake recognised, whether it acted or only
|
||||
* observed, and why. Read only – the work itself happens under "Zu erledigen" and on the case page.
|
||||
*/
|
||||
class IntakeObservationResource extends Resource
|
||||
{
|
||||
use FollowsAdminMode;
|
||||
|
||||
protected static ?string $model = IntakeObservation::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedInboxArrowDown;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'System';
|
||||
|
||||
protected static ?string $navigationLabel = 'Eingangsprotokoll';
|
||||
|
||||
protected static ?string $modelLabel = 'Eingang';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Eingangsprotokoll';
|
||||
|
||||
protected static ?int $navigationSort = 20;
|
||||
|
||||
public static function canCreate(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->description('Was über die Portale hereinkam und was daraus wurde. „Nur protokolliert“ heißt: Das Portal steht auf „Beobachten“ (oder es war nichts zu tun) – es ist nichts entstanden.')
|
||||
->defaultSort('occurred_at', 'desc')
|
||||
->modifyQueryUsing(fn ($query) => $query->with(['channel', 'booking']))
|
||||
->columns([
|
||||
TextColumn::make('occurred_at')->label('Wann')->dateTime('d.m.Y H:i')->sortable(),
|
||||
TextColumn::make('channel.name')->label('Portal')->description(fn (IntakeObservation $record): string => $record->sourceLabel()),
|
||||
TextColumn::make('period')->label('Zeitraum')->state(fn (IntakeObservation $record): ?string => $record->starts_on ? $record->starts_on->format('d.m.').'–'.$record->ends_on?->format('d.m.Y') : null)->placeholder('–'),
|
||||
TextColumn::make('outcome')->label('Ergebnis')->badge()->description(fn (IntakeObservation $record): string => implode(' ', (array) $record->reasons))->wrap(),
|
||||
TextColumn::make('case_type')->label('Art')->formatStateUsing(fn (?string $state): string => strtoupper((string) $state))->placeholder('–'),
|
||||
IconColumn::make('applied')->label('Ausgeführt')->boolean()->tooltip('Ja: Vorgang angelegt, zugeordnet, Aufgabe erstellt oder zur Klärung vorgelegt. Nein: nur protokolliert.'),
|
||||
TextColumn::make('mode')->label('Einstellung')->formatStateUsing(fn (CaseIntakeMode $state): string => match ($state) {
|
||||
CaseIntakeMode::Observe => 'Beobachten',
|
||||
CaseIntakeMode::Create => 'Anlegen',
|
||||
CaseIntakeMode::Continue => 'Anlegen + weiter',
|
||||
CaseIntakeMode::Off => 'Aus',
|
||||
})->toggleable(),
|
||||
TextColumn::make('reference')->label('Buchungsnr.')->placeholder('–')->toggleable(),
|
||||
TextColumn::make('booking.reference')->label('Vorgang')->placeholder('–')
|
||||
->url(fn (IntakeObservation $record): ?string => $record->booking ? BookingResource::getUrl('view', ['record' => $record->booking]) : null),
|
||||
TextColumn::make('missing')->label('Fehlt noch')->state(fn (IntakeObservation $record): string => implode(', ', (array) $record->missing))->placeholder('–')->wrap()->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
SelectFilter::make('channel_id')->label('Portal')->options(fn (): array => Channel::query()->orderBy('name')->pluck('name', 'id')->all()),
|
||||
SelectFilter::make('outcome')->label('Ergebnis')->options(IntakeOutcome::class),
|
||||
SelectFilter::make('applied')->label('Ausgeführt')->options(['1' => 'ja', '0' => 'nur protokolliert']),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return ['index' => ListIntakeObservations::route('/')];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\IntakeObservations\Pages;
|
||||
|
||||
use App\Filament\Resources\IntakeObservations\IntakeObservationResource;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListIntakeObservations extends ListRecords
|
||||
{
|
||||
protected static string $resource = IntakeObservationResource::class;
|
||||
}
|
||||
@@ -3,7 +3,9 @@
|
||||
namespace App\Filament\Resources\PortalOccupations\Pages;
|
||||
|
||||
use App\Filament\Resources\PortalOccupations\PortalOccupationResource;
|
||||
use Filament\Actions\ActionGroup;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
|
||||
class ViewPortalOccupation extends ViewRecord
|
||||
{
|
||||
@@ -16,6 +18,9 @@ public function getTitle(): string
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return PortalOccupationResource::occupationActions();
|
||||
$actions = PortalOccupationResource::occupationActions();
|
||||
[$primary, $more] = [array_slice($actions, 0, 3), array_slice($actions, 3)];
|
||||
|
||||
return [...$primary, ActionGroup::make($more)->label('Weitere Möglichkeiten')->icon(Heroicon::OutlinedEllipsisHorizontal)->button()->color('gray')];
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
use App\Actions\ClassifyPortalOccupation;
|
||||
use App\Actions\OpenPortalFile;
|
||||
use App\Actions\ResolveChannelOccupation;
|
||||
use App\Enums\OccupationKind;
|
||||
use App\Exceptions\ReservationException;
|
||||
use App\Filament\Actions\AssignGuestAction;
|
||||
@@ -15,11 +16,13 @@
|
||||
use App\Filament\Resources\PortalOccupations\Pages\ManagePortalOccupations;
|
||||
use App\Filament\Resources\PortalOccupations\Pages\ViewPortalOccupation;
|
||||
use App\Models\BlockedPeriod;
|
||||
use App\Models\Booking;
|
||||
use App\Models\Channel;
|
||||
use BackedEnum;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\ActionGroup;
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Forms\Components\Radio;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Notifications\Notification;
|
||||
@@ -80,19 +83,85 @@ public static function table(Table $table): Table
|
||||
TextColumn::make('channel.name')->label('Importkanal'),
|
||||
TextColumn::make('property.name')->label('Wohnung')->toggleable(),
|
||||
TextColumn::make('needs_review')->label('Prüffall')->formatStateUsing(fn (bool $state): string => $state ? 'Bitte prüfen' : '–')->description(fn (BlockedPeriod $record): ?string => $record->review_note),
|
||||
])->recordActions([Action::make('fileLink')->label('Als Buchung übernehmen')->icon(Heroicon::OutlinedFolderPlus)->button()->color('primary')->visible(fn (BlockedPeriod $record): bool => static::canOpenFile($record))->url(fn (BlockedPeriod $record): string => static::getUrl('view', ['record' => $record])), static::showFileAction()->button(), ViewAction::make(), ActionGroup::make(static::occupationActions(withFile: false))->label('Weitere Aktionen')]);
|
||||
])->recordActions([Action::make('clarifyLink')->label('Klären')->icon(Heroicon::OutlinedQuestionMarkCircle)->button()->color('warning')->visible(fn (BlockedPeriod $record): bool => static::isUnclear($record))->url(fn (BlockedPeriod $record): string => static::getUrl('view', ['record' => $record])), Action::make('fileLink')->label('Als Buchung übernehmen')->icon(Heroicon::OutlinedFolderPlus)->button()->color('primary')->visible(fn (BlockedPeriod $record): bool => static::canOpenFile($record))->url(fn (BlockedPeriod $record): string => static::getUrl('view', ['record' => $record])), static::showFileAction()->button(), ViewAction::make(), ActionGroup::make(static::occupationActions(withFile: false))->label('Weitere Aktionen')]);
|
||||
}
|
||||
|
||||
public static function occupationActions(bool $withFile = true): array
|
||||
{
|
||||
return [
|
||||
...($withFile ? [static::openFileAction(), static::showFileAction()] : []),
|
||||
...($withFile ? [static::clarifyAction(), static::openFileAction(), static::showFileAction()] : []),
|
||||
AssignGuestAction::make(),
|
||||
static::classificationAction(),
|
||||
...BlockedPeriodResource::portalActions(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the entry still waits for the landlord's answer (it is listed under "Zu erledigen").
|
||||
*/
|
||||
public static function isUnclear(BlockedPeriod $record): bool
|
||||
{
|
||||
return ! $record->trashed() && BlockedPeriod::query()->unclear()->whereKey($record->id)->exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* The one question for an unclear portal entry, in plain words: is it a booking (then it becomes a case), does it
|
||||
* belong to a case that already exists, or is it no booking at all? The detailed tools stay under "Weitere".
|
||||
*/
|
||||
public static function clarifyAction(): Action
|
||||
{
|
||||
return Action::make('clarify')->label('Klären: Was ist das?')->icon(Heroicon::OutlinedQuestionMarkCircle)->color('primary')
|
||||
->visible(fn (BlockedPeriod $record): bool => static::isUnclear($record) && ! $record->is_representation)
|
||||
->authorize(fn (BlockedPeriod $record): bool => auth()->user()?->can('update', $record) ?? false)
|
||||
->modalHeading(fn (BlockedPeriod $record): string => 'Belegung von '.($record->channel?->name ?? 'einem Portal').' am '.$record->starts_on->format('d.m.').'–'.$record->ends_on->format('d.m.Y'))
|
||||
->modalDescription(fn (BlockedPeriod $record): string => 'Für diesen Zeitraum wurde eine Belegung gemeldet. Bitte wählen Sie, was es ist.'.($record->review_note ? ' Hinweis: '.$record->review_note : ''))
|
||||
->modalSubmitActionLabel('Übernehmen')
|
||||
->schema(fn (BlockedPeriod $record): array => [
|
||||
Radio::make('answer')->hiddenLabel()->required()->live()->options(array_filter([
|
||||
'booking' => static::canOpenFile($record) ? 'Eine Buchung über '.($record->channel?->name ?? 'das Portal').' – als Vorgang übernehmen' : null,
|
||||
'case' => static::sameNightCases($record) !== [] ? 'Gehört zu einem Vorgang, der schon da ist' : null,
|
||||
'block' => 'Keine Buchung: Sperre, eigene Nutzung oder Spiegelung eines anderen Portals',
|
||||
])),
|
||||
Select::make('booking_id')->label('Vorgang')->options(fn (): array => static::sameNightCases($record))
|
||||
->visible(fn (Get $get): bool => $get('answer') === 'case')->required(fn (Get $get): bool => $get('answer') === 'case'),
|
||||
])
|
||||
->action(function (BlockedPeriod $record, array $data, OpenPortalFile $open, ResolveChannelOccupation $resolve, ClassifyPortalOccupation $classify) {
|
||||
try {
|
||||
if ($data['answer'] === 'booking') {
|
||||
$booking = $open->handle($record);
|
||||
Notification::make()->title('Als Buchung übernommen')->success()->send();
|
||||
|
||||
return redirect(BookingResource::getUrl('view', ['record' => $booking]));
|
||||
}
|
||||
if ($data['answer'] === 'case') {
|
||||
$resolve->handle($record, 'booking', (int) $data['booking_id']);
|
||||
Notification::make()->title('Dem Vorgang zugeordnet')->success()->send();
|
||||
|
||||
return null;
|
||||
}
|
||||
$classify->handle($record, OccupationKind::Block);
|
||||
$record->refresh()->forceFill(['needs_review' => false, 'reviewed_at' => now(), 'review_note' => 'Persönlich als Sperre eingeordnet.'])->save();
|
||||
Notification::make()->title('Als Sperre eingeordnet')->success()->send();
|
||||
} catch (ReservationException $exception) {
|
||||
Notification::make()->title('Nicht möglich')->body($exception->getMessage())->danger()->send();
|
||||
}
|
||||
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Cases of the same property with exactly these nights (the only ones the entry may belong to).
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public static function sameNightCases(BlockedPeriod $record): array
|
||||
{
|
||||
return Booking::query()->occupying()->with('guest')->where('property_id', $record->property_id)
|
||||
->whereDate('arrival', $record->starts_on)->whereDate('departure', $record->ends_on)->get()
|
||||
->mapWithKeys(fn (Booking $booking): array => [$booking->id => $booking->reference.' · '.$booking->guestName().' · '.$booking->bookingChannelLabel()])->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes a reservation from a portal calendar over as a case (no second, manual "file").
|
||||
*/
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
use App\Channels\ChannelRegistry;
|
||||
use App\Channels\Contracts\ChannelConnector;
|
||||
use App\Enums\CaseIntakeMode;
|
||||
use App\Enums\ChannelBookingModel;
|
||||
use App\Enums\ChannelEchoBehavior;
|
||||
use App\Enums\ChannelExportMode;
|
||||
@@ -26,7 +27,7 @@
|
||||
* A sales channel (portal) of a property. Our system leads: occupations are imported from the
|
||||
* channel and every channel gets its own export feed without its own occupations.
|
||||
*/
|
||||
#[Fillable(['property_id', 'name', 'connector', 'settings', 'is_active', 'requires_manual_blocking', 'manage_url', 'status', 'booking_model', 'import_enabled', 'export_enabled', 'export_mode', 'external_poll_minutes', 'echo_behavior', 'echo_notes', 'operating_notes', 'portal_verified_at', 'payment_tasks_inquiry', 'payment_tasks_reservation', 'contract_template_id', 'contract_template_reservation_id', 'process_overrides'])]
|
||||
#[Fillable(['property_id', 'name', 'connector', 'settings', 'is_active', 'requires_manual_blocking', 'manage_url', 'status', 'booking_model', 'import_enabled', 'export_enabled', 'export_mode', 'external_poll_minutes', 'echo_behavior', 'echo_notes', 'operating_notes', 'portal_verified_at', 'payment_tasks_inquiry', 'payment_tasks_reservation', 'contract_template_id', 'contract_template_reservation_id', 'process_overrides', 'case_intake'])]
|
||||
#[Hidden(['export_token', 'previous_export_token', 'export_snapshot', 'settings', 'ical_analysis'])]
|
||||
class Channel extends Model
|
||||
{
|
||||
@@ -36,7 +37,7 @@ class Channel extends Model
|
||||
protected $attributes = [
|
||||
'status' => 'setup', 'booking_model' => 'mixed', 'import_enabled' => false,
|
||||
'export_enabled' => false, 'export_mode' => 'test',
|
||||
'echo_behavior' => 'unverified',
|
||||
'echo_behavior' => 'unverified', 'case_intake' => 'off',
|
||||
];
|
||||
|
||||
protected static function booted(): void
|
||||
@@ -63,6 +64,7 @@ protected function casts(): array
|
||||
return [
|
||||
'settings' => 'array',
|
||||
'process_overrides' => 'array',
|
||||
'case_intake' => CaseIntakeMode::class,
|
||||
'ical_analysis' => 'encrypted:array',
|
||||
'ical_analyzed_at' => 'immutable_datetime',
|
||||
'ical_rules' => 'array',
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
use App\Availability\AvailabilityChecker;
|
||||
use App\Enums\ChannelTaskAction;
|
||||
use App\Enums\ChannelTaskProof;
|
||||
use App\Enums\ChannelTaskStatus;
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use Database\Factories\ChannelTaskFactory;
|
||||
@@ -18,7 +19,7 @@
|
||||
* A change that has to be made by hand (or by an external automation) on a portal that
|
||||
* cannot be kept in sync fast enough by calendar feeds, e.g. because of instant booking.
|
||||
*/
|
||||
#[Fillable(['channel_id', 'action', 'starts_on', 'ends_on', 'reason', 'status', 'completed_by', 'completed_at', 'reminded_at', 'automation_sent_at', 'automation_error'])]
|
||||
#[Fillable(['channel_id', 'action', 'starts_on', 'ends_on', 'reason', 'status', 'completed_by', 'completed_at', 'reminded_at', 'automation_sent_at', 'automation_error', 'proof', 'proof_note', 'proof_at', 'proof_by'])]
|
||||
class ChannelTask extends Model
|
||||
{
|
||||
/** @use HasFactory<ChannelTaskFactory> */
|
||||
@@ -39,6 +40,8 @@ protected function casts(): array
|
||||
'completed_at' => 'immutable_datetime',
|
||||
'reminded_at' => 'immutable_datetime',
|
||||
'automation_sent_at' => 'immutable_datetime',
|
||||
'proof' => ChannelTaskProof::class,
|
||||
'proof_at' => 'immutable_datetime',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -60,7 +63,10 @@ protected function open(Builder $query): Builder
|
||||
return $query->where('status', ChannelTaskStatus::Open);
|
||||
}
|
||||
|
||||
public function complete(string $completedBy): void
|
||||
/**
|
||||
* Completes the task with the proof the person can give (at least: the change was made or started).
|
||||
*/
|
||||
public function complete(string $completedBy, ChannelTaskProof $proof = ChannelTaskProof::Initiated, ?string $note = null): void
|
||||
{
|
||||
if ($this->status !== ChannelTaskStatus::Open) {
|
||||
return;
|
||||
@@ -74,9 +80,38 @@ public function complete(string $completedBy): void
|
||||
'status' => ChannelTaskStatus::Done,
|
||||
'completed_by' => $completedBy,
|
||||
'completed_at' => now(),
|
||||
'proof' => $proof,
|
||||
'proof_note' => filled($note) ? trim($note) : null,
|
||||
'proof_at' => now(),
|
||||
'proof_by' => $completedBy,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Raises the proof of a completed task (e.g. the block was later seen in the portal); never lowers it.
|
||||
*/
|
||||
public function prove(ChannelTaskProof $proof, string $by, ?string $note = null): void
|
||||
{
|
||||
$order = array_flip(array_map(fn (ChannelTaskProof $case): string => $case->value, ChannelTaskProof::cases()));
|
||||
if ($this->status !== ChannelTaskStatus::Done || ($this->proof !== null && $order[$proof->value] <= $order[$this->proof->value])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->update(['proof' => $proof, 'proof_note' => filled($note) ? trim($note) : $this->proof_note, 'proof_at' => now(), 'proof_by' => $by]);
|
||||
}
|
||||
|
||||
/**
|
||||
* The state of the task in plain words, including how far it is proven.
|
||||
*/
|
||||
public function proofLabel(): string
|
||||
{
|
||||
return match ($this->status) {
|
||||
ChannelTaskStatus::Open => 'noch offen',
|
||||
ChannelTaskStatus::Dismissed => 'verworfen',
|
||||
ChannelTaskStatus::Done => ($this->proof ?? ChannelTaskProof::Initiated)->getLabel().($this->proof_note ? ' ('.$this->proof_note.')' : ''),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Human readable period, e.g. "14.06.2027 – 21.06.2027".
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\CaseIntakeMode;
|
||||
use App\Enums\IntakeOutcome;
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* One entry of the intake record: an incoming portal event, what the intake recognised and whether it acted. The same
|
||||
* event with the same result is recorded once (fingerprint), however often the calendar is read or the mail arrives.
|
||||
*/
|
||||
#[Fillable(['channel_id', 'blocked_period_id', 'portal_email_id', 'booking_id', 'fingerprint', 'source', 'mode', 'outcome', 'applied', 'case_type', 'starts_on', 'ends_on', 'reference', 'reasons', 'missing', 'occurred_at'])]
|
||||
class IntakeObservation extends Model
|
||||
{
|
||||
use BelongsToTenant;
|
||||
|
||||
public const SOURCE_CALENDAR = 'calendar';
|
||||
|
||||
public const SOURCE_MAIL = 'mail';
|
||||
|
||||
public const SOURCE_ADOPTION = 'adoption';
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'mode' => CaseIntakeMode::class,
|
||||
'outcome' => IntakeOutcome::class,
|
||||
'applied' => 'boolean',
|
||||
'starts_on' => 'immutable_date',
|
||||
'ends_on' => 'immutable_date',
|
||||
'reasons' => 'array',
|
||||
'missing' => 'array',
|
||||
'occurred_at' => 'immutable_datetime',
|
||||
];
|
||||
}
|
||||
|
||||
/** @return BelongsTo<Channel, $this> */
|
||||
public function channel(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Channel::class);
|
||||
}
|
||||
|
||||
/** @return BelongsTo<Booking, $this> */
|
||||
public function booking(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Booking::class);
|
||||
}
|
||||
|
||||
/** @return BelongsTo<BlockedPeriod, $this> */
|
||||
public function blockedPeriod(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(BlockedPeriod::class)->withTrashed();
|
||||
}
|
||||
|
||||
public function sourceLabel(): string
|
||||
{
|
||||
return match ($this->source) {
|
||||
self::SOURCE_MAIL => 'Portal-E-Mail',
|
||||
self::SOURCE_ADOPTION => 'Bestandsübernahme',
|
||||
default => 'Portalkalender',
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,9 @@ class CaseActivities
|
||||
/** Activities that are listed on their own in the work list (they are not "the" next step of a case). */
|
||||
private const LISTED_SEPARATELY = ['channel_block'];
|
||||
|
||||
/** Activities that are the next step whatever else is open. */
|
||||
private const URGENT = ['task_portal_cancel_reported', 'task_portal_change_reported'];
|
||||
|
||||
/**
|
||||
* @return list<Activity>
|
||||
*/
|
||||
@@ -110,7 +113,7 @@ public static function for(Booking $booking): array
|
||||
}
|
||||
|
||||
foreach (self::channelTasks($booking) as $task) {
|
||||
$activities[] = 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(), url: ChannelTaskResource::getUrl());
|
||||
$activities[] = 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());
|
||||
}
|
||||
|
||||
if ($profile->payments() === Responsibility::Portal) {
|
||||
@@ -157,7 +160,11 @@ public static function for(Booking $booking): array
|
||||
*/
|
||||
public static function next(Booking $booking): ?Activity
|
||||
{
|
||||
foreach (self::for($booking) as $activity) {
|
||||
$activities = self::for($booking);
|
||||
// A report of the portal (cancellation, other dates) comes before everything else on the case.
|
||||
usort($activities, fn (Activity $a, Activity $b): int => (int) in_array($b->key, self::URGENT, true) <=> (int) in_array($a->key, self::URGENT, true));
|
||||
|
||||
foreach ($activities as $activity) {
|
||||
if ($activity->state->needsAction() && ! in_array($activity->key, self::LISTED_SEPARATELY, true)) {
|
||||
return $activity;
|
||||
}
|
||||
|
||||
@@ -62,8 +62,8 @@ public static function items(): array
|
||||
|
||||
foreach (BlockedPeriod::query()->unclear()->with(['channel', 'property'])->whereDate('ends_on', '>=', today())->orderBy('starts_on')->get() as $occupation) {
|
||||
$items[] = [
|
||||
'title' => 'Unbekannte Belegung von '.($occupation->channel?->name ?? 'einem Portal').' – was ist das?',
|
||||
'detail' => $occupation->starts_on->format('d.m.').'–'.$occupation->ends_on->format('d.m.Y').' · '.$occupation->property?->name,
|
||||
'title' => 'Belegung von '.($occupation->channel?->name ?? 'einem Portal').' klären',
|
||||
'detail' => 'Für den Zeitraum '.$occupation->starts_on->format('d.m.').'–'.$occupation->ends_on->format('d.m.Y').' wurde eine Belegung von '.($occupation->channel?->name ?? 'einem Portal').' gemeldet. Bitte klären Sie, um welche Art von Belegung es sich handelt. · '.$occupation->property?->name,
|
||||
'url' => PortalOccupationResource::getUrl('view', ['record' => $occupation]),
|
||||
'button' => 'Klären',
|
||||
'tone' => 'warning',
|
||||
|
||||
Reference in new issue
Block a user