feat: dynamically calculated total price

closes #8698xuzaa
This commit is contained in:
Björn Fromme
2025-05-14 12:48:49 +02:00
parent 29fc29091c
commit 2044b83abd
2 changed files with 16 additions and 3 deletions
+15 -2
View File
@@ -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) { foreach ($this->transportationServices as $service) {
if ($service->direction !== $direction) { if ($service->direction !== $direction) {
continue; 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 public function isEditable(): bool
{ {
return $this->travelDate > new \DateTimeImmutable() && false === in_array($this->status, ['S', 'U']); return $this->travelDate > new \DateTimeImmutable() && false === in_array($this->status, ['S', 'U']);
+1 -1
View File
@@ -63,7 +63,7 @@
<h3 class="text-lg font-semibold"> <h3 class="text-lg font-semibold">
Gesamtpreis Gesamtpreis
</h3> </h3>
{{ bookingData.totalPrice|format_currency('EUR') }} {{ bookingData.calculatedTotalPrice|format_currency('EUR') }}
</div> </div>
<div> <div>
<h3 class="text-lg font-semibold"> <h3 class="text-lg font-semibold">