Skip to content

Commit

Permalink
feat: ability to manage softwares (#856)
Browse files Browse the repository at this point in the history
  • Loading branch information
djaiss committed Jun 8, 2021
1 parent 56cd0fb commit 98bb0ce
Show file tree
Hide file tree
Showing 52 changed files with 3,749 additions and 14 deletions.
41 changes: 41 additions & 0 deletions app/Console/Commands/Tests/SetupDummyAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
use App\Services\Company\Adminland\Hardware\CreateHardware;
use App\Services\Company\Adminland\Position\CreatePosition;
use App\Services\Company\Adminland\Question\CreateQuestion;
use App\Services\Company\Adminland\Software\CreateSoftware;
use App\Services\Company\Employee\HiringDate\SetHiringDate;
use App\Services\Company\Employee\Timesheet\RejectTimesheet;
use App\Services\Company\Employee\Timesheet\SubmitTimesheet;
Expand All @@ -64,6 +65,7 @@
use App\Services\Company\Team\Description\SetTeamDescription;
use App\Services\Company\Employee\OneOnOne\CreateOneOnOneNote;
use App\Services\Company\Employee\Skill\AttachEmployeeToSkill;
use App\Services\Company\Adminland\Software\GiveSeatToEmployee;
use App\Services\Company\Employee\OneOnOne\CreateOneOnOneEntry;
use App\Services\Company\Adminland\Employee\AddEmployeeToCompany;
use App\Services\Company\Employee\Timesheet\CreateOrGetTimesheet;
Expand Down Expand Up @@ -208,6 +210,7 @@ public function handle(): void
$this->addAnswers();
$this->addExpenses();
$this->createHardware();
$this->createSoftware();
$this->addRecentShips();
$this->addRateYourManagerSurveys();
$this->addOneOnOnes();
Expand Down Expand Up @@ -1384,6 +1387,44 @@ private function createHardware(): void
}
}

private function createSoftware(): void
{
$this->info('☐ Add softwares and associate them to employees');

$softwares = collect([
'Office 365',
'Sketch',
'Adobe Reader',
'Sublime Text 4',
'Powerpoint',
'Zoom',
'Teams',
]);

foreach ($softwares as $item) {
$newlyItem = (new CreateSoftware)->execute([
'company_id' => $this->company->id,
'author_id' => $this->michael->id,
'name' => $item,
'seats' => rand(3, 30),
'product_key' => $this->faker->uuid,
]);

foreach ($this->employees as $employee) {
if (rand(1, 2) == 1) {
continue;
}

(new GiveSeatToEmployee)->execute([
'company_id' => $this->company->id,
'author_id' => $this->michael->id,
'employee_id' => $employee->id,
'software_id' => $newlyItem->id,
]);
}
}
}

private function addRecentShips(): void
{
$this->info('☐ Add recent ships entries for teams');
Expand Down
9 changes: 9 additions & 0 deletions app/Exceptions/NotEnoughSoftwareSeat.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace App\Exceptions;

use Exception;

class NotEnoughSoftwareSeat extends Exception
{
}
46 changes: 46 additions & 0 deletions app/Helpers/LogHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1239,6 +1239,52 @@ public static function processAuditLog(AuditLog $log): string
]);
break;

case 'software_created':
$sentence = trans('account.log_software_created', [
'software_id' => $log->object->{'software_id'},
'software_name' => $log->object->{'software_name'},
]);
break;

case 'software_updated':
$sentence = trans('account.log_software_updated', [
'software_id' => $log->object->{'software_id'},
'software_name' => $log->object->{'software_name'},
]);
break;

case 'software_destroyed':
$sentence = trans('account.log_software_destroyed', [
'software_id' => $log->object->{'software_id'},
'software_name' => $log->object->{'software_name'},
]);
break;

case 'software_seat_given_to_employee':
$sentence = trans('account.log_software_seat_given_to_employee', [
'software_id' => $log->object->{'software_id'},
'software_name' => $log->object->{'software_name'},
'employee_id' => $log->object->{'employee_id'},
'employee_name' => $log->object->{'employee_name'},
]);
break;

case 'software_seat_taken_from_employee':
$sentence = trans('account.log_software_seat_taken_from_employee', [
'software_id' => $log->object->{'software_id'},
'software_name' => $log->object->{'software_name'},
'employee_id' => $log->object->{'employee_id'},
'employee_name' => $log->object->{'employee_name'},
]);
break;

case 'software_seat_given_to_employees':
$sentence = trans('account.log_software_seat_given_to_employees', [
'software_id' => $log->object->{'software_id'},
'software_name' => $log->object->{'software_name'},
]);
break;

case 'employee_joined_company':
$sentence = trans('account.log_employee_joined_company', [
'company_name' => $log->object->{'company_name'},
Expand Down

0 comments on commit 98bb0ce

Please sign in to comment.