From 652ac3d1ecc1ec41aa8bf7e267fb76fda87b1e97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9C=A0=EB=B3=91=EC=B2=A0?= Date: Thu, 5 Mar 2026 21:39:17 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20[loan]=20dashboard=20summary/=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=EC=97=90=EC=84=9C=EB=8F=84=20used/disposed=20?= =?UTF-8?q?=EC=83=81=ED=92=88=EA=B6=8C=20=EC=A0=9C=EC=99=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - dashboard summary 쿼리에 excludeUsedGiftCert 조건 적용 - 가지급금 목록 쿼리에도 동일 조건 적용 Co-Authored-By: Claude Opus 4.6 --- app/Services/LoanService.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/Services/LoanService.php b/app/Services/LoanService.php index 0db4fc3..f30c666 100644 --- a/app/Services/LoanService.php +++ b/app/Services/LoanService.php @@ -525,9 +525,18 @@ public function dashboard(?string $startDate = null, ?string $endDate = null): a return $query; }; + // 상품권 중 used/disposed 제외 조건 (접대비로 전환됨) + $excludeUsedGiftCert = function ($query) { + $query->whereNot(function ($q) { + $q->where('category', Loan::CATEGORY_GIFT_CERTIFICATE) + ->whereIn('status', [Loan::STATUS_USED, Loan::STATUS_DISPOSED]); + }); + }; + // 1. Summary 데이터 (날짜 필터 적용) $summaryQuery = Loan::query()->where('tenant_id', $tenantId); $applyDateFilter($summaryQuery); + $excludeUsedGiftCert($summaryQuery); $stats = $summaryQuery->selectRaw(' COUNT(*) as total_count, @@ -544,11 +553,12 @@ public function dashboard(?string $startDate = null, ?string $endDate = null): a // 3. 카테고리별 집계 (날짜 필터 적용) $categoryBreakdown = $this->getCategoryBreakdown($tenantId, $startDate, $endDate); - // 4. 가지급금 목록 (미정산 우선, 날짜 필터 적용) + // 4. 가지급금 목록 (미정산 우선, 날짜 필터 적용, used/disposed 상품권 제외) $loansQuery = Loan::query() ->where('tenant_id', $tenantId) ->with(['user:id,name,email', 'withdrawal']); $applyDateFilter($loansQuery); + $excludeUsedGiftCert($loansQuery); $loans = $loansQuery ->orderByRaw('CASE WHEN status = ? THEN 0 WHEN status = ? THEN 1 ELSE 2 END', [