feat:BankAccount, FundSchedule 시더 추가

This commit is contained in:
pro
2026-01-21 19:11:37 +09:00
parent d20e106964
commit 93f2941a58
2 changed files with 442 additions and 0 deletions

View File

@@ -0,0 +1,282 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class BankAccountSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
// 테넌트 ID 1 (코드보잇지엑스) 기준으로 테스트 데이터 생성
$tenantId = 1;
$userId = 1; // 관리자
// 계좌 데이터 (기존 테이블 구조에 맞게 수정)
$accounts = [
[
'tenant_id' => $tenantId,
'bank_code' => '004',
'bank_name' => '국민은행',
'account_number' => '123-456-789012',
'account_holder' => '주식회사 코드보잇지엑스',
'account_name' => '주거래 계좌',
'account_type' => '보통예금',
'balance' => 450000000, // 4.5억
'currency' => 'KRW',
'opened_at' => '2023-01-15',
'last_transaction_at' => '2026-01-15 14:30:00',
'branch_name' => '역삼지점',
'memo' => '주거래 계좌',
'status' => 'active',
'is_primary' => true,
'sort_order' => 1,
'created_by' => $userId,
'created_at' => now(),
'updated_at' => now(),
],
[
'tenant_id' => $tenantId,
'bank_code' => '088',
'bank_name' => '신한은행',
'account_number' => '234-567-890123',
'account_holder' => '주식회사 코드보잇지엑스',
'account_name' => '법인카드 결제',
'account_type' => '법인카드 출금',
'balance' => 90000000, // 9천만원
'currency' => 'KRW',
'opened_at' => '2023-01-15',
'last_transaction_at' => '2026-01-15 11:20:00',
'branch_name' => '강남지점',
'memo' => '법인카드 결제 계좌',
'status' => 'active',
'is_primary' => false,
'sort_order' => 2,
'created_by' => $userId,
'created_at' => now(),
'updated_at' => now(),
],
[
'tenant_id' => $tenantId,
'bank_code' => '020',
'bank_name' => '우리은행',
'account_number' => '345-678-901234',
'account_holder' => '주식회사 코드보잇지엑스',
'account_name' => '정기예금',
'account_type' => '정기예금',
'balance' => 200000000, // 2억
'currency' => 'KRW',
'opened_at' => '2024-06-01',
'last_transaction_at' => '2026-01-01 09:00:00',
'branch_name' => '테헤란로지점',
'memo' => '정기예금 (만기 2027-06-01)',
'status' => 'active',
'is_primary' => false,
'sort_order' => 3,
'created_by' => $userId,
'created_at' => now(),
'updated_at' => now(),
],
[
'tenant_id' => $tenantId,
'bank_code' => '081',
'bank_name' => '하나은행',
'account_number' => '456-789-012345',
'account_holder' => '주식회사 코드보잇지엑스',
'account_name' => '급여계좌',
'account_type' => '보통예금',
'balance' => 75000000, // 7천5백만원
'currency' => 'KRW',
'opened_at' => '2023-03-20',
'last_transaction_at' => '2026-01-14 16:45:00',
'branch_name' => '선릉역지점',
'memo' => '급여 지급 계좌',
'status' => 'active',
'is_primary' => false,
'sort_order' => 4,
'created_by' => $userId,
'created_at' => now(),
'updated_at' => now(),
],
[
'tenant_id' => $tenantId,
'bank_code' => '011',
'bank_name' => '농협은행',
'account_number' => '567-890-123456',
'account_holder' => '주식회사 코드보잇지엑스',
'account_name' => '퇴직금 적금',
'account_type' => '적금',
'balance' => 50000000, // 5천만원
'currency' => 'KRW',
'opened_at' => '2024-01-01',
'last_transaction_at' => '2026-01-10 10:00:00',
'branch_name' => '강남중앙지점',
'memo' => '직원 퇴직금 적립',
'status' => 'active',
'is_primary' => false,
'sort_order' => 5,
'created_by' => $userId,
'created_at' => now(),
'updated_at' => now(),
],
];
// 계좌 데이터 삽입
$accountIds = [];
foreach ($accounts as $account) {
$id = DB::table('bank_accounts')->insertGetId($account);
$accountIds[$account['account_number']] = $id;
}
$this->command->info('계좌 5개 생성 완료');
// 거래내역 데이터 (국민은행 계좌 기준)
$transactions = [
[
'tenant_id' => $tenantId,
'bank_account_id' => $accountIds['123-456-789012'],
'transaction_type' => 'deposit',
'amount' => 50000000,
'balance_after' => 450000000,
'transaction_date' => '2026-01-15',
'transaction_time' => '14:30:00',
'description' => '프로젝트 대금 입금',
'counterparty' => '주식회사 클라이언트A',
'reference_number' => 'INV-2026-0115',
'category' => '매출',
'is_reconciled' => true,
'reconciled_at' => '2026-01-15 15:00:00',
'created_by' => $userId,
'created_at' => now(),
'updated_at' => now(),
],
[
'tenant_id' => $tenantId,
'bank_account_id' => $accountIds['123-456-789012'],
'transaction_type' => 'withdrawal',
'amount' => 5000000,
'balance_after' => 400000000,
'transaction_date' => '2026-01-14',
'transaction_time' => '11:20:00',
'description' => '사무실 임대료',
'counterparty' => '강남빌딩관리(주)',
'reference_number' => 'RENT-2026-01',
'category' => '임대료',
'is_reconciled' => true,
'reconciled_at' => '2026-01-14 14:00:00',
'created_by' => $userId,
'created_at' => now(),
'updated_at' => now(),
],
[
'tenant_id' => $tenantId,
'bank_account_id' => $accountIds['123-456-789012'],
'transaction_type' => 'transfer',
'amount' => 30000000,
'balance_after' => 405000000,
'transaction_date' => '2026-01-13',
'transaction_time' => '09:00:00',
'description' => '급여계좌 이체',
'counterparty' => '하나은행 급여계좌',
'reference_number' => 'TRF-2026-0113',
'category' => '급여',
'is_reconciled' => true,
'reconciled_at' => '2026-01-13 10:00:00',
'created_by' => $userId,
'created_at' => now(),
'updated_at' => now(),
],
[
'tenant_id' => $tenantId,
'bank_account_id' => $accountIds['123-456-789012'],
'transaction_type' => 'deposit',
'amount' => 25000000,
'balance_after' => 435000000,
'transaction_date' => '2026-01-10',
'transaction_time' => '16:45:00',
'description' => '유지보수 계약금',
'counterparty' => '주식회사 클라이언트B',
'reference_number' => 'MAINT-2026-001',
'category' => '매출',
'is_reconciled' => false,
'reconciled_at' => null,
'created_by' => $userId,
'created_at' => now(),
'updated_at' => now(),
],
[
'tenant_id' => $tenantId,
'bank_account_id' => $accountIds['123-456-789012'],
'transaction_type' => 'withdrawal',
'amount' => 2500000,
'balance_after' => 410000000,
'transaction_date' => '2026-01-08',
'transaction_time' => '14:00:00',
'description' => '클라우드 서비스 이용료',
'counterparty' => 'AWS Korea',
'reference_number' => 'AWS-2026-01',
'category' => '운영비',
'is_reconciled' => false,
'reconciled_at' => null,
'created_by' => $userId,
'created_at' => now(),
'updated_at' => now(),
],
];
// 거래내역 삽입
DB::table('bank_transactions')->insert($transactions);
$this->command->info('거래내역 5개 생성 완료');
// 신한은행 거래내역
$shinhanTransactions = [
[
'tenant_id' => $tenantId,
'bank_account_id' => $accountIds['234-567-890123'],
'transaction_type' => 'withdrawal',
'amount' => 1500000,
'balance_after' => 90000000,
'transaction_date' => '2026-01-15',
'transaction_time' => '11:20:00',
'description' => '법인카드 결제',
'counterparty' => '신한카드',
'reference_number' => 'CARD-2026-0115',
'category' => '카드결제',
'is_reconciled' => true,
'reconciled_at' => '2026-01-15 12:00:00',
'created_by' => $userId,
'created_at' => now(),
'updated_at' => now(),
],
[
'tenant_id' => $tenantId,
'bank_account_id' => $accountIds['234-567-890123'],
'transaction_type' => 'deposit',
'amount' => 10000000,
'balance_after' => 91500000,
'transaction_date' => '2026-01-10',
'transaction_time' => '09:30:00',
'description' => '카드결제계좌 입금',
'counterparty' => '국민은행 주거래계좌',
'reference_number' => 'TRF-2026-0110',
'category' => '이체',
'is_reconciled' => true,
'reconciled_at' => '2026-01-10 10:00:00',
'created_by' => $userId,
'created_at' => now(),
'updated_at' => now(),
],
];
DB::table('bank_transactions')->insert($shinhanTransactions);
$this->command->info('신한은행 거래내역 2개 생성 완료');
$this->command->info('BankAccountSeeder 완료: 계좌 5개, 거래내역 7개');
}
}

