Compare commits

..
18 Commits
Author SHA1 Message Date
Björn Fromme 8f2653c706 wip: administrative roles 2026-07-17 14:27:13 +02:00
Björn Fromme d0358e584c wip: notification emails surrounding groups bookings and inquiries 2026-07-17 12:30:14 +02:00
Björn Fromme a1751f699b wip: finalize offer layout 2026-07-17 12:16:33 +02:00
Björn Fromme e7bfb19ac9 wip: group inquiries and booking 2026-07-16 17:13:26 +02:00
Björn Fromme 18a890e50e chore: adjust tests to recent changes 2026-07-16 17:13:15 +02:00
Björn Fromme 3c9caeaad0 wip: group inquiries and bookings 2026-07-16 17:13:15 +02:00
Björn Fromme eba1a901d6 wip: refactored price overrides 2026-07-16 17:13:15 +02:00
Björn Fromme f8e4fe4d1e wip: refactor admin controllers 2026-07-16 17:13:15 +02:00
Björn Fromme d9f29a5a5a wip: extend model, admin crud 2026-07-16 17:13:15 +02:00
Björn Fromme a6ba4fac0d chore: update deployer config with individual htpasswd files 2026-07-16 17:13:15 +02:00
Björn Fromme a9bd46be4a wip: integrate with bpn-connect for admin crud, calendars 2026-07-16 17:13:15 +02:00
Björn Fromme d0511ba2cd fix: provide required parameter, make parameter required 2026-07-16 17:13:15 +02:00
Björn Fromme 487597c828 wip: api endpoint for calendar data to be consumed by cms 2026-07-16 17:13:15 +02:00
Björn Fromme b3210a7a27 wip: api client for bpn-connect 2026-07-16 17:13:15 +02:00
Björn Fromme a8c0801c32 chore: add develop environment to deployer config 2026-07-16 17:13:15 +02:00
Björn Fromme 690391da98 wip: replace flatpickr 2026-07-16 17:13:15 +02:00
Björn Fromme b075e3ecfc wip: implement admin crud 2026-07-16 17:13:15 +02:00
Björn Fromme 13491f346d wip: implement model 2026-07-16 17:13:15 +02:00
36 changed files with 373 additions and 799 deletions

No files matched your search

