feat: correct calculation and display of individual pricing
This commit is contained in:
@@ -8,6 +8,7 @@ use App\Controller\Traits\HtmxControllerTrait;
|
||||
use App\Form\BookingCreateStep2Type;
|
||||
use App\Form\Model\BookingCreateDto;
|
||||
use App\Form\Model\ParticipantDto;
|
||||
use App\Service\BookingPriceCalculatorService;
|
||||
use App\Service\BookingService;
|
||||
use App\Service\TravelDataService;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
@@ -29,6 +30,7 @@ class CreateStep2Controller extends AbstractController
|
||||
|
||||
public function __construct(
|
||||
private readonly BookingService $bookingService,
|
||||
private readonly BookingPriceCalculatorService $priceCalculator,
|
||||
private readonly TravelDataService $travelDataService,
|
||||
) {
|
||||
}
|
||||
@@ -80,12 +82,14 @@ class CreateStep2Controller extends AbstractController
|
||||
$roomAssignmentCounts = $this->bookingService->getRoomAssignmentCounts($bookingCreateDto);
|
||||
$availableRooms = $bookingCreateDto->travel->getAvailableRooms();
|
||||
$groupedSelectedRooms = $this->bookingService->groupRoomSelectionsByType($bookingCreateDto->getSelectedRooms(), $availableRooms);
|
||||
$participantPrices = $this->priceCalculator->calculateAllParticipantIndividualPrices($bookingCreateDto);
|
||||
|
||||
return $this->render('booking/create_step_2.html.twig', [
|
||||
'bookingCreateDto' => $bookingCreateDto,
|
||||
'participantsCount' => $participantsCount,
|
||||
'pricingData' => $summary['pricing'],
|
||||
'assignmentCounts' => $roomAssignmentCounts,
|
||||
'participantPrices' => $participantPrices,
|
||||
'form' => $form->createView(),
|
||||
'groupedSelectedRooms' => $groupedSelectedRooms,
|
||||
]);
|
||||
@@ -132,6 +136,7 @@ class CreateStep2Controller extends AbstractController
|
||||
$roomAssignmentCounts = $this->bookingService->getRoomAssignmentCounts($bookingCreateDto);
|
||||
$availableRooms = $bookingCreateDto->travel->getAvailableRooms();
|
||||
$groupedSelectedRooms = $this->bookingService->groupRoomSelectionsByType($bookingCreateDto->getSelectedRooms(), $availableRooms);
|
||||
$participantPrices = $this->priceCalculator->calculateAllParticipantIndividualPrices($bookingCreateDto);
|
||||
|
||||
// The DTO is now updated with the latest selection and submitted data has been cleaned.
|
||||
// We can now render the blocks with the fresh data.
|
||||
@@ -144,6 +149,7 @@ class CreateStep2Controller extends AbstractController
|
||||
'participantsCount' => $participantsCount,
|
||||
'pricingData' => $summary['pricing'],
|
||||
'assignmentCounts' => $roomAssignmentCounts,
|
||||
'participantPrices' => $participantPrices,
|
||||
'groupedSelectedRooms' => $groupedSelectedRooms,
|
||||
]
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user