A new Notifications module shows a bell beside the profile menu with the number of unseen notifications and a panel of the last 7 days; opening it marks them seen, and each notification links to its job or task. - A daily run at 14.00 (notifications:task-starts) tells the assignee and members of tasks that start by the next working day, skipping holidays and days off, done tasks and archived jobs. - Jobs publishes PeopleAddedToTask and PeopleAddedToJob when someone else makes a user a task's assignee or member or gives them a role on a job; those users are notified at once. UpdateTask and ScheduleTask now take the acting user. - A notification link to #task-<id> opens that task card on the job page. Also: simplifying job fields per service unit (K31) moves to the end of phase 4, and the workflow template browser test waits for Livewire's progress bar before its last accessibility check. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
59 lines
1.9 KiB
PHP
59 lines
1.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Modules\Jobs\Application\UseCases;
|
|
|
|
use App\Modules\Jobs\Application\DTOs\CustomerJobData;
|
|
use App\Modules\Jobs\Application\Services\JobDetailsFactory;
|
|
use App\Modules\Jobs\Domain\Contracts\CustomerJobRepository;
|
|
use App\Modules\Jobs\Domain\Events\PeopleAddedToJob;
|
|
use App\Modules\Jobs\Domain\Exceptions\CustomerJobNotFound;
|
|
use App\Modules\Jobs\Domain\Exceptions\InvalidJobReference;
|
|
use App\Modules\Shared\Application\Contracts\EventDispatcher;
|
|
use App\Modules\Shared\Application\Contracts\TransactionManager;
|
|
use App\Modules\Users\Application\Contracts\Clock;
|
|
|
|
/**
|
|
* Changes a customer job and records each changed field in its history.
|
|
* Who may set billing statuses or archive is checked by the caller.
|
|
*/
|
|
final class UpdateCustomerJob
|
|
{
|
|
public function __construct(
|
|
private CustomerJobRepository $jobs,
|
|
private JobDetailsFactory $detailsFactory,
|
|
private TransactionManager $transactions,
|
|
private Clock $clock,
|
|
private EventDispatcher $events,
|
|
) {}
|
|
|
|
/**
|
|
* @throws CustomerJobNotFound
|
|
* @throws InvalidJobReference
|
|
*/
|
|
public function execute(int $jobId, CustomerJobData $data, int $actorUserId): void
|
|
{
|
|
$this->transactions->run(function () use ($jobId, $data, $actorUserId): void {
|
|
$job = $this->jobs->findById($jobId) ?? throw new CustomerJobNotFound($jobId);
|
|
|
|
$before = $job->details();
|
|
$changes = $job->changeDetails($this->detailsFactory->build($data, $before));
|
|
$job->recordCompletion($this->clock->now());
|
|
|
|
if ($changes === []) {
|
|
return;
|
|
}
|
|
|
|
$job = $this->jobs->save($job);
|
|
$this->jobs->recordChanges($jobId, $actorUserId, $changes);
|
|
|
|
$added = PeopleAddedToJob::between($before, $job, $actorUserId);
|
|
|
|
if ($added !== null) {
|
|
$this->events->dispatch($added);
|
|
}
|
|
});
|
|
}
|
|
}
|