feat: replace custom discount with absolute value in favor of percentage

This commit is contained in:
fromme committed 2026-09-08 17:11:00 +02:00
1 parent d6c2cfaf1c
commit f8ff4b82a3
15 files changed
+105 -50

No files matched your search

@@ -14,11 +14,13 @@ use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\Extension\Core\Type\MoneyType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\Positive;
use Symfony\Component\Validator\Constraints\Range;
/** @extends AbstractType<AccommodationBooking> */
@@ -158,14 +160,17 @@ class AccommodationBookingType extends AbstractType
new Range(min: 1, max: 100),
],
])
// Applies to the total after the three section discounts. The label is not marked
// required here — a percentage may legitimately be absent — but the entity refuses
// a percentage without one, so no unnamed discount can reach the customer.
->add('totalDiscount', IntegerType::class, [
'label' => 'Rabatt Gesamtpreis (%)',
// A fixed sum, not a percentage, applied to the total after the three section
// discounts. The label is not marked required here — an amount may legitimately be
// absent — but the entity refuses an amount without one, so no unnamed discount can
// reach the customer.
->add('totalDiscountAmount', MoneyType::class, [
'label' => 'Rabatt Gesamtpreis',
'currency' => $options['currency'],
'divisor' => 100,
'required' => false,
'constraints' => [
new Range(min: 1, max: 100),
new Positive(),
],
])
->add('totalDiscountLabel', TextType::class, [
@@ -201,6 +206,7 @@ class AccommodationBookingType extends AbstractType
'current_board_service' => null,
'current_additional_services' => [],
'assignable_managers' => [],
'currency' => 'EUR',
]);
$resolver->setAllowedTypes('max_adolescent_age', 'int');
$resolver->setAllowedTypes('board_services', 'array');
@@ -208,5 +214,6 @@ class AccommodationBookingType extends AbstractType
$resolver->setAllowedTypes('current_board_service', ['null', BoardService::class]);
$resolver->setAllowedTypes('current_additional_services', 'array');
$resolver->setAllowedTypes('assignable_managers', 'array');
$resolver->setAllowedTypes('currency', 'string');
}
}