feat: complete Epic 0 — foundation migration & infrastructure setup
Stories 0.2-0.5: rename folders→declarations (backend+frontend), configure Redis for cache/queue/sessions, add foundation database migrations (permissions, archived_at), replace DeclarationStatus enum with architecture lifecycle values, create DeclarationObserver for status transition validation and auto-archive, fix controller status transitions to respect observer rules. 93 tests pass (240 assertions). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
78
database/factories/DeclarationFactory.php
Normal file
78
database/factories/DeclarationFactory.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\DeclarationPriority;
|
||||
use App\Enums\DeclarationStatus;
|
||||
use App\Enums\DeclarationType;
|
||||
use App\Models\Client;
|
||||
use App\Models\Workspace;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Declaration>
|
||||
*/
|
||||
class DeclarationFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
$workspace = Workspace::factory()->create();
|
||||
$client = Client::factory()->create(['workspace_id' => $workspace->id]);
|
||||
|
||||
$year = fake()->numberBetween(2024, 2026);
|
||||
$excludeOldVat = array_filter(DeclarationType::getValues(), fn ($v) => $v !== 'vat');
|
||||
$type = fake()->randomElement(array_values($excludeOldVat));
|
||||
|
||||
$isVatMonthly = $type === 'vat_monthly';
|
||||
$isVatQuarterly = $type === 'vat_quarterly';
|
||||
|
||||
return [
|
||||
'workspace_id' => $workspace->id,
|
||||
'client_id' => $client->id,
|
||||
'created_by' => null,
|
||||
'title' => 'Déclaration '.$this->typeLabel($type).' - '.$year,
|
||||
'type' => $type,
|
||||
'period_year' => $year,
|
||||
'period_month' => $isVatMonthly ? fake()->numberBetween(1, 12) : null,
|
||||
'period_quarter' => $isVatQuarterly ? fake()->numberBetween(1, 4) : null,
|
||||
'due_date' => fake()->dateTimeBetween('now', '+3 months'),
|
||||
'status' => DeclarationStatus::Created,
|
||||
'priority' => fake()->randomElement(DeclarationPriority::getValues()),
|
||||
'assigned_to' => null,
|
||||
'validated_at' => null,
|
||||
'closed_at' => null,
|
||||
'notes_internal' => fake()->optional(0.3)->sentence(),
|
||||
'notes_client' => null,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the model factory to use existing workspace and client.
|
||||
*/
|
||||
public function forWorkspace(Workspace $workspace): static
|
||||
{
|
||||
return $this->state(fn () => [
|
||||
'workspace_id' => $workspace->id,
|
||||
'client_id' => Client::factory()->create(['workspace_id' => $workspace->id])->id,
|
||||
]);
|
||||
}
|
||||
|
||||
private function typeLabel(string $type): string
|
||||
{
|
||||
return match ($type) {
|
||||
'vat' => 'TVA',
|
||||
'vat_monthly' => 'TVA mensuelle',
|
||||
'vat_quarterly' => 'TVA trimestrielle',
|
||||
'corporate_tax' => 'IS',
|
||||
'income_tax' => 'IR',
|
||||
'cnss' => 'CNSS',
|
||||
'annual_balance' => 'Bilan',
|
||||
default => 'Autre',
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user