chore(API): Seeder 파일 정리

- Dummy Seeder 파일들 정리 및 개선
- ApprovalTestDataSeeder 수정
- PositionSeeder, StockReceivingSeeder 수정

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-01-13 19:49:28 +09:00
parent 1044b57e15
commit be90c351fa
23 changed files with 206 additions and 154 deletions

View File

@@ -2,9 +2,9 @@
namespace Database\Seeders;
use Carbon\Carbon;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use Carbon\Carbon;
class ApprovalTestDataSeeder extends Seeder
{
@@ -29,6 +29,7 @@ public function run(): void
->toArray();
if (count($users) < 3) {
$this->command->error('최소 3명의 사용자가 필요합니다.');
return;
}
@@ -65,7 +66,7 @@ private function createApprovalForms(int $tenantId, int $userId, Carbon $now): a
['name' => 'description', 'type' => 'textarea', 'label' => '내용', 'required' => true],
['name' => 'reason', 'type' => 'textarea', 'label' => '사유', 'required' => true],
['name' => 'estimatedCost', 'type' => 'number', 'label' => '예상비용', 'required' => false],
]
],
]),
'is_active' => true,
'created_by' => $userId,
@@ -83,7 +84,7 @@ private function createApprovalForms(int $tenantId, int $userId, Carbon $now): a
['name' => 'paymentDate', 'type' => 'date', 'label' => '지급일', 'required' => true],
['name' => 'items', 'type' => 'array', 'label' => '지출항목', 'required' => true],
['name' => 'totalAmount', 'type' => 'number', 'label' => '총액', 'required' => true],
]
],
]),
'is_active' => true,
'created_by' => $userId,
@@ -100,7 +101,7 @@ private function createApprovalForms(int $tenantId, int $userId, Carbon $now): a
['name' => 'items', 'type' => 'array', 'label' => '비용항목', 'required' => true],
['name' => 'totalExpense', 'type' => 'number', 'label' => '총지출', 'required' => true],
['name' => 'accountBalance', 'type' => 'number', 'label' => '계좌잔액', 'required' => true],
]
],
]),
'is_active' => true,
'created_by' => $userId,
@@ -144,12 +145,12 @@ private function createApprovals(
];
$expenseItems = [
'교통비', '식비', '숙박비', '소모품비', '통신비', '유류비', '접대비', '회의비'
'교통비', '식비', '숙박비', '소모품비', '통신비', '유류비', '접대비', '회의비',
];
$vendors = [
'삼성전자', 'LG전자', 'SK하이닉스', '현대자동차', '네이버', '카카오',
'쿠팡', '배달의민족', '토스', '당근마켓'
'쿠팡', '배달의민족', '토스', '당근마켓',
];
$docNumber = 1;
@@ -223,7 +224,7 @@ private function createApprovals(
$formId = $forms[$formCode];
$drafter = $i < 3 ? $approver1 : $approver2;
$title = '추가 결재 요청 문서 ' . ($i + 1);
$title = '추가 결재 요청 문서 '.($i + 1);
$content = $this->generateContent($formCode, $title, $vendors, $expenseItems);
$approvalId = DB::table('approvals')->insertGetId([
@@ -262,7 +263,7 @@ private function generateContent(string $formCode, string $title, array $vendors
'title' => $title,
'vendor' => $vendors[array_rand($vendors)],
'vendorPaymentDate' => Carbon::now()->addDays(rand(7, 30))->format('Y-m-d'),
'description' => $title . '에 대한 상세 설명입니다. 업무 효율성 향상과 비용 절감을 위해 필요합니다.',
'description' => $title.'에 대한 상세 설명입니다. 업무 효율성 향상과 비용 절감을 위해 필요합니다.',
'reason' => '업무 효율성 향상 및 경쟁력 강화를 위해 필수적으로 진행해야 합니다.',
'estimatedCost' => rand(100, 5000) * 10000,
];
@@ -280,11 +281,12 @@ private function generateContent(string $formCode, string $title, array $vendors
'note' => '업무 관련 지출',
];
}
return [
'requestDate' => Carbon::now()->subDays(rand(1, 7))->format('Y-m-d'),
'paymentDate' => Carbon::now()->addDays(rand(1, 14))->format('Y-m-d'),
'items' => $items,
'cardId' => 'CARD-' . rand(1000, 9999),
'cardId' => 'CARD-'.rand(1000, 9999),
'totalAmount' => $total,
];
@@ -304,6 +306,7 @@ private function generateContent(string $formCode, string $title, array $vendors
'checked' => false,
];
}
return [
'items' => $items,
'totalExpense' => $total,

View File

@@ -22,6 +22,7 @@ public function run(): void
if (empty($userIds)) {
$this->command->warn(' ⚠ attendances: 사용자가 없습니다');
return;
}
@@ -48,6 +49,7 @@ public function run(): void
// 주말 제외
if ($currentDate->isWeekend()) {
$currentDate->addDay();
continue;
}
@@ -61,6 +63,7 @@ public function run(): void
if ($exists) {
$currentDate->addDay();
continue;
}
@@ -85,7 +88,7 @@ public function run(): void
}
}
$this->command->info(' ✓ attendances: ' . $count . '건 생성');
$this->command->info(' ✓ attendances: '.$count.'건 생성');
}
private function getRandomStatus(array $weights): string
@@ -188,4 +191,4 @@ private function getRemarks(string $status): ?string
default => null,
};
}
}
}

