fix: don't hide voucher fields for booking status 'O'
closes #869bvbkrd
This commit is contained in:
@@ -4,30 +4,33 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Form\Service\Condition;
|
||||
|
||||
use App\BusProNet\Constants;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Service\Contract\FieldConditionInterface;
|
||||
|
||||
/**
|
||||
* Condition that checks if the booking is a final booking (not an inquiry).
|
||||
* Condition that checks if the booking is not an inquiry booking.
|
||||
*
|
||||
* This condition is used to exclude certain fields (like vouchers) from inquiry
|
||||
* bookings where they are not applicable. When a booking has inquiry status ('A'),
|
||||
* fields with this condition will be excluded from the form.
|
||||
*
|
||||
* Returns true for both final ('F') and option ('O') bookings.
|
||||
*/
|
||||
class FinalBookingOnlyCondition implements FieldConditionInterface
|
||||
{
|
||||
/**
|
||||
* Evaluates if the booking is a final booking.
|
||||
* Evaluates if the booking is not an inquiry booking.
|
||||
*
|
||||
* @param BookingDto $bookingDto The current booking data (create or edit)
|
||||
* @param int $participantIndex The index of the participant being evaluated
|
||||
* @param array<string, mixed> $formData Current form data (unused)
|
||||
*
|
||||
* @return bool True if booking status is 'F' (final), false if 'A' (inquiry)
|
||||
* @return bool True if booking status is not 'A' (inquiry), false otherwise
|
||||
*/
|
||||
public function evaluate(BookingDto $bookingDto, int $participantIndex, array $formData): bool
|
||||
{
|
||||
return 'F' === $bookingDto->bookingStatus;
|
||||
return Constants::BOOKING_STATUS_INQUIRY !== $bookingDto->bookingStatus;
|
||||
}
|
||||
|
||||
public function getDependentFields(): array
|
||||
@@ -37,6 +40,6 @@ class FinalBookingOnlyCondition implements FieldConditionInterface
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Only available for final bookings (not inquiry bookings)';
|
||||
return 'Only available for non-inquiry bookings (final or option)';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user