Files
fewo-stommer/app/Models/Payment.php
LarsandClaude Opus 5.5 40d20cb7d1 Pakete 7 und 9: Auskunft und Buchungswunsch, Aufenthalt und Abschluss (Zwischenstand)
- 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>
2026-11-02 08:29:19 +01:00

57 lines
1.8 KiB
PHP

<?php
namespace App\Models;
use App\Actions\RecordPayment;
use App\Enums\PaymentKind;
use App\Enums\PaymentMethod;
use App\Models\Concerns\BelongsToTenant;
use App\Process\CaseLog;
use Database\Factories\PaymentFactory;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* A payment in euro cents (negative amount = refund) and its kind: the guest paid us, the portal reports the guest paid
* it, the portal paid out to us, or we refunded the guest ({@see PaymentKind}).
*/
#[Fillable(['booking_id', 'amount', 'paid_on', 'method', 'note', 'recorded_by', 'kind', 'source'])]
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', RecordPayment::summary($payment->booking, $payment->kind ?? PaymentKind::Guest, (int) $payment->amount, $payment->paid_on, $payment->source), data: ['payment_id' => $payment->id, 'kind' => ($payment->kind ?? PaymentKind::Guest)->value]);
}
});
}
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'paid_on' => 'immutable_date',
'method' => PaymentMethod::class,
'kind' => PaymentKind::class,
];
}
/**
* @return BelongsTo<Booking, $this>
*/
public function booking(): BelongsTo
{
return $this->belongsTo(Booking::class);
}
}