Skip to content

Commit

Permalink
feat: add approver id and name for a timesheet (#467)
Browse files Browse the repository at this point in the history
  • Loading branch information
djaiss committed Jan 3, 2021
1 parent 70526e6 commit 2309598
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/Services/Company/Employee/Timesheet/ApproveTimesheet.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ private function validate(): void
private function accept(): void
{
$this->timesheet->status = Timesheet::APPROVED;
$this->timesheet->approver_id = $this->author->id;
$this->timesheet->approver_name = $this->author->name;
$this->timesheet->save();
}

Expand Down
2 changes: 2 additions & 0 deletions app/Services/Company/Employee/Timesheet/RejectTimesheet.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ private function validate(): void
private function reject(): void
{
$this->timesheet->status = Timesheet::REJECTED;
$this->timesheet->approver_id = $this->author->id;
$this->timesheet->approver_name = $this->author->name;
$this->timesheet->save();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ private function executeService(Employee $author, Employee $employee, Timesheet
$this->assertDatabaseHas('timesheets', [
'id' => $timesheet->id,
'status' => Timesheet::APPROVED,
'approver_id' => $author->id,
'approver_name' => $author->name,
'started_at' => Carbon::now()->startOfWeek()->format('Y-m-d 00:00:00'),
'ended_at' => Carbon::now()->endOfWeek()->format('Y-m-d 23:59:59'),
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ private function executeService(Employee $author, Employee $employee, Timesheet
$this->assertDatabaseHas('timesheets', [
'id' => $timesheet->id,
'status' => Timesheet::REJECTED,
'approver_id' => $author->id,
'approver_name' => $author->name,
'started_at' => Carbon::now()->startOfWeek()->format('Y-m-d 00:00:00'),
'ended_at' => Carbon::now()->endOfWeek()->format('Y-m-d 23:59:59'),
]);
Expand Down

0 comments on commit 2309598

Please sign in to comment.