Add approval of hours and lock opening for management
- Time entries store who approved them and when. Approved hours are locked: cells, task page edits and removals are refused. - "Hyväksy viikko" in the weekly view approves the user's own week; subcontractors' hours are approved by management. - Management gets an approval page (unapproved weeks by person, recently approved weeks) and can open anyone's week read-only to approve it or cancel its approval, which only management may do. - Only management may move a done job back to an earlier status, which opens the lock on its hours and expenses; the history marks it. - The Clock contract gets now() for approval times. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -10,6 +10,7 @@ use App\Modules\TimeTracking\Application\UseCases\RemoveTimeEntry;
|
||||
use App\Modules\TimeTracking\Application\UseCases\UpdateTimeEntry;
|
||||
use App\Modules\TimeTracking\Domain\Exceptions\DailyHoursExceeded;
|
||||
use App\Modules\TimeTracking\Domain\Exceptions\InvalidWorkedHours;
|
||||
use App\Modules\TimeTracking\Domain\Exceptions\TimeApproved;
|
||||
use App\Modules\TimeTracking\Domain\Exceptions\TimeLocked;
|
||||
use App\Modules\TimeTracking\Domain\ValueObjects\WorkedHours;
|
||||
use App\Modules\Users\Application\Contracts\Clock;
|
||||
@@ -104,7 +105,7 @@ new class extends Component
|
||||
{
|
||||
$entry = collect($this->entries)->firstWhere('id', $entryId);
|
||||
|
||||
if ($entry === null) {
|
||||
if ($entry === null || $entry->isApproved) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -151,7 +152,9 @@ new class extends Component
|
||||
|
||||
public function confirmRemoval(int $entryId): void
|
||||
{
|
||||
if (collect($this->entries)->firstWhere('id', $entryId) === null) {
|
||||
$entry = collect($this->entries)->firstWhere('id', $entryId);
|
||||
|
||||
if ($entry === null || $entry->isApproved) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -199,6 +202,7 @@ new class extends Component
|
||||
$exception instanceof InvalidWorkedHours => 'time.errors.invalid_hours',
|
||||
$exception instanceof DailyHoursExceeded => 'time.errors.day_full',
|
||||
$exception instanceof TimeLocked => 'time.errors.locked',
|
||||
$exception instanceof TimeApproved => 'time.errors.approved',
|
||||
default => 'time.errors.not_found',
|
||||
});
|
||||
}
|
||||
@@ -266,7 +270,11 @@ new class extends Component
|
||||
<p class="whitespace-pre-line text-zinc-700 dark:text-zinc-300">{{ $entry->note }}</p>
|
||||
@endif
|
||||
</div>
|
||||
@unless ($task->isLocked())
|
||||
@if ($entry->isApproved)
|
||||
<span class="inline-flex items-center gap-1">
|
||||
<x-icon name="check-circle" class="size-4" aria-hidden="true" /> {{ __('time.approval.cell_approved') }}
|
||||
</span>
|
||||
@elseif (! $task->isLocked())
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<x-button
|
||||
id="edit-entry-{{ $entry->id }}"
|
||||
@@ -288,7 +296,7 @@ new class extends Component
|
||||
:aria-label="__('time.task_page.remove_named', ['day' => $this->dayLabel($entry->workedOn)])"
|
||||
/>
|
||||
</div>
|
||||
@endunless
|
||||
@endif
|
||||
</div>
|
||||
@endif
|
||||
</li>
|
||||
|
||||
Reference in New Issue
Block a user