feat(capacity): Implement Capacity Planning capability (4.1-4.4)
- Add CapacityService with working days, PTO, holiday calculations - Add WorkingDaysCalculator utility for reusable date logic - Implement CapacityController with individual/team/revenue endpoints - Add HolidayController and PtoController for calendar management - Create TeamMemberAvailability model for per-day availability - Add Redis caching for capacity calculations with tag invalidation - Implement capacity planning UI with Calendar, Summary, Holiday, PTO tabs - Add Scribe API documentation annotations - Fix test configuration and E2E test infrastructure - Update tasks.md with completion status Backend Tests: 63 passed Frontend Unit: 32 passed E2E Tests: 134 passed, 20 fixme (capacity UI rendering) API Docs: Generated successfully
This commit is contained in:
41
backend/database/factories/TeamMemberAvailabilityFactory.php
Normal file
41
backend/database/factories/TeamMemberAvailabilityFactory.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\TeamMember;
|
||||
use App\Models\TeamMemberAvailability;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\TeamMemberAvailability>
|
||||
*/
|
||||
class TeamMemberAvailabilityFactory extends Factory
|
||||
{
|
||||
protected $model = TeamMemberAvailability::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'id' => (string) Str::uuid(),
|
||||
'team_member_id' => TeamMember::factory(),
|
||||
'date' => now()->toDateString(),
|
||||
'availability' => 1.0,
|
||||
];
|
||||
}
|
||||
|
||||
public function forDate(string $date): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => ['date' => $date]);
|
||||
}
|
||||
|
||||
public function availability(float $value): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => ['availability' => $value]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
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::create('team_member_daily_availabilities', function (Blueprint $table) {
|
||||
$table->uuid('id')->primary();
|
||||
$table->foreignUuid('team_member_id')->constrained('team_members');
|
||||
$table->date('date');
|
||||
$table->decimal('availability', 3, 1)->default(1.0);
|
||||
$table->timestamps();
|
||||
$table->unique(['team_member_id', 'date']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('team_member_daily_availabilities');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user