chore: [misc] 거래처 통계 수정 + 문서 템플릿 file_id 추가 + 라우트 정리
- ClientService stats() active/inactive 카운트 추가 - DocumentTemplateSection file_id 컬럼 마이그레이션 - 논리 관계 문서 업데이트 (BendingItemMapping 추가)
This commit is contained in:
@@ -53,7 +53,7 @@ public function index(array $params)
|
||||
$query->whereDate('created_at', '<=', $endDate);
|
||||
}
|
||||
|
||||
$query->orderBy('client_code')->orderBy('id');
|
||||
$query->orderBy('id', 'desc');
|
||||
|
||||
$paginator = $query->paginate($size, ['*'], 'page', $page);
|
||||
|
||||
@@ -304,10 +304,14 @@ public function stats(): array
|
||||
{
|
||||
$tenantId = $this->tenantId();
|
||||
|
||||
$total = Client::where('tenant_id', $tenantId)->count();
|
||||
$base = Client::where('tenant_id', $tenantId);
|
||||
|
||||
$total = (clone $base)->count();
|
||||
$active = (clone $base)->where('is_active', true)->count();
|
||||
$inactive = $total - $active;
|
||||
|
||||
// 거래처 유형별 통계
|
||||
$typeCounts = Client::where('tenant_id', $tenantId)
|
||||
$typeCounts = (clone $base)
|
||||
->selectRaw('client_type, COUNT(*) as count')
|
||||
->groupBy('client_type')
|
||||
->pluck('count', 'client_type')
|
||||
@@ -321,12 +325,14 @@ public function stats(): array
|
||||
->distinct('client_id')
|
||||
->pluck('client_id');
|
||||
|
||||
$badDebtCount = Client::where('tenant_id', $tenantId)
|
||||
$badDebtCount = (clone $base)
|
||||
->whereIn('id', $badDebtClientIds)
|
||||
->count();
|
||||
|
||||
return [
|
||||
'total' => $total,
|
||||
'active' => $active,
|
||||
'inactive' => $inactive,
|
||||
'sales' => $typeCounts['SALES'] ?? 0,
|
||||
'purchase' => $typeCounts['PURCHASE'] ?? 0,
|
||||
'both' => $typeCounts['BOTH'] ?? 0,
|
||||
|
||||
Reference in New Issue
Block a user