View File

@@ -17,6 +17,7 @@ public function run(): void
$existing = AttendanceSetting::where('tenant_id', $tenantId)->first();
if ($existing) {
$this->command->info(' ⚠ attendance_settings: 이미 존재 (스킵)');
return;
}
@@ -31,4 +32,4 @@ public function run(): void
$this->command->info(' ✓ attendance_settings: 1건 생성');
}
}
}

View File

@@ -17,7 +17,8 @@ public function run(): void
// 기존 데이터 있으면 스킵
$existing = BadDebt::where('tenant_id', $tenantId)->count();
if ($existing > 0) {
$this->command->info(' ⚠ bad_debts: 이미 ' . $existing . '건 존재 (스킵)');
$this->command->info(' ⚠ bad_debts: 이미 '.$existing.'건 존재 (스킵)');
return;
}
@@ -28,22 +29,23 @@ public function run(): void
if ($clients->isEmpty()) {
$this->command->warn(' ⚠ clients 데이터가 없습니다. DummyClientSeeder를 먼저 실행하세요.');
return;
}
// 상태별 분포
$statuses = [
'collecting' => 6, // 추심중
'collecting' => 6, // 추심중
'legal_action' => 4, // 법적조치
'recovered' => 5, // 회수완료
'bad_debt' => 3, // 대손처리
'recovered' => 5, // 회수완료
'bad_debt' => 3, // 대손처리
];
// 금액 범위 (채권 금액)
$amounts = [
'small' => [500000, 3000000], // 50만~300만
'small' => [500000, 3000000], // 50만~300만
'medium' => [3000000, 15000000], // 300만~1500만
'large' => [15000000, 50000000], // 1500만~5000만
'large' => [15000000, 50000000], // 1500만~5000만
];
$count = 0;
@@ -84,24 +86,24 @@ public function run(): void
}
BadDebt::create([
'tenant_id' => $tenantId,
'client_id' => $client->id,
'debt_amount' => $amount,
'status' => $status,
'overdue_days' => $overdueDays,
'tenant_id' => $tenantId,
'client_id' => $client->id,
'debt_amount' => $amount,
'status' => $status,
'overdue_days' => $overdueDays,
'assigned_user_id' => $userId,
'occurred_at' => $occurredAt,
'closed_at' => $closedAt,
'is_active' => true,
'options' => null,
'created_by' => $userId,
'occurred_at' => $occurredAt,
'closed_at' => $closedAt,
'is_active' => true,
'options' => null,
'created_by' => $userId,
]);
$count++;
}
}
$this->command->info(' ✓ bad_debts: ' . $count . '건 생성');
$this->command->info(' ✓ bad_debts: '.$count.'건 생성');
$this->command->info(' - collecting: 6건, legal_action: 4건, recovered: 5건, bad_debt: 3건');
}
}
}

View File

