fix: adopt travel info urls

This commit is contained in:
Björn Fromme
2025-03-21 16:26:49 +01:00
parent b88be16550
commit 6326e1ffc3
5 changed files with 27 additions and 4 deletions
+2
View File
@@ -46,4 +46,6 @@ APP_BPN_IP=
APP_BPN_PORT=
APP_BPN_DEBUG=false
APP_TRAVEL_INFO_BASE_URL=https://www.ep-reisen.de/reiseinformationen/
API_KEYS=
+2
View File
@@ -4,6 +4,7 @@
# Put parameters here that don't need to change on each machine where the app is deployed
# https://symfony.com/doc/current/best_practices.html#use-parameters-for-application-configuration
parameters:
travel_info_base_url: '%env(APP_TRAVEL_INFO_BASE_URL)%'
services:
# default configuration for services in *this* file
@@ -12,6 +13,7 @@ services:
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
bind:
$xmlPath: '%kernel.project_dir%/var/xmlexport'
$travelInfoBaseUrl: '%env(APP_TRAVEL_INFO_BASE_URL)%'
$logger: '@monolog.logger.core'
# makes classes in src/ available to be used as services
+1
View File
@@ -34,6 +34,7 @@ class Booking
public array $surcharges = [];
public ?int $invoiceNumber = null;
public ?float $totalPrice = null;
public ?string $travelInfoUrl = null;
public function getBalance(): float
{
+19 -1
View File
@@ -22,6 +22,7 @@ class TravelLoader extends AbstractLoader
public function __construct(
private readonly HotelLoader $hotelDataLoader,
CacheInterface $cache,
private readonly string $travelInfoBaseUrl,
?string $xmlPath = null
) {
parent::__construct($cache, $xmlPath);
@@ -345,7 +346,24 @@ class TravelLoader extends AbstractLoader
continue;
}
$booking->travelData = $this->loadById($travelId);
$travelData = $this->loadById($travelId);
$booking->travelData = $travelData;
if (null === $travelData || null === $travelData->dateFrom) {
continue;
}
$now = new \DateTimeImmutable();
$travelDate = $travelData->dateFrom;
$travelCode = $travelData->code;
if ($travelDate->modify('-5 days') < $now) {
$booking->travelInfoUrl = sprintf(
'%s/%s',
rtrim($this->travelInfoBaseUrl, '/'),
str_replace('/', '-', $travelCode)
);
}
}
}
}
+3 -3
View File
@@ -75,11 +75,11 @@
target="_blank">
Rechnung
</a>
{% if booking.hasDocuments %}
<a href="{{ path('app_booking_documents', { 'id': booking.id }) }}"
{% if booking.travelInfoUrl is not null %}
<a href="{{ booking.travelInfoUrl }}"
class="button bg-button bg-pink button--small"
target="_blank">
Reisedokumente
Reiseinfos
</a>
{% endif %}
</div>