View File

@@ -0,0 +1,160 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class FundScheduleSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
// 테넌트 ID 1 (코드보잇지엑스) 기준으로 테스트 데이터 생성
$tenantId = 1;
$userId = 1; // 관리자
// 현재 월 기준으로 데이터 생성
$year = now()->year;
$month = now()->month;
// 자금계획일정 데이터
$schedules = [
// 입금 예정
[
'tenant_id' => $tenantId,
'title' => '(주)스마트팩토리 개발비 1차',
'description' => 'ERP 시스템 개발 프로젝트 1차 중도금',
'schedule_type' => 'income',
'scheduled_date' => sprintf('%04d-%02d-10', $year, $month),
'amount' => 100000000, // 1억원
'currency' => 'KRW',
'counterparty' => '(주)스마트팩토리',
'category' => '매출',
'status' => 'pending',
'is_recurring' => false,
'recurrence_rule' => null,
'memo' => '계약서 기준 착수금 30%, 중도금 40%, 잔금 30%',
'created_by' => $userId,
'created_at' => now(),
'updated_at' => now(),
],
[
'tenant_id' => $tenantId,
'title' => '영업파트너 수수료 지급',
'description' => '1월 영업 수수료 정산',
'schedule_type' => 'expense',
'scheduled_date' => sprintf('%04d-%02d-10', $year, $month),
'amount' => 20000000, // 2천만원
'currency' => 'KRW',
'counterparty' => '영업파트너',
'category' => '매입',
'status' => 'pending',
'is_recurring' => false,
'recurrence_rule' => null,
'memo' => null,
'created_by' => $userId,
'created_at' => now(),
'updated_at' => now(),
],
[
'tenant_id' => $tenantId,
'title' => '(주)디지털제조 개발비 잔금',
'description' => 'MES 시스템 개발 프로젝트 잔금',
'schedule_type' => 'income',
'scheduled_date' => sprintf('%04d-%02d-15', $year, $month),
'amount' => 30000000, // 3천만원
'currency' => 'KRW',
'counterparty' => '(주)디지털제조',
'category' => '매출',
'status' => 'pending',
'is_recurring' => false,
'recurrence_rule' => null,
'memo' => '검수 완료 후 지급',
'created_by' => $userId,
'created_at' => now(),
'updated_at' => now(),
],
[
'tenant_id' => $tenantId,
'title' => '직원 급여 지급',
'description' => sprintf('%d년 %d월 급여', $year, $month),
'schedule_type' => 'expense',
'scheduled_date' => sprintf('%04d-%02d-25', $year, $month),
'amount' => 25000000, // 2천5백만원
'currency' => 'KRW',
'counterparty' => '직원',
'category' => '급여',
'status' => 'pending',
'is_recurring' => true,
'recurrence_rule' => 'monthly',
'memo' => '매월 25일 정기 지급',
'created_by' => $userId,
'created_at' => now(),
'updated_at' => now(),
],
[
'tenant_id' => $tenantId,
'title' => '구독료 CMS 출금',
'description' => '클라우드 서비스 월 구독료',
'schedule_type' => 'expense',
'scheduled_date' => sprintf('%04d-%02d-28', $year, $month),
'amount' => 8500000, // 850만원
'currency' => 'KRW',
'counterparty' => 'AWS/Azure',
'category' => '운영비',
'status' => 'pending',
'is_recurring' => true,
'recurrence_rule' => 'monthly',
'memo' => 'AWS + Azure 클라우드 비용',
'created_by' => $userId,
'created_at' => now(),
'updated_at' => now(),
],
// 다음 달 일정도 추가
[
'tenant_id' => $tenantId,
'title' => '사무실 임대료',
'description' => '강남 오피스 임대료',
'schedule_type' => 'expense',
'scheduled_date' => sprintf('%04d-%02d-05', $month == 12 ? $year + 1 : $year, $month == 12 ? 1 : $month + 1),
'amount' => 5000000, // 500만원
'currency' => 'KRW',
'counterparty' => '강남빌딩관리(주)',
'category' => '임대료',
'status' => 'pending',
'is_recurring' => true,
'recurrence_rule' => 'monthly',
'memo' => '매월 5일 자동이체',
'created_by' => $userId,
'created_at' => now(),
'updated_at' => now(),
],
[
'tenant_id' => $tenantId,
'title' => '유지보수 계약금 입금',
'description' => '연간 유지보수 계약 선금',
'schedule_type' => 'income',
'scheduled_date' => sprintf('%04d-%02d-15', $month == 12 ? $year + 1 : $year, $month == 12 ? 1 : $month + 1),
'amount' => 50000000, // 5천만원
'currency' => 'KRW',
'counterparty' => '(주)테크솔루션',
'category' => '매출',
'status' => 'pending',
'is_recurring' => false,
'recurrence_rule' => null,
'memo' => '2026년 연간 유지보수 계약',
'created_by' => $userId,
'created_at' => now(),
'updated_at' => now(),
],
];
// 데이터 삽입
DB::table('fund_schedules')->insert($schedules);
$this->command->info('FundScheduleSeeder 완료: 자금계획일정 ' . count($schedules) . '개 생성');
}
}