@@ -16,7 +16,8 @@ public function run(): void
// 기존 데이터 있으면 스킵
$existing = BankAccount::where('tenant_id', $tenantId)->count();
if ($existing > 0) {
$this->command->info(' ⚠ bank_accounts: 이미 ' . $existing . '개 존재 (스킵)');
$this->command->info(' ⚠ bank_accounts: 이미 '.$existing.'개 존재 (스킵)');
return;
}
@@ -24,24 +25,24 @@ public function run(): void
['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],
['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'],
'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,
'account_name' => $account['account_name'],
'status' => 'active',
'is_primary' => $account['is_primary'],
'created_by' => $userId,
]);
}
$this->command->info(' ✓ bank_accounts: ' . count($accounts) . '건 생성');
$this->command->info(' ✓ bank_accounts: '.count($accounts).'건 생성');
}
}
}

View File

@@ -19,7 +19,8 @@ public function run(): void
// 기존 데이터 있으면 스킵
$existing = Bill::where('tenant_id', $tenantId)->count();
if ($existing > 0) {
$this->command->info(' ⚠ bills: 이미 ' . $existing . '건 존재 (스킵)');
$this->command->info(' ⚠ bills: 이미 '.$existing.'건 존재 (스킵)');
return;
}

View File

@@ -16,7 +16,8 @@ public function run(): void
// 기존 데이터 있으면 스킵
$existing = ClientGroup::where('tenant_id', $tenantId)->count();
if ($existing > 0) {
$this->command->info(' ⚠ client_groups: 이미 ' . $existing . '개 존재 (스킵)');
$this->command->info(' ⚠ client_groups: 이미 '.$existing.'개 존재 (스킵)');
return;
}
@@ -30,15 +31,15 @@ public function run(): void
foreach ($groups as $group) {
ClientGroup::create([
'tenant_id' => $tenantId,
'tenant_id' => $tenantId,
'group_code' => $group['group_code'],
'group_name' => $group['group_name'],
'price_rate' => $group['price_rate'],
'is_active' => true,
'is_active' => true,
'created_by' => $userId,
]);
}
$this->command->info(' ✓ client_groups: ' . count($groups) . '건 생성');
$this->command->info(' ✓ client_groups: '.count($groups).'건 생성');
}
}
}

View File

@@ -17,7 +17,8 @@ public function run(): void
// 기존 데이터 있으면 스킵
$existing = Client::where('tenant_id', $tenantId)->count();
if ($existing > 0) {
$this->command->info(' ⚠ clients: 이미 ' . $existing . '개 존재 (스킵)');
$this->command->info(' ⚠ clients: 이미 '.$existing.'개 존재 (스킵)');
return;
}
@@ -78,24 +79,24 @@ public function run(): void
$count++;
}
$this->command->info(' ✓ clients: ' . $count . '건 생성');
$this->command->info(' ✓ clients: '.$count.'건 생성');
}
private function createClient(array $data, string $type, int $tenantId, int $userId, array $groups): void
{
Client::create([
'tenant_id' => $tenantId,
'tenant_id' => $tenantId,
'client_group_id' => $data['group'] ? ($groups[$data['group']] ?? null) : null,
'client_code' => $data['code'],
'name' => $data['name'],
'client_type' => $type,
'contact_person' => $data['contact'],
'phone' => $data['phone'],
'email' => $data['email'],
'business_no' => $data['business_no'],
'business_type' => '제조업',
'business_item' => '전자제품',
'is_active' => true,
'client_code' => $data['code'],
'name' => $data['name'],
'client_type' => $type,
'contact_person' => $data['contact'],
'phone' => $data['phone'],
'email' => $data['email'],
'business_no' => $data['business_no'],
'business_type' => '제조업',
'business_item' => '전자제품',
'is_active' => true,
]);
}
}
}

View File

@@ -17,7 +17,8 @@ public function run(): void
// 기존 부서가 있으면 스킵
$existing = Department::where('tenant_id', $tenantId)->count();
if ($existing > 0) {
$this->command->info(' ⚠ departments: 이미 ' . $existing . '개 존재 (스킵)');
$this->command->info(' ⚠ departments: 이미 '.$existing.'개 존재 (스킵)');
return;
}
@@ -86,7 +87,7 @@ public function run(): void
// 사용자-부서 연결
$this->assignUsersToDepartments($tenantId);
$this->command->info(' ✓ departments: ' . $count . '개 생성 (본부 3개, 부서 8개)');
$this->command->info(' ✓ departments: '.$count.'개 생성 (본부 3개, 부서 8개)');
}
private function assignUsersToDepartments(int $tenantId): void
@@ -117,7 +118,7 @@ private function assignUsersToDepartments(int $tenantId): void
->where('department_id', $dept->id)
->exists();
if (!$exists) {
if (! $exists) {
DB::table('department_user')->insert([
'tenant_id' => $tenantId,
'user_id' => $userId,
@@ -130,4 +131,4 @@ private function assignUsersToDepartments(int $tenantId): void
}
}
}
}
}

