From 0e2021e96d09c2911f53894f3da506700fde0f4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Fri, 16 Oct 2026 08:33:25 +0200 Subject: [PATCH] refactor: derive the bus escort from the travel date --- migrations/Version20261016090000.php | 37 +++++++++++++++++++ src/Entity/StaffingRule.php | 23 ------------ src/Form/StaffingRuleType.php | 4 -- src/Service/Assignment/AssignmentPlanner.php | 8 ++-- .../system/staffing_rule/_form.html.twig | 1 - .../system/staffing_rule/index.html.twig | 7 ++-- tests/Entity/StaffingRuleTest.php | 3 -- .../Assignment/AssignmentPlannerTest.php | 25 +++++++------ .../Assignment/StaffingFixturesTrait.php | 1 - 9 files changed, 59 insertions(+), 50 deletions(-) create mode 100644 migrations/Version20261016090000.php diff --git a/migrations/Version20261016090000.php b/migrations/Version20261016090000.php new file mode 100644 index 0000000..d26d5f2 --- /dev/null +++ b/migrations/Version20261016090000.php @@ -0,0 +1,37 @@ +addSql('ALTER TABLE staffing_rule DROP bus_escort'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE staffing_rule ADD bus_escort TINYINT NOT NULL'); + } +} diff --git a/src/Entity/StaffingRule.php b/src/Entity/StaffingRule.php index b28ba12..60e7ed5 100644 --- a/src/Entity/StaffingRule.php +++ b/src/Entity/StaffingRule.php @@ -62,9 +62,6 @@ class StaffingRule implements BlameableEntityInterface, TimestampableEntityInter #[ORM\Column] private bool $guiding = false; - #[ORM\Column] - private bool $busEscort = false; - /** Previewed either way; only enabled rows generate. */ #[ORM\Column] private bool $enabled = false; @@ -102,14 +99,6 @@ class StaffingRule implements BlameableEntityInterface, TimestampableEntityInter ->addViolation() ; } - - if (true === $this->busEscort && 0 === (int) $this->guides) { - $context - ->buildViolation('Busbegleitung braucht mindestens eine Reiseleitung') - ->atPath('busEscort') - ->addViolation() - ; - } } public function getSkiLevelCount(): int @@ -200,18 +189,6 @@ class StaffingRule implements BlameableEntityInterface, TimestampableEntityInter return $this; } - public function isBusEscort(): bool - { - return $this->busEscort; - } - - public function setBusEscort(bool $busEscort): static - { - $this->busEscort = $busEscort; - - return $this; - } - public function isEnabled(): bool { return $this->enabled; diff --git a/src/Form/StaffingRuleType.php b/src/Form/StaffingRuleType.php index e980701..2fd19d6 100644 --- a/src/Form/StaffingRuleType.php +++ b/src/Form/StaffingRuleType.php @@ -40,10 +40,6 @@ class StaffingRuleType extends AbstractType 'label' => 'Guiding', 'required' => false, ]) - ->add('busEscort', CheckboxType::class, [ - 'label' => 'Busbegleitung', - 'required' => false, - ]) ->add('enabled', CheckboxType::class, [ 'label' => 'aktiv', 'help' => 'Nur aktive Zeilen legen Einsätze an; die Vorschau zeigt alle', diff --git a/src/Service/Assignment/AssignmentPlanner.php b/src/Service/Assignment/AssignmentPlanner.php index 6029973..3fd09a7 100644 --- a/src/Service/Assignment/AssignmentPlanner.php +++ b/src/Service/Assignment/AssignmentPlanner.php @@ -18,8 +18,10 @@ use App\Service\Common\PickupOptions; * - with split, a Reiseleitung takes over each level through the combined profile, one place * per level, and the plain Reiseleitung keeps the remaining places; * - Guiding is the guiding fee on every guide-type assignment, not an assignment of its own; - * - Busbegleitung pre-selects the first boarding point on exactly one assignment, the first - * guide-type one - the plain Reiseleitung where there is one. + * - a date with bus travel (boarding points) gets its first boarding point pre-selected as + * Busbegleitung on exactly one assignment, the first guide-type one - the plain Reiseleitung + * where there is one. Taken from the date, not the matrix: bus travel varies between the + * dates of one product. */ final class AssignmentPlanner { @@ -61,7 +63,7 @@ final class AssignmentPlanner } } - $pickup = true === $rule->isBusEscort() ? $this->firstPickup($destination) : null; + $pickup = $this->firstPickup($destination); $planned = []; foreach ($roles as [$role, $places]) { diff --git a/templates/admin/system/staffing_rule/_form.html.twig b/templates/admin/system/staffing_rule/_form.html.twig index 0278b1f..76f88f0 100644 --- a/templates/admin/system/staffing_rule/_form.html.twig +++ b/templates/admin/system/staffing_rule/_form.html.twig @@ -6,7 +6,6 @@ {{ form_row(form.skiAdvanced) }} {{ form_row(form.split) }} {{ form_row(form.guiding) }} - {{ form_row(form.busEscort) }} {{ form_row(form.enabled) }}