Generated
+263 -263
View File
File diff suppressed because it is too large. Load diff
@@ -8,7 +8,6 @@ league_oauth2_server:
enable_auth_code_grant: true
enable_refresh_token_grant: true
enable_password_grant: false
enable_implicit_grant: false
access_token_ttl: PT10M
resource_server:
public_key: '%env(resolve:OAUTH_PUBLIC_KEY)%'
+1 -1
View File
@@ -208,6 +208,7 @@ services:
- 'App\Form\Service\ParticipantTransportationInboundFieldHandler'
- 'App\Form\Service\ParticipantPickupFieldHandler'
- 'App\Form\Service\ParticipantDropOffFieldHandler'
- 'App\Form\Service\ParticipantParkingFieldHandler'
- 'App\Form\Service\ParticipantRentalInsuranceFieldHandler'
- 'App\Form\Service\ParticipantLicensePlateFieldHandler'
# Complex handlers with dependencies - use service references
@@ -217,7 +218,6 @@ services:
- '@App\Form\Service\ParticipantInsuranceFieldHandler'
- '@App\Form\Service\ParticipantPurchaseVoucherFieldHandler'
- '@App\Form\Service\ParticipantPromoVoucherFieldHandler'
- '@App\Form\Service\ParticipantParkingFieldHandler'
# Booking Status Rules
App\BusProNet\Service\StatusRule\Selection1473StatusRule: ~
@@ -29,7 +29,7 @@ class ImportGroupsLegacyDataCommand extends Command
private const int DEFAULT_MIN_NIGHTS = 1;
private const Season DEFAULT_SEASON = Season::SECONDARY;
/** @var array<int, AdditionalServiceType> maps groupspriceoption "type" column to AdditionalServiceType */
/** @var array<int, string> maps groupspriceoption "type" column to AdditionalServiceType */
private const array OPTION_TYPE_MAP = [
1 => AdditionalServiceType::Flat,
2 => AdditionalServiceType::PerPerson,
@@ -5,8 +5,6 @@ declare(strict_types=1);
namespace App\Controller\Admin\Accommodation;
use App\Entity\Groups\Accommodation;
use App\Entity\Groups\AdditionalService;
use App\Entity\Groups\BoardService;
use App\Form\Admin\Groups\AccommodationType;
use App\Service\CmsDataProvider;
use Doctrine\ORM\EntityManagerInterface;
@@ -54,31 +52,10 @@ class EditController extends AbstractController
return $this->redirectToRoute('app_admin_accommodation_edit', ['id' => $accommodation->getId()]);
}
$boardServices = $accommodation->getBoardServices()->toArray();
usort($boardServices, $this->compareServices(...));
$additionalServices = $accommodation->getAdditionalServices()->toArray();
usort($additionalServices, $this->compareServices(...));
return $this->render('admin/accommodation/edit.html.twig', [
'accommodation' => $accommodation,
'form' => $form,
'cmsData' => $cmsData,
'boardServices' => $boardServices,
'additionalServices' => $additionalServices,
]);
}
/**
* DateFrom ascending, then free (price 0) before paid, then alphabetically by label.
*/
private function compareServices(BoardService|AdditionalService $a, BoardService|AdditionalService $b): int
{
$aFree = 0 === $a->getPrice() ? 0 : 1;
$bFree = 0 === $b->getPrice() ? 0 : 1;
return $a->getDateFrom() <=> $b->getDateFrom()
?: $aFree <=> $bFree
?: strnatcasecmp($a->getLabel(), $b->getLabel());
}
}
+1 -8
View File
@@ -5,8 +5,6 @@ declare(strict_types=1);
namespace App\Controller\Groups;
use App\Entity\Groups\Accommodation;
use App\Entity\Groups\AdditionalService;
use App\Entity\Groups\BoardService;
use App\Exception\AccommodationSessionNotFoundException;
use App\Form\AccommodationBookingConfirmationType;
use App\Form\AccommodationInquiryConfirmationType;
@@ -140,12 +138,7 @@ class Step4Controller extends AbstractAccommodationController
}
/**
* @param array{
* boardServices: BoardService[],
* additionalServices: AdditionalService[],
* groupedAdditionalServices: array<string, AdditionalService[]>,
* ungroupedAdditionalServices: AdditionalService[]
* } $services
* @param array{boardServices: array, additionalServices: array} $services
*/
private function persistBooking(Request $request, AccommodationBookingDto $dto, Accommodation $accommodation, array $services): void
{
+2 -2
View File
@@ -6,9 +6,9 @@ interface BlameableEntityInterface
{
public function getCreatedBy(): ?User;
public function setCreatedBy(?User $createdBy): self;
public function setCreatedBy(?User $createdBy);
public function getUpdatedBy(): ?User;
public function setUpdatedBy(?User $updatedBy): self;
public function setUpdatedBy(?User $updatedBy);
}
+4 -4
View File
@@ -4,11 +4,11 @@ namespace App\Entity;
interface TimestampableEntityInterface
{
public function getCreatedAt(): \DateTimeImmutable;
public function getCreatedAt();
public function setCreatedAt(\DateTimeImmutable $createdAt): self;
public function setCreatedAt(\DateTimeImmutable $createdAt);
public function getUpdatedAt(): ?\DateTimeImmutable;
public function getUpdatedAt();
public function setUpdatedAt(\DateTimeImmutable $updatedAt): self;
public function setUpdatedAt(\DateTimeImmutable $updatedAt);
}
+2 -15
View File
@@ -3,7 +3,6 @@
namespace App\EventListener;
use App\Entity\BlameableEntityInterface;
use App\Entity\User;
use Doctrine\Bundle\DoctrineBundle\Attribute\AsDoctrineListener;
use Doctrine\ORM\Event\PrePersistEventArgs;
use Doctrine\ORM\Event\PreUpdateEventArgs;
@@ -26,13 +25,7 @@ class BlamableEntityListener
return;
}
$user = $this->security->getUser();
if (!$user instanceof User) {
return;
}
$entity->setCreatedBy($user);
$entity->setCreatedBy($this->security->getUser());
}
public function preUpdate(PreUpdateEventArgs $args): void
@@ -43,12 +36,6 @@ class BlamableEntityListener
return;
}
$user = $this->security->getUser();
if (!$user instanceof User) {
return;
}
$entity->setUpdatedBy($user);
$entity->setUpdatedBy($this->security->getUser());
}
}
@@ -21,7 +21,6 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\Range;
/** @extends AbstractType<AccommodationBooking> */
class AccommodationBookingType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
@@ -16,7 +16,6 @@ use Symfony\Component\Form\Extension\Core\Type\MoneyType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/** @extends AbstractType<AccommodationPrice> */
class AccommodationPriceType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
@@ -12,7 +12,6 @@ use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/** @extends AbstractType<Accommodation> */
class AccommodationType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
@@ -15,7 +15,6 @@ use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/** @extends AbstractType<AdditionalService> */
class AdditionalServiceType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
@@ -13,7 +13,6 @@ use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/** @extends AbstractType<BoardService> */
class BoardServiceType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
-1
View File
@@ -8,7 +8,6 @@ use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\OptionsResolver\OptionsResolver;
/** @extends AbstractType<mixed> */
class DatepickerType extends AbstractType
{
public function configureOptions(OptionsResolver $resolver): void
@@ -647,28 +647,13 @@ class ParticipantFieldOptionsProvider extends AbstractFieldOptionsProvider
return [];
}
$fieldOptions = [
return [
'label' => $this->serviceLabelFormatter->formatServiceLabelForServices(
Constants::SERVICE_LABELS[Constants::TOKEN_PARKING],
$parkingServices
),
'required' => false,
];
// There's only ever one parking type, so check readonly state against the single service
$parkingService = reset($parkingServices);
// Add service description as data attribute for frontend use
if (null !== $parkingService->description && '' !== trim($parkingService->description)) {
$fieldOptions['attr']['data-description'] = $parkingService->description;
}
if ($this->shouldMakeServiceReadonly($parkingService, $bookingDto, $participantIndex, 'parking')) {
$fieldOptions['attr']['readonly'] = true;
$fieldOptions['attr']['data-tooltip'] = 'ausgebucht';
}
return $fieldOptions;
};
// Bulk insurance booking checkbox (applicant only - controls insurance assignment for all participants)
@@ -10,7 +10,6 @@ use App\BusProNet\Utility\DirectionMapper;
use App\Form\Model\BookingDto;
use App\Form\Model\ParticipantDto;
use App\Form\Service\Abstract\AbstractParticipantFieldHandler;
use App\Service\ServiceAvailabilityCalculator;
/**
* Handles parking service selection for self-organized transportation.
@@ -21,11 +20,6 @@ use App\Service\ServiceAvailabilityCalculator;
*/
class ParticipantParkingFieldHandler extends AbstractParticipantFieldHandler
{
public function __construct(
private readonly ServiceAvailabilityCalculator $serviceAvailabilityCalculator,
) {
}
public function getFieldName(): string
{
return 'parking';
@@ -79,22 +73,7 @@ class ParticipantParkingFieldHandler extends AbstractParticipantFieldHandler
// Store parking service object for pricing calculation
if (true === $isParkingSelected) {
$parkingService = $this->findParkingService($bookingDto, $participantIndex);
// Reject the selection if the service is sold out, in case the client
// bypassed the readonly UI state (e.g. a stale form or manual submission)
if (
null !== $parkingService
&& BookingDto::MODE_EDIT !== $bookingDto->getMode()
&& $this->serviceAvailabilityCalculator->isServiceUnavailable($parkingService->id, $bookingDto, $participantIndex)
) {
$participant->parking = false;
$participant->parkingService = null;
return;
}
$participant->parkingService = $parkingService;
$participant->parkingService = $this->findParkingService($bookingDto, $participantIndex);
} else {
$participant->parkingService = null;
}
-19
View File
@@ -1,19 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Model;
final readonly class CalendarDay
{
public function __construct(
public string $date,
public bool $hasPrice,
public bool $hasBoard,
public bool $hasAdditional,
public bool $isBlocked,
public ?string $tooltip,
public bool $isToday,
) {
}
}
-18
View File
@@ -1,18 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Model;
final readonly class CalendarMonth
{
/**
* @param array<int, CalendarDay> $days keyed by day-of-month number
*/
public function __construct(
public string $label,
public int $firstDow,
public array $days,
) {
}
}
-22
View File
@@ -1,22 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Model;
final readonly class PriceTimelineItem
{
public function __construct(
public string $dateFrom,
public string $dateTo,
public ?string $season,
public ?int $includedPax,
public float $pricePerNight,
public float $priceAdditionalPerson,
public ?float $defaultPricePerNight,
public ?float $defaultPriceAdditionalPerson,
public string $currency,
public ?string $type,
) {
}
}
@@ -13,7 +13,6 @@ use Doctrine\Persistence\ManagerRegistry;
*/
class AdditionalServiceRepository extends ServiceEntityRepository
{
/** @use FindsByAccommodationAndDateRangeTrait<AdditionalService> */
use FindsByAccommodationAndDateRangeTrait;
public function __construct(ManagerRegistry $registry)
@@ -13,7 +13,6 @@ use Doctrine\Persistence\ManagerRegistry;
*/
class BoardServiceRepository extends ServiceEntityRepository
{
/** @use FindsByAccommodationAndDateRangeTrait<BoardService> */
use FindsByAccommodationAndDateRangeTrait;
public function __construct(ManagerRegistry $registry)
@@ -5,21 +5,13 @@ declare(strict_types=1);
namespace App\Repository\Groups;
use App\Entity\Groups\Accommodation;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
/**
* @template T of object
*
* @phpstan-require-extends ServiceEntityRepository<T>
*/
trait FindsByAccommodationAndDateRangeTrait
{
/**
* Returns all records active during the given date range.
*
* Overlap condition: entity.dateFrom <= dateTo AND entity.dateTo >= dateFrom
*
* @return array<int, T>
*/
public function findByAccommodationAndDateRange(
Accommodation $accommodation,
@@ -156,12 +156,6 @@ class AccommodationBookingService
}
}
$boardServices = $this->sortServicesByPriceThenLabel($boardServices);
$ungrouped = $this->sortServicesByPriceThenLabel($ungrouped);
foreach ($grouped as $groupName => $groupServices) {
$grouped[$groupName] = $this->sortServicesByPriceThenLabel($groupServices);
}
return [
'boardServices' => $boardServices,
'additionalServices' => $additionalServices,
@@ -170,27 +164,6 @@ class AccommodationBookingService
];
}
/**
* Free services (price 0) first, then alphabetically; each group sorted alphabetically.
*
* @template T of BoardService|AdditionalService
*
* @param T[] $services
*
* @return T[]
*/
private function sortServicesByPriceThenLabel(array $services): array
{
usort($services, static function (BoardService|AdditionalService $a, BoardService|AdditionalService $b): int {
$aFree = 0 === $a->getPrice() ? 0 : 1;
$bFree = 0 === $b->getPrice() ? 0 : 1;
return $aFree <=> $bFree ?: strnatcasecmp($a->getLabel(), $b->getLabel());
});
return $services;
}
/**
* Determines whether the booking must be treated as non-binding and why.
*
+3 -6
View File
@@ -18,9 +18,6 @@ class GroupsPriceCalculator
/** @var array<string, int|float> */
private array $config;
/**
* @param array<string, int|float> $config
*/
public function __construct(
private readonly PriceTimelineBuilder $priceTimelineBuilder,
array $config,
@@ -137,9 +134,9 @@ class GroupsPriceCalculator
): array {
$items = array_map(
fn(array $s) => [
'label' => $s['label'],
'price' => $s['price'],
'type' => AdditionalServiceType::tryFrom($s['type']) ?? AdditionalServiceType::Flat,
'label' => $s['label'] ?? '',
'price' => $s['price'] ?? 0,
'type' => AdditionalServiceType::tryFrom($s['type'] ?? '') ?? AdditionalServiceType::Flat,
],
$additionalServiceSnapshots,
);
+13 -28
View File
@@ -6,7 +6,6 @@ namespace App\Service;
use App\Entity\Groups\AccommodationPrice;
use App\Enum\Groups\PriceType;
use App\Model\PriceTimelineItem;
class PriceTimelineBuilder
{
@@ -34,8 +33,6 @@ class PriceTimelineBuilder
* changes mid-discount period. A gap (no winner) resets both trackers.
*
* @param AccommodationPrice[] $prices
*
* @return list<PriceTimelineItem>
*/
public function buildTimeline(
array $prices,
@@ -104,32 +101,20 @@ class PriceTimelineBuilder
// Step 3: extend the previous row if both the winner and the default-price entity
// are unchanged; otherwise open a new row.
if ($lastWinner === $winner && $lastDefault === $defaultWinner) {
$lastRow = $rows[count($rows) - 1];
$rows[count($rows) - 1] = new PriceTimelineItem(
dateFrom: $lastRow->dateFrom,
dateTo: $segDateTo->format('Y-m-d'),
season: $lastRow->season,
includedPax: $lastRow->includedPax,
pricePerNight: $lastRow->pricePerNight,
priceAdditionalPerson: $lastRow->priceAdditionalPerson,
defaultPricePerNight: $lastRow->defaultPricePerNight,
defaultPriceAdditionalPerson: $lastRow->defaultPriceAdditionalPerson,
currency: $lastRow->currency,
type: $lastRow->type,
);
$rows[count($rows) - 1]['dateTo'] = $segDateTo->format('Y-m-d');
} else {
$rows[] = new PriceTimelineItem(
dateFrom: $segStart->format('Y-m-d'),
dateTo: $segDateTo->format('Y-m-d'),
season: $winner->getSeason()?->value,
includedPax: $winner->getIncludedPax(),
pricePerNight: round($winner->getPricePerNight() / 100, 2),
priceAdditionalPerson: round($winner->getPriceAdditionalPerson() / 100, 2),
defaultPricePerNight: $defaultWinner !== null ? round($defaultWinner->getPricePerNight() / 100, 2) : null,
defaultPriceAdditionalPerson: $defaultWinner !== null ? round($defaultWinner->getPriceAdditionalPerson() / 100, 2) : null,
currency: $currency,
type: $winner->getType()?->value,
);
$rows[] = [
'dateFrom' => $segStart->format('Y-m-d'),
'dateTo' => $segDateTo->format('Y-m-d'),
'season' => $winner->getSeason()?->value,
'includedPax' => $winner->getIncludedPax(),
'pricePerNight' => round($winner->getPricePerNight() / 100, 2),
'priceAdditionalPerson' => round($winner->getPriceAdditionalPerson() / 100, 2),
'defaultPricePerNight' => $defaultWinner !== null ? round($defaultWinner->getPricePerNight() / 100, 2) : null,
'defaultPriceAdditionalPerson' => $defaultWinner !== null ? round($defaultWinner->getPriceAdditionalPerson() / 100, 2) : null,
'currency' => $currency,
'type' => $winner->getType()?->value,
];
$lastWinner = $winner;
$lastDefault = $defaultWinner;
}
@@ -173,11 +173,6 @@ class ServiceAvailabilityCalculator
$serviceUsage[$participant->skiPass->id] = ($serviceUsage[$participant->skiPass->id] ?? 0) + 1;
}
// Parking service (single selection)
if (null !== $participant->parkingService && null !== $participant->parkingService->id) {
$serviceUsage[$participant->parkingService->id] = ($serviceUsage[$participant->parkingService->id] ?? 0) + 1;
}
// Transportation services (single selection each)
if (null !== $participant->transportationOutbound && null !== $participant->transportationOutbound->id) {
$serviceUsage[$participant->transportationOutbound->id] = ($serviceUsage[$participant->transportationOutbound->id] ?? 0) + 1;
@@ -236,7 +231,6 @@ class ServiceAvailabilityCalculator
Constants::TOKEN_RENTALS,
Constants::TOKEN_SKI_PASS,
Constants::TOKEN_BOARD,
Constants::TOKEN_PARKING,
];
foreach ($additionalServiceTokens as $token) {
+16 -40
View File
@@ -8,8 +8,6 @@ use App\BpnConnect\ContingentsClient;
use App\BpnConnect\Exception\BpnConnectException;
use App\BpnConnect\Model\ContingentStatus;
use App\Entity\Groups\Accommodation;
use App\Model\CalendarDay;
use App\Model\CalendarMonth;
use Carbon\CarbonImmutable;
use Psr\Cache\InvalidArgumentException;
use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;
@@ -35,7 +33,6 @@ class Calendar
public Accommodation $accommodation;
public ?string $startMonth = null;
/** @var list<CalendarMonth> */
public array $months = [];
public string $prevMonth = '';
public string $nextMonth = '';
@@ -122,9 +119,6 @@ class Calendar
return $blocked;
}
/**
* @return CarbonImmutable[]
*/
private function collectAllDates(): array
{
$dates = [];
@@ -157,9 +151,6 @@ class Calendar
return $dates;
}
/**
* @param CarbonImmutable[] $dates
*/
private function determineStartMonth(array $dates): CarbonImmutable
{
$earliest = min($dates);
@@ -172,13 +163,6 @@ class Calendar
return CarbonImmutable::now()->startOfMonth();
}
/**
* @return array<string, array{
* price: array{label: string, span: float, priority: int}|null,
* board: array{label: string, span: float}|null,
* additional: array{label: string, span: float}|null,
* }>
*/
private function buildCoverageMap(): array
{
$map = [];
@@ -240,7 +224,7 @@ class Calendar
}
$typeLabel = $service->getType() !== null
? self::TYPE_LABELS[$service->getType()->value]
? (self::TYPE_LABELS[$service->getType()->value] ?? $service->getType()->value)
: '';
$label = sprintf('Zusatz: %s%s', $service->getLabel(), $typeLabel !== '' ? ' (' . $typeLabel . ')' : '');
@@ -262,15 +246,7 @@ class Calendar
return $map;
}
/**
* @param array<string, array{
* price: array{label: string, span: float, priority: int}|null,
* board: array{label: string, span: float}|null,
* additional: array{label: string, span: float}|null,
* }> $map
* @param array<string, true> $blockedDates
*/
private function buildMonth(CarbonImmutable $month, array $map, array $blockedDates): CalendarMonth
private function buildMonth(CarbonImmutable $month, array $map, array $blockedDates): array
{
$start = $month->startOfMonth();
$today = CarbonImmutable::now()->format('Y-m-d');
@@ -299,21 +275,21 @@ class Calendar
$parts[] = 'Buchungsstopp';
}
$days[$d] = new CalendarDay(
date: $dateStr,
hasPrice: isset($coverage['price']),
hasBoard: isset($coverage['board']),
hasAdditional: isset($coverage['additional']),
isBlocked: $isBlocked,
tooltip: !empty($parts) ? implode(' | ', $parts) : null,
isToday: $dateStr === $today,
);
$days[$d] = [
'date' => $dateStr,
'hasPrice' => isset($coverage['price']),
'hasBoard' => isset($coverage['board']),
'hasAdditional' => isset($coverage['additional']),
'isBlocked' => $isBlocked,
'tooltip' => !empty($parts) ? implode(' | ', $parts) : null,
'isToday' => $dateStr === $today,
];
}
return new CalendarMonth(
label: self::MONTHS[$month->month] . ' ' . $month->year,
firstDow: $firstDow,
days: $days,
);
return [
'label' => self::MONTHS[$month->month] . ' ' . $month->year,
'firstDow' => $firstDow,
'days' => $days,
];
}
}
@@ -188,7 +188,7 @@
</tr>
</thead>
<tbody>
{% for service in boardServices %}
{% for service in accommodation.boardServices %}
<tr>
<td>
{{ service.dateFrom | date('d.m.Y') }} - {{ service.dateTo | date('d.m.Y') }}
@@ -258,7 +258,7 @@
</tr>
</thead>
<tbody>
{% for service in additionalServices %}
{% for service in accommodation.additionalServices %}
<tr>
<td>
{{ service.dateFrom | date('d.m.Y') }} - {{ service.dateTo | date('d.m.Y') }}
@@ -608,12 +608,11 @@
{% set parkingService = bookingDto.travel.getAdditionalServicesBySubTypes(constant('App\\BusProNet\\Constants::TOKEN_PARKING'))|first %}
{{ macros.checkbox_row(
form.parking,
parkingService.label|default('Parkplatz'),
'Parkplatz',
parkingService.price|default(null),
form.parking.vars.attr['data-description']|default(null),
'Info',
htmxAttr,
false
null,
null,
htmxAttr
) }}
{% endif %}
</table>
+1 -1
View File
@@ -45,7 +45,7 @@
{% endif %}
{% for dayNum, day in month.days %}
<div class="w-6 px-px">
<div class="h-3 {{ attribute(day, row.key) ? row.color : 'bg-gray-100' }}"></div>
<div class="h-3 {{ day[row.key] ? row.color : 'bg-gray-100' }}"></div>
</div>
{% endfor %}
</div>
+3 -3
View File
@@ -109,7 +109,7 @@
{% endif %}
</td>
<td class="border border-primary-bg p-2 align-top w-32 text-right">
<div>{% if service.price == 0 %}inkl.{% else %}{{ (service.price / 100)|format_currency(ctx.accommodation.currency) }}{% endif %}</div>
<div>{{ (service.price / 100)|format_currency(ctx.accommodation.currency) }}</div>
<div class="text-xs text-gray-500">pro Person und Nacht</div>
</td>
<td class="border border-primary-bg p-2 align-top w-12 text-center">
@@ -155,7 +155,7 @@
{% endif %}
</td>
<td class="border border-primary-bg p-2 align-top w-32 text-right">
<div>{% if service.price == 0 %}inkl.{% else %}{{ (service.price / 100)|format_currency(ctx.accommodation.currency) }}{% endif %}</div>
<div>{{ (service.price / 100)|format_currency(ctx.accommodation.currency) }}</div>
<div class="text-xs text-gray-500">{{ service.type.label | trans }}</div>
</td>
<td class="border border-primary-bg p-2 align-top w-12 text-center">
@@ -193,7 +193,7 @@
{% endif %}
</td>
<td class="border border-primary-bg p-2 align-top w-32 text-right">
<div>{% if service.price == 0 %}inkl.{% else %}{{ (service.price / 100)|format_currency(ctx.accommodation.currency) }}{% endif %}</div>
<div>{{ (service.price / 100)|format_currency(ctx.accommodation.currency) }}</div>
<div class="text-xs text-gray-500">{{ service.type.label | trans }}</div>
</td>
<td class="border border-primary-bg p-2 align-top w-12 text-center">
@@ -135,64 +135,6 @@ class ParticipantFieldOptionsProviderMandatoryServiceTest extends TestCase
$this->assertSame('Parkplatz (€12,50)', $options['label']);
}
public function testParkingIsReadonlyWhenSoldOut(): void
{
$parkingService = new Service();
$parkingService->id = 3;
$parkingService->label = 'Parkplatz';
$parkingService->subType = Constants::TOKEN_PARKING;
$parkingService->available = 0;
$parkingService->price = 12.5;
$travel = $this->createTravelWithAdditionalServices([$parkingService]);
$bookingDto = new BookingDto($travel, 1);
$participant = new ParticipantDto();
$participant->index = 0;
$participant->dateOfBirth = $travel->dateFrom->modify('-25 years');
$bookingDto->participants[0] = $participant;
$serviceAvailabilityCalculator = $this->createMock(ServiceAvailabilityCalculator::class);
$serviceAvailabilityCalculator->method('isServiceUnavailable')
->with($parkingService->id, $bookingDto, 0)
->willReturn(true);
$provider = new ParticipantFieldOptionsProvider(
$serviceAvailabilityCalculator,
$this->createMock(InsuranceManager::class),
$this->createMock(BookingPriceCalculator::class),
new ServiceLabelFormatter(),
$this->createMock(TranslatorInterface::class)
);
$options = $provider->getFieldOptions('parking', $bookingDto, 0);
$this->assertTrue($options['attr']['readonly']);
$this->assertSame('ausgebucht', $options['attr']['data-tooltip']);
}
public function testParkingIsNotReadonlyWhenAvailable(): void
{
$parkingService = new Service();
$parkingService->id = 3;
$parkingService->label = 'Parkplatz';
$parkingService->subType = Constants::TOKEN_PARKING;
$parkingService->available = 10;
$parkingService->price = 12.5;
$travel = $this->createTravelWithAdditionalServices([$parkingService]);
$bookingDto = new BookingDto($travel, 1);
$participant = new ParticipantDto();
$participant->index = 0;
$participant->dateOfBirth = $travel->dateFrom->modify('-25 years');
$bookingDto->participants[0] = $participant;
$options = $this->provider->getFieldOptions('parking', $bookingDto, 0);
$this->assertArrayNotHasKey('attr', $options);
}
public function testNullParticipantReturnsEmptyOptions(): void
{
$mandatoryService = $this->createMandatoryService(1, 'Ortstaxe');
@@ -7,11 +7,9 @@ namespace App\Tests\Form\Service;
use App\BusProNet\Model\Service;
use App\BusProNet\Model\Travel;
use App\BusProNet\Utility\DirectionMapper;
use App\BusProNet\Constants;
use App\Form\Model\BookingDto;
use App\Form\Model\ParticipantDto;
use App\Form\Service\ParticipantParkingFieldHandler;
use App\Service\ServiceAvailabilityCalculator;
use PHPUnit\Framework\TestCase;
class ParticipantParkingFieldHandlerTest extends TestCase
@@ -20,7 +18,7 @@ class ParticipantParkingFieldHandlerTest extends TestCase
protected function setUp(): void
{
$this->handler = new ParticipantParkingFieldHandler(new ServiceAvailabilityCalculator());
$this->handler = new ParticipantParkingFieldHandler();
}
public function testGetFieldName(): void
@@ -239,50 +237,6 @@ class ParticipantParkingFieldHandlerTest extends TestCase
$this->assertFalse($participant->parking);
}
public function testProcessFieldRejectsParkingWhenSoldOut(): void
{
$pkwService = $this->createTransportationService(DirectionMapper::SUBTYPE_CAR_API);
$parkingService = $this->createParkingService(available: 0);
$participant = new ParticipantDto();
$participant->dateOfBirth = new \DateTimeImmutable('-25 years');
$participant->transportationOutbound = $pkwService;
$travel = new Travel();
$travel->additionalServices = [$parkingService->id => $parkingService];
$bookingDto = new BookingDto($travel, 1);
$bookingDto->participants = [$participant];
$submittedData = ['parking' => true];
$this->handler->processField($submittedData, $bookingDto, 0);
$this->assertFalse($participant->parking);
$this->assertNull($participant->parkingService);
}
public function testProcessFieldAllowsParkingWhenAvailable(): void
{
$pkwService = $this->createTransportationService(DirectionMapper::SUBTYPE_CAR_API);
$parkingService = $this->createParkingService(available: 5);
$participant = new ParticipantDto();
$participant->dateOfBirth = new \DateTimeImmutable('-25 years');
$participant->transportationOutbound = $pkwService;
$travel = new Travel();
$travel->additionalServices = [$parkingService->id => $parkingService];
$bookingDto = new BookingDto($travel, 1);
$bookingDto->participants = [$participant];
$submittedData = ['parking' => true];
$this->handler->processField($submittedData, $bookingDto, 0);
$this->assertTrue($participant->parking);
$this->assertSame($parkingService, $participant->parkingService);
}
public function testProcessFieldSetsParkingToFalseWhenNotSelected(): void
{
$pkwService = $this->createTransportationService(DirectionMapper::SUBTYPE_CAR_API);
@@ -346,15 +300,4 @@ class ParticipantParkingFieldHandlerTest extends TestCase
return $service;
}
private function createParkingService(int $available): Service
{
$service = new Service();
$service->id = 200;
$service->label = 'Parkplatz';
$service->subType = Constants::TOKEN_PARKING;
$service->available = $available;
return $service;
}
}
+54 -54
View File
@@ -34,15 +34,15 @@ class PriceTimelineBuilderTest extends TestCase
$result = $this->builder->buildTimeline([$price], new \DateTimeImmutable('2026-01-01'), new \DateTimeImmutable('2026-12-31'), 'EUR');
$this->assertCount(1, $result);
$this->assertSame('2026-01-01', $result[0]->dateFrom);
$this->assertSame('2026-03-31', $result[0]->dateTo);
$this->assertSame(150.0, $result[0]->pricePerNight);
$this->assertSame(20.0, $result[0]->priceAdditionalPerson);
$this->assertSame(2, $result[0]->includedPax);
$this->assertNull($result[0]->type);
$this->assertNull($result[0]->defaultPricePerNight);
$this->assertNull($result[0]->defaultPriceAdditionalPerson);
$this->assertSame('EUR', $result[0]->currency);
$this->assertSame('2026-01-01', $result[0]['dateFrom']);
$this->assertSame('2026-03-31', $result[0]['dateTo']);
$this->assertSame(150.0, $result[0]['pricePerNight']);
$this->assertSame(20.0, $result[0]['priceAdditionalPerson']);
$this->assertSame(2, $result[0]['includedPax']);
$this->assertNull($result[0]['type']);
$this->assertNull($result[0]['defaultPricePerNight']);
$this->assertNull($result[0]['defaultPriceAdditionalPerson']);
$this->assertSame('EUR', $result[0]['currency']);
}
public function testBasePriceStartingBeforeYearIsClamped(): void
@@ -52,8 +52,8 @@ class PriceTimelineBuilderTest extends TestCase
$result = $this->builder->buildTimeline([$price], new \DateTimeImmutable('2026-01-01'), new \DateTimeImmutable('2026-12-31'), 'EUR');
$this->assertCount(1, $result);
$this->assertSame('2026-01-01', $result[0]->dateFrom);
$this->assertSame('2026-03-31', $result[0]->dateTo);
$this->assertSame('2026-01-01', $result[0]['dateFrom']);
$this->assertSame('2026-03-31', $result[0]['dateTo']);
}
public function testBasePriceEndingAfterYearIsClamped(): void
@@ -63,8 +63,8 @@ class PriceTimelineBuilderTest extends TestCase
$result = $this->builder->buildTimeline([$price], new \DateTimeImmutable('2026-01-01'), new \DateTimeImmutable('2026-12-31'), 'EUR');
$this->assertCount(1, $result);
$this->assertSame('2026-10-01', $result[0]->dateFrom);
$this->assertSame('2026-12-31', $result[0]->dateTo);
$this->assertSame('2026-10-01', $result[0]['dateFrom']);
$this->assertSame('2026-12-31', $result[0]['dateTo']);
}
public function testDiscountSplitsBasePeriodIntoThreeRows(): void
@@ -75,17 +75,17 @@ class PriceTimelineBuilderTest extends TestCase
$result = $this->builder->buildTimeline([$base, $discount], new \DateTimeImmutable('2026-01-01'), new \DateTimeImmutable('2026-12-31'), 'EUR');
$this->assertCount(3, $result);
$this->assertSame('2026-01-01', $result[0]->dateFrom);
$this->assertSame('2026-01-14', $result[0]->dateTo);
$this->assertNull($result[0]->type);
$this->assertSame('2026-01-01', $result[0]['dateFrom']);
$this->assertSame('2026-01-14', $result[0]['dateTo']);
$this->assertNull($result[0]['type']);
$this->assertSame('2026-01-15', $result[1]->dateFrom);
$this->assertSame('2026-01-31', $result[1]->dateTo);
$this->assertSame('discount', $result[1]->type);
$this->assertSame('2026-01-15', $result[1]['dateFrom']);
$this->assertSame('2026-01-31', $result[1]['dateTo']);
$this->assertSame('discount', $result[1]['type']);
$this->assertSame('2026-02-01', $result[2]->dateFrom);
$this->assertSame('2026-03-31', $result[2]->dateTo);
$this->assertNull($result[2]->type);
$this->assertSame('2026-02-01', $result[2]['dateFrom']);
$this->assertSame('2026-03-31', $result[2]['dateTo']);
$this->assertNull($result[2]['type']);
}
public function testDiscountRowIncludesDefaultPrice(): void
@@ -96,10 +96,10 @@ class PriceTimelineBuilderTest extends TestCase
$result = $this->builder->buildTimeline([$base, $discount], new \DateTimeImmutable('2026-01-01'), new \DateTimeImmutable('2026-12-31'), 'EUR');
$discountRow = $result[1];
$this->assertSame(120.0, $discountRow->pricePerNight);
$this->assertSame(150.0, $discountRow->defaultPricePerNight);
$this->assertSame(20.0, $discountRow->priceAdditionalPerson);
$this->assertSame(30.0, $discountRow->defaultPriceAdditionalPerson);
$this->assertSame(120.0, $discountRow['pricePerNight']);
$this->assertSame(150.0, $discountRow['defaultPricePerNight']);
$this->assertSame(20.0, $discountRow['priceAdditionalPerson']);
$this->assertSame(30.0, $discountRow['defaultPriceAdditionalPerson']);
}
public function testBaseRowsHaveNullDefaultPriceFields(): void
@@ -109,10 +109,10 @@ class PriceTimelineBuilderTest extends TestCase
$result = $this->builder->buildTimeline([$base, $discount], new \DateTimeImmutable('2026-01-01'), new \DateTimeImmutable('2026-12-31'), 'EUR');
$this->assertNull($result[0]->defaultPricePerNight);
$this->assertNull($result[0]->defaultPriceAdditionalPerson);
$this->assertNull($result[2]->defaultPricePerNight);
$this->assertNull($result[2]->defaultPriceAdditionalPerson);
$this->assertNull($result[0]['defaultPricePerNight']);
$this->assertNull($result[0]['defaultPriceAdditionalPerson']);
$this->assertNull($result[2]['defaultPricePerNight']);
$this->assertNull($result[2]['defaultPriceAdditionalPerson']);
}
public function testDiscountWithNoBasePriceHasNullDefaultPrice(): void
@@ -122,8 +122,8 @@ class PriceTimelineBuilderTest extends TestCase
$result = $this->builder->buildTimeline([$discount], new \DateTimeImmutable('2026-01-01'), new \DateTimeImmutable('2026-12-31'), 'EUR');
$this->assertCount(1, $result);
$this->assertSame('discount', $result[0]->type);
$this->assertNull($result[0]->defaultPricePerNight);
$this->assertSame('discount', $result[0]['type']);
$this->assertNull($result[0]['defaultPricePerNight']);
}
public function testGapBetweenTwoPricesIsOmitted(): void
@@ -134,10 +134,10 @@ class PriceTimelineBuilderTest extends TestCase
$result = $this->builder->buildTimeline([$first, $second], new \DateTimeImmutable('2026-01-01'), new \DateTimeImmutable('2026-12-31'), 'EUR');
$this->assertCount(2, $result);
$this->assertSame('2026-01-01', $result[0]->dateFrom);
$this->assertSame('2026-01-31', $result[0]->dateTo);
$this->assertSame('2026-03-01', $result[1]->dateFrom);
$this->assertSame('2026-03-31', $result[1]->dateTo);
$this->assertSame('2026-01-01', $result[0]['dateFrom']);
$this->assertSame('2026-01-31', $result[0]['dateTo']);
$this->assertSame('2026-03-01', $result[1]['dateFrom']);
$this->assertSame('2026-03-31', $result[1]['dateTo']);
}
public function testOverrideSplitsBasePeriod(): void
@@ -148,10 +148,10 @@ class PriceTimelineBuilderTest extends TestCase
$result = $this->builder->buildTimeline([$base, $override], new \DateTimeImmutable('2026-01-01'), new \DateTimeImmutable('2026-12-31'), 'EUR');
$this->assertCount(3, $result);
$this->assertNull($result[0]->type);
$this->assertSame('override', $result[1]->type);
$this->assertSame(180.0, $result[1]->pricePerNight);
$this->assertNull($result[2]->type);
$this->assertNull($result[0]['type']);
$this->assertSame('override', $result[1]['type']);
$this->assertSame(180.0, $result[1]['pricePerNight']);
$this->assertNull($result[2]['type']);
}
public function testDiscountOverTwoDifferentBasePricesProducesTwoDiscountRows(): void
@@ -166,23 +166,23 @@ class PriceTimelineBuilderTest extends TestCase
$this->assertCount(4, $result);
$this->assertSame('2026-01-01', $result[0]->dateFrom);
$this->assertSame('2026-01-14', $result[0]->dateTo);
$this->assertNull($result[0]->type);
$this->assertSame('2026-01-01', $result[0]['dateFrom']);
$this->assertSame('2026-01-14', $result[0]['dateTo']);
$this->assertNull($result[0]['type']);
$this->assertSame('2026-01-15', $result[1]->dateFrom);
$this->assertSame('2026-01-20', $result[1]->dateTo);
$this->assertSame('discount', $result[1]->type);
$this->assertSame(100.0, $result[1]->defaultPricePerNight); // baseA
$this->assertSame('2026-01-15', $result[1]['dateFrom']);
$this->assertSame('2026-01-20', $result[1]['dateTo']);
$this->assertSame('discount', $result[1]['type']);
$this->assertSame(100.0, $result[1]['defaultPricePerNight']); // baseA
$this->assertSame('2026-01-21', $result[2]->dateFrom);
$this->assertSame('2026-01-31', $result[2]->dateTo);
$this->assertSame('discount', $result[2]->type);
$this->assertSame(120.0, $result[2]->defaultPricePerNight); // baseB
$this->assertSame('2026-01-21', $result[2]['dateFrom']);
$this->assertSame('2026-01-31', $result[2]['dateTo']);
$this->assertSame('discount', $result[2]['type']);
$this->assertSame(120.0, $result[2]['defaultPricePerNight']); // baseB
$this->assertSame('2026-02-01', $result[3]->dateFrom);
$this->assertSame('2026-03-31', $result[3]->dateTo);
$this->assertNull($result[3]->type);
$this->assertSame('2026-02-01', $result[3]['dateFrom']);
$this->assertSame('2026-03-31', $result[3]['dateTo']);
$this->assertNull($result[3]['type']);
}
// --- resolveWinner ---
@@ -1,80 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Tests\Service;
use App\BusProNet\Constants;
use App\BusProNet\Model\Service;
use App\BusProNet\Model\Travel;
use App\Form\Model\BookingDto;
use App\Form\Model\ParticipantDto;
use App\Service\ServiceAvailabilityCalculator;
use PHPUnit\Framework\TestCase;
class ServiceAvailabilityCalculatorTest extends TestCase
{
private ServiceAvailabilityCalculator $calculator;
protected function setUp(): void
{
$this->calculator = new ServiceAvailabilityCalculator();
}
public function testParkingServiceIsUnavailableWhenSoldOut(): void
{
$parkingService = $this->createParkingService(id: 1, available: 0);
$bookingDto = $this->createBookingDtoWithServices([$parkingService]);
$this->assertTrue($this->calculator->isServiceUnavailable(1, $bookingDto, 0));
}
public function testParkingServiceIsAvailableWhenQuotaRemains(): void
{
$parkingService = $this->createParkingService(id: 1, available: 5);
$bookingDto = $this->createBookingDtoWithServices([$parkingService]);
$this->assertFalse($this->calculator->isServiceUnavailable(1, $bookingDto, 0));
}
public function testParkingSelectedByOtherParticipantCountsTowardUsage(): void
{
$parkingService = $this->createParkingService(id: 1, available: 1);
$bookingDto = $this->createBookingDtoWithServices([$parkingService]);
$otherParticipant = new ParticipantDto();
$otherParticipant->parkingService = $parkingService;
$bookingDto->participants[1] = $otherParticipant;
// Only one parking slot remains, and another participant already claimed it,
// so it must show unavailable for the current participant (index 0)
$this->assertTrue($this->calculator->isServiceUnavailable(1, $bookingDto, 0));
}
private function createParkingService(int $id, int $available): Service
{
$service = new Service();
$service->id = $id;
$service->label = 'Parkplatz';
$service->subType = Constants::TOKEN_PARKING;
$service->available = $available;
return $service;
}
private function createBookingDtoWithServices(array $services): BookingDto
{
$travel = new Travel();
$indexed = [];
foreach ($services as $service) {
$indexed[$service->id] = $service;
}
$travel->additionalServices = $indexed;
$bookingDto = new BookingDto($travel, 1);
$bookingDto->participants[0] = new ParticipantDto();
return $bookingDto;
}
}