Pakete 8, 5 und 6: Beträge und Zahlungen, Ändern und Stornieren, A6 im Vorgang
Deploy FeWo mit PipelineManager / deploy (push) Successful in 4m44s
Deploy FeWo mit PipelineManager / deploy (push) Successful in 4m44s
- 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>
This commit is contained in:
1 parent
33f8f899d6
commit
3bcfc09417
77 files changed
+3638
-122
No files matched your search
+80
-3
@@ -7,6 +7,8 @@
|
||||
use App\Enums\BookingTaskKind;
|
||||
use App\Enums\CaseType;
|
||||
use App\Enums\IntakeKind;
|
||||
use App\Enums\InternalKind;
|
||||
use App\Enums\PaymentKind;
|
||||
use App\Enums\ProcessingMode;
|
||||
use App\Enums\ReferralSource;
|
||||
use App\Enums\Responsibility;
|
||||
@@ -91,13 +93,19 @@
|
||||
'balance_requested_at',
|
||||
'balance_reminded_at',
|
||||
'arrival_info_sent_at',
|
||||
'internal_kind',
|
||||
'occasion',
|
||||
'tourist_tax_persons',
|
||||
'tourist_tax_note',
|
||||
'portal_cancellation_requested_at',
|
||||
'export_uid',
|
||||
])]
|
||||
class Booking extends Model
|
||||
{
|
||||
/** @use HasFactory<BookingFactory> */
|
||||
use BelongsToTenant, HasChannelProvenance, HasFactory;
|
||||
|
||||
public const DIRECT_SOURCES = ['website', 'manual', 'phone', 'direct', 'email'];
|
||||
public const DIRECT_SOURCES = ['website', 'manual', 'phone', 'direct', 'email', 'internal'];
|
||||
|
||||
public function isDirect(): bool
|
||||
{
|
||||
@@ -177,6 +185,8 @@ protected function casts(): array
|
||||
'contact_requested_at' => 'immutable_datetime',
|
||||
'guest_confirmed_at' => 'immutable_datetime',
|
||||
'archived_at' => 'immutable_datetime',
|
||||
'internal_kind' => InternalKind::class,
|
||||
'portal_cancellation_requested_at' => 'immutable_datetime',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -267,6 +277,7 @@ public function bookingChannelLabel(): string
|
||||
'phone' => 'Telefon',
|
||||
'email' => 'E-Mail',
|
||||
'direct' => 'Direkt',
|
||||
'internal' => 'Eigene Belegung',
|
||||
default => $this->source,
|
||||
};
|
||||
}
|
||||
@@ -336,7 +347,73 @@ public function payments(): HasMany
|
||||
*/
|
||||
public function paidAmount(): int
|
||||
{
|
||||
return (int) ($this->relationLoaded('payments') ? $this->payments->sum('amount') : $this->payments()->sum('amount'));
|
||||
return $this->sumOfPayments([PaymentKind::Guest, PaymentKind::GuestViaPortal, PaymentKind::Refund]);
|
||||
}
|
||||
|
||||
/**
|
||||
* What the guest paid us directly, less refunds (money on our account from the guest).
|
||||
*/
|
||||
public function paidToUs(): int
|
||||
{
|
||||
return $this->sumOfPayments([PaymentKind::Guest, PaymentKind::Refund]);
|
||||
}
|
||||
|
||||
/**
|
||||
* What the guest paid to the portal according to the portal (no money on our account).
|
||||
*/
|
||||
public function paidViaPortal(): int
|
||||
{
|
||||
return $this->sumOfPayments([PaymentKind::GuestViaPortal]);
|
||||
}
|
||||
|
||||
/**
|
||||
* What the portal paid out to us.
|
||||
*/
|
||||
public function payoutsReceived(): int
|
||||
{
|
||||
return $this->sumOfPayments([PaymentKind::PortalPayout]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<PaymentKind> $kinds
|
||||
*/
|
||||
private function sumOfPayments(array $kinds): int
|
||||
{
|
||||
$payments = $this->relationLoaded('payments') ? $this->payments : $this->payments()->get();
|
||||
|
||||
return (int) $payments->filter(fn (Payment $payment): bool => in_array($payment->kind ?? PaymentKind::Guest, $kinds, true))->sum('amount');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasOne<Cancellation, $this>
|
||||
*/
|
||||
public function cancellation(): HasOne
|
||||
{
|
||||
return $this->hasOne(Cancellation::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany<CaseAmount, $this>
|
||||
*/
|
||||
public function amounts(): HasMany
|
||||
{
|
||||
return $this->hasMany(CaseAmount::class)->orderBy('id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany<BookingChange, $this>
|
||||
*/
|
||||
public function changes(): HasMany
|
||||
{
|
||||
return $this->hasMany(BookingChange::class)->orderBy('id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Own use, private stay or block (A6).
|
||||
*/
|
||||
public function isInternal(): bool
|
||||
{
|
||||
return $this->intake === IntakeKind::Internal;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -366,7 +443,7 @@ public function requiresFullPayment(): bool
|
||||
*/
|
||||
public function wantsPaymentTasks(): bool
|
||||
{
|
||||
return $this->process()->payments() === Responsibility::Landlord && $this->total !== null && $this->total > 0;
|
||||
return ! $this->isInternal() && $this->process()->payments() === Responsibility::Landlord && $this->total !== null && $this->total > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\ChangeBasis;
|
||||
use App\Enums\ChangeStatus;
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* One change of a booking (package 5): what it was before and after, who asked and why, from when, and on which basis
|
||||
* the guest agreed – or, as long as it is only proposed, that the guest still has to agree.
|
||||
*/
|
||||
#[Fillable(['booking_id', 'status', 'requested_by', 'basis', 'reason', 'effective_on', 'agreed_at', 'agreed_by', 'before', 'after', 'consequences', 'expires_at', 'decided_at', 'decision_ip_hash', 'applied_at', 'confirmation_sent_at', 'recorded_by'])]
|
||||
class BookingChange extends Model
|
||||
{
|
||||
use BelongsToTenant;
|
||||
|
||||
public const REQUESTERS = ['guest' => 'Der Gast', 'landlord' => 'Wir (Vermieter)', 'portal' => 'Das Portal'];
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'status' => ChangeStatus::class,
|
||||
'basis' => ChangeBasis::class,
|
||||
'effective_on' => 'immutable_date',
|
||||
'agreed_at' => 'immutable_datetime',
|
||||
'before' => 'array',
|
||||
'after' => 'array',
|
||||
'consequences' => 'array',
|
||||
'expires_at' => 'immutable_datetime',
|
||||
'decided_at' => 'immutable_datetime',
|
||||
'applied_at' => 'immutable_datetime',
|
||||
'confirmation_sent_at' => 'immutable_datetime',
|
||||
];
|
||||
}
|
||||
|
||||
/** @return BelongsTo<Booking, $this> */
|
||||
public function booking(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Booking::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* The change in one line, e.g. "07.11.–10.11.2026 → 07.11.–12.11.2026 · 2 → 3 Personen · 368,00 € → 450,00 €".
|
||||
*/
|
||||
public function summary(): string
|
||||
{
|
||||
return implode(' · ', (array) ($this->consequences['summary'] ?? []));
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@
|
||||
* The record of a cancelled booking: when, how many days before arrival, the cost proposed by the cancellation rule
|
||||
* and the amount the landlord finally charges. Cancelled bookings stay in the system for this history.
|
||||
*/
|
||||
#[Fillable(['booking_id', 'cancelled_on', 'initiated_by', 'has_policy', 'policy_name', 'days_before', 'percent', 'base_amount', 'calculated_fee', 'final_fee', 'paid_amount', 'status', 'note', 'settled_at'])]
|
||||
#[Fillable(['booking_id', 'cancelled_on', 'initiated_by', 'has_policy', 'policy_name', 'days_before', 'percent', 'base_amount', 'calculated_fee', 'final_fee', 'paid_amount', 'status', 'note', 'settled_at', 'reason', 'recorded_by'])]
|
||||
class Cancellation extends Model
|
||||
{
|
||||
use BelongsToTenant;
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\AmountKind;
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use App\Process\CaseLog;
|
||||
use App\Support\Money;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* An amount of a case as a source states it (package 8): the portal's price positions, what it keeps as commission,
|
||||
* what it announces to pay out, instalments of the guest. Stored as stated – contradicting statements stand side by
|
||||
* side, and nothing is derived from them.
|
||||
*/
|
||||
#[Fillable(['booking_id', 'kind', 'label', 'amount', 'source', 'stated_on', 'due_on', 'note', 'recorded_by'])]
|
||||
class CaseAmount extends Model
|
||||
{
|
||||
use BelongsToTenant;
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::created(function (CaseAmount $amount): void {
|
||||
if ($amount->booking !== null) {
|
||||
CaseLog::record($amount->booking, 'amount', ($amount->label ?: $amount->kind->getLabel()).': '.Money::format($amount->amount).($amount->source ? ' laut '.$amount->source : ''), data: ['case_amount_id' => $amount->id]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return ['kind' => AmountKind::class, 'amount' => 'integer', 'stated_on' => 'immutable_date', 'due_on' => 'immutable_date'];
|
||||
}
|
||||
|
||||
/** @return BelongsTo<Booking, $this> */
|
||||
public function booking(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Booking::class);
|
||||
}
|
||||
|
||||
public function title(): string
|
||||
{
|
||||
return $this->label ?: $this->kind->getLabel();
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\PaymentKind;
|
||||
use App\Enums\PaymentMethod;
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use App\Process\CaseLog;
|
||||
@@ -13,9 +14,10 @@
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* A received payment (negative amount = refund), in euro cents.
|
||||
* 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'])]
|
||||
#[Fillable(['booking_id', 'amount', 'paid_on', 'method', 'note', 'recorded_by', 'kind', 'source'])]
|
||||
class Payment extends Model
|
||||
{
|
||||
/** @use HasFactory<PaymentFactory> */
|
||||
@@ -25,7 +27,7 @@ protected static function booted(): void
|
||||
{
|
||||
static::created(function (Payment $payment): void {
|
||||
if ($payment->booking !== null) {
|
||||
CaseLog::record($payment->booking, 'payment', ($payment->amount < 0 ? 'Erstattung ' : 'Zahlung ').Money::format(abs($payment->amount)).' erfasst', data: ['payment_id' => $payment->id]);
|
||||
CaseLog::record($payment->booking, 'payment', ($payment->kind ?? PaymentKind::Guest)->getLabel().': '.Money::format(abs($payment->amount)).($payment->source ? ' ('.$payment->source.')' : ''), data: ['payment_id' => $payment->id]);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -40,6 +42,7 @@ protected function casts(): array
|
||||
return [
|
||||
'paid_on' => 'immutable_date',
|
||||
'method' => PaymentMethod::class,
|
||||
'kind' => PaymentKind::class,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
'included_guests',
|
||||
'extra_guest_fee_per_night',
|
||||
'cleaning_fee',
|
||||
'tourist_tax_rate',
|
||||
'deposit_percent',
|
||||
'balance_due_days_before_arrival',
|
||||
'hold_hours',
|
||||
|
||||
Reference in new issue
Block a user