feat: implement screendesign
This commit is contained in:
@@ -69,10 +69,14 @@ class BookingSummaryDataService
|
||||
// Calculate participant count from room capacity (source of truth)
|
||||
$participantCount = $this->calculateParticipantCountFromRooms($bookingDto);
|
||||
|
||||
// Calculate payable amount after voucher deductions
|
||||
$payableAmount = $this->calculatePayableAmount($bookingDto, $pricingData['grandTotal'], $participantPrices);
|
||||
|
||||
return new BookingSummaryDto(
|
||||
selectedRooms: $selectedRooms,
|
||||
participantCount: $participantCount,
|
||||
totalPrice: number_format($totalPrice, 2, ',', '.').' €',
|
||||
totalPrice: $pricingData['grandTotal'],
|
||||
payableAmount: $payableAmount,
|
||||
groupedSelectedRooms: $groupedSelectedRooms,
|
||||
assignmentCounts: $roomCounts,
|
||||
pricingData: $pricingData,
|
||||
@@ -81,13 +85,35 @@ class BookingSummaryDataService
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates participant count from room selections.
|
||||
* Calculates the payable amount after voucher deductions.
|
||||
*
|
||||
* This is the source of truth for participant count, calculated by
|
||||
* multiplying each selected room's quantity by its maximum capacity (maxPax).
|
||||
* @param array<int, float> $participantPrices Prices per participant for percentage voucher calculation
|
||||
*/
|
||||
private function calculatePayableAmount(BookingDto $bookingDto, float $grandTotal, array $participantPrices): float
|
||||
{
|
||||
$acceptedVouchers = $bookingDto->getAcceptedVouchers($participantPrices);
|
||||
|
||||
if (null === $acceptedVouchers) {
|
||||
return $grandTotal;
|
||||
}
|
||||
|
||||
return max(0.0, $grandTotal - $acceptedVouchers->getTotalDiscount());
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates participant count.
|
||||
*
|
||||
* In edit mode, counts actual participants. In create mode, calculates
|
||||
* from room selections by multiplying quantity by maximum capacity (maxPax).
|
||||
*/
|
||||
private function calculateParticipantCountFromRooms(BookingDto $bookingDto): int
|
||||
{
|
||||
// In edit mode, use actual participant count
|
||||
if (BookingDto::MODE_EDIT === $bookingDto->getMode()) {
|
||||
return count($bookingDto->participants);
|
||||
}
|
||||
|
||||
// In create mode, calculate from room selections
|
||||
$totalCapacity = 0;
|
||||
$availableRooms = $bookingDto->travel->getAvailableRooms();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user