mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-15 11:42:15 +01:00
Fixed reports in deletion service
This commit is contained in:
@@ -13,6 +13,7 @@ use App\Models\Organization;
|
|||||||
use App\Models\OrganizationInvitation;
|
use App\Models\OrganizationInvitation;
|
||||||
use App\Models\Project;
|
use App\Models\Project;
|
||||||
use App\Models\ProjectMember;
|
use App\Models\ProjectMember;
|
||||||
|
use App\Models\Report;
|
||||||
use App\Models\Tag;
|
use App\Models\Tag;
|
||||||
use App\Models\Task;
|
use App\Models\Task;
|
||||||
use App\Models\TimeEntry;
|
use App\Models\TimeEntry;
|
||||||
@@ -71,6 +72,9 @@ class DeletionService
|
|||||||
// Delete all clients
|
// Delete all clients
|
||||||
Client::query()->whereBelongsTo($organization, 'organization')->delete();
|
Client::query()->whereBelongsTo($organization, 'organization')->delete();
|
||||||
|
|
||||||
|
// Delete all reports
|
||||||
|
Report::query()->whereBelongsTo($organization, 'organization')->delete();
|
||||||
|
|
||||||
// Reset the current organization
|
// Reset the current organization
|
||||||
$organization->owner()
|
$organization->owner()
|
||||||
->where('current_team_id', $organization->getKey())
|
->where('current_team_id', $organization->getKey())
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ use App\Models\Member;
|
|||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use App\Models\Project;
|
use App\Models\Project;
|
||||||
use App\Models\ProjectMember;
|
use App\Models\ProjectMember;
|
||||||
|
use App\Models\Report;
|
||||||
use App\Models\Tag;
|
use App\Models\Tag;
|
||||||
use App\Models\Task;
|
use App\Models\Task;
|
||||||
use App\Models\TimeEntry;
|
use App\Models\TimeEntry;
|
||||||
@@ -55,7 +56,8 @@ class DeletionServiceTest extends TestCaseWithDatabase
|
|||||||
* members: Collection<Member>,
|
* members: Collection<Member>,
|
||||||
* tasks: Collection<Task>,
|
* tasks: Collection<Task>,
|
||||||
* timeEntries: Collection<TimeEntry>,
|
* timeEntries: Collection<TimeEntry>,
|
||||||
* owner: User
|
* owner: User,
|
||||||
|
* reports: Collection<Report>
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
private function createOrganizationWithAllRelations(): object
|
private function createOrganizationWithAllRelations(): object
|
||||||
@@ -96,6 +98,10 @@ class DeletionServiceTest extends TestCaseWithDatabase
|
|||||||
$task2 = Task::factory()->forProject($projectWithoutClient)->forOrganization($organization)->create();
|
$task2 = Task::factory()->forProject($projectWithoutClient)->forOrganization($organization)->create();
|
||||||
$tasks = collect([$task1, $task2]);
|
$tasks = collect([$task1, $task2]);
|
||||||
|
|
||||||
|
$report1 = Report::factory()->forOrganization($organization)->create();
|
||||||
|
$report2 = Report::factory()->forOrganization($organization)->create();
|
||||||
|
$reports = collect([$report1, $report2]);
|
||||||
|
|
||||||
$timeEntries = TimeEntry::factory()->forOrganization($organization)->forMember($memberOwner)->createMany(2);
|
$timeEntries = TimeEntry::factory()->forOrganization($organization)->forMember($memberOwner)->createMany(2);
|
||||||
$timeEntriesWithTask = TimeEntry::factory()->forTask($task1)->forOrganization($organization)->forMember($memberEmployee)->createMany(2);
|
$timeEntriesWithTask = TimeEntry::factory()->forTask($task1)->forOrganization($organization)->forMember($memberEmployee)->createMany(2);
|
||||||
$timeEntriesWithProject = TimeEntry::factory()->forProject($projectWithClient)->forOrganization($organization)->forMember($memberPlaceholder)->createMany(2);
|
$timeEntriesWithProject = TimeEntry::factory()->forProject($projectWithClient)->forOrganization($organization)->forMember($memberPlaceholder)->createMany(2);
|
||||||
@@ -111,6 +117,7 @@ class DeletionServiceTest extends TestCaseWithDatabase
|
|||||||
'tasks' => $tasks,
|
'tasks' => $tasks,
|
||||||
'timeEntries' => $timeEntries,
|
'timeEntries' => $timeEntries,
|
||||||
'owner' => $userOwner,
|
'owner' => $userOwner,
|
||||||
|
'reports' => $reports,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,6 +133,7 @@ class DeletionServiceTest extends TestCaseWithDatabase
|
|||||||
$this->assertSame(0, Tag::query()->whereBelongsTo($organization, 'organization')->count());
|
$this->assertSame(0, Tag::query()->whereBelongsTo($organization, 'organization')->count());
|
||||||
$this->assertSame(0, Member::query()->whereBelongsTo($organization, 'organization')->count());
|
$this->assertSame(0, Member::query()->whereBelongsTo($organization, 'organization')->count());
|
||||||
$this->assertSame(0, Task::query()->whereBelongsTo($organization, 'organization')->count());
|
$this->assertSame(0, Task::query()->whereBelongsTo($organization, 'organization')->count());
|
||||||
|
$this->assertSame(0, Report::query()->whereBelongsTo($organization, 'organization')->count());
|
||||||
$this->assertSame(0, TimeEntry::query()->whereBelongsTo($organization, 'organization')->count());
|
$this->assertSame(0, TimeEntry::query()->whereBelongsTo($organization, 'organization')->count());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,6 +146,7 @@ class DeletionServiceTest extends TestCaseWithDatabase
|
|||||||
$this->assertSame(2, Tag::query()->whereBelongsTo($organization, 'organization')->count());
|
$this->assertSame(2, Tag::query()->whereBelongsTo($organization, 'organization')->count());
|
||||||
$this->assertSame(3, Member::query()->whereBelongsTo($organization, 'organization')->count());
|
$this->assertSame(3, Member::query()->whereBelongsTo($organization, 'organization')->count());
|
||||||
$this->assertSame(2, Task::query()->whereBelongsTo($organization, 'organization')->count());
|
$this->assertSame(2, Task::query()->whereBelongsTo($organization, 'organization')->count());
|
||||||
|
$this->assertSame(2, Report::query()->whereBelongsTo($organization, 'organization')->count());
|
||||||
$this->assertSame($specialCase ? 7 : 6, TimeEntry::query()->whereBelongsTo($organization, 'organization')->count());
|
$this->assertSame($specialCase ? 7 : 6, TimeEntry::query()->whereBelongsTo($organization, 'organization')->count());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user