fix: put the guiding fee on one guide place only

This commit is contained in:
fromme committed 2026-10-16 09:56:04 +02:00
1 parent f0ad5374e9
commit c7e0ad67e6
4 files changed
+53 -21

No files matched your search

+19 -13
View File
@@ -17,11 +17,13 @@ use App\Service\Common\PickupOptions;
* - without split, each ski level is a Kursleitung of its own, one place;
* - 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;
* - 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.
* dates of one product;
* - Guiding is the guiding fee on exactly one guide place, not an assignment of its own: the
* bus escort's. Where that assignment has more places, one place is split off to carry
* fee and pickup, so the others are neither guiding nor escorting the bus.
*/
final class AssignmentPlanner
{
@@ -64,6 +66,7 @@ final class AssignmentPlanner
}
$pickup = $this->firstPickup($destination);
$guiding = $rule->isGuiding();
$planned = [];
foreach ($roles as [$role, $places]) {
@@ -71,26 +74,29 @@ final class AssignmentPlanner
continue;
}
$fees = [];
$fees = true === $role->isCourse() ? [StaffingFee::COURSE] : [];
if (true === $role->isGuide() && true === $rule->isGuiding()) {
$fees[] = StaffingFee::GUIDING;
if (false === $role->isGuide()) {
$planned[] = new PlannedAssignment($role, $places, null, $fees);
continue;
}
if (true === $role->isCourse()) {
$fees[] = StaffingFee::COURSE;
}
$first = true === $guiding ? 1 : $places;
$planned[] = new PlannedAssignment(
$role,
$places,
true === $role->isGuide() ? $pickup : null,
$fees,
$first,
$pickup,
true === $guiding ? [StaffingFee::GUIDING, ...$fees] : $fees,
);
if (true === $role->isGuide()) {
$pickup = null;
if ($first < $places) {
$planned[] = new PlannedAssignment($role, $places - $first, null, $fees);
}
$guiding = false;
$pickup = null;
}
return $planned;