Phase 3: Zahlungen, Mietvertrag, Erinnerungen, Anreiseinformationen
- Zahlungen erfassen (inkl. Erstattungen), Status automatisch: Bestätigt → Anzahlung erhalten → Bezahlt → Abgeschlossen - Anzahlungsfrist bei Bestätigung; kurzfristige Buchungen: Gesamtbetrag sofort - Mietvertrag als PDF (dompdf, Font-Subsetting), bei Bestätigung gespeichert und angehängt; Texte im Admin (Muster) - Täglich: Zahlungserinnerungen (Anzahlung/Rest überfällig, Kopie an Vermieter), Zahlungsaufforderung Rest 7 Tage vorher, Anreiseinfos 7 Tage vorher, Abschluss nach Abreise - Admin: Zahlungen je Buchung, offene Beträge, Vertrag herunterladen/neu erzeugen Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e5f9e0762f
commit
0bf302fcf9
29 files changed
+1248
-18
No files matched your search
@@ -14,6 +14,7 @@
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
|
||||
/**
|
||||
@@ -38,13 +39,19 @@
|
||||
'quote',
|
||||
'total',
|
||||
'deposit',
|
||||
'deposit_due_on',
|
||||
'balance_due_on',
|
||||
'contract_path',
|
||||
'hold_expires_at',
|
||||
'message',
|
||||
'internal_notes',
|
||||
'confirmed_at',
|
||||
'cancelled_at',
|
||||
'review_requested_at',
|
||||
'deposit_reminded_at',
|
||||
'balance_requested_at',
|
||||
'balance_reminded_at',
|
||||
'arrival_info_sent_at',
|
||||
])]
|
||||
class Booking extends Model
|
||||
{
|
||||
@@ -72,11 +79,16 @@ protected function casts(): array
|
||||
'departure' => 'immutable_date',
|
||||
'extras' => 'array',
|
||||
'quote' => 'array',
|
||||
'deposit_due_on' => 'immutable_date',
|
||||
'balance_due_on' => 'immutable_date',
|
||||
'hold_expires_at' => 'immutable_datetime',
|
||||
'confirmed_at' => 'immutable_datetime',
|
||||
'cancelled_at' => 'immutable_datetime',
|
||||
'review_requested_at' => 'immutable_datetime',
|
||||
'deposit_reminded_at' => 'immutable_datetime',
|
||||
'balance_requested_at' => 'immutable_datetime',
|
||||
'balance_reminded_at' => 'immutable_datetime',
|
||||
'arrival_info_sent_at' => 'immutable_datetime',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -132,6 +144,40 @@ public function review(): HasOne
|
||||
return $this->hasOne(Review::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany<Payment, $this>
|
||||
*/
|
||||
public function payments(): HasMany
|
||||
{
|
||||
return $this->hasMany(Payment::class)->orderBy('paid_on');
|
||||
}
|
||||
|
||||
/**
|
||||
* Sum of all payments in cents (refunds are negative).
|
||||
*/
|
||||
public function paidAmount(): int
|
||||
{
|
||||
return (int) ($this->relationLoaded('payments') ? $this->payments->sum('amount') : $this->payments()->sum('amount'));
|
||||
}
|
||||
|
||||
public function openAmount(): int
|
||||
{
|
||||
return max(0, $this->total - $this->paidAmount());
|
||||
}
|
||||
|
||||
public function openDeposit(): int
|
||||
{
|
||||
return max(0, $this->deposit - $this->paidAmount());
|
||||
}
|
||||
|
||||
/**
|
||||
* When the balance is already due at confirmation (short-term booking), the guest pays everything at once.
|
||||
*/
|
||||
public function requiresFullPayment(): bool
|
||||
{
|
||||
return $this->deposit_due_on !== null && $this->balance_due_on->lessThanOrEqualTo($this->deposit_due_on);
|
||||
}
|
||||
|
||||
public function nights(): int
|
||||
{
|
||||
return (int) $this->arrival->diffInDays($this->departure);
|
||||
|
||||
Reference in new issue
Block a user