fix: exclude cancelled participants' services from price breakdown
This commit is contained in:
1 parent
553ec901f3
commit
849a19b67a
4 files changed
+74
-4
No files matched your search
@@ -100,6 +100,27 @@ class BookingConfiguratorBabyTest extends TestCase
|
||||
$this->assertSame('Mandatory Service', $participant->additionalServices[0]->label);
|
||||
}
|
||||
|
||||
public function testPreselectMandatoryServicesSkipsCanceledParticipant(): void
|
||||
{
|
||||
$travel = $this->createTravelWithMandatoryServices();
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
|
||||
$participant = new ParticipantDto();
|
||||
$participant->index = 0;
|
||||
$participant->status = 'S';
|
||||
$participant->dateOfBirth = $travel->dateFrom->modify('-25 years');
|
||||
$participant->additionalServices = [];
|
||||
$bookingDto->participants[0] = $participant;
|
||||
|
||||
$this->participantEligibilityService
|
||||
->method('isParticipantEligible')
|
||||
->willReturn(true);
|
||||
|
||||
$this->bookingService()->preselectDefaultServices($bookingDto);
|
||||
|
||||
$this->assertSame([], $participant->additionalServices, 'Mandatory services should not be preselected for cancelled participants');
|
||||
}
|
||||
|
||||
public function testPreselectMandatoryServicesIncludesAdultParticipant(): void
|
||||
{
|
||||
$travel = $this->createTravelWithMandatoryServices();
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Service;
|
||||
|
||||
use App\BusProNet\Constants;
|
||||
use App\BusProNet\Model\Booking;
|
||||
use App\BusProNet\Model\Insurance;
|
||||
use App\BusProNet\Model\Pickup;
|
||||
@@ -358,6 +359,40 @@ class BookingPricingAssemblerTest extends TestCase
|
||||
$this->assertEqualsWithDelta($group['groupTotal'], $participantTotal, 0.001, 'Summary and per-participant totals must agree');
|
||||
}
|
||||
|
||||
public function testServicePricingExcludesCanceledParticipants(): void
|
||||
{
|
||||
$travel = new Travel();
|
||||
$travel->insurances = [];
|
||||
|
||||
$bookingDto = new BookingDto($travel, 2);
|
||||
$bookingDto->participants = [];
|
||||
|
||||
foreach (['F', 'S'] as $index => $status) {
|
||||
$mandatoryService = new Service();
|
||||
$mandatoryService->id = 1;
|
||||
$mandatoryService->label = 'Kurtaxe';
|
||||
$mandatoryService->subType = Constants::TOKEN_ADDITIONAL;
|
||||
$mandatoryService->mandatory = true;
|
||||
$mandatoryService->price = 12.5;
|
||||
|
||||
$participant = new ParticipantDto();
|
||||
$participant->index = $index;
|
||||
$participant->status = $status;
|
||||
$participant->additionalServices = [$mandatoryService];
|
||||
$participant->transportationOutbound = $this->createTransportationService(203222, 'Bus-Hinfahrt', 'BUS');
|
||||
$participant->pickup = $this->createBoardingPoint(18, 17.9);
|
||||
$bookingDto->participants[$index] = $participant;
|
||||
}
|
||||
|
||||
$servicePricing = $this->assembler->calculateServicePricing($bookingDto);
|
||||
|
||||
$this->assertCount(2, $servicePricing);
|
||||
foreach ($servicePricing as $group) {
|
||||
$this->assertSame(1, $group['services'][0]['participantCount'], $group['groupName'].' counts only the active participant');
|
||||
}
|
||||
$this->assertEqualsWithDelta(12.5 + 17.9, array_sum(array_column($servicePricing, 'groupTotal')), 0.001);
|
||||
}
|
||||
|
||||
public function testSurchargePricingOmitsZeroAmountSurcharges(): void
|
||||
{
|
||||
$booking = new Booking();
|
||||
|
||||
Reference in new issue
Block a user