From eaa3490c9a55fb380e910e3240b56eb75ce08388 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 17:59:21 +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?=ED=82=A4=EC=97=90=EC=84=9C=20balance=20=EC=A0=9C=EC=99=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 같은 거래가 잔액만 다르게 저장된 경우도 중복으로 인식하도록 수정 - save() upsert에서도 balance 제외하여 향후 중복 방지 - 기존 레코드 발견 시 balance도 갱신 Co-Authored-By: Claude Opus 4.6 --- app/Http/Controllers/Barobill/EaccountController.php | 6 +++--- app/Http/Controllers/Finance/DailyFundController.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/Barobill/EaccountController.php b/app/Http/Controllers/Barobill/EaccountController.php index 2b587bd3..bb1f1a96 100644 --- a/app/Http/Controllers/Barobill/EaccountController.php +++ b/app/Http/Controllers/Barobill/EaccountController.php @@ -928,18 +928,18 @@ public function save(Request $request): JsonResponse ]; // Upsert: 있으면 업데이트, 없으면 생성 - // 금액 비교 시 정수로 캐스트하여 decimal 정밀도 차이로 인한 중복 방지 + // balance 제외: 같은 거래가 잔액만 다르게 저장되는 중복 방지 $existing = BankTransaction::where('tenant_id', $tenantId) ->where('bank_account_num', $data['bank_account_num']) ->where('trans_dt', $transDt) ->whereRaw('CAST(deposit AS SIGNED) = ?', [(int) $data['deposit']]) ->whereRaw('CAST(withdraw AS SIGNED) = ?', [(int) $data['withdraw']]) - ->whereRaw('CAST(balance AS SIGNED) = ?', [(int) $data['balance']]) ->first(); if ($existing) { - // 계정과목만 업데이트 + // 계정과목 + 잔액 업데이트 $existing->update([ + 'balance' => $data['balance'], 'account_code' => $data['account_code'], 'account_name' => $data['account_name'], ]); diff --git a/app/Http/Controllers/Finance/DailyFundController.php b/app/Http/Controllers/Finance/DailyFundController.php index affe5979..e5da019f 100644 --- a/app/Http/Controllers/Finance/DailyFundController.php +++ b/app/Http/Controllers/Finance/DailyFundController.php @@ -180,7 +180,7 @@ public function periodReport(Request $request): JsonResponse ->orderBy('trans_date', 'desc') ->orderBy('trans_time', 'desc') ->get() - ->unique(fn($tx) => $tx->bank_account_num . '|' . $tx->trans_dt . '|' . (int)$tx->deposit . '|' . (int)$tx->withdraw . '|' . (int)$tx->balance) + ->unique(fn($tx) => $tx->bank_account_num . '|' . $tx->trans_dt . '|' . (int)$tx->deposit . '|' . (int)$tx->withdraw) ->values(); // 오버라이드 데이터 병합 (수정된 적요/내용)