fix: give chatbot pickups per-leg surcharges including the return leg

This commit is contained in:
fromme committed 2026-10-09 08:38:57 +02:00
1 parent ac5ca7b18b
commit 3cb1548f2f
8 files changed
+58 -7

No files matched your search

+19 -3
View File
@@ -127,10 +127,26 @@ class TripCatalogTest extends TestCase
self::assertCount(1, $trip['dates']);
self::assertSame('Hotel Eins', $trip['dates'][0]['hotels'][0]['hotel']);
self::assertSame([['room' => 'Zimmer', 'board' => 'HP', 'nights' => 7, 'price' => 450, 'availability' => 'frei']], $trip['dates'][0]['hotels'][0]['rooms']);
self::assertSame([['city' => 'Frankfurt', 'place' => 'Flughafen', 'departure' => '2026-12-04 23:30', 'surcharge' => 5.9]], $trip['dates'][0]['pickups']);
self::assertSame([['city' => 'Frankfurt', 'place' => 'Flughafen', 'departure' => '2026-12-04 23:30', 'surchargeOutbound' => 5.9, 'surchargeReturn' => 5.9, 'surchargeRoundTrip' => 11.8]], $trip['dates'][0]['pickups']);
self::assertArrayNotHasKey('guide', $trip['dates'][0]);
}
public function testPickupSurchargesArePerLegAndAnUnpricedLegIsFree(): void
{
$row = $this->row('VTH', 2, '2026-12-05', 'HOT1', [$this->room(450)]);
$row['pickups'] = [
['busProId' => 18, 'code' => 'ESS', 'city' => 'Essen', 'street' => 'Hbf', 'price' => 17.9, 'returnLeg' => true, 'returnPrice' => null, 'datetime' => null],
['busProId' => 4, 'code' => 'FRA', 'city' => 'Frankfurt', 'street' => 'Flughafen', 'price' => null, 'returnLeg' => false, 'returnPrice' => null, 'datetime' => null],
];
$pickups = $this->catalog([$row])->get('VTH')['dates'][0]['pickups'] ?? null;
self::assertSame([
['city' => 'Essen', 'place' => 'Hbf', 'surchargeOutbound' => 17.9, 'surchargeReturn' => 0.0, 'surchargeRoundTrip' => 17.9],
['city' => 'Frankfurt', 'place' => 'Flughafen', 'surchargeOutbound' => 0.0],
], $pickups, 'BusPro bills only priced legs; no return leg, no return surcharge');
}
public function testProductsHiddenFromTheWebsiteSearchAreNotOfferedButCanBeNamed(): void
{
$rows = [$this->row('GRP', 2, '2026-12-05', 'HOT1', [$this->room(300)])];
@@ -225,8 +241,8 @@ class TripCatalogTest extends TestCase
],
'rooms' => $rooms,
'pickups' => [
['busProId' => 4, 'code' => 'FRA', 'city' => 'Frankfurt', 'street' => 'Flughafen', 'price' => 5.9, 'datetime' => $dateFrom->modify('-1 day')->format('Y-m-d').'T23:30:00'],
['busProId' => 0, 'code' => null, 'city' => null, 'street' => null, 'price' => null, 'datetime' => null],
['busProId' => 4, 'code' => 'FRA', 'city' => 'Frankfurt', 'street' => 'Flughafen', 'price' => 5.9, 'returnLeg' => true, 'returnPrice' => 5.9, 'datetime' => $dateFrom->modify('-1 day')->format('Y-m-d').'T23:30:00'],
['busProId' => 0, 'code' => null, 'city' => null, 'street' => null, 'price' => null, 'returnLeg' => false, 'returnPrice' => null, 'datetime' => null],
],
'guide' => ['name' => 'Anna', 'phone' => '0170'],
];