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
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace App\Process;
|
||||
|
||||
use App\Enums\ChannelBookingModel;
|
||||
use App\Enums\IntakeKind;
|
||||
use App\Enums\ProcessSetting;
|
||||
use App\Enums\Responsibility;
|
||||
use App\Models\Booking;
|
||||
use App\Models\Channel;
|
||||
use App\Models\Property;
|
||||
use App\Models\Tenant;
|
||||
|
||||
/**
|
||||
* Resolves the effective process settings: built-in default → landlord default (tenant) → deviation of the property
|
||||
* (expert area) → deviation of the channel for the intake kind. A value that is not set inherits from the level above;
|
||||
* a deliberately set 0, "no" or "manual" is a value of its own.
|
||||
*/
|
||||
class ProcessSettings
|
||||
{
|
||||
public function resolve(Property $property, ?Channel $channel, IntakeKind $intake): ProcessProfile
|
||||
{
|
||||
$propertyLevel = (array) ($property->process_overrides ?? []);
|
||||
if ($property->contract_template_id !== null) {
|
||||
$propertyLevel[ProcessSetting::ContractTemplate->value] = $property->contract_template_id;
|
||||
}
|
||||
|
||||
$levels = [
|
||||
ProcessProfile::TENANT => $this->tenantDefaults($property->tenant_id),
|
||||
ProcessProfile::PROPERTY => $propertyLevel,
|
||||
ProcessProfile::CHANNEL => $intake === IntakeKind::Internal || $channel === null ? [] : (array) (($channel->process_overrides ?? [])[$intake->value] ?? []),
|
||||
];
|
||||
|
||||
$values = [];
|
||||
$sources = [];
|
||||
foreach (ProcessSetting::cases() as $setting) {
|
||||
$values[$setting->value] = $setting->default();
|
||||
$sources[$setting->value] = ProcessProfile::SYSTEM;
|
||||
|
||||
foreach ($levels as $level => $settings) {
|
||||
if ($level === ProcessProfile::CHANNEL && ! in_array($intake, $setting->channelIntakes(), true)) {
|
||||
continue;
|
||||
}
|
||||
$value = $setting->normalize($settings[$setting->value] ?? null);
|
||||
if ($value !== null) {
|
||||
$values[$setting->value] = $value;
|
||||
$sources[$setting->value] = $level;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($intake !== IntakeKind::Booking) {
|
||||
// A request is answered with our own offer and an internal case is ours anyway: the documents are ours.
|
||||
$values[ProcessSetting::Documents->value] = Responsibility::Landlord->value;
|
||||
$sources[ProcessSetting::Documents->value] = ProcessProfile::SYSTEM;
|
||||
}
|
||||
|
||||
$documents = Responsibility::from((string) $values[ProcessSetting::Documents->value]);
|
||||
$payments = Responsibility::from((string) $values[ProcessSetting::Payments->value]);
|
||||
|
||||
return new ProcessProfile($intake, ProcessProfile::caseTypeFor($intake, $channel !== null, $documents, $payments), $values, $sources);
|
||||
}
|
||||
|
||||
/**
|
||||
* The settings that would apply to a case right now (its frozen profile is what counts for the case itself).
|
||||
*/
|
||||
public function forBooking(Booking $booking): ProcessProfile
|
||||
{
|
||||
// The case's own landlord counts, whichever landlord is current (e.g. a case written by the system).
|
||||
$property = $booking->property ?? Property::withoutGlobalScope('tenant')->findOrFail($booking->property_id);
|
||||
|
||||
return $this->resolve($property, $booking->processChannel(), $booking->intake ?? self::intakeFor($booking));
|
||||
}
|
||||
|
||||
/**
|
||||
* Landlord defaults as stored on the tenant (not set: empty).
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function tenantDefaults(?int $tenantId): array
|
||||
{
|
||||
if ($tenantId === null) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return (array) (Tenant::query()->find($tenantId)?->process_defaults ?? []);
|
||||
}
|
||||
|
||||
/**
|
||||
* Intake kind of a case that does not name one: a case from a channel that only passes on requests is a request,
|
||||
* from other channels a booking that is already binding; everything else (website, phone, e-mail) a request.
|
||||
*/
|
||||
public static function intakeFor(Booking $booking): IntakeKind
|
||||
{
|
||||
$channel = $booking->processChannel();
|
||||
if ($channel === null) {
|
||||
return IntakeKind::Inquiry;
|
||||
}
|
||||
|
||||
return $channel->booking_model === ChannelBookingModel::Inquiry ? IntakeKind::Inquiry : IntakeKind::Booking;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user