- 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>
59 lines
2.5 KiB
PHP
59 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Actions\RecordPayment;
|
|
use App\Enums\BookingStatus;
|
|
use App\Models\Booking;
|
|
use App\Models\Tenant;
|
|
use App\Process\CaseLog;
|
|
use App\Tenancy\TenantRunner;
|
|
use Illuminate\Console\Attributes\Description;
|
|
use Illuminate\Console\Attributes\Signature;
|
|
use Illuminate\Console\Command;
|
|
|
|
#[Signature('cases:recheck-payment-status
|
|
{--apply : Wirklich korrigieren (ohne: nur Vorschau)}')]
|
|
#[Description('Zahlungsstatus bestehender Vorgänge nach der neuen Regel prüfen: nur Geld des Gastes auf unserem Konto zählt als „Anzahlung erhalten“/„Bezahlt“, nicht „laut Portal bezahlt“ (Vorschau, Korrektur nur mit --apply und mit Eintrag im Verlauf)')]
|
|
class RecheckPaymentStatus extends Command
|
|
{
|
|
public function handle(TenantRunner $runner): int
|
|
{
|
|
$apply = (bool) $this->option('apply');
|
|
$rows = [];
|
|
|
|
$succeeded = $runner->each(function (Tenant $tenant) use ($apply, &$rows): void {
|
|
$cases = Booking::query()->with(['payments', 'property', 'importChannel', 'originChannel'])
|
|
->whereIn('status', [BookingStatus::Confirmed, BookingStatus::DepositPaid, BookingStatus::Paid])->get();
|
|
|
|
foreach ($cases as $booking) {
|
|
$target = RecordPayment::statusFor($booking);
|
|
if ($target === null || $target === $booking->status) {
|
|
continue;
|
|
}
|
|
$rows[] = [$tenant->name, $booking->reference, $booking->status->getLabel(), $target->getLabel(), $apply ? 'korrigiert' : 'Vorschau'];
|
|
if ($apply) {
|
|
CaseLog::context(fn () => $booking->update(['status' => $target]), actor: CaseLog::SYSTEM, reason: 'Zahlungsstatus nach neuer Regel: „laut Portal bezahlt“ ist kein Eingang auf unserem Konto (cases:recheck-payment-status).');
|
|
}
|
|
}
|
|
});
|
|
|
|
if ($rows === []) {
|
|
$this->info('Kein Vorgang mit abweichendem Zahlungsstatus.');
|
|
} else {
|
|
$this->table(['Vermieter', 'Vorgang', 'bisher', 'nach neuer Regel', 'Ergebnis'], $rows);
|
|
if (! $apply) {
|
|
$this->comment('Nur Vorschau. Mit --apply werden die Status korrigiert und im Verlauf vermerkt.');
|
|
}
|
|
}
|
|
|
|
if ($succeeded < $runner->tenants()->count()) {
|
|
$this->error('Für mindestens einen Vermieter ist die Prüfung fehlgeschlagen (siehe Log).');
|
|
|
|
return self::FAILURE;
|
|
}
|
|
|
|
return self::SUCCESS;
|
|
}
|
|
}
|