Pakete 7 und 9: Auskunft und Buchungswunsch, Aufenthalt und Abschluss (Zwischenstand)
- Haltefrist 0: unverbindliche Auskunft mit signiertem Link "Buchung anfragen", erneute Prüfung unter Sperre, automatische oder manuelle Bestätigung, Absage bei vergebenem Zeitraum, Ablauf unbeantworteter Auskünfte - Aufenthalt: Anreisedaten, Aufgaben je Wohnung, gebuchte Leistungen, Abweichungen und Folgeaufgaben als Aufgaben am Vorgang - Abschluss getrennt: Aufenthalt abgeschlossen / kaufmännisch abgeschlossen, Nachläufer (Forderung, Auszahlung) bleiben sichtbar - Zahlungsstatus nur aus Geld auf unserem Konto; Altbestand per Vorschau-Befehl - Verlauf weist Testzustellungen als solche aus - Abnahmetests T16-T25, T23 über isolierten SMTP-Empfänger Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3bcfc09417
commit
40d20cb7d1
52 files changed
+3196
-89
No files matched your search
@@ -99,6 +99,17 @@
|
||||
'tourist_tax_note',
|
||||
'portal_cancellation_requested_at',
|
||||
'export_uid',
|
||||
'information_version',
|
||||
'information_sent_at',
|
||||
'information_valid_until',
|
||||
'information',
|
||||
'wish_at',
|
||||
'wish',
|
||||
'arrival_time',
|
||||
'completed_at',
|
||||
'settled_at',
|
||||
'settled_note',
|
||||
'settled_by',
|
||||
])]
|
||||
class Booking extends Model
|
||||
{
|
||||
@@ -187,6 +198,13 @@ protected function casts(): array
|
||||
'archived_at' => 'immutable_datetime',
|
||||
'internal_kind' => InternalKind::class,
|
||||
'portal_cancellation_requested_at' => 'immutable_datetime',
|
||||
'information_sent_at' => 'immutable_datetime',
|
||||
'information_valid_until' => 'immutable_datetime',
|
||||
'information' => 'array',
|
||||
'wish_at' => 'immutable_datetime',
|
||||
'wish' => 'array',
|
||||
'completed_at' => 'immutable_datetime',
|
||||
'settled_at' => 'immutable_datetime',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ protected static function booted(): void
|
||||
CaseLog::record($message->booking, 'mail', 'E-Mail '.match ($message->audience) {
|
||||
'guest' => 'an den Gast',
|
||||
'landlord' => 'an uns',
|
||||
default => '(Testbetrieb)',
|
||||
default => 'im Testbetrieb an die Testadresse (nicht an den Gast)',
|
||||
}.': '.$message->subject, actor: CaseLog::SYSTEM, at: $message->sent_at);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
use App\Enums\BookingTaskKind;
|
||||
use App\Enums\BookingTaskStatus;
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use App\Process\CaseClosure;
|
||||
use App\Process\CaseLog;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\Scope;
|
||||
@@ -16,7 +17,7 @@
|
||||
* Something the landlord has to do about a booking. One task per booking and kind; a finished or
|
||||
* dismissed task is never created again.
|
||||
*/
|
||||
#[Fillable(['booking_id', 'kind', 'status', 'due_on', 'note', 'completed_by', 'completed_at'])]
|
||||
#[Fillable(['booking_id', 'kind', 'subject', 'title', 'responsible', 'status', 'due_on', 'note', 'completed_by', 'completed_at'])]
|
||||
class BookingTask extends Model
|
||||
{
|
||||
use BelongsToTenant;
|
||||
@@ -25,12 +26,19 @@ protected static function booted(): void
|
||||
{
|
||||
static::created(function (BookingTask $task): void {
|
||||
if ($task->booking !== null) {
|
||||
CaseLog::record($task->booking, 'task', 'Aufgabe: '.$task->kind->getLabel());
|
||||
CaseLog::record($task->booking, 'task', 'Aufgabe: '.$task->label().($task->responsible ? ' (zuständig: '.$task->responsible.')' : ''));
|
||||
if ($task->kind->isCommercial() && $task->status === BookingTaskStatus::Open) {
|
||||
CaseClosure::refresh($task->booking);
|
||||
}
|
||||
}
|
||||
});
|
||||
static::updated(function (BookingTask $task): void {
|
||||
if ($task->wasChanged('status') && $task->status !== BookingTaskStatus::Open && $task->booking !== null) {
|
||||
CaseLog::record($task->booking, 'task', 'Aufgabe '.($task->status === BookingTaskStatus::Done ? 'erledigt' : 'verworfen').': '.$task->kind->getLabel(), actor: $task->completed_by);
|
||||
CaseLog::record($task->booking, 'task', 'Aufgabe '.($task->status === BookingTaskStatus::Done ? 'erledigt' : 'verworfen').': '.$task->label().($task->wasChanged('note') && filled($task->note) ? ' – '.$task->note : ''), actor: $task->completed_by);
|
||||
}
|
||||
// Money tasks decide the commercial closing of the case (package 9).
|
||||
if ($task->wasChanged('status') && $task->booking !== null && $task->kind->isCommercial()) {
|
||||
CaseClosure::refresh($task->booking);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -68,8 +76,31 @@ protected function open(Builder $query): Builder
|
||||
return $query->where('status', BookingTaskStatus::Open);
|
||||
}
|
||||
|
||||
public function complete(string $by): void
|
||||
public function complete(string $by, ?string $note = null): void
|
||||
{
|
||||
$this->update(['status' => BookingTaskStatus::Done, 'completed_by' => $by, 'completed_at' => now()]);
|
||||
$this->update(['status' => BookingTaskStatus::Done, 'completed_by' => $by, 'completed_at' => now(), ...($note !== null && $note !== '' ? ['note' => mb_substr($note, 0, 1000)] : [])]);
|
||||
}
|
||||
|
||||
/**
|
||||
* What the task is about in plain words: its own title (services, issues, follow-ups) or the label of its kind.
|
||||
*/
|
||||
public function label(): string
|
||||
{
|
||||
return filled($this->title) ? (string) $this->title : $this->kind->getLabel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the task of this kind and subject for the case once; a task that was done or dismissed is not opened again.
|
||||
*
|
||||
* @param array<string, mixed> $attributes
|
||||
*/
|
||||
public static function openOnce(Booking $booking, BookingTaskKind $kind, string $subject = '', array $attributes = []): self
|
||||
{
|
||||
$task = static::withoutGlobalScope('tenant')->firstOrNew(['booking_id' => $booking->id, 'kind' => $kind, 'subject' => $subject]);
|
||||
if (! $task->exists) {
|
||||
$task->forceFill(['tenant_id' => $booking->tenant_id, 'status' => BookingTaskStatus::Open, ...$attributes])->save();
|
||||
}
|
||||
|
||||
return $task;
|
||||
}
|
||||
}
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Actions\RecordPayment;
|
||||
use App\Enums\PaymentKind;
|
||||
use App\Enums\PaymentMethod;
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use App\Process\CaseLog;
|
||||
use App\Support\Money;
|
||||
use Database\Factories\PaymentFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
@@ -27,7 +27,7 @@ protected static function booted(): void
|
||||
{
|
||||
static::created(function (Payment $payment): void {
|
||||
if ($payment->booking !== null) {
|
||||
CaseLog::record($payment->booking, 'payment', ($payment->kind ?? PaymentKind::Guest)->getLabel().': '.Money::format(abs($payment->amount)).($payment->source ? ' ('.$payment->source.')' : ''), data: ['payment_id' => $payment->id]);
|
||||
CaseLog::record($payment->booking, 'payment', RecordPayment::summary($payment->booking, $payment->kind ?? PaymentKind::Guest, (int) $payment->amount, $payment->paid_on, $payment->source), data: ['payment_id' => $payment->id, 'kind' => ($payment->kind ?? PaymentKind::Guest)->value]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* A rentable holiday apartment. All money amounts are stored in euro cents.
|
||||
@@ -47,6 +48,8 @@
|
||||
'min_stay_absolute',
|
||||
'is_active',
|
||||
'process_overrides',
|
||||
'stay_tasks',
|
||||
'asks_arrival_time',
|
||||
])]
|
||||
class Property extends Model
|
||||
{
|
||||
@@ -85,6 +88,8 @@ protected function casts(): array
|
||||
'free_cancellation_days' => 'integer',
|
||||
'contract_data' => 'array',
|
||||
'process_overrides' => 'array',
|
||||
'stay_tasks' => 'array',
|
||||
'asks_arrival_time' => 'boolean',
|
||||
'min_stay_fill_gaps' => 'boolean',
|
||||
'min_stay_until_changeover' => 'boolean',
|
||||
'changeover_weekday' => 'integer',
|
||||
@@ -188,4 +193,31 @@ public function extras(): HasMany
|
||||
{
|
||||
return $this->hasMany(Extra::class)->orderBy('sort_order');
|
||||
}
|
||||
|
||||
/**
|
||||
* The stay tasks of this property (package 9): local services and provider jobs such as cleaning, linen or the key
|
||||
* handover, each with when it is due and for which kinds of stays it applies. No staff planning – a task per case.
|
||||
*
|
||||
* @return list<array{key: string, title: string, when: string, days: int, responsible: ?string, applies_to: list<string>}>
|
||||
*/
|
||||
public function stayTaskDefinitions(): array
|
||||
{
|
||||
$definitions = [];
|
||||
foreach ((array) ($this->stay_tasks ?? []) as $task) {
|
||||
$title = trim((string) ($task['title'] ?? ''));
|
||||
if ($title === '') {
|
||||
continue;
|
||||
}
|
||||
$definitions[] = [
|
||||
'key' => 'stay:'.mb_substr(Str::slug($title), 0, 70),
|
||||
'title' => $title,
|
||||
'when' => in_array($task['when'] ?? null, ['before_arrival', 'on_arrival', 'after_departure'], true) ? $task['when'] : 'before_arrival',
|
||||
'days' => max(0, (int) ($task['days'] ?? 1)),
|
||||
'responsible' => filled($task['responsible'] ?? null) ? trim((string) $task['responsible']) : null,
|
||||
'applies_to' => array_values(array_filter((array) ($task['applies_to'] ?? ['rental']))) ?: ['rental'],
|
||||
];
|
||||
}
|
||||
|
||||
return $definitions;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user