From a7973bb555406d1f1abddc7ddf881e39fc2f1648 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9C=A0=EB=B3=91=EC=B2=A0?= Date: Fri, 6 Mar 2026 10:37:57 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20[loan]=20=EC=83=81=ED=92=88=EA=B6=8C=20?= =?UTF-8?q?summary=EC=97=90=20=EC=A0=91=EB=8C=80=EB=B9=84=20=ED=95=B4?= =?UTF-8?q?=EB=8B=B9=20=EC=A7=91=EA=B3=84=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - expense_accounts 테이블에서 접대비(상품권) 건수/금액 조회 - entertainment_count, entertainment_amount 응답 필드 추가 Co-Authored-By: Claude Opus 4.6 --- app/Services/LoanService.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/Services/LoanService.php b/app/Services/LoanService.php index f04739f..87cb509 100644 --- a/app/Services/LoanService.php +++ b/app/Services/LoanService.php @@ -152,6 +152,17 @@ public function summary(?int $userId = null, ?string $category = null): array $result['used_count'] = (int) $stats->used_count; $result['used_amount'] = (float) $stats->used_amount; $result['disposed_count'] = (int) $stats->disposed_count; + + // 접대비 해당 집계 (expense_accounts 테이블에서 조회) + $entertainmentStats = ExpenseAccount::query() + ->where('tenant_id', $tenantId) + ->where('account_type', ExpenseAccount::TYPE_ENTERTAINMENT) + ->where('sub_type', ExpenseAccount::SUB_TYPE_GIFT_CERTIFICATE) + ->selectRaw('COUNT(*) as count, COALESCE(SUM(amount), 0) as amount') + ->first(); + + $result['entertainment_count'] = (int) ($entertainmentStats->count ?? 0); + $result['entertainment_amount'] = (float) ($entertainmentStats->amount ?? 0); } return $result;