View File

@@ -18,7 +18,8 @@ public function run(): void
// 기존 데이터 있으면 스킵
$existing = Deposit::where('tenant_id', $tenantId)->count();
if ($existing > 0) {
$this->command->info(' ⚠ deposits: 이미 ' . $existing . '건 존재 (스킵)');
$this->command->info(' ⚠ deposits: 이미 '.$existing.'건 존재 (스킵)');
return;
}
@@ -53,9 +54,9 @@ public function run(): void
// 금액 범위
$amounts = [
'small' => [1000000, 5000000], // 30%
'small' => [1000000, 5000000], // 30%
'medium' => [5000000, 30000000], // 50%
'large' => [30000000, 100000000], // 20%
'large' => [30000000, 100000000], // 20%
];
$count = 0;
@@ -81,21 +82,21 @@ public function run(): void
}
Deposit::create([
'tenant_id' => $tenantId,
'deposit_date' => sprintf('%04d-%02d-%02d', $year, $month, $day),
'client_id' => $client?->id,
'client_name' => $client ? null : $clientName,
'tenant_id' => $tenantId,
'deposit_date' => sprintf('%04d-%02d-%02d', $year, $month, $day),
'client_id' => $client?->id,
'client_name' => $client ? null : $clientName,
'bank_account_id' => $primaryBankId,
'amount' => $amount,
'payment_method' => $methods[array_rand($methods)],
'description' => $clientName . ' 입금',
'created_by' => $userId,
'amount' => $amount,
'payment_method' => $methods[array_rand($methods)],
'description' => $clientName.' 입금',
'created_by' => $userId,
]);
$count++;
}
}
$this->command->info(' ✓ deposits: ' . $count . '건 생성');
$this->command->info(' ✓ deposits: '.$count.'건 생성');
}
}
}

View File

@@ -156,4 +156,4 @@ private function generateAttributes(string $type): array
default => $base,
};
}
}
}

View File

@@ -22,6 +22,7 @@ public function run(): void
if (empty($userIds)) {
$this->command->warn(' ⚠ leave_grants: 사용자가 없습니다');
return;
}
@@ -37,7 +38,7 @@ public function run(): void
->whereYear('grant_date', $year)
->exists();
if (!$existing) {
if (! $existing) {
LeaveGrant::create([
'tenant_id' => $tenantId,
'user_id' => $uId,
@@ -60,7 +61,7 @@ public function run(): void
->where('grant_date', $grantDate)
->exists();
if (!$monthlyExists) {
if (! $monthlyExists) {
LeaveGrant::create([
'tenant_id' => $tenantId,
'user_id' => $uId,
@@ -90,6 +91,6 @@ public function run(): void
}
}
$this->command->info(' ✓ leave_grants: ' . $count . '건 생성');
$this->command->info(' ✓ leave_grants: '.$count.'건 생성');
}
}
}

View File

@@ -22,6 +22,7 @@ public function run(): void
if (empty($userIds)) {
$this->command->warn(' ⚠ leaves: 사용자가 없습니다');
return;
}
@@ -64,7 +65,7 @@ public function run(): void
$endDate = $startDate;
} else {
$days = rand(1, 3);
$endDate = date('Y-m-d', strtotime($startDate . ' + ' . ($days - 1) . ' days'));
$endDate = date('Y-m-d', strtotime($startDate.' + '.($days - 1).' days'));
}
// 승인자 정보
@@ -74,10 +75,10 @@ public function run(): void
if ($status === 'approved') {
$approvedBy = $userId;
$approvedAt = date('Y-m-d H:i:s', strtotime($startDate . ' - 2 days'));
$approvedAt = date('Y-m-d H:i:s', strtotime($startDate.' - 2 days'));
} elseif ($status === 'rejected') {
$approvedBy = $userId;
$approvedAt = date('Y-m-d H:i:s', strtotime($startDate . ' - 2 days'));
$approvedAt = date('Y-m-d H:i:s', strtotime($startDate.' - 2 days'));
$rejectReason = '업무 일정 상 불가';
}
@@ -100,7 +101,7 @@ public function run(): void
}
}
$this->command->info(' ✓ leaves: ' . $count . '건 생성');
$this->command->info(' ✓ leaves: '.$count.'건 생성');
}
private function getRandomWeighted(array $weights): string
@@ -132,4 +133,4 @@ private function getLeaveReason(string $type): string
default => '개인 사유',
};
}
}
}

