Vorgangskern und geführte Vorgangsbearbeitung (Pakete 1 und 2, Prozessarchitektur v0.10)
- Buchung ist der einheitliche Vorgang: Eingangsart, Vorgangsart A1–A6, eingefrorenes Abwicklungsprofil, gespeicherter Verlauf (booking_events); Gast, Personen und Beträge dürfen unbekannt sein, Platzhalter-Gäste werden migriert und nicht mehr angelegt - Einstellungen in Ebenen: Vermieterstandard (So arbeite ich), Abweichung der Wohnung (Experte), Abweichung je Portal und Eingangsart; ersetzt booking_model als Steuergröße - Ein Weg für extern verbindliche Buchungen (TakeOverExternalBooking) statt RecordPortalBooking und "Akte anlegen"; Portalpreis als belegte Gesamtposition - Startseite "Zu erledigen", neue Vorgangsseite mit nächstem Schritt, Automatik-Schalter, "Beenden" mit Storno statt Statusumschaltung; Status von Hand nur im Expertenmodus - Migration übernimmt bisheriges Verhalten unverändert (abweichende Wohnungswerte bleiben als Abweichung), Bericht: php artisan process:settings-report Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9005c12164
commit
3a728c3255
78 files changed
+4296
-1180
No files matched your search
+21
-48
@@ -7,68 +7,41 @@
|
||||
use Carbon\CarbonImmutable;
|
||||
|
||||
/**
|
||||
* The price a portal charged for a stay as booking columns. Our own calculation is the basis; the difference to the
|
||||
* portal price becomes an adjustment line, so the quote adds up to what the portal charged. When our price list does
|
||||
* not cover the stay (or the stay breaks a rule the portal did not know), the portal price stands alone as one line.
|
||||
* The price of a booking that was made binding on a portal, as booking columns. The total the guest agreed to on the
|
||||
* portal is taken over as one line with its source – it is never split into our own price items, and our own price
|
||||
* list never replaces it (docs/Prozessarchitektur/Querschnitt/Preise_und_Zahlungen.md). An unknown portal price stays
|
||||
* unknown: no quote, no total, no payment plan.
|
||||
*/
|
||||
class PortalPrice
|
||||
{
|
||||
public const LABEL = 'Abweichung Portalpreis';
|
||||
|
||||
public function __construct(private PriceCalculator $calculator) {}
|
||||
public const LABEL = 'Gesamtpreis laut Portal';
|
||||
|
||||
/**
|
||||
* @return array<string, mixed> booking columns (quote, total, deposit, price_adjustment, ...)
|
||||
* @return array{quote: ?array<string, mixed>, total: ?int, deposit: ?int, balance_due_on: ?string, price_adjustment: null, price_adjustment_label: null}
|
||||
*/
|
||||
public function columns(Property $property, StayRequest $stay, int $portalTotal): array
|
||||
public function columns(Property $property, CarbonImmutable $arrival, CarbonImmutable $departure, ?int $guests, ?int $portalTotal, ?string $channelName = null): array
|
||||
{
|
||||
try {
|
||||
$quote = $this->calculator->calculate($property, $stay);
|
||||
} catch (QuoteException) {
|
||||
return $this->columnsOf($this->standalone($property, $stay, $portalTotal), null);
|
||||
if ($portalTotal === null) {
|
||||
return ['quote' => null, 'total' => null, 'deposit' => null, 'balance_due_on' => null, 'price_adjustment' => null, 'price_adjustment_label' => null];
|
||||
}
|
||||
|
||||
$difference = max($portalTotal - $quote->total(), -$quote->rent());
|
||||
if ($difference === 0) {
|
||||
return $this->columnsOf($quote, null);
|
||||
}
|
||||
$label = self::LABEL.($channelName ? ' ('.$channelName.')' : '');
|
||||
$quote = new PriceQuote(
|
||||
$arrival,
|
||||
$departure,
|
||||
(int) $guests,
|
||||
[new QuoteLine(QuoteLineType::Accommodation, $label, 1, $portalTotal, $portalTotal)],
|
||||
$property->deposit_percent,
|
||||
$arrival->subDays($property->balance_due_days_before_arrival),
|
||||
);
|
||||
|
||||
return $this->columnsOf($quote->withLine(new QuoteLine(QuoteLineType::Adjustment, self::LABEL, 1, $difference, $difference)), $difference);
|
||||
}
|
||||
|
||||
/**
|
||||
* Quote for a stay without a known portal price: our calculation, or an empty quote when it is not possible.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function unknownColumns(Property $property, StayRequest $stay): array
|
||||
{
|
||||
try {
|
||||
return $this->columnsOf($this->calculator->calculate($property, $stay), null);
|
||||
} catch (QuoteException) {
|
||||
return $this->columnsOf($this->standalone($property, $stay, 0), null);
|
||||
}
|
||||
}
|
||||
|
||||
private function standalone(Property $property, StayRequest $stay, int $total): PriceQuote
|
||||
{
|
||||
$lines = $total > 0 ? [new QuoteLine(QuoteLineType::Accommodation, 'Preis laut Portal', 1, $total, $total)] : [];
|
||||
|
||||
return new PriceQuote($stay->arrival, $stay->departure, $stay->guests, $lines, $property->deposit_percent, CarbonImmutable::instance($stay->arrival)->subDays($property->balance_due_days_before_arrival));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function columnsOf(PriceQuote $quote, ?int $adjustment): array
|
||||
{
|
||||
return [
|
||||
'quote' => $quote->toArray(),
|
||||
'quote' => [...$quote->toArray(), 'source' => 'portal'],
|
||||
'total' => $quote->total(),
|
||||
'deposit' => $quote->deposit(),
|
||||
'balance_due_on' => $quote->balanceDueOn->toDateString(),
|
||||
'price_adjustment' => $adjustment,
|
||||
'price_adjustment_label' => $adjustment !== null ? self::LABEL : null,
|
||||
'price_adjustment' => null,
|
||||
'price_adjustment_label' => null,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user