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) {
|
||||
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']);
|
||||
|
||||
Reference in New Issue
Block a user