fix:수당 정산 탭 테넌트 표시를 실제 고객사 기반으로 수정

- eager loading에 management.tenant, management.tenantProspect 추가
- 검색 필터를 management 기반 고객사명 검색으로 변경
- 테넌트 컬럼을 management→tenant/tenantProspect 기반으로 표시
- 본사 진행상태(hq_status) 배지 추가
- 입금액 0원일 때 '-' 표시로 개선

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
김보곤
2026-02-19 14:24:44 +09:00
parent a1aa6036cf
commit d2b099a166
2 changed files with 35 additions and 8 deletions

View File

@@ -32,7 +32,7 @@ class SalesCommissionService
public function getCommissions(array $filters = [], int $perPage = 20): LengthAwarePaginator
{
$query = SalesCommission::query()
->with(['tenant', 'partner.user', 'manager', 'management', 'referrerPartner.user']);
->with(['tenant', 'partner.user', 'manager', 'management.tenant', 'management.tenantProspect', 'referrerPartner.user']);
// 상태 필터
if (!empty($filters['status'])) {
@@ -77,12 +77,17 @@ public function getCommissions(array $filters = [], int $perPage = 20): LengthAw
}
}
// 테넌트 검색
// 고객사 검색 (management → tenant 또는 tenantProspect)
if (!empty($filters['search'])) {
$search = $filters['search'];
$query->whereHas('tenant', function ($q) use ($search) {
$q->where('name', 'like', "%{$search}%")
->orWhere('company_name', 'like', "%{$search}%");
$query->whereHas('management', function ($q) use ($search) {
$q->where(function ($sub) use ($search) {
$sub->whereHas('tenant', function ($tq) use ($search) {
$tq->where('company_name', 'like', "%{$search}%");
})->orWhereHas('tenantProspect', function ($tpq) use ($search) {
$tpq->where('company_name', 'like', "%{$search}%");
});
});
});
}

View File

@@ -34,8 +34,26 @@ class="commission-checkbox rounded border-gray-300 text-emerald-600 focus:ring-e
@endif
</td>
<td class="px-4 py-3">
<div class="text-sm font-medium text-gray-900">{{ $commission->tenant->name ?? $commission->tenant->company_name ?? '-' }}</div>
<div class="text-xs text-gray-500">ID: {{ $commission->tenant_id }}</div>
<div class="text-sm font-medium text-gray-900">
{{ $commission->management?->tenant?->company_name ?? $commission->management?->tenantProspect?->company_name ?? '-' }}
</div>
@if ($commission->management?->hq_status)
@php
$hqColors = [
'pending' => 'bg-gray-100 text-gray-600',
'review' => 'bg-yellow-100 text-yellow-700',
'planning' => 'bg-blue-100 text-blue-700',
'coding' => 'bg-indigo-100 text-indigo-700',
'dev_test' => 'bg-purple-100 text-purple-700',
'dev_done' => 'bg-teal-100 text-teal-700',
'int_test' => 'bg-cyan-100 text-cyan-700',
'handover' => 'bg-green-100 text-green-700',
];
@endphp
<span class="inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium {{ $hqColors[$commission->management->hq_status] ?? 'bg-gray-100 text-gray-600' }}">
{{ $commission->management->hq_status_label }}
</span>
@endif
</td>
<td class="px-4 py-3">
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium
@@ -44,7 +62,11 @@ class="commission-checkbox rounded border-gray-300 text-emerald-600 focus:ring-e
</span>
</td>
<td class="px-4 py-3 text-right text-sm text-gray-900">
{{ number_format($commission->payment_amount) }}
@if ($commission->payment_amount > 0)
{{ number_format($commission->payment_amount) }}
@else
<span class="text-gray-400">-</span>
@endif
</td>
<td class="px-4 py-3 text-center text-sm text-gray-500">
{{ $commission->payment_date->format('Y-m-d') }}