diff --git a/src/BusProNet/Model/Booking.php b/src/BusProNet/Model/Booking.php index 1cd3295..1e94cdc 100644 --- a/src/BusProNet/Model/Booking.php +++ b/src/BusProNet/Model/Booking.php @@ -64,8 +64,10 @@ class Booking }); } - public function getTransportationServiceForParticipantAndDirection(int $participantIndex, string $direction): ?Service - { + public function getTransportationServiceForParticipantAndDirection( + int $participantIndex, + string $direction + ): ?Service { foreach ($this->transportationServices as $service) { if ($service->direction !== $direction) { continue; @@ -131,6 +133,17 @@ class Booking }); } + public function getCalculatedTotalPrice(): float + { + $totalPrice = 0.0; + + foreach ($this->participants as $index => $participant) { + $totalPrice += $this->getPriceForParticipant($index); + } + + return $totalPrice; + } + 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 593e107..9753cc9 100644 --- a/templates/booking/edit.html.twig +++ b/templates/booking/edit.html.twig @@ -63,7 +63,7 @@

Gesamtpreis

- {{ bookingData.totalPrice|format_currency('EUR') }} + {{ bookingData.calculatedTotalPrice|format_currency('EUR') }}