Vorgangskern und geführte Vorgangsbearbeitung (Pakete 1 und 2, Prozessarchitektur v0.10)
- Buchung ist der einheitliche Vorgang: Eingangsart, Vorgangsart A1–A6, eingefrorenes Abwicklungsprofil, gespeicherter Verlauf (booking_events); Gast, Personen und Beträge dürfen unbekannt sein, Platzhalter-Gäste werden migriert und nicht mehr angelegt - Einstellungen in Ebenen: Vermieterstandard (So arbeite ich), Abweichung der Wohnung (Experte), Abweichung je Portal und Eingangsart; ersetzt booking_model als Steuergröße - Ein Weg für extern verbindliche Buchungen (TakeOverExternalBooking) statt RecordPortalBooking und "Akte anlegen"; Portalpreis als belegte Gesamtposition - Startseite "Zu erledigen", neue Vorgangsseite mit nächstem Schritt, Automatik-Schalter, "Beenden" mit Storno statt Statusumschaltung; Status von Hand nur im Expertenmodus - Migration übernimmt bisheriges Verhalten unverändert (abweichende Wohnungswerte bleiben als Abweichung), Bericht: php artisan process:settings-report Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9005c12164
commit
3a728c3255
78 files changed
+4296
-1180
No files matched your search
+77
-18
@@ -5,11 +5,17 @@
|
||||
use App\Documents\OfferTerms;
|
||||
use App\Enums\BookingStatus;
|
||||
use App\Enums\BookingTaskKind;
|
||||
use App\Enums\ChannelBookingModel;
|
||||
use App\Enums\CaseType;
|
||||
use App\Enums\IntakeKind;
|
||||
use App\Enums\ProcessingMode;
|
||||
use App\Enums\ReferralSource;
|
||||
use App\Enums\Responsibility;
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use App\Models\Concerns\HasChannelProvenance;
|
||||
use App\Observers\BookingObserver;
|
||||
use App\Process\CaseRecorder;
|
||||
use App\Process\ProcessProfile;
|
||||
use App\Process\ProcessSettings;
|
||||
use Carbon\CarbonInterface;
|
||||
use Database\Factories\BookingFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
@@ -24,8 +30,10 @@
|
||||
use Illuminate\Support\HtmlString;
|
||||
|
||||
/**
|
||||
* A reservation or booking. arrival is the first night, departure the day the guest leaves,
|
||||
* so a departure and the next arrival on the same day do not collide.
|
||||
* A case ("Vorgang", docs/Prozessarchitektur): one business occasion from its first arrival to its end – a request,
|
||||
* a booking already binding on a portal, or an internal use. arrival is the first night, departure the day the guest
|
||||
* leaves, so a departure and the next arrival on the same day do not collide. Guest, number of guests and amounts may
|
||||
* be unknown (null) – unknown is never replaced by an invented value.
|
||||
*/
|
||||
#[ObservedBy(BookingObserver::class)]
|
||||
#[Fillable([
|
||||
@@ -33,6 +41,10 @@
|
||||
'guest_id',
|
||||
'status',
|
||||
'source',
|
||||
'intake',
|
||||
'case_type',
|
||||
'profile',
|
||||
'processing_mode',
|
||||
'import_channel_id',
|
||||
'origin_channel_id',
|
||||
'portal_reference',
|
||||
@@ -94,9 +106,12 @@ public function isDirect(): bool
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::saving(fn (Booking $booking) => CaseRecorder::freeze($booking));
|
||||
static::created(function (Booking $booking): void {
|
||||
$booking->forceFill(['reference' => $booking->nextReference()])->saveQuietly();
|
||||
CaseRecorder::created($booking);
|
||||
});
|
||||
static::updated(fn (Booking $booking) => CaseRecorder::updated($booking));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,6 +149,10 @@ protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'status' => BookingStatus::class,
|
||||
'intake' => IntakeKind::class,
|
||||
'case_type' => CaseType::class,
|
||||
'profile' => 'array',
|
||||
'processing_mode' => ProcessingMode::class,
|
||||
'referral_source' => ReferralSource::class,
|
||||
'arrival' => 'immutable_date',
|
||||
'departure' => 'immutable_date',
|
||||
@@ -189,6 +208,51 @@ public function importChannel(): BelongsTo
|
||||
return $this->belongsTo(Channel::class, 'import_channel_id');
|
||||
}
|
||||
|
||||
/** @return HasMany<BookingEvent, $this> */
|
||||
public function events(): HasMany
|
||||
{
|
||||
return $this->hasMany(BookingEvent::class)->orderBy('occurred_at')->orderBy('id');
|
||||
}
|
||||
|
||||
/**
|
||||
* The channel whose settings apply: the one the case was imported from, else its origin channel (owner).
|
||||
*/
|
||||
public function processChannel(): ?Channel
|
||||
{
|
||||
return $this->importChannel ?? $this->originChannel;
|
||||
}
|
||||
|
||||
/**
|
||||
* The rules of this case as frozen when it came in (resolved now for a case that has none yet).
|
||||
*/
|
||||
public function process(): ProcessProfile
|
||||
{
|
||||
return filled($this->profile) ? ProcessProfile::fromArray($this->profile) : app(ProcessSettings::class)->forBooking($this);
|
||||
}
|
||||
|
||||
public function caseType(): CaseType
|
||||
{
|
||||
return $this->case_type ?? $this->process()->caseType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Automatic or manual: the decision taken on this case, else the setting frozen with its profile.
|
||||
*/
|
||||
public function processingMode(): ProcessingMode
|
||||
{
|
||||
return $this->processing_mode ?? $this->process()->processing();
|
||||
}
|
||||
|
||||
public function isBinding(): bool
|
||||
{
|
||||
return in_array($this->status, BookingStatus::occupying(), true);
|
||||
}
|
||||
|
||||
public function guestName(): string
|
||||
{
|
||||
return $this->guest?->full_name ?? 'Gast noch nicht bekannt';
|
||||
}
|
||||
|
||||
/** @return HasMany<BlockedPeriod, $this> */
|
||||
public function channelRepresentations(): HasMany
|
||||
{
|
||||
@@ -197,7 +261,7 @@ public function channelRepresentations(): HasMany
|
||||
|
||||
public function bookingChannelLabel(): string
|
||||
{
|
||||
return $this->originChannel?->name ?? $this->importChannel?->name ?? match ($this->source) {
|
||||
return $this->originChannel?->name ?? $this->importChannel?->name ?? match ($this->source ?? 'website') {
|
||||
'website' => 'Eigene Webseite',
|
||||
'manual' => 'Manuell / direkt',
|
||||
'phone' => 'Telefon',
|
||||
@@ -275,14 +339,17 @@ public function paidAmount(): int
|
||||
return (int) ($this->relationLoaded('payments') ? $this->payments->sum('amount') : $this->payments()->sum('amount'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Amount still to be paid in cents; 0 while the price is unknown.
|
||||
*/
|
||||
public function openAmount(): int
|
||||
{
|
||||
return max(0, $this->total - $this->paidAmount());
|
||||
return $this->total === null ? 0 : max(0, $this->total - $this->paidAmount());
|
||||
}
|
||||
|
||||
public function openDeposit(): int
|
||||
{
|
||||
return max(0, $this->deposit - $this->paidAmount());
|
||||
return $this->deposit === null ? 0 : max(0, $this->deposit - $this->paidAmount());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -290,24 +357,16 @@ public function openDeposit(): int
|
||||
*/
|
||||
public function requiresFullPayment(): bool
|
||||
{
|
||||
return $this->deposit_due_on !== null && $this->balance_due_on->lessThanOrEqualTo($this->deposit_due_on);
|
||||
return $this->deposit_due_on !== null && $this->balance_due_on !== null && $this->balance_due_on->lessThanOrEqualTo($this->deposit_due_on);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the landlord chases payments of this booking. Own bookings: always. Portal bookings: as configured
|
||||
* per channel and kind – a reservation whose payment the portal collects (e.g. instant booking) needs no
|
||||
* tasks, a mere inquiry passed on by the portal does.
|
||||
* Whether the landlord chases payments of this case: only when the guest pays us (process profile – a portal that
|
||||
* collects the money needs no tasks) and the price is known.
|
||||
*/
|
||||
public function wantsPaymentTasks(): bool
|
||||
{
|
||||
$channel = $this->importChannel ?? $this->originChannel;
|
||||
if ($channel === null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $channel->booking_model === ChannelBookingModel::PortalBooking
|
||||
? $channel->payment_tasks_reservation
|
||||
: $channel->payment_tasks_inquiry;
|
||||
return $this->process()->payments() === Responsibility::Landlord && $this->total !== null && $this->total > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* One entry in the stored history of a case: what happened, who did it, why and when. Entries are only added, never
|
||||
* changed, so the history stays the same whatever happens to the case later.
|
||||
*/
|
||||
#[Fillable(['booking_id', 'type', 'summary', 'actor', 'reason', 'data', 'occurred_at'])]
|
||||
class BookingEvent extends Model
|
||||
{
|
||||
use BelongsToTenant;
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'data' => 'array',
|
||||
'occurred_at' => 'immutable_datetime',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo<Booking, $this>
|
||||
*/
|
||||
public function booking(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Booking::class);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use App\Process\CaseLog;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
@@ -17,6 +18,19 @@ class BookingMessage extends Model
|
||||
|
||||
use BelongsToTenant;
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::created(function (BookingMessage $message): void {
|
||||
if ($message->booking !== null) {
|
||||
CaseLog::record($message->booking, 'mail', 'E-Mail '.match ($message->audience) {
|
||||
'guest' => 'an den Gast',
|
||||
'landlord' => 'an uns',
|
||||
default => '(Testbetrieb)',
|
||||
}.': '.$message->subject, actor: CaseLog::SYSTEM, at: $message->sent_at);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
use App\Enums\BookingTaskKind;
|
||||
use App\Enums\BookingTaskStatus;
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use App\Process\CaseLog;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\Scope;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
@@ -20,6 +21,20 @@ class BookingTask extends Model
|
||||
{
|
||||
use BelongsToTenant;
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::created(function (BookingTask $task): void {
|
||||
if ($task->booking !== null) {
|
||||
CaseLog::record($task->booking, 'task', 'Aufgabe: '.$task->kind->getLabel());
|
||||
}
|
||||
});
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
|
||||
@@ -26,7 +26,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'])]
|
||||
#[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'])]
|
||||
#[Hidden(['export_token', 'previous_export_token', 'export_snapshot', 'settings', 'ical_analysis'])]
|
||||
class Channel extends Model
|
||||
{
|
||||
@@ -62,6 +62,7 @@ protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'settings' => 'array',
|
||||
'process_overrides' => 'array',
|
||||
'ical_analysis' => 'encrypted:array',
|
||||
'ical_analyzed_at' => 'immutable_datetime',
|
||||
'ical_rules' => 'array',
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
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;
|
||||
@@ -19,6 +21,15 @@ class Payment extends Model
|
||||
/** @use HasFactory<PaymentFactory> */
|
||||
use BelongsToTenant, HasFactory;
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::created(function (Payment $payment): void {
|
||||
if ($payment->booking !== null) {
|
||||
CaseLog::record($payment->booking, 'payment', ($payment->amount < 0 ? 'Erstattung ' : 'Zahlung ').Money::format(abs($payment->amount)).' erfasst', data: ['payment_id' => $payment->id]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
'min_stay_until_changeover',
|
||||
'min_stay_absolute',
|
||||
'is_active',
|
||||
'process_overrides',
|
||||
])]
|
||||
class Property extends Model
|
||||
{
|
||||
@@ -82,6 +83,7 @@ protected function casts(): array
|
||||
'cancellation_mode' => CancellationMode::class,
|
||||
'free_cancellation_days' => 'integer',
|
||||
'contract_data' => 'array',
|
||||
'process_overrides' => 'array',
|
||||
'min_stay_fill_gaps' => 'boolean',
|
||||
'min_stay_until_changeover' => 'boolean',
|
||||
'changeover_weekday' => 'integer',
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
'channel_stale_after_minutes', 'channel_task_reminder_after_minutes',
|
||||
'reminder_interval_days', 'digest_daily', 'digest_weekly', 'digest_weekday', 'digest_hour', 'digest_sections',
|
||||
'digest_when_empty', 'digest_daily_sent_on', 'digest_weekly_sent_on',
|
||||
'process_defaults',
|
||||
])]
|
||||
class Tenant extends Model
|
||||
{
|
||||
@@ -74,6 +75,7 @@ protected function casts(): array
|
||||
'digest_weekday' => 'integer',
|
||||
'digest_hour' => 'integer',
|
||||
'digest_sections' => 'array',
|
||||
'process_defaults' => 'array',
|
||||
'digest_when_empty' => 'boolean',
|
||||
'digest_daily_sent_on' => 'immutable_date',
|
||||
'digest_weekly_sent_on' => 'immutable_date',
|
||||
|
||||
Reference in new issue
Block a user