39 lines
1.1 KiB
PHP
39 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\Budget;
|
|
use App\Models\BudgetItem;
|
|
use App\Models\ChartOfAccount;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
class BudgetItemFactory extends Factory
|
|
{
|
|
protected $model = BudgetItem::class;
|
|
|
|
public function definition(): array
|
|
{
|
|
$account = ChartOfAccount::first();
|
|
|
|
if (! $account) {
|
|
$account = ChartOfAccount::create([
|
|
'account_code' => $this->faker->unique()->numerify('4###'),
|
|
'account_name_zh' => '測試費用',
|
|
'account_name_en' => 'Test Expense',
|
|
'account_type' => 'expense',
|
|
'category' => 'operating',
|
|
'is_active' => true,
|
|
'display_order' => 1,
|
|
]);
|
|
}
|
|
|
|
return [
|
|
'budget_id' => Budget::factory(),
|
|
'chart_of_account_id' => $account->id,
|
|
'budgeted_amount' => $this->faker->numberBetween(1000, 5000),
|
|
'actual_amount' => $this->faker->numberBetween(0, 4000),
|
|
'notes' => $this->faker->sentence(),
|
|
];
|
|
}
|
|
}
|