feat: consistent display of included services and prices

This commit is contained in:
Björn Fromme
2025-12-11 11:17:03 +01:00
parent e42ef2d3c9
commit b4c03160ca
11 changed files with 54 additions and 27 deletions
+1
View File
@@ -14,6 +14,7 @@ class AppExtension extends AbstractExtension
new TwigFilter('file_size', [AppRuntime::class, 'formatBytes']),
new TwigFilter('file_icon', [AppRuntime::class, 'fileIconFilter'], ['is_safe' => ['html']]),
new TwigFilter('format_money', [AppRuntime::class, 'formatMoney']),
new TwigFilter('format_service_price', [AppRuntime::class, 'formatServicePrice']),
new TwigFilter('map_gender', [AppRuntime::class, 'mapGender']),
new TwigFilter('map_status', [AppRuntime::class, 'mapStatus']),
new TwigFilter('map_country', [AppRuntime::class, 'mapCountry']),
+20
View File
@@ -52,6 +52,26 @@ class AppRuntime implements RuntimeExtensionInterface
return $this->intlExtension->formatCurrency($amount, 'EUR');
}
/**
* Formats a service price, showing "inkl." for zero-priced (included) services.
*
* @param float|int|null $price The price to format
*
* @return string The formatted price or "inkl." for zero/null prices
*/
public function formatServicePrice(float|int|null $price): string
{
if (null === $price) {
return '';
}
if (0 === $price || 0.0 === $price) {
return 'inkl.';
}
return $this->intlExtension->formatCurrency((float) $price, 'EUR');
}
public function mapStatus(string $status): string
{
$status = strtoupper($status);