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:
2026-11-24 08:24:34 +02:00
co-authored by Claude Opus 5.5
parent 54d98d9d2f
commit d5cbf9d6eb
43 changed files with 1183 additions and 34 deletions
@@ -76,3 +76,38 @@ it('records hours from the task page', function () {
->assertSee('kirjaus on nyt 3,5 h.')
->assertNoAccessibilityIssues(level: 2);
});
it('has no accessibility issues on the approval pages', function (string $page, string $device, string $colorScheme) {
TimeEntryModel::query()->update(['approved_at' => now(), 'approved_by' => $this->user->id]);
$other = User::factory()->employee()->create(['name' => 'Kaisa Kollega']);
TimeEntryModel::factory()->create(['task_id' => TaskModel::factory()->assignedTo([$other->id])->create()->id, 'user_id' => $other->id, 'worked_on' => $this->monday]);
$this->actingAs(User::factory()->management()->create());
$url = $page === 'approvals' ? route('time.approvals') : route('time.week', ['kayttaja' => $this->user->id]);
$visit = visit($url);
$visit = $device === 'mobile' ? $visit->on()->mobile() : $visit->on()->desktop();
$visit = $colorScheme === 'dark' ? $visit->inDarkMode() : $visit->inLightMode();
$visit->assertSee($page === 'approvals' ? 'Kaisa Kollega' : 'hyväksytty')
->assertScript('document.documentElement.scrollWidth <= window.innerWidth', true)
->assertNoJavaScriptErrors()
->assertNoAccessibilityIssues(level: 2);
})->with(['approvals', 'week of another user'])->with([
'desktop, light' => ['desktop', 'light'],
'desktop, dark' => ['desktop', 'dark'],
'mobile, light' => ['mobile', 'light'],
'mobile, dark' => ['mobile', 'dark'],
]);
it('approves the own week with the keyboard and shows the cells as approved', function () {
visit(route('time.week'))
->assertSee('Hyväksymättä 1,5 h.')
->keys('#approval-heading + p + div button', 'Enter')
->assertSee('Hyväksytyt tunnit on lukittu.')
->assertSee('hyväksytty')
->assertNoAccessibilityIssues(level: 2);
expect(TimeEntryModel::query()->sole()->approved_at)->not->toBeNull();
});