feat: dynamically calculated total price
closes #8698xuzaa
This commit is contained in:
@@ -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']);
|
||||||
|
|||||||
@@ -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">
|
||||||
|
|||||||
Reference in New Issue
Block a user