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:
@@ -3,28 +3,36 @@
|
||||
use App\Modules\Jobs\Application\DTOs\CustomerJobData;
|
||||
use App\Modules\Jobs\Application\DTOs\TaskData;
|
||||
use App\Modules\Jobs\Application\Services\JobDetailsFactory;
|
||||
use App\Modules\Jobs\Application\Services\TaskPlanner;
|
||||
use App\Modules\Jobs\Application\Services\TaskReferenceChecker;
|
||||
use App\Modules\Jobs\Application\UseCases\AddTask;
|
||||
use App\Modules\Jobs\Application\UseCases\ChangeJobStatus;
|
||||
use App\Modules\Jobs\Application\UseCases\ChangeTaskStatus;
|
||||
use App\Modules\Jobs\Application\UseCases\ClearTaskSchedule;
|
||||
use App\Modules\Jobs\Application\UseCases\CreateCustomerJob;
|
||||
use App\Modules\Jobs\Application\UseCases\RemoveTask;
|
||||
use App\Modules\Jobs\Application\UseCases\ScheduleTask;
|
||||
use App\Modules\Jobs\Application\UseCases\UpdateTask;
|
||||
use App\Modules\Jobs\Domain\Enums\JobStatus;
|
||||
use App\Modules\Jobs\Domain\Enums\TaskStatus;
|
||||
use App\Modules\Jobs\Domain\Exceptions\InvalidTaskReference;
|
||||
use App\Modules\Jobs\Domain\Exceptions\InvalidTaskTitle;
|
||||
use App\Modules\Jobs\Domain\Exceptions\PlanEndsBeforeStart;
|
||||
use App\Modules\Jobs\Domain\Exceptions\TaskHasTimeEntries;
|
||||
use App\Modules\Jobs\Domain\Exceptions\TaskNotFound;
|
||||
use App\Modules\Jobs\Domain\Exceptions\TasksNotAllowedYet;
|
||||
use App\Modules\Jobs\Domain\ValueObjects\TaskTitle;
|
||||
use App\Modules\Shared\Application\UseCases\HolidayCalendar;
|
||||
use Tests\Fakes\FakeCatalogQueries;
|
||||
use Tests\Fakes\FakeClock;
|
||||
use Tests\Fakes\FakeCustomerQueries;
|
||||
use Tests\Fakes\FakeSettings;
|
||||
use Tests\Fakes\FakeTaskUsage;
|
||||
use Tests\Fakes\FakeTransactionManager;
|
||||
use Tests\Fakes\FakeUserAccountQueries;
|
||||
use Tests\Fakes\InMemoryCustomerJobRepository;
|
||||
use Tests\Fakes\InMemoryHolidayOverrides;
|
||||
use Tests\Fakes\InMemoryTaskBookingRepository;
|
||||
use Tests\Fakes\InMemoryTaskRepository;
|
||||
|
||||
beforeEach(function () {
|
||||
@@ -50,8 +58,12 @@ beforeEach(function () {
|
||||
$this->tentativeJobId = $createJob->execute(new CustomerJobData('Alustava', 1, [1], 10, 'one_off', 'tentative', 'normal'), 10);
|
||||
|
||||
$checker = new TaskReferenceChecker($this->catalog, $this->users);
|
||||
$this->addTask = new AddTask($this->jobs, $this->tasks, $checker, $transactions);
|
||||
$this->updateTask = new UpdateTask($this->jobs, $this->tasks, $checker, $transactions);
|
||||
$this->bookings = new InMemoryTaskBookingRepository($this->tasks);
|
||||
$this->planner = new TaskPlanner($this->bookings, new HolidayCalendar(new InMemoryHolidayOverrides), new FakeSettings);
|
||||
$this->addTask = new AddTask($this->jobs, $this->tasks, $checker, $this->planner, $transactions);
|
||||
$this->updateTask = new UpdateTask($this->jobs, $this->tasks, $checker, $this->planner, $transactions);
|
||||
$this->scheduleTask = new ScheduleTask($this->jobs, $this->tasks, $checker, $this->planner, $transactions);
|
||||
$this->clearSchedule = new ClearTaskSchedule($this->tasks, $this->planner, $transactions);
|
||||
$this->changeTaskStatus = new ChangeTaskStatus($this->tasks, $transactions);
|
||||
$this->usage = new FakeTaskUsage;
|
||||
$this->removeTask = new RemoveTask($this->tasks, $this->usage, $transactions);
|
||||
@@ -136,3 +148,61 @@ it('does not remove a task with time entries', function () {
|
||||
->and(JobStatus::Done->locksTime())->toBeTrue()
|
||||
->and(JobStatus::OnHold->locksTime())->toBeFalse();
|
||||
});
|
||||
|
||||
it('books a scheduled task evenly from the working days of its period', function () {
|
||||
$taskId = $this->addTask->execute($this->jobId, new TaskData('Taitto', 11, 'waiting', estimatedHours: '12', assigneeUserIds: [10], plannedFrom: '2026-12-04', plannedTo: '2026-12-07'), 10);
|
||||
$oneDayId = $this->addTask->execute($this->jobId, new TaskData('Palaveri', 91, 'waiting', assigneeUserIds: [10], plannedFrom: '2026-12-08'), 10);
|
||||
|
||||
expect($this->bookings->of($taskId, 10))->toBe(['2026-12-04' => 360, '2026-12-07' => 360])
|
||||
->and($this->tasks->findForJob($this->jobId, $oneDayId)?->plannedTo()?->format('Y-m-d'))->toBe('2026-12-08')
|
||||
->and($this->bookings->of($oneDayId, 10))->toBe([]);
|
||||
});
|
||||
|
||||
it('moves what does not fit in a full day to the next working day', function () {
|
||||
$this->addTask->execute($this->jobId, new TaskData('Kuvaus', 11, 'waiting', estimatedHours: '6', assigneeUserIds: [10], plannedFrom: '2026-12-04'), 10);
|
||||
$taskId = $this->addTask->execute($this->jobId, new TaskData('Taitto', 11, 'waiting', estimatedHours: '4', assigneeUserIds: [10]), 10);
|
||||
|
||||
$result = $this->scheduleTask->execute($this->jobId, $taskId, 10, 10, '2026-12-04', '2026-12-04');
|
||||
|
||||
expect($result->extended)->toBeTrue()
|
||||
->and($result->plannedTo)->toBe('2026-12-07')
|
||||
->and($this->bookings->of($taskId, 10))->toBe(['2026-12-04' => 120, '2026-12-07' => 120]);
|
||||
});
|
||||
|
||||
it('does not count done tasks in the day load', function () {
|
||||
$doneId = $this->addTask->execute($this->jobId, new TaskData('Kuvaus', 11, 'waiting', estimatedHours: '8', assigneeUserIds: [10], plannedFrom: '2026-12-04'), 10);
|
||||
$this->changeTaskStatus->execute($this->jobId, $doneId, TaskStatus::Done);
|
||||
$taskId = $this->addTask->execute($this->jobId, new TaskData('Taitto', 11, 'waiting', estimatedHours: '8', assigneeUserIds: [10], plannedFrom: '2026-12-04'), 10);
|
||||
|
||||
expect($this->bookings->of($taskId, 10))->toBe(['2026-12-04' => 480]);
|
||||
});
|
||||
|
||||
it('moves a task to another person and gives it the days its estimate needs', function () {
|
||||
$this->users->addUser(11, 'Aino');
|
||||
$taskId = $this->addTask->execute($this->jobId, new TaskData('Taitto', 11, 'waiting', estimatedHours: '20', assigneeUserIds: [10], plannedFrom: '2026-12-01'), 10);
|
||||
|
||||
$result = $this->scheduleTask->execute($this->jobId, $taskId, 10, 11, '2026-12-11', null);
|
||||
|
||||
expect($this->tasks->findForJob($this->jobId, $taskId)?->assigneeUserIds())->toBe([11])
|
||||
->and($result->plannedFrom)->toBe('2026-12-11')
|
||||
->and($result->plannedTo)->toBe('2026-12-15')
|
||||
->and($result->extended)->toBeFalse()
|
||||
->and($this->bookings->of($taskId, 10))->toBe([])
|
||||
->and(array_sum($this->bookings->of($taskId, 11)))->toBe(1200);
|
||||
});
|
||||
|
||||
it('rejects moving a task to an inactive person or ending it before it starts', function () {
|
||||
$taskId = $this->addTask->execute($this->jobId, new TaskData('Taitto', 11, 'waiting', assigneeUserIds: [10]), 10);
|
||||
|
||||
expect(fn () => $this->scheduleTask->execute($this->jobId, $taskId, 10, 12, '2026-12-07', '2026-12-07'))->toThrow(InvalidTaskReference::class)
|
||||
->and(fn () => $this->scheduleTask->execute($this->jobId, $taskId, 10, 10, '2026-12-07', '2026-12-04'))->toThrow(PlanEndsBeforeStart::class);
|
||||
});
|
||||
|
||||
it('takes a task out of the calendar', function () {
|
||||
$taskId = $this->addTask->execute($this->jobId, new TaskData('Taitto', 11, 'waiting', estimatedHours: '4', assigneeUserIds: [10], plannedFrom: '2026-12-07'), 10);
|
||||
|
||||
$this->clearSchedule->execute($this->jobId, $taskId);
|
||||
|
||||
expect($this->tasks->findForJob($this->jobId, $taskId)?->isScheduled())->toBeFalse()
|
||||
->and($this->bookings->of($taskId, 10))->toBe([]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user