fix: streamlined discount display in all breakdowns

This commit is contained in:
Björn Fromme committed 2026-08-18 13:04:33 +02:00
1 parent 8dee65d0dc
commit ef24c9a616
10 files changed
+185 -118

No files matched your search

+3 -15
View File
@@ -356,28 +356,16 @@ class AccommodationBookingService
return;
}
$accommodationBase = (int) ($breakdown['basePrice'] ?? 0) + (int) ($breakdown['additionalPersonsPrice'] ?? 0);
$boardBase = (int) ($breakdown['boardPrice'] ?? 0);
$servicesBase = (int) ($breakdown['servicesPrice'] ?? 0);
$total = (int) ($breakdown['total'] ?? 0)
- $this->discountAmount($accommodationBase, $booking->getAccommodationDiscount())
- $this->discountAmount($boardBase, $booking->getBoardServiceDiscount())
- $this->discountAmount($servicesBase, $booking->getAdditionalServicesDiscount());
// The raw breakdown is what gets frozen; the discounted total comes from the same
// calculator the templates read, so the stored number always matches what is shown.
$booking->setPriceSnapshot(
$breakdown,
$total,
$this->breakdownCalculator->withDiscounts($booking, $breakdown)['discountedTotal'],
(string) ($breakdown['currency'] ?? $booking->getAccommodation()?->getCurrency() ?? 'EUR'),
self::PRICING_VERSION,
);
}
private function discountAmount(int $base, ?int $percent): int
{
return null !== $percent ? (int) round($base * $percent / 100) : 0;
}
public function sendNotificationEmail(AccommodationBooking $booking): void
{
$this->sendBookingEmail(