View File

@@ -20,7 +20,8 @@ public function run(): void
$q->where('tenant_id', $tenantId);
})->count();
if ($existing > 0) {
$this->command->info(' ⚠ payments: 이미 ' . $existing . '건 존재 (스킵)');
$this->command->info(' ⚠ payments: 이미 '.$existing.'건 존재 (스킵)');
return;
}

View File

@@ -16,7 +16,8 @@ public function run(): void
// 기존 데이터 있으면 스킵
$existing = Popup::where('tenant_id', $tenantId)->count();
if ($existing > 0) {
$this->command->info(' ⚠ popups: 이미 ' . $existing . '개 존재 (스킵)');
$this->command->info(' ⚠ popups: 이미 '.$existing.'개 존재 (스킵)');
return;
}
@@ -109,6 +110,6 @@ public function run(): void
]);
}
$this->command->info(' ✓ popups: ' . count($popups) . '건 생성');
$this->command->info(' ✓ popups: '.count($popups).'건 생성');
}
}
}

View File

@@ -17,7 +17,8 @@ public function run(): void
// 기존 데이터 있으면 스킵
$existing = Purchase::where('tenant_id', $tenantId)->count();
if ($existing > 0) {
$this->command->info(' ⚠ purchases: 이미 ' . $existing . '건 존재 (스킵)');
$this->command->info(' ⚠ purchases: 이미 '.$existing.'건 존재 (스킵)');
return;
}
@@ -28,6 +29,7 @@ public function run(): void
if ($clients->isEmpty()) {
$this->command->warn(' ⚠ purchases: 매입 거래처 없음 (스킵)');
return;
}
@@ -40,9 +42,9 @@ public function run(): void
];
$amounts = [
'small' => [1000000, 5000000],
'small' => [1000000, 5000000],
'medium' => [5000000, 30000000],
'large' => [30000000, 80000000],
'large' => [30000000, 80000000],
];
// 월별 건수: 1~10월 5~6건, 11월 7건, 12월 6건 = 70건
@@ -63,7 +65,7 @@ public function run(): void
$client = $clientsByName->get($clientName);
// 이름 매칭 실패 시 기존 클라이언트 중 랜덤 선택
if (!$client) {
if (! $client) {
$clientId = $clientIds[array_rand($clientIds)];
$client = $clients->firstWhere('id', $clientId);
$clientName = $client->name;
@@ -91,22 +93,22 @@ public function run(): void
$total = $supply + $tax;
Purchase::create([
'tenant_id' => $tenantId,
'tenant_id' => $tenantId,
'purchase_number' => sprintf('PUR-%04d%02d-%04d', $year, $month, $i + 1),
'purchase_date' => sprintf('%04d-%02d-%02d', $year, $month, $day),
'client_id' => $client->id,
'supply_amount' => $supply,
'tax_amount' => $tax,
'total_amount' => $total,
'description' => $clientName . ' 매입',
'status' => $status,
'created_by' => $userId,
'purchase_date' => sprintf('%04d-%02d-%02d', $year, $month, $day),
'client_id' => $client->id,
'supply_amount' => $supply,
'tax_amount' => $tax,
'total_amount' => $total,
'description' => $clientName.' 매입',
'status' => $status,
'created_by' => $userId,
]);
$count++;
}
}
$this->command->info(' ✓ purchases: ' . $count . '건 생성');
$this->command->info(' ✓ purchases: '.$count.'건 생성');
}
}
}

View File

