<?php

namespace Database\Seeders\Dummy;

use App\Models\Tenants\BankAccount;
use Database\Seeders\DummyDataSeeder;
use Illuminate\Database\Seeder;

class DummyBankAccountSeeder extends Seeder
{
    public function run(): void
    {
        $tenantId = DummyDataSeeder::TENANT_ID;
        $userId = DummyDataSeeder::USER_ID;

        // 기존 데이터 있으면 스킵
        $existing = BankAccount::where('tenant_id', $tenantId)->count();
        if ($existing > 0) {
            $this->command->info('   ⚠ bank_accounts: 이미 '.$existing.'개 존재 (스킵)');

            return;
        }

        $accounts = [
            ['bank_code' => '004', 'bank_name' => 'KB국민은행', 'account_number' => '123-45-6789012',   'account_holder' => '프론트테스트', 'account_name' => '운영계좌', 'is_primary' => true],
            ['bank_code' => '088', 'bank_name' => '신한은행',   'account_number' => '110-123-456789',  'account_holder' => '프론트테스트', 'account_name' => '급여계좌', 'is_primary' => false],
            ['bank_code' => '020', 'bank_name' => '우리은행',   'account_number' => '1002-123-456789', 'account_holder' => '프론트테스트', 'account_name' => '예비계좌', 'is_primary' => false],
            ['bank_code' => '081', 'bank_name' => '하나은행',   'account_number' => '123-456789-12345', 'account_holder' => '프론트테스트', 'account_name' => '법인카드', 'is_primary' => false],
            ['bank_code' => '011', 'bank_name' => 'NH농협은행', 'account_number' => '351-1234-5678-12', 'account_holder' => '프론트테스트', 'account_name' => '비상금',   'is_primary' => false],
        ];

        foreach ($accounts as $account) {
            BankAccount::create([
                'tenant_id' => $tenantId,
                'bank_code' => $account['bank_code'],
                'bank_name' => $account['bank_name'],
                'account_number' => $account['account_number'],
                'account_holder' => $account['account_holder'],
                'account_name' => $account['account_name'],
                'status' => 'active',
                'is_primary' => $account['is_primary'],
                'created_by' => $userId,
            ]);
        }

        $this->command->info('   ✓ bank_accounts: '.count($accounts).'건 생성');
    }
}
