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,81 @@
|
||||
<?php
|
||||
|
||||
namespace App\Process\Modules\Money;
|
||||
|
||||
use App\Enums\ActivityState;
|
||||
use App\Enums\ProcessSetting;
|
||||
use App\Enums\Responsibility;
|
||||
use App\Process\Activity;
|
||||
use App\Process\CaseContext;
|
||||
use App\Process\Modules\Module;
|
||||
use App\Process\Modules\ModuleDefinition;
|
||||
use App\Support\Money;
|
||||
|
||||
/**
|
||||
* P03: the guest's payments – deposit and balance when we collect (A1–A3), the portal's collection when it collects
|
||||
* (A4/A5: only "laut Portal", never money on our account). Reminders are sent by SendBookingReminders.
|
||||
*/
|
||||
final class PaymentMonitoring extends Module
|
||||
{
|
||||
public static function key(): string
|
||||
{
|
||||
return 'payments.monitor';
|
||||
}
|
||||
|
||||
public static function definition(): ModuleDefinition
|
||||
{
|
||||
return new ModuleDefinition(
|
||||
label: 'Zahlungen des Gastes',
|
||||
purpose: 'Überwacht Anzahlung und Restzahlung und erinnert rechtzeitig – oder zeigt, was das Portal laut eigener Angabe eingezogen hat.',
|
||||
phase: 'P03',
|
||||
effects: ['case_write', 'guest_mail'],
|
||||
waits: ['guest', 'portal', 'time'],
|
||||
triggers: ['payment.recorded', 'portal.amounts', 'schedule:reminders'],
|
||||
parameters: [ProcessSetting::Payments, ProcessSetting::GuestMessages],
|
||||
performers: ['landlord', 'portal'],
|
||||
events: ['payment', 'amount'],
|
||||
readsContractData: true,
|
||||
);
|
||||
}
|
||||
|
||||
public function applies(CaseContext $case): bool
|
||||
{
|
||||
return ! $case->booking->isInternal();
|
||||
}
|
||||
|
||||
public function activities(CaseContext $case): array
|
||||
{
|
||||
$booking = $case->booking;
|
||||
$binding = $case->binding;
|
||||
|
||||
if ($case->profile->payments() === Responsibility::Portal) {
|
||||
$portal = $booking->processChannel()?->name ?? 'das Portal';
|
||||
$viaPortal = $booking->paidViaPortal();
|
||||
|
||||
return [new Activity('payment', 'Zahlung des Gastes an '.$portal, ActivityState::External, match (true) {
|
||||
$booking->total === null => 'zieht das Portal ein',
|
||||
$viaPortal > 0 => 'laut Portal bezahlt: '.Money::format($viaPortal).' von '.Money::format($booking->total).' (Angabe des Portals, kein Geld bei uns)',
|
||||
default => 'zieht das Portal ein; noch keine Zahlungsangabe',
|
||||
})];
|
||||
}
|
||||
|
||||
if ($booking->total === null) {
|
||||
return [new Activity('payment', 'Zahlungen überwachen', $case->later(ActivityState::Waiting), 'erst möglich, wenn der Preis bekannt ist')];
|
||||
}
|
||||
|
||||
$paid = $booking->paidAmount();
|
||||
|
||||
return [
|
||||
new Activity('deposit', 'Anzahlung erhalten', $case->later(match (true) {
|
||||
$binding && $paid >= (int) $booking->deposit => ActivityState::Done,
|
||||
$binding => ActivityState::Waiting,
|
||||
default => ActivityState::Later,
|
||||
}), Money::format((int) $booking->deposit).($booking->deposit_due_on ? ', fällig '.$booking->deposit_due_on->format('d.m.Y') : '')),
|
||||
new Activity('balance', 'Restzahlung erhalten', $case->later(match (true) {
|
||||
$binding && $paid >= $booking->total => ActivityState::Done,
|
||||
$binding && $paid >= (int) $booking->deposit => ActivityState::Waiting,
|
||||
default => ActivityState::Later,
|
||||
}), Money::format(max(0, $booking->total - (int) $booking->deposit)).($booking->balance_due_on ? ', fällig '.$booking->balance_due_on->format('d.m.Y') : '')),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user