fix: list boarding surcharges per leg and count them once in the summary
This commit is contained in:
1 parent
57b86a8fbc
commit
d4296f30a5
2 files changed
+104
-75
No files matched your search
@@ -328,6 +328,25 @@ class BookingPricingAssemblerTest extends TestCase
|
||||
$this->assertEqualsWithDelta(71.6, $group['groupTotal'], 0.001, 'Both legs are charged at €17,90 per participant');
|
||||
}
|
||||
|
||||
public function testBoardingSurchargeIsListedPerLegAsBusProBillsIt(): void
|
||||
{
|
||||
$bookingDto = $this->createBusBookingDto('BUS', 'BUS');
|
||||
|
||||
$group = $this->findServiceGroup($this->assembler->calculateServicePricing($bookingDto), 'Beförderung');
|
||||
|
||||
$this->assertSame([
|
||||
['label' => 'Abfahrtsortzuschlag (Hinfahrt)', 'participantCount' => 2, 'totalPrice' => 35.8],
|
||||
['label' => 'Abfahrtsortzuschlag (Rückfahrt)', 'participantCount' => 2, 'totalPrice' => 35.8],
|
||||
], array_map(
|
||||
static fn (array $line): array => [
|
||||
'label' => $line['label'],
|
||||
'participantCount' => $line['participantCount'],
|
||||
'totalPrice' => round($line['totalPrice'], 2),
|
||||
],
|
||||
$group['services']
|
||||
), 'A free bus leg adds no Beförderung line of its own');
|
||||
}
|
||||
|
||||
public function testBoardingSurchargeSkipsTheReturnLegWhenItIsNotByBus(): void
|
||||
{
|
||||
$bookingDto = $this->createBusBookingDto('BUS', 'PKW');
|
||||
@@ -409,6 +428,37 @@ class BookingPricingAssemblerTest extends TestCase
|
||||
], $surchargePricing);
|
||||
}
|
||||
|
||||
public function testSurchargePricingOmitsBoardingSurchargesListedAmongTheServices(): void
|
||||
{
|
||||
// Booking 98398: BusPro reports the boarding surcharge as untyped <zuschlag> lines,
|
||||
// which the transportation group already lists per leg.
|
||||
$booking = new Booking();
|
||||
$booking->surcharges = [
|
||||
$this->createSurcharge('Abfahrtsortzuschlag (Hinfahrt)', 141.9, range(0, 10)),
|
||||
$this->createSurcharge('Abfahrtsortzuschlag (Rückfahrt)', 141.9, range(0, 10)),
|
||||
$this->createSurcharge('Stornokosten', 120.0, [3]),
|
||||
];
|
||||
|
||||
$this->assertSame([
|
||||
['label' => 'Stornokosten', 'participantCount' => 1, 'totalPrice' => 120.0],
|
||||
], $this->assembler->calculateSurchargePricing($booking));
|
||||
}
|
||||
|
||||
public function testPricingBreakdownCountsTheBoardingSurchargeOnceInEditMode(): void
|
||||
{
|
||||
$bookingDto = $this->createBusBookingDto('BUS', 'BUS');
|
||||
$bookingDto->booking = new Booking();
|
||||
$bookingDto->booking->surcharges = [
|
||||
$this->createSurcharge('Abfahrtsortzuschlag (Hinfahrt)', 35.8, [0, 1]),
|
||||
$this->createSurcharge('Abfahrtsortzuschlag (Rückfahrt)', 35.8, [0, 1]),
|
||||
];
|
||||
|
||||
$breakdown = $this->assembler->getPricingBreakdown($bookingDto);
|
||||
|
||||
$this->assertArrayNotHasKey('surcharges', $breakdown);
|
||||
$this->assertEqualsWithDelta(71.6, $breakdown['grandTotal'], 0.001);
|
||||
}
|
||||
|
||||
public function testPricingBreakdownOmitsSurchargesWhenAllAreZero(): void
|
||||
{
|
||||
$travel = new Travel();
|
||||
|
||||
Reference in new issue
Block a user