Files
AFC-Demo/database/factories/TransactionFactory.php
T
2025-10-20 22:14:15 +02:00

52 lines
1.7 KiB
PHP

<?php
namespace Database\Factories;
use App\Models\Company;
use App\Models\Transaction;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
/**
* @extends Factory<\App\Models\Transaction>
*/
class TransactionFactory extends Factory
{
protected $model = Transaction::class;
public function definition(): array
{
return [
'company_id' => Company::factory(),
'reference' => Str::upper($this->faker->unique()->bothify('TRX########')),
'amount' => $this->faker->randomFloat(2, 1000, 500000),
'currency' => 'EUR',
'counterparty' => $this->faker->company(),
'counterparty_country' => $this->faker->countryCode(),
'channel' => $this->faker->randomElement(['SWIFT', 'SEPA', 'ACH']),
'executed_at' => $this->faker->dateTimeBetween('-7 days', 'now'),
'risk_score' => $this->faker->numberBetween(10, 99),
'status' => $this->faker->randomElement([
Transaction::STATUS_TRUE_POSITIVE,
Transaction::STATUS_FALSE_POSITIVE,
Transaction::STATUS_CLEARED,
]),
'requires_review' => $this->faker->boolean(70),
'flagged_by' => $this->faker->randomElement(['Rule Engine', 'Sanctions Monitor', 'Analyst']),
'flagged_reason' => $this->faker->sentence(6),
'signals' => [$this->faker->word()],
];
}
public function requiresReview(bool $value = true): static
{
return $this->state(fn () => ['requires_review' => $value]);
}
public function status(string $status): static
{
return $this->state(fn () => ['status' => $status]);
}
}