fix: [loan] getCategoryBreakdown SQL alias 충돌 수정

- outstanding_amount → cat_outstanding alias 변경 (Loan accessor 충돌 방지)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
유병철
2026-03-04 15:30:31 +09:00
parent 66da2972fa
commit a173a5a4fc

View File

@@ -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,
];