45 lines
1.3 KiB
PHP
45 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Enums\InvoiceStatus;
|
|
use App\Models\Invoice;
|
|
use App\Models\InvoiceBillingAddress;
|
|
use App\Models\User;
|
|
use App\Models\UserPayment;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
/**
|
|
* @extends Factory<Invoice>
|
|
*/
|
|
class InvoiceFactory extends Factory
|
|
{
|
|
/**
|
|
* Define the model's default state.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function definition(): array
|
|
{
|
|
$amount = fake()->numberBetween(1000, 20000);
|
|
$tax = (int) round($amount * 0.19);
|
|
|
|
return [
|
|
'user_id' => User::factory(),
|
|
'user_payment_id' => UserPayment::factory(),
|
|
'invoice_billing_address_id' => InvoiceBillingAddress::factory(),
|
|
'number' => now()->format('Ym').'-'.fake()->unique()->numerify('####'),
|
|
'status' => fake()->randomElement(InvoiceStatus::cases())->value,
|
|
'amount_cents' => $amount,
|
|
'tax_cents' => $tax,
|
|
'total_cents' => $amount + $tax,
|
|
'currency' => 'EUR',
|
|
'is_netto' => false,
|
|
'invoice_date' => now()->toDateString(),
|
|
'due_date' => now()->addDays(14)->toDateString(),
|
|
'paid_at' => null,
|
|
'stripe_invoice_id' => fake()->optional()->regexify('in_[A-Za-z0-9]{14}'),
|
|
'pdf_path' => null,
|
|
];
|
|
}
|
|
}
|