Files
fewo-stommer/app/Models/Payment.php
LarsandClaude Opus 5.5 3bcfc09417
Deploy FeWo mit PipelineManager / deploy (push) Successful in 4m44s
Pakete 8, 5 und 6: Beträge und Zahlungen, Ändern und Stornieren, A6 im Vorgang
- Paket 8: Zahlungsarten (Gast an uns, laut Portal, Auszahlung, Erstattung),
  Portalbeträge als Angaben mit Quelle, Übersicht nach Zuständigkeit (R09).
- Paket 5: Ändern mit Folgenvorschau, vereinbart oder dem Gast vorgeschlagen
  (signierter Link), ein Stornoweg mit Grund und Erstattung, Portalstorno erst
  nach Bestätigung.
- Paket 6: eigene Nutzung, Besuch und Sperre als Vorgang mit Kurabgabe und
  Aufenthaltsbestätigung; Bestandsübernahme der Sperren mit identischem Export.
- Wirksame Einstellungen (Expertenansicht), Abnahmekatalog T01–T14, Ergebnis-,
  Abnahme- und Konfigurationsdokument.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 22:16:47 +01:00

57 lines
1.7 KiB
PHP

<?php
namespace App\Models;
use App\Enums\PaymentKind;
use App\Enums\PaymentMethod;
use App\Models\Concerns\BelongsToTenant;
use App\Process\CaseLog;
use App\Support\Money;
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', ($payment->kind ?? PaymentKind::Guest)->getLabel().': '.Money::format(abs($payment->amount)).($payment->source ? ' ('.$payment->source.')' : ''), data: ['payment_id' => $payment->id]);
}
});
}
/**
* 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);
}
}