From a173a5a4fc2c8288486425a762a99b092c1bef1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9C=A0=EB=B3=91=EC=B2=A0?= Date: Wed, 4 Mar 2026 15:30:31 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20[loan]=20getCategoryBreakdown=20SQL=20al?= =?UTF-8?q?ias=20=EC=B6=A9=EB=8F=8C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - outstanding_amount → cat_outstanding alias 변경 (Loan accessor 충돌 방지) Co-Authored-By: Claude Opus 4.6 --- app/Services/LoanService.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Services/LoanService.php b/app/Services/LoanService.php index 1fac7b5..40e290c 100644 --- a/app/Services/LoanService.php +++ b/app/Services/LoanService.php @@ -483,8 +483,10 @@ private function getCategoryBreakdown(int $tenantId, ?string $startDate = null, $query->where('loan_date', '<=', $endDate); } + // NOTE: SQL alias를 'cat_outstanding'으로 사용 — Loan 모델의 + // getOutstandingAmountAttribute() accessor와 이름 충돌 방지 $stats = $query - ->selectRaw('category, COUNT(*) as total_count, SUM(amount - COALESCE(settlement_amount, 0)) as outstanding_amount') + ->selectRaw('category, COUNT(*) as total_count, SUM(amount - COALESCE(settlement_amount, 0)) as cat_outstanding') ->selectRaw('SUM(CASE WHEN purpose IS NULL OR purpose = \'\' THEN 1 ELSE 0 END) as unverified_count') ->groupBy('category') ->get(); @@ -493,7 +495,7 @@ private function getCategoryBreakdown(int $tenantId, ?string $startDate = null, $cat = $stat->category ?? Loan::CATEGORY_CARD; if (isset($breakdown[$cat])) { $breakdown[$cat] = [ - 'outstanding_amount' => (float) $stat->outstanding_amount, + 'outstanding_amount' => (float) $stat->cat_outstanding, 'total_count' => (int) $stat->total_count, 'unverified_count' => (int) $stat->unverified_count, ];