From fb1bbe88acfbef2eb72971ee70b910fc8c1afd40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B3=B4=EA=B3=A4?= Date: Thu, 19 Mar 2026 16:01:43 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20[finance]=20=EC=86=90=EC=9D=B5=EA=B3=84?= =?UTF-8?q?=EC=82=B0=EC=84=9C=20AccountCode=20=EC=A1=B0=ED=9A=8C=EC=97=90?= =?UTF-8?q?=20withoutGlobalScopes=20=EC=A0=81=EC=9A=A9=20+=20=EC=83=81?= =?UTF-8?q?=EC=84=B8=20=EB=94=94=EB=B2=84=EA=B7=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Finance/IncomeStatementController.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Finance/IncomeStatementController.php b/app/Http/Controllers/Finance/IncomeStatementController.php index 06b8ec3e..2ba9d682 100644 --- a/app/Http/Controllers/Finance/IncomeStatementController.php +++ b/app/Http/Controllers/Finance/IncomeStatementController.php @@ -56,7 +56,9 @@ public function data(Request $request): JsonResponse $currentSums = $this->getAccountSums($tenantId, $startDate, $endDate); $previousSums = $this->getAccountSums($tenantId, $prevStartDate, $prevEndDate); - $accountCodes = AccountCode::where('tenant_id', $tenantId) + // BelongsToTenant 스코프 우회하여 정확한 테넌트 데이터만 조회 + $accountCodes = AccountCode::withoutGlobalScopes() + ->where('tenant_id', $tenantId) ->where('is_active', true) ->whereIn('category', ['revenue', 'expense']) ->orderBy('sort_order') @@ -69,6 +71,10 @@ public function data(Request $request): JsonResponse $currentYear = (int) date('Y', strtotime($endDate)); $fiscalYear = $this->getFiscalYear($tenantId, $currentYear); + // 디버그: revenue 계정 수 & sums 키 확인 + $revenueAccounts = $accountCodes->where('category', 'revenue')->where('sub_category', 'sales_revenue'); + $revenueSumsKeys = array_filter(array_keys($currentSums), fn ($k) => str_starts_with($k, '4')); + return response()->json([ 'period' => [ 'current' => [ @@ -84,7 +90,15 @@ public function data(Request $request): JsonResponse ], 'unit' => $unit, 'sections' => $sections, - '_debug_tenant_id' => $tenantId, + '_debug' => [ + 'tenant_id' => $tenantId, + 'account_codes_count' => $accountCodes->count(), + 'revenue_sales_count' => $revenueAccounts->count(), + 'revenue_sales_codes' => $revenueAccounts->pluck('code')->toArray(), + 'sums_4xx_keys' => $revenueSumsKeys, + 'sums_40400' => $currentSums['40400'] ?? 'NOT_FOUND', + 'sums_40100' => $currentSums['40100'] ?? 'NOT_FOUND', + ], ]); }