U-A/U-B: Prozesskern mit Fachmodulen, versionierten Modellen, eingefrorenem Prozessplan, ProcessRunner (harte/weiche Abhängigkeiten), CasePricing, Loyalty nur im Tester
CaseActivities/CaseAutomation sind Fassaden über ProcessRunner. Verhaltensvergleich v0.11: 11 Abläufe und 198 Konstellationen gleich, beabsichtigte Abweichungen I-004/I-005 (F-001/F-002). Volle Suite vor U-B: 785/785. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
98df5e9e3b
commit
7e22e12cac
80 files changed
+4628
-445
No files matched your search
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Process\Modules\Offer;
|
||||
|
||||
use App\Actions\AutoOffer;
|
||||
use App\Enums\BookingStatus;
|
||||
use App\Enums\IntakeKind;
|
||||
use App\Enums\ProcessingMode;
|
||||
use App\Process\CaseContext;
|
||||
use App\Process\StepResult;
|
||||
|
||||
/**
|
||||
* The automatic answer of a request (binding offer or information "unter Vorbehalt"): due while the request waits for
|
||||
* its first answer and the case is handled automatically; carried out by {@see AutoOffer}, which checks every release
|
||||
* rule (dates, contract texts, calendar clearance, document composition) itself.
|
||||
*/
|
||||
trait AnswersRequest
|
||||
{
|
||||
public function due(CaseContext $case): bool
|
||||
{
|
||||
$booking = $case->booking;
|
||||
|
||||
return $booking->processingMode() === ProcessingMode::Automatic
|
||||
&& $booking->status === BookingStatus::Reserved && $booking->offer_version === 0 && $booking->information_version === 0
|
||||
&& $booking->intake !== IntakeKind::Booking;
|
||||
}
|
||||
|
||||
public function blockers(CaseContext $case): array
|
||||
{
|
||||
return app(AutoOffer::class)->blockers($case->booking);
|
||||
}
|
||||
|
||||
public function run(CaseContext $case): StepResult
|
||||
{
|
||||
$reasons = app(AutoOffer::class)->handle($case->booking);
|
||||
|
||||
return $reasons === [] ? StepResult::ran() : StepResult::blocked($reasons);
|
||||
}
|
||||
|
||||
public function isOutward(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\Process\Modules\Offer;
|
||||
|
||||
use App\Availability\AvailabilityChecker;
|
||||
use App\Enums\ActivityState;
|
||||
use App\Enums\BookingStatus;
|
||||
use App\Enums\ProcessingMode;
|
||||
use App\Enums\ProcessSetting;
|
||||
use App\Process\Activity;
|
||||
use App\Process\CaseContext;
|
||||
use App\Process\CaseRequirements;
|
||||
use App\Process\Modules\Dependency;
|
||||
use App\Process\Modules\Module;
|
||||
use App\Process\Modules\ModuleDefinition;
|
||||
use App\Process\Modules\RunsAutomatically;
|
||||
|
||||
/**
|
||||
* P02: our own binding offer with the contract draft (SendOffer, versioned). The price is fixed here – extension point
|
||||
* BeforePriceFixing lies before it. Never without every required detail (hard dependency on guest.details) and never
|
||||
* for dates that are taken.
|
||||
*/
|
||||
final class BindingOffer extends Module implements RunsAutomatically
|
||||
{
|
||||
use AnswersRequest;
|
||||
|
||||
public static function key(): string
|
||||
{
|
||||
return 'offer.binding';
|
||||
}
|
||||
|
||||
public static function version(): int
|
||||
{
|
||||
// 2: dates taken meanwhile are a problem of the step, an expired hold is not shown as reserved (F-001, F-002).
|
||||
return 2;
|
||||
}
|
||||
|
||||
public static function definition(): ModuleDefinition
|
||||
{
|
||||
return new ModuleDefinition(
|
||||
label: 'Verbindliches Angebot',
|
||||
purpose: 'Erstellt das verbindliche Angebot mit Vertragsentwurf und sendet es dem Gast; der Zeitraum ist für die Haltefrist reserviert.',
|
||||
phase: 'P02',
|
||||
requires: [Dependency::hard('guest.details'), Dependency::hard('availability.check'), Dependency::soft('guest.data_request')],
|
||||
effects: ['case_write', 'guest_mail', 'landlord_mail', 'document', 'calendar_hold', 'network'],
|
||||
waits: ['guest', 'landlord'],
|
||||
triggers: ['automation', 'request.created', 'schedule:bookings:auto-offers'],
|
||||
parameters: [ProcessSetting::Processing, ProcessSetting::HoldHours, ProcessSetting::ContractTemplate],
|
||||
performers: ['system', 'landlord'],
|
||||
modes: ['automatic', 'manual'],
|
||||
events: ['offer', 'hold', 'mail', 'status'],
|
||||
);
|
||||
}
|
||||
|
||||
/** The binding way: the request reserves (pre-reservation) or an offer was made anyway. */
|
||||
public function applies(CaseContext $case): bool
|
||||
{
|
||||
return $case->inquiry && ! ($case->profile->preReservation() === false && $case->booking->offer_version === 0);
|
||||
}
|
||||
|
||||
public function activities(CaseContext $case): array
|
||||
{
|
||||
$booking = $case->booking;
|
||||
$offerDone = $booking->offer_version > 0 || $case->binding;
|
||||
// G2a (v0.11): without every required detail there is no offer – the step waits for the guest's answer
|
||||
// (mail, link or the landlord's entry) instead of being offered as the next step.
|
||||
$offerMissing = $offerDone ? [] : CaseRequirements::missing($booking, CaseRequirements::OFFER);
|
||||
$open = ! $offerDone && $offerMissing === [] && $booking->status === BookingStatus::Reserved && filled($booking->guest?->email);
|
||||
$taken = $open && ! app(AvailabilityChecker::class)->isAvailable($booking->property, $booking->arrival, $booking->departure, ignore: $booking);
|
||||
|
||||
return [new Activity('offer', $booking->processingMode() === ProcessingMode::Automatic ? 'Angebot senden (automatisch)' : 'Angebot prüfen und senden', $case->later(match (true) {
|
||||
$offerDone => ActivityState::Done,
|
||||
$offerMissing !== [] => ActivityState::Later,
|
||||
$taken => ActivityState::Problem,
|
||||
$open => ActivityState::Open,
|
||||
default => ActivityState::Later,
|
||||
}), match (true) {
|
||||
$booking->offer_version > 0 => 'Version '.$booking->offer_version.' vom '.$booking->offer_sent_at?->format('d.m.Y'),
|
||||
$offerMissing !== [] => 'erst wenn alle Angaben da sind',
|
||||
$taken => 'Der Zeitraum ist inzwischen belegt.',
|
||||
$booking->isHoldActive() => 'Zeitraum reserviert bis '.$booking->hold_expires_at->format('d.m.Y, H:i').' Uhr',
|
||||
$booking->hold_expires_at !== null => 'Reservierung abgelaufen am '.$booking->hold_expires_at->format('d.m.Y, H:i').' Uhr – Zeitraum nicht reserviert',
|
||||
default => null,
|
||||
}, $offerDone || $offerMissing !== [] || $taken ? null : 'sendOffer')];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\Process\Modules\Offer;
|
||||
|
||||
use App\Enums\ActivityState;
|
||||
use App\Enums\BookingStatus;
|
||||
use App\Enums\ProcessingMode;
|
||||
use App\Enums\ProcessSetting;
|
||||
use App\Process\Activity;
|
||||
use App\Process\CaseContext;
|
||||
use App\Process\Modules\Dependency;
|
||||
use App\Process\Modules\Module;
|
||||
use App\Process\Modules\ModuleDefinition;
|
||||
use App\Process\Modules\RunsAutomatically;
|
||||
|
||||
/**
|
||||
* P02 (package 7): a request without a hold is answered with an information "unter Vorbehalt"; the guest asks for
|
||||
* the booking (wish) and we check again and confirm bindingly.
|
||||
*/
|
||||
final class Information extends Module implements RunsAutomatically
|
||||
{
|
||||
use AnswersRequest;
|
||||
|
||||
public static function key(): string
|
||||
{
|
||||
return 'offer.information';
|
||||
}
|
||||
|
||||
public static function definition(): ModuleDefinition
|
||||
{
|
||||
return new ModuleDefinition(
|
||||
label: 'Unverbindliche Auskunft und Buchungswunsch',
|
||||
purpose: 'Beantwortet die Anfrage mit einer unverbindlichen Auskunft ohne Reservierung; fragt der Gast die Buchung an, wird erneut geprüft und verbindlich bestätigt.',
|
||||
phase: 'P02',
|
||||
requires: [Dependency::hard('intake.record'), Dependency::soft('guest.data_request')],
|
||||
effects: ['case_write', 'guest_mail', 'landlord_mail', 'document'],
|
||||
waits: ['guest', 'landlord'],
|
||||
triggers: ['automation', 'request.created', 'schedule:bookings:auto-offers'],
|
||||
parameters: [ProcessSetting::Processing, ProcessSetting::GuestLinkValidDays],
|
||||
performers: ['system', 'landlord', 'guest'],
|
||||
modes: ['automatic', 'manual'],
|
||||
events: ['information', 'mail', 'hold', 'wish', 'status'],
|
||||
);
|
||||
}
|
||||
|
||||
public function applies(CaseContext $case): bool
|
||||
{
|
||||
return $case->inquiry && ! $case->profile->preReservation() && $case->booking->offer_version === 0;
|
||||
}
|
||||
|
||||
public function activities(CaseContext $case): array
|
||||
{
|
||||
$booking = $case->booking;
|
||||
$binding = $case->binding;
|
||||
$informed = $booking->information_version > 0 || $binding;
|
||||
|
||||
return [
|
||||
new Activity('information', $booking->processingMode() === ProcessingMode::Automatic ? 'Unverbindliche Auskunft senden (automatisch)' : 'Unverbindliche Auskunft prüfen und senden', $case->later(match (true) {
|
||||
$booking->information_version > 0 => ActivityState::Done,
|
||||
$binding => ActivityState::NotApplicable,
|
||||
$booking->status === BookingStatus::Reserved && filled($booking->guest?->email) => ActivityState::Open,
|
||||
default => ActivityState::Later,
|
||||
}), $booking->information_version > 0 ? 'Version '.$booking->information_version.' vom '.$booking->information_sent_at?->format('d.m.Y').' · ohne Reservierung' : 'der Zeitraum wird nicht reserviert', $informed ? null : 'sendInformation'),
|
||||
new Activity('wish', 'Gast fragt die Buchung an', $case->later(match (true) {
|
||||
$booking->wish_at !== null => ActivityState::Done,
|
||||
$binding => ActivityState::NotApplicable,
|
||||
$booking->information_version > 0 && $booking->information_valid_until?->isFuture() => ActivityState::Waiting,
|
||||
default => ActivityState::Later,
|
||||
}), match (true) {
|
||||
$booking->wish_at !== null => 'angefragt am '.$booking->wish_at->format('d.m.Y, H:i').' Uhr',
|
||||
$booking->information_version > 0 => 'möglich bis '.$booking->information_valid_until?->format('d.m.Y, H:i').' Uhr',
|
||||
default => null,
|
||||
}),
|
||||
new Activity('wish_check', 'Erneut prüfen und verbindlich bestätigen', $case->later(match (true) {
|
||||
$binding => ActivityState::Done,
|
||||
$booking->wish_at !== null && $booking->status === BookingStatus::Reserved => ActivityState::Waiting,
|
||||
default => ActivityState::Later,
|
||||
}), match (true) {
|
||||
$booking->accepted_at !== null && ($booking->acceptance['via'] ?? null) === 'booking_wish' => 'bestätigt am '.$booking->confirmed_at?->format('d.m.Y').' ('.($booking->acceptance['confirmed_by'] ?? '').')',
|
||||
$booking->wish_at !== null && $booking->status === BookingStatus::Reserved => 'siehe Aufgabe „Buchungswunsch bestätigen?“',
|
||||
$binding => 'direkt verbindlich bestätigt (ohne Buchungswunsch)',
|
||||
default => $booking->processingMode() === ProcessingMode::Automatic ? 'automatisch, wenn alles passt' : 'durch Sie',
|
||||
}),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Process\Modules\Offer;
|
||||
|
||||
use App\Enums\ActivityState;
|
||||
use App\Enums\BookingStatus;
|
||||
use App\Process\Activity;
|
||||
use App\Process\CaseContext;
|
||||
use App\Process\Modules\Dependency;
|
||||
use App\Process\Modules\Module;
|
||||
use App\Process\Modules\ModuleDefinition;
|
||||
|
||||
/**
|
||||
* P02: the guest accepts (AcceptOffer, acceptance record) or declines (RejectOffer); the booking becomes binding
|
||||
* (ConfirmBooking). Cannot be switched off – our own way never binds without the guest's acceptance.
|
||||
*/
|
||||
final class OfferAcceptance extends Module
|
||||
{
|
||||
public static function key(): string
|
||||
{
|
||||
return 'offer.acceptance';
|
||||
}
|
||||
|
||||
public static function definition(): ModuleDefinition
|
||||
{
|
||||
return new ModuleDefinition(
|
||||
label: 'Annahme durch den Gast',
|
||||
purpose: 'Der Gast nimmt das Angebot an oder lehnt es ab; mit der Annahme wird die Buchung verbindlich.',
|
||||
phase: 'P02',
|
||||
requires: [Dependency::hard('offer.binding')],
|
||||
effects: ['case_write', 'guest_mail', 'landlord_mail', 'document'],
|
||||
waits: ['guest', 'time'],
|
||||
triggers: ['offer.accepted', 'offer.declined'],
|
||||
performers: ['guest'],
|
||||
events: ['offer', 'status'],
|
||||
);
|
||||
}
|
||||
|
||||
public function applies(CaseContext $case): bool
|
||||
{
|
||||
return app(BindingOffer::class)->applies($case);
|
||||
}
|
||||
|
||||
public function activities(CaseContext $case): array
|
||||
{
|
||||
$booking = $case->booking;
|
||||
|
||||
return [new Activity('acceptance', 'Gast nimmt das Angebot an', $case->later(match (true) {
|
||||
$case->binding => ActivityState::Done,
|
||||
$booking->status === BookingStatus::OfferSent => ActivityState::Waiting,
|
||||
default => ActivityState::Later,
|
||||
}), match (true) {
|
||||
$booking->accepted_at !== null => 'angenommen am '.$booking->accepted_at->format('d.m.Y'),
|
||||
$case->binding => 'direkt bestätigt',
|
||||
$booking->status === BookingStatus::OfferSent => 'Angebot gültig bis '.$booking->hold_expires_at?->format('d.m.Y, H:i').' Uhr',
|
||||
default => null,
|
||||
})];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user