@@ -18,7 +18,8 @@ public function run(): void
// 기존 급여 데이터가 있으면 스킵
$existing = Salary::withoutGlobalScopes()->where('tenant_id', $tenantId)->count();
if ($existing > 0) {
$this->command->info(' ⚠ salaries: 이미 ' . $existing . '개 존재 (스킵)');
$this->command->info(' ⚠ salaries: 이미 '.$existing.'개 존재 (스킵)');
return;
}
@@ -31,6 +32,7 @@ public function run(): void
if (empty($userIds)) {
$this->command->warn(' ⚠ salaries: 테넌트에 연결된 사용자가 없습니다');
return;
}
@@ -138,7 +140,7 @@ public function run(): void
$count++;
}
$this->command->info(' ✓ salaries: ' . $count . '개 생성 (2025년 12월)');
$this->command->info(' ✓ salaries: '.$count.'개 생성 (2025년 12월)');
}
/**
@@ -149,11 +151,22 @@ private function getRankIndex(int $index, int $total): int
// 배분: 사원 40%, 대리 25%, 과장 15%, 차장 10%, 부장 7%, 이사 3%
$ratio = $index / $total;
if ($ratio < 0.40) return 0; // 사원
if ($ratio < 0.65) return 1; // 대리
if ($ratio < 0.80) return 2; // 과장
if ($ratio < 0.90) return 3; // 차장
if ($ratio < 0.97) return 4; // 부장
if ($ratio < 0.40) {
return 0;
} // 사원
if ($ratio < 0.65) {
return 1;
} // 대리
if ($ratio < 0.80) {
return 2;
} // 과장
if ($ratio < 0.90) {
return 3;
} // 차장
if ($ratio < 0.97) {
return 4;
} // 부장
return 5; // 이사
}
@@ -163,12 +176,25 @@ private function getRankIndex(int $index, int $total): int
private function calculateIncomeTax(float $taxableIncome): int
{
// 월 급여 기준 간이세액 (부양가족 1인 기준, 간략화)
if ($taxableIncome <= 1500000) return 0;
if ($taxableIncome <= 2000000) return round($taxableIncome * 0.02);
if ($taxableIncome <= 3000000) return round($taxableIncome * 0.03);
if ($taxableIncome <= 4500000) return round($taxableIncome * 0.05);
if ($taxableIncome <= 6000000) return round($taxableIncome * 0.08);
if ($taxableIncome <= 8000000) return round($taxableIncome * 0.12);
if ($taxableIncome <= 1500000) {
return 0;
}
if ($taxableIncome <= 2000000) {
return round($taxableIncome * 0.02);
}
if ($taxableIncome <= 3000000) {
return round($taxableIncome * 0.03);
}
if ($taxableIncome <= 4500000) {
return round($taxableIncome * 0.05);
}
if ($taxableIncome <= 6000000) {
return round($taxableIncome * 0.08);
}
if ($taxableIncome <= 8000000) {
return round($taxableIncome * 0.12);
}
return round($taxableIncome * 0.15);
}
}

View File

@@ -17,7 +17,8 @@ public function run(): void
// 기존 데이터 있으면 스킵
$existing = Sale::where('tenant_id', $tenantId)->count();
if ($existing > 0) {
$this->command->info(' ⚠ sales: 이미 ' . $existing . '건 존재 (스킵)');
$this->command->info(' ⚠ sales: 이미 '.$existing.'건 존재 (스킵)');
return;
}
@@ -28,6 +29,7 @@ public function run(): void
if ($clients->isEmpty()) {
$this->command->warn(' ⚠ sales: 매출 거래처 없음 (스킵)');
return;
}
@@ -41,9 +43,9 @@ public function run(): void
];
$amounts = [
'small' => [1000000, 5000000],
'small' => [1000000, 5000000],
'medium' => [5000000, 30000000],
'large' => [30000000, 100000000],
'large' => [30000000, 100000000],
];
// 월별 건수: 1~10월 6~7건, 11월 8건, 12월 7건 = 80건
@@ -64,7 +66,7 @@ public function run(): void
$client = $clientsByName->get($clientName);
// 이름 매칭 실패 시 기존 클라이언트 중 랜덤 선택
if (!$client) {
if (! $client) {
$clientId = $clientIds[array_rand($clientIds)];
$client = $clients->firstWhere('id', $clientId);
$clientName = $client->name;
@@ -93,22 +95,22 @@ public function run(): void
$total = $supply + $tax;
Sale::create([
'tenant_id' => $tenantId,
'sale_number' => sprintf('SAL-%04d%02d-%04d', $year, $month, $i + 1),
'sale_date' => sprintf('%04d-%02d-%02d', $year, $month, $day),
'client_id' => $client->id,
'tenant_id' => $tenantId,
'sale_number' => sprintf('SAL-%04d%02d-%04d', $year, $month, $i + 1),
'sale_date' => sprintf('%04d-%02d-%02d', $year, $month, $day),
'client_id' => $client->id,
'supply_amount' => $supply,
'tax_amount' => $tax,
'total_amount' => $total,
'description' => $clientName . ' 매출',
'status' => $status,
'created_by' => $userId,
'tax_amount' => $tax,
'total_amount' => $total,
'description' => $clientName.' 매출',
'status' => $status,
'created_by' => $userId,
]);
$count++;
}
}
$this->command->info(' ✓ sales: ' . $count . '건 생성');
$this->command->info(' ✓ sales: '.$count.'건 생성');
}
}
}

View File

@@ -46,7 +46,7 @@ public function run(): void
->where('tenant_id', $tenantId)
->exists();
if (!$linked) {
if (! $linked) {
DB::table('user_tenants')->insert([
'user_id' => $existing->id,
'tenant_id' => $tenantId,
@@ -57,6 +57,7 @@ public function run(): void
'updated_at' => now(),
]);
}
continue;
}
@@ -84,6 +85,6 @@ public function run(): void
$count++;
}
$this->command->info(' ✓ users: ' . $count . '명 생성 (테넌트 연결 완료)');
$this->command->info(' ✓ users: '.$count.'명 생성 (테넌트 연결 완료)');
}
}

View File

@@ -18,7 +18,8 @@ public function run(): void
// 기존 데이터 있으면 스킵
$existing = Withdrawal::where('tenant_id', $tenantId)->count();
if ($existing > 0) {
$this->command->info(' ⚠ withdrawals: 이미 ' . $existing . '건 존재 (스킵)');
$this->command->info(' ⚠ withdrawals: 이미 '.$existing.'건 존재 (스킵)');
return;
}
@@ -48,9 +49,9 @@ public function run(): void
];
$amounts = [
'small' => [1000000, 5000000],
'small' => [1000000, 5000000],
'medium' => [5000000, 30000000],
'large' => [30000000, 80000000],
'large' => [30000000, 80000000],
];
$count = 0;
@@ -74,21 +75,21 @@ public function run(): void
}
Withdrawal::create([
'tenant_id' => $tenantId,
'tenant_id' => $tenantId,
'withdrawal_date' => sprintf('%04d-%02d-%02d', $year, $month, $day),
'client_id' => $client?->id,
'client_name' => $client ? null : $clientName,
'client_id' => $client?->id,
'client_name' => $client ? null : $clientName,
'bank_account_id' => $primaryBankId,
'amount' => $amount,
'payment_method' => $methods[array_rand($methods)],
'description' => $clientName . ' 지급',
'created_by' => $userId,
'amount' => $amount,
'payment_method' => $methods[array_rand($methods)],
'description' => $clientName.' 지급',
'created_by' => $userId,
]);
$count++;
}
}
$this->command->info(' ✓ withdrawals: ' . $count . '건 생성');
$this->command->info(' ✓ withdrawals: '.$count.'건 생성');
}
}
}

View File

@@ -17,6 +17,7 @@ public function run(): void
$existing = WorkSetting::where('tenant_id', $tenantId)->first();
if ($existing) {
$this->command->info(' ⚠ work_settings: 이미 존재 (스킵)');
return;
}
@@ -36,4 +37,4 @@ public function run(): void
$this->command->info(' ✓ work_settings: 1건 생성');
}
}
}

View File

@@ -71,6 +71,6 @@ public function run(): void
);
}
$this->command->info('Positions seeded: ' . count($ranks) . ' ranks, ' . count($titles) . ' titles');
$this->command->info('Positions seeded: '.count($ranks).' ranks, '.count($titles).' titles');
}
}
}

View File

@@ -226,4 +226,4 @@ private function randomRemark(): ?string
return $remarks[array_rand($remarks)];
}
}
}