feat: list and respect all surcharges

This commit is contained in:
Björn Fromme
2024-12-03 16:36:02 +01:00
parent aa0e3ef978
commit 273db3bdb7
3 changed files with 30 additions and 10 deletions
@@ -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;
+7
View File
@@ -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']);