feat: comprehensive booking overview for confirmation
This commit is contained in:
@@ -41,4 +41,49 @@ class Pickup
|
||||
|
||||
#[Groups(['api:booking'])]
|
||||
public array $mapping = [];
|
||||
|
||||
/**
|
||||
* Gets the formatted label for the pickup location without pricing.
|
||||
*
|
||||
* Creates user-friendly labels following the pattern:
|
||||
* - Primary format: "City (Street)" if street is available
|
||||
* - Fallback format: "City" if no street information
|
||||
*
|
||||
* @return string The formatted pickup location label
|
||||
*/
|
||||
public function getLabel(): string
|
||||
{
|
||||
$label = $this->city ?? '';
|
||||
|
||||
if (null !== $this->street && '' !== trim($this->street)) {
|
||||
$label .= ' ('.$this->street.')';
|
||||
}
|
||||
|
||||
return $label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the formatted label with pricing information.
|
||||
*
|
||||
* Formats the pickup label with price display:
|
||||
* - Zero/null price: Just the label without price suffix
|
||||
* - Positive price: "Label (€X,XX)" as surcharge
|
||||
* - Negative price: "Label (-X,XX€ Rabatt)" as discount
|
||||
*
|
||||
* @return string The formatted pickup label with pricing
|
||||
*/
|
||||
public function getLabelWithPrice(): string
|
||||
{
|
||||
$label = $this->getLabel();
|
||||
|
||||
if (null === $this->price || 0.0 === $this->price) {
|
||||
return $label;
|
||||
}
|
||||
|
||||
if ($this->price < 0) {
|
||||
return sprintf('%s (-%s€ Rabatt)', $label, number_format(abs($this->price), 2, ',', '.'));
|
||||
}
|
||||
|
||||
return sprintf('%s (€%s)', $label, number_format($this->price, 2, ',', '.'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,4 +228,22 @@ class Travel
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a room by its ID.
|
||||
*
|
||||
* @param int|null $roomId The room ID to search for
|
||||
*
|
||||
* @return Room|null The room with the matching ID, or null if not found
|
||||
*/
|
||||
public function getRoomById(?int $roomId): ?Room
|
||||
{
|
||||
if (null === $roomId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$rooms = $this->getRoomsByIds([$roomId]);
|
||||
|
||||
return false === empty($rooms) ? reset($rooms) : null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -544,46 +544,13 @@ class ParticipantFieldOptionsProvider extends AbstractFieldOptionsProvider
|
||||
return $label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format pickup labels with city and street information.
|
||||
*
|
||||
* Creates user-friendly labels for pickup locations following the existing pattern:
|
||||
* - Primary format: "City (Street)" if street is available
|
||||
* - Fallback format: "City" if no street information
|
||||
*
|
||||
* @param Pickup $pickup The pickup location to format
|
||||
*
|
||||
* @return string The formatted pickup location label
|
||||
*/
|
||||
private function formatPickupLabel(Pickup $pickup): string
|
||||
{
|
||||
$label = $pickup->city ?? '';
|
||||
|
||||
if (null !== $pickup->street && '' !== trim($pickup->street)) {
|
||||
$label .= ' ('.$pickup->street.')';
|
||||
}
|
||||
|
||||
return $label;
|
||||
}
|
||||
|
||||
private function formatPickupLabelWithPrice(?Pickup $pickup): string
|
||||
{
|
||||
if (null === $pickup) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$label = $this->formatPickupLabel($pickup);
|
||||
|
||||
if (null === $pickup->price || 0.0 === $pickup->price) {
|
||||
return $label;
|
||||
}
|
||||
|
||||
if ($pickup->price < 0) {
|
||||
// Negative prices are discounts
|
||||
return sprintf('%s (-%s€ Rabatt)', $label, number_format(abs($pickup->price), 2, ',', '.'));
|
||||
}
|
||||
|
||||
return sprintf('%s (€%s)', $label, number_format($pickup->price, 2, ',', '.'));
|
||||
return $pickup->getLabelWithPrice();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user