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(); // 오버라이드 데이터 병합 (수정된 적요/내용)