Set the calendar's daily capacity in the company details
The task calendar's daily maximum moves from the hidden setting jobs.daily_capacity_hours to shared.daily_capacity_hours, edited by the admin on the company details page. An empty field means 7.5 hours. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
@@ -7,7 +7,7 @@ namespace App\Modules\Jobs\Application\Services;
|
||||
use App\Modules\Jobs\Domain\Contracts\TaskBookingRepository;
|
||||
use App\Modules\Jobs\Domain\Entities\Task;
|
||||
use App\Modules\Jobs\Domain\Services\TaskScheduler;
|
||||
use App\Modules\Shared\Application\Contracts\Settings;
|
||||
use App\Modules\Shared\Application\UseCases\DailyCapacity;
|
||||
use App\Modules\Shared\Application\UseCases\HolidayCalendar;
|
||||
use DateInterval;
|
||||
use DateTimeImmutable;
|
||||
@@ -15,29 +15,23 @@ use DateTimeImmutable;
|
||||
/**
|
||||
* Books a saved task's estimate from its assignee's days with the
|
||||
* TaskScheduler, using the holidays in use and the daily maximum
|
||||
* (setting `jobs.daily_capacity_hours`, 8 h by default). When the days
|
||||
* are full, the task's planned end moves later.
|
||||
* (Shared's DailyCapacity, set in the company details, 7.5 h by default).
|
||||
* When the days are full, the task's planned end moves later.
|
||||
*/
|
||||
final class TaskPlanner
|
||||
{
|
||||
public const string CAPACITY_KEY = 'jobs.daily_capacity_hours';
|
||||
|
||||
private const int DEFAULT_CAPACITY_HOURS = 8;
|
||||
|
||||
/** Days past the start in which holidays and other bookings are looked up. */
|
||||
private const int LOOKAHEAD_DAYS = 400;
|
||||
|
||||
public function __construct(
|
||||
private TaskBookingRepository $bookings,
|
||||
private HolidayCalendar $holidays,
|
||||
private Settings $settings,
|
||||
private DailyCapacity $capacity,
|
||||
) {}
|
||||
|
||||
public function capacityMinutes(): int
|
||||
{
|
||||
$hours = (float) str_replace(',', '.', $this->settings->get(self::CAPACITY_KEY) ?? '');
|
||||
|
||||
return (int) round(($hours > 0 && $hours <= 24 ? $hours : self::DEFAULT_CAPACITY_HOURS) * 60);
|
||||
return $this->capacity->minutes();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user