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
@@ -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