Compare commits
18
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8f2653c706 | ||
|
|
d0358e584c | ||
|
|
a1751f699b | ||
|
|
e7bfb19ac9 | ||
|
|
18a890e50e | ||
|
|
3c9caeaad0 | ||
|
|
eba1a901d6 | ||
|
|
f8e4fe4d1e | ||
|
|
d9f29a5a5a | ||
|
|
a6ba4fac0d | ||
|
|
a9bd46be4a | ||
|
|
d0511ba2cd | ||
|
|
487597c828 | ||
|
|
b3210a7a27 | ||
|
|
a8c0801c32 | ||
|
|
690391da98 | ||
|
|
b075e3ecfc | ||
|
|
13491f346d |
No files matched your search
Generated
+263
-263
File diff suppressed because it is too large.
Load diff
@@ -8,7 +8,6 @@ league_oauth2_server:
|
|||||||
enable_auth_code_grant: true
|
enable_auth_code_grant: true
|
||||||
enable_refresh_token_grant: true
|
enable_refresh_token_grant: true
|
||||||
enable_password_grant: false
|
enable_password_grant: false
|
||||||
enable_implicit_grant: false
|
|
||||||
access_token_ttl: PT10M
|
access_token_ttl: PT10M
|
||||||
resource_server:
|
resource_server:
|
||||||
public_key: '%env(resolve:OAUTH_PUBLIC_KEY)%'
|
public_key: '%env(resolve:OAUTH_PUBLIC_KEY)%'
|
||||||
|
|||||||
@@ -208,6 +208,7 @@ services:
|
|||||||
- 'App\Form\Service\ParticipantTransportationInboundFieldHandler'
|
- 'App\Form\Service\ParticipantTransportationInboundFieldHandler'
|
||||||
- 'App\Form\Service\ParticipantPickupFieldHandler'
|
- 'App\Form\Service\ParticipantPickupFieldHandler'
|
||||||
- 'App\Form\Service\ParticipantDropOffFieldHandler'
|
- 'App\Form\Service\ParticipantDropOffFieldHandler'
|
||||||
|
- 'App\Form\Service\ParticipantParkingFieldHandler'
|
||||||
- 'App\Form\Service\ParticipantRentalInsuranceFieldHandler'
|
- 'App\Form\Service\ParticipantRentalInsuranceFieldHandler'
|
||||||
- 'App\Form\Service\ParticipantLicensePlateFieldHandler'
|
- 'App\Form\Service\ParticipantLicensePlateFieldHandler'
|
||||||
# Complex handlers with dependencies - use service references
|
# Complex handlers with dependencies - use service references
|
||||||
@@ -217,7 +218,6 @@ services:
|
|||||||
- '@App\Form\Service\ParticipantInsuranceFieldHandler'
|
- '@App\Form\Service\ParticipantInsuranceFieldHandler'
|
||||||
- '@App\Form\Service\ParticipantPurchaseVoucherFieldHandler'
|
- '@App\Form\Service\ParticipantPurchaseVoucherFieldHandler'
|
||||||
- '@App\Form\Service\ParticipantPromoVoucherFieldHandler'
|
- '@App\Form\Service\ParticipantPromoVoucherFieldHandler'
|
||||||
- '@App\Form\Service\ParticipantParkingFieldHandler'
|
|
||||||
|
|
||||||
# Booking Status Rules
|
# Booking Status Rules
|
||||||
App\BusProNet\Service\StatusRule\Selection1473StatusRule: ~
|
App\BusProNet\Service\StatusRule\Selection1473StatusRule: ~
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ class ImportGroupsLegacyDataCommand extends Command
|
|||||||
private const int DEFAULT_MIN_NIGHTS = 1;
|
private const int DEFAULT_MIN_NIGHTS = 1;
|
||||||
private const Season DEFAULT_SEASON = Season::SECONDARY;
|
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 = [
|
private const array OPTION_TYPE_MAP = [
|
||||||
1 => AdditionalServiceType::Flat,
|
1 => AdditionalServiceType::Flat,
|
||||||
2 => AdditionalServiceType::PerPerson,
|
2 => AdditionalServiceType::PerPerson,
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ declare(strict_types=1);
|
|||||||
namespace App\Controller\Admin\Accommodation;
|
namespace App\Controller\Admin\Accommodation;
|
||||||
|
|
||||||
use App\Entity\Groups\Accommodation;
|
use App\Entity\Groups\Accommodation;
|
||||||
use App\Entity\Groups\AdditionalService;
|
|
||||||
use App\Entity\Groups\BoardService;
|
|
||||||
use App\Form\Admin\Groups\AccommodationType;
|
use App\Form\Admin\Groups\AccommodationType;
|
||||||
use App\Service\CmsDataProvider;
|
use App\Service\CmsDataProvider;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
@@ -54,31 +52,10 @@ class EditController extends AbstractController
|
|||||||
return $this->redirectToRoute('app_admin_accommodation_edit', ['id' => $accommodation->getId()]);
|
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', [
|
return $this->render('admin/accommodation/edit.html.twig', [
|
||||||
'accommodation' => $accommodation,
|
'accommodation' => $accommodation,
|
||||||
'form' => $form,
|
'form' => $form,
|
||||||
'cmsData' => $cmsData,
|
'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());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -5,8 +5,6 @@ declare(strict_types=1);
|
|||||||
namespace App\Controller\Groups;
|
namespace App\Controller\Groups;
|
||||||
|
|
||||||
use App\Entity\Groups\Accommodation;
|
use App\Entity\Groups\Accommodation;
|
||||||
use App\Entity\Groups\AdditionalService;
|
|
||||||
use App\Entity\Groups\BoardService;
|
|
||||||
use App\Exception\AccommodationSessionNotFoundException;
|
use App\Exception\AccommodationSessionNotFoundException;
|
||||||
use App\Form\AccommodationBookingConfirmationType;
|
use App\Form\AccommodationBookingConfirmationType;
|
||||||
use App\Form\AccommodationInquiryConfirmationType;
|
use App\Form\AccommodationInquiryConfirmationType;
|
||||||
@@ -140,12 +138,7 @@ class Step4Controller extends AbstractAccommodationController
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array{
|
* @param array{boardServices: array, additionalServices: array} $services
|
||||||
* boardServices: BoardService[],
|
|
||||||
* additionalServices: AdditionalService[],
|
|
||||||
* groupedAdditionalServices: array<string, AdditionalService[]>,
|
|
||||||
* ungroupedAdditionalServices: AdditionalService[]
|
|
||||||
* } $services
|
|
||||||
*/
|
*/
|
||||||
private function persistBooking(Request $request, AccommodationBookingDto $dto, Accommodation $accommodation, array $services): void
|
private function persistBooking(Request $request, AccommodationBookingDto $dto, Accommodation $accommodation, array $services): void
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ interface BlameableEntityInterface
|
|||||||
{
|
{
|
||||||
public function getCreatedBy(): ?User;
|
public function getCreatedBy(): ?User;
|
||||||
|
|
||||||
public function setCreatedBy(?User $createdBy): self;
|
public function setCreatedBy(?User $createdBy);
|
||||||
|
|
||||||
public function getUpdatedBy(): ?User;
|
public function getUpdatedBy(): ?User;
|
||||||
|
|
||||||
public function setUpdatedBy(?User $updatedBy): self;
|
public function setUpdatedBy(?User $updatedBy);
|
||||||
}
|
}
|
||||||
@@ -4,11 +4,11 @@ namespace App\Entity;
|
|||||||
|
|
||||||
interface TimestampableEntityInterface
|
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);
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,6 @@
|
|||||||
namespace App\EventListener;
|
namespace App\EventListener;
|
||||||
|
|
||||||
use App\Entity\BlameableEntityInterface;
|
use App\Entity\BlameableEntityInterface;
|
||||||
use App\Entity\User;
|
|
||||||
use Doctrine\Bundle\DoctrineBundle\Attribute\AsDoctrineListener;
|
use Doctrine\Bundle\DoctrineBundle\Attribute\AsDoctrineListener;
|
||||||
use Doctrine\ORM\Event\PrePersistEventArgs;
|
use Doctrine\ORM\Event\PrePersistEventArgs;
|
||||||
use Doctrine\ORM\Event\PreUpdateEventArgs;
|
use Doctrine\ORM\Event\PreUpdateEventArgs;
|
||||||
@@ -26,13 +25,7 @@ class BlamableEntityListener
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = $this->security->getUser();
|
$entity->setCreatedBy($this->security->getUser());
|
||||||
|
|
||||||
if (!$user instanceof User) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$entity->setCreatedBy($user);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function preUpdate(PreUpdateEventArgs $args): void
|
public function preUpdate(PreUpdateEventArgs $args): void
|
||||||
@@ -43,12 +36,6 @@ class BlamableEntityListener
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = $this->security->getUser();
|
$entity->setUpdatedBy($this->security->getUser());
|
||||||
|
|
||||||
if (!$user instanceof User) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$entity->setUpdatedBy($user);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -21,7 +21,6 @@ use Symfony\Component\Form\FormBuilderInterface;
|
|||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
use Symfony\Component\Validator\Constraints\Range;
|
use Symfony\Component\Validator\Constraints\Range;
|
||||||
|
|
||||||
/** @extends AbstractType<AccommodationBooking> */
|
|
||||||
class AccommodationBookingType extends AbstractType
|
class AccommodationBookingType extends AbstractType
|
||||||
{
|
{
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
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\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
/** @extends AbstractType<AccommodationPrice> */
|
|
||||||
class AccommodationPriceType extends AbstractType
|
class AccommodationPriceType extends AbstractType
|
||||||
{
|
{
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
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\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
/** @extends AbstractType<Accommodation> */
|
|
||||||
class AccommodationType extends AbstractType
|
class AccommodationType extends AbstractType
|
||||||
{
|
{
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
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\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
/** @extends AbstractType<AdditionalService> */
|
|
||||||
class AdditionalServiceType extends AbstractType
|
class AdditionalServiceType extends AbstractType
|
||||||
{
|
{
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
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\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
/** @extends AbstractType<BoardService> */
|
|
||||||
class BoardServiceType extends AbstractType
|
class BoardServiceType extends AbstractType
|
||||||
{
|
{
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ use Symfony\Component\Form\FormInterface;
|
|||||||
use Symfony\Component\Form\FormView;
|
use Symfony\Component\Form\FormView;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
/** @extends AbstractType<mixed> */
|
|
||||||
class DatepickerType extends AbstractType
|
class DatepickerType extends AbstractType
|
||||||
{
|
{
|
||||||
public function configureOptions(OptionsResolver $resolver): void
|
public function configureOptions(OptionsResolver $resolver): void
|
||||||
|
|||||||
@@ -647,28 +647,13 @@ class ParticipantFieldOptionsProvider extends AbstractFieldOptionsProvider
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$fieldOptions = [
|
return [
|
||||||
'label' => $this->serviceLabelFormatter->formatServiceLabelForServices(
|
'label' => $this->serviceLabelFormatter->formatServiceLabelForServices(
|
||||||
Constants::SERVICE_LABELS[Constants::TOKEN_PARKING],
|
Constants::SERVICE_LABELS[Constants::TOKEN_PARKING],
|
||||||
$parkingServices
|
$parkingServices
|
||||||
),
|
),
|
||||||
'required' => false,
|
'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)
|
// 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\BookingDto;
|
||||||
use App\Form\Model\ParticipantDto;
|
use App\Form\Model\ParticipantDto;
|
||||||
use App\Form\Service\Abstract\AbstractParticipantFieldHandler;
|
use App\Form\Service\Abstract\AbstractParticipantFieldHandler;
|
||||||
use App\Service\ServiceAvailabilityCalculator;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles parking service selection for self-organized transportation.
|
* Handles parking service selection for self-organized transportation.
|
||||||
@@ -21,11 +20,6 @@ use App\Service\ServiceAvailabilityCalculator;
|
|||||||
*/
|
*/
|
||||||
class ParticipantParkingFieldHandler extends AbstractParticipantFieldHandler
|
class ParticipantParkingFieldHandler extends AbstractParticipantFieldHandler
|
||||||
{
|
{
|
||||||
public function __construct(
|
|
||||||
private readonly ServiceAvailabilityCalculator $serviceAvailabilityCalculator,
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getFieldName(): string
|
public function getFieldName(): string
|
||||||
{
|
{
|
||||||
return 'parking';
|
return 'parking';
|
||||||
@@ -79,22 +73,7 @@ class ParticipantParkingFieldHandler extends AbstractParticipantFieldHandler
|
|||||||
|
|
||||||
// Store parking service object for pricing calculation
|
// Store parking service object for pricing calculation
|
||||||
if (true === $isParkingSelected) {
|
if (true === $isParkingSelected) {
|
||||||
$parkingService = $this->findParkingService($bookingDto, $participantIndex);
|
$participant->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;
|
|
||||||
} else {
|
} else {
|
||||||
$participant->parkingService = null;
|
$participant->parkingService = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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,
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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
|
class AdditionalServiceRepository extends ServiceEntityRepository
|
||||||
{
|
{
|
||||||
/** @use FindsByAccommodationAndDateRangeTrait<AdditionalService> */
|
|
||||||
use FindsByAccommodationAndDateRangeTrait;
|
use FindsByAccommodationAndDateRangeTrait;
|
||||||
|
|
||||||
public function __construct(ManagerRegistry $registry)
|
public function __construct(ManagerRegistry $registry)
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ use Doctrine\Persistence\ManagerRegistry;
|
|||||||
*/
|
*/
|
||||||
class BoardServiceRepository extends ServiceEntityRepository
|
class BoardServiceRepository extends ServiceEntityRepository
|
||||||
{
|
{
|
||||||
/** @use FindsByAccommodationAndDateRangeTrait<BoardService> */
|
|
||||||
use FindsByAccommodationAndDateRangeTrait;
|
use FindsByAccommodationAndDateRangeTrait;
|
||||||
|
|
||||||
public function __construct(ManagerRegistry $registry)
|
public function __construct(ManagerRegistry $registry)
|
||||||
|
|||||||
@@ -5,21 +5,13 @@ declare(strict_types=1);
|
|||||||
namespace App\Repository\Groups;
|
namespace App\Repository\Groups;
|
||||||
|
|
||||||
use App\Entity\Groups\Accommodation;
|
use App\Entity\Groups\Accommodation;
|
||||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @template T of object
|
|
||||||
*
|
|
||||||
* @phpstan-require-extends ServiceEntityRepository<T>
|
|
||||||
*/
|
|
||||||
trait FindsByAccommodationAndDateRangeTrait
|
trait FindsByAccommodationAndDateRangeTrait
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Returns all records active during the given date range.
|
* Returns all records active during the given date range.
|
||||||
*
|
*
|
||||||
* Overlap condition: entity.dateFrom <= dateTo AND entity.dateTo >= dateFrom
|
* Overlap condition: entity.dateFrom <= dateTo AND entity.dateTo >= dateFrom
|
||||||
*
|
|
||||||
* @return array<int, T>
|
|
||||||
*/
|
*/
|
||||||
public function findByAccommodationAndDateRange(
|
public function findByAccommodationAndDateRange(
|
||||||
Accommodation $accommodation,
|
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 [
|
return [
|
||||||
'boardServices' => $boardServices,
|
'boardServices' => $boardServices,
|
||||||
'additionalServices' => $additionalServices,
|
'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.
|
* Determines whether the booking must be treated as non-binding and why.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -18,9 +18,6 @@ class GroupsPriceCalculator
|
|||||||
/** @var array<string, int|float> */
|
/** @var array<string, int|float> */
|
||||||
private array $config;
|
private array $config;
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array<string, int|float> $config
|
|
||||||
*/
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly PriceTimelineBuilder $priceTimelineBuilder,
|
private readonly PriceTimelineBuilder $priceTimelineBuilder,
|
||||||
array $config,
|
array $config,
|
||||||
@@ -137,9 +134,9 @@ class GroupsPriceCalculator
|
|||||||
): array {
|
): array {
|
||||||
$items = array_map(
|
$items = array_map(
|
||||||
fn(array $s) => [
|
fn(array $s) => [
|
||||||
'label' => $s['label'],
|
'label' => $s['label'] ?? '',
|
||||||
'price' => $s['price'],
|
'price' => $s['price'] ?? 0,
|
||||||
'type' => AdditionalServiceType::tryFrom($s['type']) ?? AdditionalServiceType::Flat,
|
'type' => AdditionalServiceType::tryFrom($s['type'] ?? '') ?? AdditionalServiceType::Flat,
|
||||||
],
|
],
|
||||||
$additionalServiceSnapshots,
|
$additionalServiceSnapshots,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ namespace App\Service;
|
|||||||
|
|
||||||
use App\Entity\Groups\AccommodationPrice;
|
use App\Entity\Groups\AccommodationPrice;
|
||||||
use App\Enum\Groups\PriceType;
|
use App\Enum\Groups\PriceType;
|
||||||
use App\Model\PriceTimelineItem;
|
|
||||||
|
|
||||||
class PriceTimelineBuilder
|
class PriceTimelineBuilder
|
||||||
{
|
{
|
||||||
@@ -34,8 +33,6 @@ class PriceTimelineBuilder
|
|||||||
* changes mid-discount period. A gap (no winner) resets both trackers.
|
* changes mid-discount period. A gap (no winner) resets both trackers.
|
||||||
*
|
*
|
||||||
* @param AccommodationPrice[] $prices
|
* @param AccommodationPrice[] $prices
|
||||||
*
|
|
||||||
* @return list<PriceTimelineItem>
|
|
||||||
*/
|
*/
|
||||||
public function buildTimeline(
|
public function buildTimeline(
|
||||||
array $prices,
|
array $prices,
|
||||||
@@ -104,32 +101,20 @@ class PriceTimelineBuilder
|
|||||||
// Step 3: extend the previous row if both the winner and the default-price entity
|
// Step 3: extend the previous row if both the winner and the default-price entity
|
||||||
// are unchanged; otherwise open a new row.
|
// are unchanged; otherwise open a new row.
|
||||||
if ($lastWinner === $winner && $lastDefault === $defaultWinner) {
|
if ($lastWinner === $winner && $lastDefault === $defaultWinner) {
|
||||||
$lastRow = $rows[count($rows) - 1];
|
$rows[count($rows) - 1]['dateTo'] = $segDateTo->format('Y-m-d');
|
||||||
$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,
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
$rows[] = new PriceTimelineItem(
|
$rows[] = [
|
||||||
dateFrom: $segStart->format('Y-m-d'),
|
'dateFrom' => $segStart->format('Y-m-d'),
|
||||||
dateTo: $segDateTo->format('Y-m-d'),
|
'dateTo' => $segDateTo->format('Y-m-d'),
|
||||||
season: $winner->getSeason()?->value,
|
'season' => $winner->getSeason()?->value,
|
||||||
includedPax: $winner->getIncludedPax(),
|
'includedPax' => $winner->getIncludedPax(),
|
||||||
pricePerNight: round($winner->getPricePerNight() / 100, 2),
|
'pricePerNight' => round($winner->getPricePerNight() / 100, 2),
|
||||||
priceAdditionalPerson: round($winner->getPriceAdditionalPerson() / 100, 2),
|
'priceAdditionalPerson' => round($winner->getPriceAdditionalPerson() / 100, 2),
|
||||||
defaultPricePerNight: $defaultWinner !== null ? round($defaultWinner->getPricePerNight() / 100, 2) : null,
|
'defaultPricePerNight' => $defaultWinner !== null ? round($defaultWinner->getPricePerNight() / 100, 2) : null,
|
||||||
defaultPriceAdditionalPerson: $defaultWinner !== null ? round($defaultWinner->getPriceAdditionalPerson() / 100, 2) : null,
|
'defaultPriceAdditionalPerson' => $defaultWinner !== null ? round($defaultWinner->getPriceAdditionalPerson() / 100, 2) : null,
|
||||||
currency: $currency,
|
'currency' => $currency,
|
||||||
type: $winner->getType()?->value,
|
'type' => $winner->getType()?->value,
|
||||||
);
|
];
|
||||||
$lastWinner = $winner;
|
$lastWinner = $winner;
|
||||||
$lastDefault = $defaultWinner;
|
$lastDefault = $defaultWinner;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -173,11 +173,6 @@ class ServiceAvailabilityCalculator
|
|||||||
$serviceUsage[$participant->skiPass->id] = ($serviceUsage[$participant->skiPass->id] ?? 0) + 1;
|
$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)
|
// Transportation services (single selection each)
|
||||||
if (null !== $participant->transportationOutbound && null !== $participant->transportationOutbound->id) {
|
if (null !== $participant->transportationOutbound && null !== $participant->transportationOutbound->id) {
|
||||||
$serviceUsage[$participant->transportationOutbound->id] = ($serviceUsage[$participant->transportationOutbound->id] ?? 0) + 1;
|
$serviceUsage[$participant->transportationOutbound->id] = ($serviceUsage[$participant->transportationOutbound->id] ?? 0) + 1;
|
||||||
@@ -236,7 +231,6 @@ class ServiceAvailabilityCalculator
|
|||||||
Constants::TOKEN_RENTALS,
|
Constants::TOKEN_RENTALS,
|
||||||
Constants::TOKEN_SKI_PASS,
|
Constants::TOKEN_SKI_PASS,
|
||||||
Constants::TOKEN_BOARD,
|
Constants::TOKEN_BOARD,
|
||||||
Constants::TOKEN_PARKING,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($additionalServiceTokens as $token) {
|
foreach ($additionalServiceTokens as $token) {
|
||||||
|
|||||||
@@ -8,8 +8,6 @@ use App\BpnConnect\ContingentsClient;
|
|||||||
use App\BpnConnect\Exception\BpnConnectException;
|
use App\BpnConnect\Exception\BpnConnectException;
|
||||||
use App\BpnConnect\Model\ContingentStatus;
|
use App\BpnConnect\Model\ContingentStatus;
|
||||||
use App\Entity\Groups\Accommodation;
|
use App\Entity\Groups\Accommodation;
|
||||||
use App\Model\CalendarDay;
|
|
||||||
use App\Model\CalendarMonth;
|
|
||||||
use Carbon\CarbonImmutable;
|
use Carbon\CarbonImmutable;
|
||||||
use Psr\Cache\InvalidArgumentException;
|
use Psr\Cache\InvalidArgumentException;
|
||||||
use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;
|
use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;
|
||||||
@@ -35,7 +33,6 @@ class Calendar
|
|||||||
public Accommodation $accommodation;
|
public Accommodation $accommodation;
|
||||||
public ?string $startMonth = null;
|
public ?string $startMonth = null;
|
||||||
|
|
||||||
/** @var list<CalendarMonth> */
|
|
||||||
public array $months = [];
|
public array $months = [];
|
||||||
public string $prevMonth = '';
|
public string $prevMonth = '';
|
||||||
public string $nextMonth = '';
|
public string $nextMonth = '';
|
||||||
@@ -122,9 +119,6 @@ class Calendar
|
|||||||
return $blocked;
|
return $blocked;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return CarbonImmutable[]
|
|
||||||
*/
|
|
||||||
private function collectAllDates(): array
|
private function collectAllDates(): array
|
||||||
{
|
{
|
||||||
$dates = [];
|
$dates = [];
|
||||||
@@ -157,9 +151,6 @@ class Calendar
|
|||||||
return $dates;
|
return $dates;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param CarbonImmutable[] $dates
|
|
||||||
*/
|
|
||||||
private function determineStartMonth(array $dates): CarbonImmutable
|
private function determineStartMonth(array $dates): CarbonImmutable
|
||||||
{
|
{
|
||||||
$earliest = min($dates);
|
$earliest = min($dates);
|
||||||
@@ -172,13 +163,6 @@ class Calendar
|
|||||||
return CarbonImmutable::now()->startOfMonth();
|
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
|
private function buildCoverageMap(): array
|
||||||
{
|
{
|
||||||
$map = [];
|
$map = [];
|
||||||
@@ -240,7 +224,7 @@ class Calendar
|
|||||||
}
|
}
|
||||||
|
|
||||||
$typeLabel = $service->getType() !== null
|
$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 . ')' : '');
|
$label = sprintf('Zusatz: %s%s', $service->getLabel(), $typeLabel !== '' ? ' (' . $typeLabel . ')' : '');
|
||||||
|
|
||||||
@@ -262,15 +246,7 @@ class Calendar
|
|||||||
return $map;
|
return $map;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private function buildMonth(CarbonImmutable $month, array $map, array $blockedDates): array
|
||||||
* @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
|
|
||||||
{
|
{
|
||||||
$start = $month->startOfMonth();
|
$start = $month->startOfMonth();
|
||||||
$today = CarbonImmutable::now()->format('Y-m-d');
|
$today = CarbonImmutable::now()->format('Y-m-d');
|
||||||
@@ -299,21 +275,21 @@ class Calendar
|
|||||||
$parts[] = 'Buchungsstopp';
|
$parts[] = 'Buchungsstopp';
|
||||||
}
|
}
|
||||||
|
|
||||||
$days[$d] = new CalendarDay(
|
$days[$d] = [
|
||||||
date: $dateStr,
|
'date' => $dateStr,
|
||||||
hasPrice: isset($coverage['price']),
|
'hasPrice' => isset($coverage['price']),
|
||||||
hasBoard: isset($coverage['board']),
|
'hasBoard' => isset($coverage['board']),
|
||||||
hasAdditional: isset($coverage['additional']),
|
'hasAdditional' => isset($coverage['additional']),
|
||||||
isBlocked: $isBlocked,
|
'isBlocked' => $isBlocked,
|
||||||
tooltip: !empty($parts) ? implode(' | ', $parts) : null,
|
'tooltip' => !empty($parts) ? implode(' | ', $parts) : null,
|
||||||
isToday: $dateStr === $today,
|
'isToday' => $dateStr === $today,
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return new CalendarMonth(
|
return [
|
||||||
label: self::MONTHS[$month->month] . ' ' . $month->year,
|
'label' => self::MONTHS[$month->month] . ' ' . $month->year,
|
||||||
firstDow: $firstDow,
|
'firstDow' => $firstDow,
|
||||||
days: $days,
|
'days' => $days,
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -188,7 +188,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for service in boardServices %}
|
{% for service in accommodation.boardServices %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
{{ service.dateFrom | date('d.m.Y') }} - {{ service.dateTo | date('d.m.Y') }}
|
{{ service.dateFrom | date('d.m.Y') }} - {{ service.dateTo | date('d.m.Y') }}
|
||||||
@@ -258,7 +258,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for service in additionalServices %}
|
{% for service in accommodation.additionalServices %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
{{ service.dateFrom | date('d.m.Y') }} - {{ service.dateTo | date('d.m.Y') }}
|
{{ 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 %}
|
{% set parkingService = bookingDto.travel.getAdditionalServicesBySubTypes(constant('App\\BusProNet\\Constants::TOKEN_PARKING'))|first %}
|
||||||
{{ macros.checkbox_row(
|
{{ macros.checkbox_row(
|
||||||
form.parking,
|
form.parking,
|
||||||
parkingService.label|default('Parkplatz'),
|
'Parkplatz',
|
||||||
parkingService.price|default(null),
|
parkingService.price|default(null),
|
||||||
form.parking.vars.attr['data-description']|default(null),
|
null,
|
||||||
'Info',
|
null,
|
||||||
htmxAttr,
|
htmxAttr
|
||||||
false
|
|
||||||
) }}
|
) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% for dayNum, day in month.days %}
|
{% for dayNum, day in month.days %}
|
||||||
<div class="w-6 px-px">
|
<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>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -109,7 +109,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td class="border border-primary-bg p-2 align-top w-32 text-right">
|
<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>
|
<div class="text-xs text-gray-500">pro Person und Nacht</div>
|
||||||
</td>
|
</td>
|
||||||
<td class="border border-primary-bg p-2 align-top w-12 text-center">
|
<td class="border border-primary-bg p-2 align-top w-12 text-center">
|
||||||
@@ -155,7 +155,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td class="border border-primary-bg p-2 align-top w-32 text-right">
|
<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>
|
<div class="text-xs text-gray-500">{{ service.type.label | trans }}</div>
|
||||||
</td>
|
</td>
|
||||||
<td class="border border-primary-bg p-2 align-top w-12 text-center">
|
<td class="border border-primary-bg p-2 align-top w-12 text-center">
|
||||||
@@ -193,7 +193,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td class="border border-primary-bg p-2 align-top w-32 text-right">
|
<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>
|
<div class="text-xs text-gray-500">{{ service.type.label | trans }}</div>
|
||||||
</td>
|
</td>
|
||||||
<td class="border border-primary-bg p-2 align-top w-12 text-center">
|
<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']);
|
$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
|
public function testNullParticipantReturnsEmptyOptions(): void
|
||||||
{
|
{
|
||||||
$mandatoryService = $this->createMandatoryService(1, 'Ortstaxe');
|
$mandatoryService = $this->createMandatoryService(1, 'Ortstaxe');
|
||||||
|
|||||||
@@ -7,11 +7,9 @@ namespace App\Tests\Form\Service;
|
|||||||
use App\BusProNet\Model\Service;
|
use App\BusProNet\Model\Service;
|
||||||
use App\BusProNet\Model\Travel;
|
use App\BusProNet\Model\Travel;
|
||||||
use App\BusProNet\Utility\DirectionMapper;
|
use App\BusProNet\Utility\DirectionMapper;
|
||||||
use App\BusProNet\Constants;
|
|
||||||
use App\Form\Model\BookingDto;
|
use App\Form\Model\BookingDto;
|
||||||
use App\Form\Model\ParticipantDto;
|
use App\Form\Model\ParticipantDto;
|
||||||
use App\Form\Service\ParticipantParkingFieldHandler;
|
use App\Form\Service\ParticipantParkingFieldHandler;
|
||||||
use App\Service\ServiceAvailabilityCalculator;
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class ParticipantParkingFieldHandlerTest extends TestCase
|
class ParticipantParkingFieldHandlerTest extends TestCase
|
||||||
@@ -20,7 +18,7 @@ class ParticipantParkingFieldHandlerTest extends TestCase
|
|||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
$this->handler = new ParticipantParkingFieldHandler(new ServiceAvailabilityCalculator());
|
$this->handler = new ParticipantParkingFieldHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetFieldName(): void
|
public function testGetFieldName(): void
|
||||||
@@ -239,50 +237,6 @@ class ParticipantParkingFieldHandlerTest extends TestCase
|
|||||||
$this->assertFalse($participant->parking);
|
$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
|
public function testProcessFieldSetsParkingToFalseWhenNotSelected(): void
|
||||||
{
|
{
|
||||||
$pkwService = $this->createTransportationService(DirectionMapper::SUBTYPE_CAR_API);
|
$pkwService = $this->createTransportationService(DirectionMapper::SUBTYPE_CAR_API);
|
||||||
@@ -346,15 +300,4 @@ class ParticipantParkingFieldHandlerTest extends TestCase
|
|||||||
|
|
||||||
return $service;
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -34,15 +34,15 @@ class PriceTimelineBuilderTest extends TestCase
|
|||||||
$result = $this->builder->buildTimeline([$price], new \DateTimeImmutable('2026-01-01'), new \DateTimeImmutable('2026-12-31'), 'EUR');
|
$result = $this->builder->buildTimeline([$price], new \DateTimeImmutable('2026-01-01'), new \DateTimeImmutable('2026-12-31'), 'EUR');
|
||||||
|
|
||||||
$this->assertCount(1, $result);
|
$this->assertCount(1, $result);
|
||||||
$this->assertSame('2026-01-01', $result[0]->dateFrom);
|
$this->assertSame('2026-01-01', $result[0]['dateFrom']);
|
||||||
$this->assertSame('2026-03-31', $result[0]->dateTo);
|
$this->assertSame('2026-03-31', $result[0]['dateTo']);
|
||||||
$this->assertSame(150.0, $result[0]->pricePerNight);
|
$this->assertSame(150.0, $result[0]['pricePerNight']);
|
||||||
$this->assertSame(20.0, $result[0]->priceAdditionalPerson);
|
$this->assertSame(20.0, $result[0]['priceAdditionalPerson']);
|
||||||
$this->assertSame(2, $result[0]->includedPax);
|
$this->assertSame(2, $result[0]['includedPax']);
|
||||||
$this->assertNull($result[0]->type);
|
$this->assertNull($result[0]['type']);
|
||||||
$this->assertNull($result[0]->defaultPricePerNight);
|
$this->assertNull($result[0]['defaultPricePerNight']);
|
||||||
$this->assertNull($result[0]->defaultPriceAdditionalPerson);
|
$this->assertNull($result[0]['defaultPriceAdditionalPerson']);
|
||||||
$this->assertSame('EUR', $result[0]->currency);
|
$this->assertSame('EUR', $result[0]['currency']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBasePriceStartingBeforeYearIsClamped(): void
|
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');
|
$result = $this->builder->buildTimeline([$price], new \DateTimeImmutable('2026-01-01'), new \DateTimeImmutable('2026-12-31'), 'EUR');
|
||||||
|
|
||||||
$this->assertCount(1, $result);
|
$this->assertCount(1, $result);
|
||||||
$this->assertSame('2026-01-01', $result[0]->dateFrom);
|
$this->assertSame('2026-01-01', $result[0]['dateFrom']);
|
||||||
$this->assertSame('2026-03-31', $result[0]->dateTo);
|
$this->assertSame('2026-03-31', $result[0]['dateTo']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBasePriceEndingAfterYearIsClamped(): void
|
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');
|
$result = $this->builder->buildTimeline([$price], new \DateTimeImmutable('2026-01-01'), new \DateTimeImmutable('2026-12-31'), 'EUR');
|
||||||
|
|
||||||
$this->assertCount(1, $result);
|
$this->assertCount(1, $result);
|
||||||
$this->assertSame('2026-10-01', $result[0]->dateFrom);
|
$this->assertSame('2026-10-01', $result[0]['dateFrom']);
|
||||||
$this->assertSame('2026-12-31', $result[0]->dateTo);
|
$this->assertSame('2026-12-31', $result[0]['dateTo']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDiscountSplitsBasePeriodIntoThreeRows(): void
|
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');
|
$result = $this->builder->buildTimeline([$base, $discount], new \DateTimeImmutable('2026-01-01'), new \DateTimeImmutable('2026-12-31'), 'EUR');
|
||||||
|
|
||||||
$this->assertCount(3, $result);
|
$this->assertCount(3, $result);
|
||||||
$this->assertSame('2026-01-01', $result[0]->dateFrom);
|
$this->assertSame('2026-01-01', $result[0]['dateFrom']);
|
||||||
$this->assertSame('2026-01-14', $result[0]->dateTo);
|
$this->assertSame('2026-01-14', $result[0]['dateTo']);
|
||||||
$this->assertNull($result[0]->type);
|
$this->assertNull($result[0]['type']);
|
||||||
|
|
||||||
$this->assertSame('2026-01-15', $result[1]->dateFrom);
|
$this->assertSame('2026-01-15', $result[1]['dateFrom']);
|
||||||
$this->assertSame('2026-01-31', $result[1]->dateTo);
|
$this->assertSame('2026-01-31', $result[1]['dateTo']);
|
||||||
$this->assertSame('discount', $result[1]->type);
|
$this->assertSame('discount', $result[1]['type']);
|
||||||
|
|
||||||
$this->assertSame('2026-02-01', $result[2]->dateFrom);
|
$this->assertSame('2026-02-01', $result[2]['dateFrom']);
|
||||||
$this->assertSame('2026-03-31', $result[2]->dateTo);
|
$this->assertSame('2026-03-31', $result[2]['dateTo']);
|
||||||
$this->assertNull($result[2]->type);
|
$this->assertNull($result[2]['type']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDiscountRowIncludesDefaultPrice(): void
|
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');
|
$result = $this->builder->buildTimeline([$base, $discount], new \DateTimeImmutable('2026-01-01'), new \DateTimeImmutable('2026-12-31'), 'EUR');
|
||||||
|
|
||||||
$discountRow = $result[1];
|
$discountRow = $result[1];
|
||||||
$this->assertSame(120.0, $discountRow->pricePerNight);
|
$this->assertSame(120.0, $discountRow['pricePerNight']);
|
||||||
$this->assertSame(150.0, $discountRow->defaultPricePerNight);
|
$this->assertSame(150.0, $discountRow['defaultPricePerNight']);
|
||||||
$this->assertSame(20.0, $discountRow->priceAdditionalPerson);
|
$this->assertSame(20.0, $discountRow['priceAdditionalPerson']);
|
||||||
$this->assertSame(30.0, $discountRow->defaultPriceAdditionalPerson);
|
$this->assertSame(30.0, $discountRow['defaultPriceAdditionalPerson']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBaseRowsHaveNullDefaultPriceFields(): void
|
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');
|
$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]['defaultPricePerNight']);
|
||||||
$this->assertNull($result[0]->defaultPriceAdditionalPerson);
|
$this->assertNull($result[0]['defaultPriceAdditionalPerson']);
|
||||||
$this->assertNull($result[2]->defaultPricePerNight);
|
$this->assertNull($result[2]['defaultPricePerNight']);
|
||||||
$this->assertNull($result[2]->defaultPriceAdditionalPerson);
|
$this->assertNull($result[2]['defaultPriceAdditionalPerson']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDiscountWithNoBasePriceHasNullDefaultPrice(): void
|
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');
|
$result = $this->builder->buildTimeline([$discount], new \DateTimeImmutable('2026-01-01'), new \DateTimeImmutable('2026-12-31'), 'EUR');
|
||||||
|
|
||||||
$this->assertCount(1, $result);
|
$this->assertCount(1, $result);
|
||||||
$this->assertSame('discount', $result[0]->type);
|
$this->assertSame('discount', $result[0]['type']);
|
||||||
$this->assertNull($result[0]->defaultPricePerNight);
|
$this->assertNull($result[0]['defaultPricePerNight']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGapBetweenTwoPricesIsOmitted(): void
|
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');
|
$result = $this->builder->buildTimeline([$first, $second], new \DateTimeImmutable('2026-01-01'), new \DateTimeImmutable('2026-12-31'), 'EUR');
|
||||||
|
|
||||||
$this->assertCount(2, $result);
|
$this->assertCount(2, $result);
|
||||||
$this->assertSame('2026-01-01', $result[0]->dateFrom);
|
$this->assertSame('2026-01-01', $result[0]['dateFrom']);
|
||||||
$this->assertSame('2026-01-31', $result[0]->dateTo);
|
$this->assertSame('2026-01-31', $result[0]['dateTo']);
|
||||||
$this->assertSame('2026-03-01', $result[1]->dateFrom);
|
$this->assertSame('2026-03-01', $result[1]['dateFrom']);
|
||||||
$this->assertSame('2026-03-31', $result[1]->dateTo);
|
$this->assertSame('2026-03-31', $result[1]['dateTo']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testOverrideSplitsBasePeriod(): void
|
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');
|
$result = $this->builder->buildTimeline([$base, $override], new \DateTimeImmutable('2026-01-01'), new \DateTimeImmutable('2026-12-31'), 'EUR');
|
||||||
|
|
||||||
$this->assertCount(3, $result);
|
$this->assertCount(3, $result);
|
||||||
$this->assertNull($result[0]->type);
|
$this->assertNull($result[0]['type']);
|
||||||
$this->assertSame('override', $result[1]->type);
|
$this->assertSame('override', $result[1]['type']);
|
||||||
$this->assertSame(180.0, $result[1]->pricePerNight);
|
$this->assertSame(180.0, $result[1]['pricePerNight']);
|
||||||
$this->assertNull($result[2]->type);
|
$this->assertNull($result[2]['type']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDiscountOverTwoDifferentBasePricesProducesTwoDiscountRows(): void
|
public function testDiscountOverTwoDifferentBasePricesProducesTwoDiscountRows(): void
|
||||||
@@ -166,23 +166,23 @@ class PriceTimelineBuilderTest extends TestCase
|
|||||||
|
|
||||||
$this->assertCount(4, $result);
|
$this->assertCount(4, $result);
|
||||||
|
|
||||||
$this->assertSame('2026-01-01', $result[0]->dateFrom);
|
$this->assertSame('2026-01-01', $result[0]['dateFrom']);
|
||||||
$this->assertSame('2026-01-14', $result[0]->dateTo);
|
$this->assertSame('2026-01-14', $result[0]['dateTo']);
|
||||||
$this->assertNull($result[0]->type);
|
$this->assertNull($result[0]['type']);
|
||||||
|
|
||||||
$this->assertSame('2026-01-15', $result[1]->dateFrom);
|
$this->assertSame('2026-01-15', $result[1]['dateFrom']);
|
||||||
$this->assertSame('2026-01-20', $result[1]->dateTo);
|
$this->assertSame('2026-01-20', $result[1]['dateTo']);
|
||||||
$this->assertSame('discount', $result[1]->type);
|
$this->assertSame('discount', $result[1]['type']);
|
||||||
$this->assertSame(100.0, $result[1]->defaultPricePerNight); // baseA
|
$this->assertSame(100.0, $result[1]['defaultPricePerNight']); // baseA
|
||||||
|
|
||||||
$this->assertSame('2026-01-21', $result[2]->dateFrom);
|
$this->assertSame('2026-01-21', $result[2]['dateFrom']);
|
||||||
$this->assertSame('2026-01-31', $result[2]->dateTo);
|
$this->assertSame('2026-01-31', $result[2]['dateTo']);
|
||||||
$this->assertSame('discount', $result[2]->type);
|
$this->assertSame('discount', $result[2]['type']);
|
||||||
$this->assertSame(120.0, $result[2]->defaultPricePerNight); // baseB
|
$this->assertSame(120.0, $result[2]['defaultPricePerNight']); // baseB
|
||||||
|
|
||||||
$this->assertSame('2026-02-01', $result[3]->dateFrom);
|
$this->assertSame('2026-02-01', $result[3]['dateFrom']);
|
||||||
$this->assertSame('2026-03-31', $result[3]->dateTo);
|
$this->assertSame('2026-03-31', $result[3]['dateTo']);
|
||||||
$this->assertNull($result[3]->type);
|
$this->assertNull($result[3]['type']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- resolveWinner ---
|
// --- 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in new issue
Block a user