Deploy FeWo mit PipelineManager / deploy (push) Successful in 4m44s
- Paket 8: Zahlungsarten (Gast an uns, laut Portal, Auszahlung, Erstattung), Portalbeträge als Angaben mit Quelle, Übersicht nach Zuständigkeit (R09). - Paket 5: Ändern mit Folgenvorschau, vereinbart oder dem Gast vorgeschlagen (signierter Link), ein Stornoweg mit Grund und Erstattung, Portalstorno erst nach Bestätigung. - Paket 6: eigene Nutzung, Besuch und Sperre als Vorgang mit Kurabgabe und Aufenthaltsbestätigung; Bestandsübernahme der Sperren mit identischem Export. - Wirksame Einstellungen (Expertenansicht), Abnahmekatalog T01–T14, Ergebnis-, Abnahme- und Konfigurationsdokument. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
43 lines
1.5 KiB
PHP
43 lines
1.5 KiB
PHP
<?php
|
||
|
||
namespace App\Actions;
|
||
|
||
use App\Enums\BookingStatus;
|
||
use App\Enums\InternalKind;
|
||
use App\Exceptions\ReservationException;
|
||
use App\Models\Booking;
|
||
use App\Process\CaseLog;
|
||
use Illuminate\Support\Facades\DB;
|
||
|
||
/**
|
||
* Lifts a block or calls off an own use / private stay (A6). It is no cancellation: no costs, no refund rule, no mails –
|
||
* the dates are free again and the portals are released like for any booking that ends.
|
||
*/
|
||
class EndInternalCase
|
||
{
|
||
/**
|
||
* @throws ReservationException
|
||
*/
|
||
public function handle(Booking $booking, string $reason, ?string $by = null): void
|
||
{
|
||
if (! $booking->isInternal()) {
|
||
throw new ReservationException('Nur eigene Nutzung, private Aufenthalte und Sperren werden so beendet.');
|
||
}
|
||
|
||
DB::transaction(function () use ($booking, $reason, $by): void {
|
||
$booking->lockForTransition();
|
||
if (! in_array($booking->status, BookingStatus::occupying(), true)) {
|
||
throw ReservationException::invalidTransition($booking->status->getLabel(), 'aufgehoben');
|
||
}
|
||
|
||
CaseLog::context(fn () => $booking->update(['status' => BookingStatus::Cancelled, 'cancelled_at' => now()]), actor: $by, reason: $reason);
|
||
CaseLog::record($booking, 'status', self::label($booking), $reason, actor: $by);
|
||
});
|
||
}
|
||
|
||
public static function label(Booking $booking): string
|
||
{
|
||
return $booking->internal_kind === InternalKind::Block ? 'Sperre aufgehoben' : 'Aufenthalt abgesagt';
|
||
}
|
||
}
|