$extras extra id => quantity * * @throws QuoteException */ public function quote(Property $property, CarbonImmutable $arrival, CarbonImmutable $departure, ?int $guests, array $extras, int $rent, ?int $taxPersons): PriceQuote { $nights = (int) $arrival->diffInDays($departure); $lines = [new QuoteLine(QuoteLineType::Rent, 'Miete (vereinbart)', 1, $rent, $rent)]; array_push($lines, ...$this->calculator->extraLines($property, $extras, $nights)); $tax = self::touristTax($property, $nights, $taxPersons); if ($tax !== null) { $lines[] = $tax; } return new PriceQuote($arrival, $departure, (int) $guests, $lines, 0, $arrival); } /** * The tourist tax line, or null when no rate is kept or nobody is liable. */ public static function touristTax(Property $property, int $nights, ?int $persons): ?QuoteLine { $rate = (int) ($property->tourist_tax_rate ?? 0); if ($rate <= 0 || (int) $persons <= 0 || $nights <= 0) { return null; } $units = (int) $persons * $nights; return new QuoteLine(QuoteLineType::TouristTax, 'Kurabgabe ('.$persons.' '.((int) $persons === 1 ? 'Person' : 'Personen').' × '.$nights.' Nächte)', $units, $rate, $units * $rate); } /** * The agreed rent of an existing internal case (its rent line), 0 when none. * * @param array|null $quote */ public static function rentOf(?array $quote): int { foreach ((array) ($quote['lines'] ?? []) as $line) { if (($line['type'] ?? null) === QuoteLineType::Rent->value) { return (int) $line['amount']; } } return 0; } }