Worklog: log deletion, User page: fix voucher calculation

This commit is contained in:
Igor Scheller 2023-12-23 00:38:44 +01:00 committed by msquare
parent 8833506e04
commit f3e1192695
3 changed files with 15 additions and 1 deletions

View File

@ -149,7 +149,10 @@ function User_get_eligable_voucher_count($user)
: null; : null;
$shiftEntries = ShiftEntries_finished_by_user($user, $start); $shiftEntries = ShiftEntries_finished_by_user($user, $start);
$worklog = UserWorkLogsForUser($user->id, $start); $worklog = $user->worklogs()
->whereDate('worked_at', '>=', $start ?: 0)
->with(['user', 'creator'])
->get();
$shifts_done = $shifts_done =
count($shiftEntries) count($shiftEntries)
+ $worklog->count(); + $worklog->count();

View File

@ -131,6 +131,16 @@ class UserWorkLogController extends BaseController
} }
$worklog->delete(); $worklog->delete();
$this->log->info(
'Deleted worklog for {name} ({id}) at {time} about {hours}h: {text}',
[
'name' => $worklog->user->name,
'id' => $worklog->user->id,
'time' => $worklog->worked_at,
'hours' => $worklog->hours,
'text' => $worklog->comment,
]
);
$this->addNotification('worklog.delete.success'); $this->addNotification('worklog.delete.success');
return $this->redirect->to('/users?action=view&user_id=' . $userId); return $this->redirect->to('/users?action=view&user_id=' . $userId);

View File

@ -306,6 +306,7 @@ class UserWorkLogControllerTest extends ControllerTest
$this->controller->deleteWorklog($request); $this->controller->deleteWorklog($request);
$this->log->hasInfoThatContains('Deleted worklog');
$this->assertHasNotification('worklog.delete.success'); $this->assertHasNotification('worklog.delete.success');
$worklog = Worklog::find($worklog->id); $worklog = Worklog::find($worklog->id);
$this->assertNull($worklog); $this->assertNull($worklog);