diff --git a/app/Http/Controllers/Finance/DailyFundController.php b/app/Http/Controllers/Finance/DailyFundController.php index 4f1f3200..53ce76eb 100644 --- a/app/Http/Controllers/Finance/DailyFundController.php +++ b/app/Http/Controllers/Finance/DailyFundController.php @@ -174,12 +174,12 @@ public function periodReport(Request $request): JsonResponse $startDateYmd = str_replace('-', '', $startDate); $endDateYmd = str_replace('-', '', $endDate); - // 기간 내 거래내역 조회 (중복 제거: 동일 trans_dt + 금액 조합이면 최신 id(정확한 잔액)만 사용) + // 기간 내 거래내역 조회 (중복 제거: balance 포함 고유키로 동일 거래만 제거) $transactions = BarobillBankTransaction::where('tenant_id', $tenantId) ->whereBetween('trans_date', [$startDateYmd, $endDateYmd]) ->orderBy('id', 'desc') // 최신 ID 우선 (올바른 잔액) ->get() - ->unique(fn($tx) => $tx->bank_account_num . '|' . $tx->trans_dt . '|' . (int)$tx->deposit . '|' . (int)$tx->withdraw) + ->unique(fn($tx) => $tx->unique_key) ->sortByDesc('trans_date') ->sortByDesc(fn($tx) => $tx->trans_date . $tx->trans_time) ->values();