From a30489f1a8202aef70665d7643d7fcc5695cb62d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B3=B4=EA=B3=A4?= Date: Fri, 6 Feb 2026 18:01:44 +0900 Subject: [PATCH] =?UTF-8?q?fix:=EC=9D=BC=EC=9D=BC=EC=9E=90=EA=B8=88?= =?UTF-8?q?=EC=9D=BC=EB=B3=B4=20=EC=A4=91=EB=B3=B5=20=EC=A0=9C=EA=B1=B0=20?= =?UTF-8?q?=EC=8B=9C=20=EC=B5=9C=EC=8B=A0=20=EB=A0=88=EC=BD=94=EB=93=9C(?= =?UTF-8?q?=EC=A0=95=ED=99=95=ED=95=9C=20=EC=9E=94=EC=95=A1)=20=EC=9C=A0?= =?UTF-8?q?=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - orderBy id DESC로 먼저 정렬하여 unique() 시 최신 ID 유지 - 중복 제거 후 날짜+시간 기준으로 재정렬 Co-Authored-By: Claude Opus 4.6 --- app/Http/Controllers/Finance/DailyFundController.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Finance/DailyFundController.php b/app/Http/Controllers/Finance/DailyFundController.php index e5da019f..4f1f3200 100644 --- a/app/Http/Controllers/Finance/DailyFundController.php +++ b/app/Http/Controllers/Finance/DailyFundController.php @@ -174,13 +174,14 @@ public function periodReport(Request $request): JsonResponse $startDateYmd = str_replace('-', '', $startDate); $endDateYmd = str_replace('-', '', $endDate); - // 기간 내 거래내역 조회 (중복 제거: 동일 trans_dt + 금액 조합이면 최신 id만 사용) + // 기간 내 거래내역 조회 (중복 제거: 동일 trans_dt + 금액 조합이면 최신 id(정확한 잔액)만 사용) $transactions = BarobillBankTransaction::where('tenant_id', $tenantId) ->whereBetween('trans_date', [$startDateYmd, $endDateYmd]) - ->orderBy('trans_date', 'desc') - ->orderBy('trans_time', 'desc') + ->orderBy('id', 'desc') // 최신 ID 우선 (올바른 잔액) ->get() ->unique(fn($tx) => $tx->bank_account_num . '|' . $tx->trans_dt . '|' . (int)$tx->deposit . '|' . (int)$tx->withdraw) + ->sortByDesc('trans_date') + ->sortByDesc(fn($tx) => $tx->trans_date . $tx->trans_time) ->values(); // 오버라이드 데이터 병합 (수정된 적요/내용)