feat: selectable drop-offs for inbound bus travel

This commit is contained in:
Björn Fromme
2026-02-17 11:53:39 +01:00
parent 41b0f56b5b
commit 0884a39f3d
31 changed files with 701 additions and 200 deletions
+5 -4
View File
@@ -91,11 +91,12 @@ class BookingParser extends AbstractParser
$pickupsData = $node->filterXPath('//zustiege/zustieg');
if (0 < $pickupsData->count()) {
$booking->pickupsOutbound = $this->pickupsParser->parse($pickupsData);
$booking->pickups = $this->pickupsParser->parse($pickupsData);
}
$pickupsData = $node->filterXPath('//zustiege_rueck/zustieg_rueck');
if (0 < $pickupsData->count()) {
$booking->pickupsInbound = $this->pickupsParser->parse($pickupsData);
$dropOffsData = $node->filterXPath('//ausstiege/ausstieg');
if (0 < $dropOffsData->count()) {
$booking->dropOffs = $this->pickupsParser->parse($dropOffsData);
}
$surchargesData = $node->filterXPath('//zuschlaege/zuschlag');
+14 -14
View File
@@ -76,11 +76,11 @@ class TravelParser extends AbstractParser
$travel->transportationServices = $this
->getTransportationServices($node->filterXPath('//lei_befoerderung/leistung'));
$travel->rooms = $this->getRooms($hotelNode);
$travel->pickupsOutbound = $this->getPickups($node->filterXPath('//zustiege/zustieg'), $dateFrom, true);
$travel->pickupsInbound = $this->getPickups($node->filterXPath('//zustiege_rueck/zustieg_rueck'), $dateTo, false);
$travel->pickups = $this->getPickups($node->filterXPath('//zustiege/zustieg'), $dateFrom, true);
$travel->dropOffs = $this->getPickups($node->filterXPath('//zustiege_rueck/zustieg_rueck'), $dateTo, false);
// Merge inbound prices into outbound pickups for split pricing support
$this->mergeInboundPricesIntoOutboundPickups($travel->pickupsOutbound, $travel->pickupsInbound);
// Merge drop-off prices into pickups for split pricing support
$this->mergeDropOffPricesIntoPickups($travel->pickups, $travel->dropOffs);
$travel->guide = $this->getGuide($node);
@@ -422,21 +422,21 @@ class TravelParser extends AbstractParser
}
/**
* Merges inbound pickup prices into outbound pickups for split pricing support.
* Merges drop-off prices into pickups for split pricing support.
*
* For each outbound pickup, finds the matching inbound pickup by ID and copies
* the inbound price to the outbound pickup's priceInbound property. This enables
* split pricing calculations where pickup costs are distributed between outbound
* For each pickup, finds the matching drop-off by ID and copies
* the inbound price to the pickup's priceInbound property. This enables
* split pricing calculations where costs are distributed between outbound
* and inbound transportation.
*
* @param array<int, Pickup> $pickupsOutbound Outbound pickups indexed by ID (modified in place)
* @param array<int, Pickup> $pickupsInbound Inbound pickups indexed by ID
* @param array<int, Pickup> $pickups Pickups indexed by ID (modified in place)
* @param array<int, Pickup> $dropOffs Drop-offs indexed by ID
*/
private function mergeInboundPricesIntoOutboundPickups(array &$pickupsOutbound, array $pickupsInbound): void
private function mergeDropOffPricesIntoPickups(array &$pickups, array $dropOffs): void
{
foreach ($pickupsOutbound as $pickupId => $outboundPickup) {
if (isset($pickupsInbound[$pickupId])) {
$outboundPickup->priceInbound = $pickupsInbound[$pickupId]->priceInbound;
foreach ($pickups as $pickupId => $pickup) {
if (isset($dropOffs[$pickupId])) {
$pickup->priceInbound = $dropOffs[$pickupId]->priceInbound;
}
}
}