Add organization setting employees_can_see_billable_rates

This commit is contained in:
Constantin Graf
2024-10-01 18:14:26 +02:00
committed by Constantin Graf
parent 9d279d4980
commit 51cd919db6
13 changed files with 269 additions and 15 deletions

View File

@@ -26,6 +26,7 @@ class OrganizationFactory extends Factory
'billable_rate' => null,
'user_id' => User::factory(),
'personal_team' => true,
'employees_can_see_billable_rates' => false,
];
}

View File

@@ -11,6 +11,7 @@ use App\Models\Project;
use App\Models\ProjectMember;
use App\Service\ColorService;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Carbon;
/**
* @extends Factory<Project>
@@ -46,12 +47,21 @@ class ProjectFactory extends Factory
});
}
public function billable(): self
public function billable(?int $billableRate = null): self
{
return $this->state(function (array $attributes): array {
return $this->state(function (array $attributes) use ($billableRate): array {
return [
'is_billable' => true,
'billable_rate' => $this->faker->numberBetween(50, 1000) * 100,
'billable_rate' => $billableRate === null ? $this->faker->numberBetween(50, 1000) * 100 : $billableRate,
];
});
}
public function createdAt(Carbon $createdAt): self
{
return $this->state(function (array $attributes) use ($createdAt): array {
return [
'created_at' => $createdAt,
];
});
}

View File

@@ -0,0 +1,30 @@
<?php
declare(strict_types=1);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('organizations', function (Blueprint $table): void {
$table->boolean('employees_can_see_billable_rates')->default(false);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('organizations', function (Blueprint $table): void {
$table->dropColumn('employees_can_see_billable_rates');
});
}
};