Files
fewo-stommer/app/Actions/RecordCancellation.php
T
LarsandClaude Sonnet 5.5 0c4187edaf
Deploy FeWo mit PipelineManager / deploy (push) Successful in 3m34s
Stornoregeln mit automatischer Kostenberechnung, Storno-Verwaltung, Vertragsanlagen
- Stornoregel (Stufen nach Tagen vor Anreise, Mietpreis oder Gesamtpreis, Ersatzmieter-Gebuehr), je Vertragsvorlage,
  beim Angebot eingefroren, als Platzhalter im Vertrag
- Stornierung (Gast-Link oder Verwaltung) berechnet die Kosten, legt einen Stornofall an; Verwaltung Stornierungen
  mit Vorschlag, Festlegung, Saldo, Abrechnung und Erlass; Gast sieht die Kosten vorab auf der Storno-Seite
- Vertragsanlagen als eigene versionierte Dokumente mit Bedingung (immer, Zusatzleistung, Portal, von Hand),
  je Angebot ausgewaehlt und eingefroren; Zusatzleistungen in der Buchung erfassbar
- FeWo-direkt-Installation legt die Stornoregel aus Paragraf 13 an

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-30 16:32:48 +01:00

36 lines
1.2 KiB
PHP

<?php
namespace App\Actions;
use App\Models\Booking;
use App\Models\Cancellation;
use App\Support\CancellationCost;
/**
* Records the cancellation of a booking with the cost proposed by the frozen cancellation rule. Called when a booking
* is cancelled (by the landlord or through the guest's link); safe to call twice.
*/
class RecordCancellation
{
public function handle(Booking $booking, string $initiatedBy): Cancellation
{
$cost = CancellationCost::calculate($booking);
return Cancellation::query()->firstOrCreate(
['booking_id' => $booking->id],
[
'cancelled_on' => today(),
'initiated_by' => $initiatedBy,
'has_policy' => $cost !== null,
'policy_name' => $cost['policy'] ?? null,
'days_before' => $cost['days_before'] ?? null,
'percent' => $cost['percent'] ?? null,
'base_amount' => $cost['base_amount'] ?? null,
'calculated_fee' => $cost['fee'] ?? null,
'paid_amount' => $booking->paidAmount(),
'status' => Cancellation::OPEN,
],
);
}
}