{{-- 고객사정산 탭 (실 테넌트 데이터 기반) --}}
{{-- 통계 카드 --}}

총 개발비

{{ number_format($customerStats['total_fee']) }}원

{{ $customerStats['total_count'] }}건

수금완료

{{ number_format($customerStats['collected_amount']) }}원

미수금

{{ number_format($customerStats['uncollected_amount']) }}원

개발 진행 중

{{ $customerStats['in_progress_count'] }}건

구독 전환

{{ $customerStats['subscription_count'] }}건

{{-- 필터 --}}
{{-- 테이블 --}}
@forelse ($managements as $mgmt) @php $companyName = $mgmt->tenant?->company_name ?? $mgmt->tenantProspect?->company_name ?? '-'; $tenantActive = $mgmt->tenant && !$mgmt->tenant->trashed(); // 개발비 총액 (management 직접 값 → contractProducts 합산) $totalFee = $mgmt->total_registration_fee > 0 ? $mgmt->total_registration_fee : ($mgmt->contractProducts?->sum('registration_fee') ?? 0); // 계약금/잔금 기본값 (총개발비의 50%) $calcBase = $totalFee / 2; // 계약금 $depositAmount = $mgmt->deposit_amount > 0 ? $mgmt->deposit_amount : ($totalFee > 0 ? $calcBase : 0); // 잔금 $balanceAmount = $mgmt->balance_amount > 0 ? $mgmt->balance_amount : ($totalFee > 0 ? $calcBase : 0); // 구독료 (tenant 기반 조회 → contractProducts fallback) $monthlyFee = $subscriptionFees[$mgmt->tenant_id] ?? 0; if ($monthlyFee <= 0) { $monthlyFee = $mgmt->contractProducts?->sum('subscription_fee') ?? 0; } // 담당파트너 (salesPartner → tenantProspect.registeredBy) $partnerName = $mgmt->salesPartner?->user?->name ?? $mgmt->tenantProspect?->registeredBy?->name ?? '-'; // 담당매니저 $managerName = $mgmt->manager?->name ?? '-'; $firstSubscriptionAt = $mgmt->commissions->first()?->first_subscription_at; @endphp {{-- 고객사 --}} {{-- 담당파트너 --}} {{-- 담당매니저 --}} {{-- 개발비 총액 --}} {{-- 1차(계약금) --}} {{-- 2차(잔금) --}} {{-- 구독료 --}} {{-- 개발상태 --}} @empty @endforelse
고객사 담당파트너 담당매니저 개발비 총액 1차(계약금) 2차(잔금) 구독료 개발상태
{{ $companyName }}
{{ $partnerName }} {{ $managerName }} @if ($totalFee > 0) {{ number_format($totalFee) }}원 @else - @endif @if ($depositAmount > 0)
{{ number_format($depositAmount) }}원
@if ($mgmt->deposit_status === 'paid') 완료 @else 대기 @endif @if ($mgmt->deposit_paid_date)
{{ $mgmt->deposit_paid_date->format('Y-m-d') }}
@endif @else - @endif
@if ($balanceAmount > 0)
{{ number_format($balanceAmount) }}원
@if ($mgmt->balance_status === 'paid') 완료 @else 대기 @endif @if ($mgmt->balance_paid_date)
{{ $mgmt->balance_paid_date->format('Y-m-d') }}
@endif @else - @endif
@if ($monthlyFee > 0)
월 {{ number_format($monthlyFee) }}원
@if ($firstSubscriptionAt)
첫입금 {{ \Carbon\Carbon::parse($firstSubscriptionAt)->format('Y-m-d') }}
@endif @else - @endif
@php $statusColor = match ($mgmt->hq_status) { 'review' => 'bg-purple-100 text-purple-700', 'planning' => 'bg-blue-100 text-blue-700', 'coding' => 'bg-indigo-100 text-indigo-700', 'dev_test' => 'bg-cyan-100 text-cyan-700', 'dev_done' => 'bg-teal-100 text-teal-700', 'int_test' => 'bg-amber-100 text-amber-700', 'handover' => 'bg-green-100 text-green-700', default => 'bg-gray-100 text-gray-700', }; @endphp {{ $mgmt->hq_status_label }}
개발이 시작된 고객사가 없습니다.
@if ($managements->hasPages())
{{ $managements->links() }}
@endif