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
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user