diff --git a/src/BusProNet/ApiResponseParser/BookingResponseParser.php b/src/BusProNet/ApiResponseParser/BookingResponseParser.php index 67a6361..27ae5af 100644 --- a/src/BusProNet/ApiResponseParser/BookingResponseParser.php +++ b/src/BusProNet/ApiResponseParser/BookingResponseParser.php @@ -226,11 +226,7 @@ class BookingResponseParser foreach ($xml->zuschlag as $item) { $attributes = $item->attributes(); - $label = (string) $attributes['bezeichnung']; - // Skip invalid entries - if (empty($label)) { - continue; - } + $label = empty($attributes['bezeichnung']) ? 'unbekannt' : (string) $attributes['bezeichnung']; $surcharge = new Surcharge(); $surcharge->label = $label; diff --git a/src/BusProNet/Model/Booking.php b/src/BusProNet/Model/Booking.php index 9d50f29..0bebd2b 100644 --- a/src/BusProNet/Model/Booking.php +++ b/src/BusProNet/Model/Booking.php @@ -121,6 +121,13 @@ class Booking return $price; } + public function getSurchargesForParticipant(int $participantIndex): array + { + return array_filter($this->surcharges, function (Surcharge $surcharge) use ($participantIndex) { + return in_array($participantIndex, $surcharge->mapping); + }); + } + public function isEditable(): bool { return $this->travelDate > new \DateTimeImmutable() && false === in_array($this->status, ['S', 'U']); diff --git a/templates/booking/edit.html.twig b/templates/booking/edit.html.twig index 511d287..14f5522 100644 --- a/templates/booking/edit.html.twig +++ b/templates/booking/edit.html.twig @@ -202,11 +202,28 @@
{% endif %} -
-

- Gesamtpreis -

- {{ bookingData.priceForParticipant(participant.index)|format_currency('EUR') }} +
+
+

+ Gesamtpreis +

+ {{ bookingData.priceForParticipant(participant.index)|format_currency('EUR') }} +
+ {% set surcharges = bookingData.surchargesForParticipant(participant.index) %} + {% if surcharges|length > 0 %} +
+

+ Zuschläge +

+
    + {% for surcharge in surcharges %} +
  • + {{ surcharge.label }}: {{ surcharge.individualPrice[participant.index]|format_currency('EUR') }} +
  • + {% endfor %} +
+
+ {% endif %}