Add the task calendar, holidays, workflow templates and customer removal

Task calendar (/jobs/calendar) replaces per-unit task Kanban columns
(K34): a two-week Gantt of tasks per person. Bars move, resize and
change person by dragging or through a keyboard dialog. Each task's
estimate is booked evenly over working days into task_bookings, and
what exceeds the daily maximum (jobs.daily_capacity_hours, 8 h) moves
to the next working day. Tasks get planned_from/planned_to on the form.

Holidays (/settings/holidays): Finnish public holidays calculated per
year, which the admin can take out of use, plus company days off.

Also includes the earlier uncommitted work: workflow templates with
adding tasks from a template, and removing customers no module refers to.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-11-24 18:13:11 +02:00
co-authored by Claude Opus 5.5
parent dfe4941f02
commit b4f2f1cfaa
134 changed files with 6930 additions and 45 deletions
@@ -0,0 +1,47 @@
<?php
use App\Modules\Jobs\Domain\Services\TaskScheduler;
function scheduleDay(string $date): DateTimeImmutable
{
return new DateTimeImmutable($date);
}
it('splits the estimate evenly over the working days of the period', function () {
// Fri 4.12.2026 – Tue 8.12.2026; the weekend in between gets nothing.
$schedule = TaskScheduler::schedule(scheduleDay('2026-12-04'), scheduleDay('2026-12-08'), 600, [], 480, []);
expect($schedule->minutesByDay)->toBe(['2026-12-04' => 210, '2026-12-07' => 195, '2026-12-08' => 195])
->and($schedule->end->format('Y-m-d'))->toBe('2026-12-08')
->and($schedule->extended)->toBeFalse();
});
it('skips holidays and uses weekend days when the period has nothing else', function () {
$overHolidays = TaskScheduler::schedule(scheduleDay('2026-12-24'), scheduleDay('2026-12-28'), 240, [], 480, ['2026-12-24', '2026-12-25']);
$weekend = TaskScheduler::schedule(scheduleDay('2026-12-05'), scheduleDay('2026-12-06'), 300, [], 480, []);
expect($overHolidays->minutesByDay)->toBe(['2026-12-28' => 240])
->and($weekend->minutesByDay)->toBe(['2026-12-05' => 150, '2026-12-06' => 150]);
});
it('moves what does not fit to the next working days and ends later', function () {
$schedule = TaskScheduler::schedule(scheduleDay('2026-12-04'), scheduleDay('2026-12-04'), 600, ['2026-12-04' => 300, '2026-12-07' => 480], 480, []);
expect($schedule->minutesByDay)->toBe(['2026-12-04' => 180, '2026-12-08' => 420])
->and($schedule->end->format('Y-m-d'))->toBe('2026-12-08')
->and($schedule->extended)->toBeTrue();
});
it('books nothing without an estimate', function () {
$schedule = TaskScheduler::schedule(scheduleDay('2026-12-07'), scheduleDay('2026-12-09'), 0, [], 480, []);
expect($schedule->minutesByDay)->toBe([])
->and($schedule->end->format('Y-m-d'))->toBe('2026-12-09');
});
it('gives a placed task the working days its estimate needs', function () {
expect(TaskScheduler::defaultEnd(scheduleDay('2026-12-07'), 240, 480, [])->format('Y-m-d'))->toBe('2026-12-07')
->and(TaskScheduler::defaultEnd(scheduleDay('2026-12-04'), 1200, 480, [])->format('Y-m-d'))->toBe('2026-12-08')
->and(TaskScheduler::defaultEnd(scheduleDay('2026-12-23'), 960, 480, ['2026-12-24', '2026-12-25'])->format('Y-m-d'))->toBe('2026-12-28')
->and(TaskScheduler::defaultEnd(scheduleDay('2026-12-05'), 0, 480, [])->format('Y-m-d'))->toBe('2026-12-05');
});