fix(SAM/API): 더미 시더 클라이언트 매칭 오류 수정
- DummySaleSeeder: 클라이언트 이름 매칭 실패 시 기존 클라이언트 랜덤 선택 - DummyPurchaseSeeder: 동일한 fallback 로직 추가 - 거래처 없을 경우 조기 반환 처리 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -24,8 +24,15 @@ public function run(): void
|
|||||||
// 거래처 매핑 (PURCHASE, BOTH만)
|
// 거래처 매핑 (PURCHASE, BOTH만)
|
||||||
$clients = Client::where('tenant_id', $tenantId)
|
$clients = Client::where('tenant_id', $tenantId)
|
||||||
->whereIn('client_type', ['PURCHASE', 'BOTH'])
|
->whereIn('client_type', ['PURCHASE', 'BOTH'])
|
||||||
->get()
|
->get();
|
||||||
->keyBy('name');
|
|
||||||
|
if ($clients->isEmpty()) {
|
||||||
|
$this->command->warn(' ⚠ purchases: 매입 거래처 없음 (스킵)');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$clientsByName = $clients->keyBy('name');
|
||||||
|
$clientIds = $clients->pluck('id')->toArray();
|
||||||
|
|
||||||
$clientNames = [
|
$clientNames = [
|
||||||
'한화솔루션', '포스코', '롯데케미칼', 'GS칼텍스', '대한항공',
|
'한화솔루션', '포스코', '롯데케미칼', 'GS칼텍스', '대한항공',
|
||||||
@@ -53,7 +60,14 @@ public function run(): void
|
|||||||
$day = max(1, min($day, $daysInMonth));
|
$day = max(1, min($day, $daysInMonth));
|
||||||
|
|
||||||
$clientName = $clientNames[($count) % count($clientNames)];
|
$clientName = $clientNames[($count) % count($clientNames)];
|
||||||
$client = $clients->get($clientName);
|
$client = $clientsByName->get($clientName);
|
||||||
|
|
||||||
|
// 이름 매칭 실패 시 기존 클라이언트 중 랜덤 선택
|
||||||
|
if (!$client) {
|
||||||
|
$clientId = $clientIds[array_rand($clientIds)];
|
||||||
|
$client = $clients->firstWhere('id', $clientId);
|
||||||
|
$clientName = $client->name;
|
||||||
|
}
|
||||||
|
|
||||||
$rand = rand(1, 100);
|
$rand = rand(1, 100);
|
||||||
if ($rand <= 30) {
|
if ($rand <= 30) {
|
||||||
|
|||||||
@@ -24,8 +24,15 @@ public function run(): void
|
|||||||
// 거래처 매핑 (SALES, BOTH만)
|
// 거래처 매핑 (SALES, BOTH만)
|
||||||
$clients = Client::where('tenant_id', $tenantId)
|
$clients = Client::where('tenant_id', $tenantId)
|
||||||
->whereIn('client_type', ['SALES', 'BOTH'])
|
->whereIn('client_type', ['SALES', 'BOTH'])
|
||||||
->get()
|
->get();
|
||||||
->keyBy('name');
|
|
||||||
|
if ($clients->isEmpty()) {
|
||||||
|
$this->command->warn(' ⚠ sales: 매출 거래처 없음 (스킵)');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$clientsByName = $clients->keyBy('name');
|
||||||
|
$clientIds = $clients->pluck('id')->toArray();
|
||||||
|
|
||||||
$clientNames = [
|
$clientNames = [
|
||||||
'삼성전자', 'LG전자', 'SK하이닉스', '현대자동차', '네이버',
|
'삼성전자', 'LG전자', 'SK하이닉스', '현대자동차', '네이버',
|
||||||
@@ -54,7 +61,14 @@ public function run(): void
|
|||||||
$day = max(1, min($day, $daysInMonth));
|
$day = max(1, min($day, $daysInMonth));
|
||||||
|
|
||||||
$clientName = $clientNames[($count) % count($clientNames)];
|
$clientName = $clientNames[($count) % count($clientNames)];
|
||||||
$client = $clients->get($clientName);
|
$client = $clientsByName->get($clientName);
|
||||||
|
|
||||||
|
// 이름 매칭 실패 시 기존 클라이언트 중 랜덤 선택
|
||||||
|
if (!$client) {
|
||||||
|
$clientId = $clientIds[array_rand($clientIds)];
|
||||||
|
$client = $clients->firstWhere('id', $clientId);
|
||||||
|
$clientName = $client->name;
|
||||||
|
}
|
||||||
|
|
||||||
// 금액 결정
|
// 금액 결정
|
||||||
$rand = rand(1, 100);
|
$rand = rand(1, 100);
|
||||||
|
|||||||
Reference in New Issue
Block a user