wip: transportation services with discount

This commit is contained in:
Björn Fromme
2025-09-10 14:08:44 +02:00
parent a3ea02a136
commit 5469c834a6
3 changed files with 9 additions and 9 deletions
-1
View File
@@ -151,7 +151,6 @@ class Travel
{ {
$services = array_filter($this->transportationServices, function (Service $service) use ($direction, $filterAvailable) { $services = array_filter($this->transportationServices, function (Service $service) use ($direction, $filterAvailable) {
return $direction === $service->direction return $direction === $service->direction
&& $service->price >= 0
&& (false === $filterAvailable || $service->available > 0 || null === $service->available); && (false === $filterAvailable || $service->available > 0 || null === $service->available);
}); });
+2
View File
@@ -178,6 +178,8 @@ class TravelParser extends AbstractParser
$service->label = $this->getStringOrNullValue($serviceNode->filterXPath('//text')); $service->label = $this->getStringOrNullValue($serviceNode->filterXPath('//text'));
$service->direction = $this->getStringOrNullValue($serviceNode->filterXPath('//richtung')); $service->direction = $this->getStringOrNullValue($serviceNode->filterXPath('//richtung'));
$service->status = $this->getStringOrNullValue($serviceNode->filterXPath('//status')); $service->status = $this->getStringOrNullValue($serviceNode->filterXPath('//status'));
$service->price = $this
->stringToFloat($this->getStringOrNullValue($serviceNode->filterXPath('//preis')));
// Parse optional description from hinweis node // Parse optional description from hinweis node
$description = $this->getStringOrNullValue($serviceNode->filterXPath('//hinweis')); $description = $this->getStringOrNullValue($serviceNode->filterXPath('//hinweis'));
@@ -406,15 +406,14 @@ class ParticipantFieldOptionsProvider extends AbstractFieldOptionsProvider
{ {
$label = $service->label; $label = $service->label;
// Transportation type indicators removed for cleaner labels if (null === $service->price || 0.0 === $service->price) {
return $service->label;
}
// Add pricing with discount indication if ($service->price > 0) {
if (null !== $service->price) { $label .= sprintf(' (€%s)', number_format($service->price, 2, ',', '.'));
if ($service->price > 0) { } else {
$label .= sprintf(' (+€%.2f)', $service->price); $label .= sprintf(' (-%s€ Rabatt)', number_format(abs($service->price), 2, ',', '.'));
} elseif ($service->price < 0) {
$label .= sprintf(' (-€%.2f Discount)', abs($service->price));
}
} }
// Add availability warning if limited // Add availability warning if limited