fix:일일자금일보 거래 중복 표시 및 잔액 NaN 버그 수정
- periodReport에서 동일 거래(계좌+일시+금액) 중복 제거 로직 추가 - EaccountController save() 금액 비교를 정수 캐스트로 변경하여 decimal 정밀도 차이 중복 방지 - 합계행 잔액 계산 시 Number() 캐스트로 NaN 방지 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -928,12 +928,13 @@ public function save(Request $request): JsonResponse
|
||||
];
|
||||
|
||||
// Upsert: 있으면 업데이트, 없으면 생성
|
||||
// 금액 비교 시 정수로 캐스트하여 decimal 정밀도 차이로 인한 중복 방지
|
||||
$existing = BankTransaction::where('tenant_id', $tenantId)
|
||||
->where('bank_account_num', $data['bank_account_num'])
|
||||
->where('trans_dt', $transDt)
|
||||
->where('deposit', $data['deposit'])
|
||||
->where('withdraw', $data['withdraw'])
|
||||
->where('balance', $data['balance'])
|
||||
->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) {
|
||||
|
||||
@@ -174,12 +174,14 @@ public function periodReport(Request $request): JsonResponse
|
||||
$startDateYmd = str_replace('-', '', $startDate);
|
||||
$endDateYmd = str_replace('-', '', $endDate);
|
||||
|
||||
// 기간 내 거래내역 조회
|
||||
// 기간 내 거래내역 조회 (중복 제거: 동일 trans_dt + 금액 조합이면 최신 id만 사용)
|
||||
$transactions = BarobillBankTransaction::where('tenant_id', $tenantId)
|
||||
->whereBetween('trans_date', [$startDateYmd, $endDateYmd])
|
||||
->orderBy('trans_date', 'desc')
|
||||
->orderBy('trans_time', 'desc')
|
||||
->get();
|
||||
->get()
|
||||
->unique(fn($tx) => $tx->bank_account_num . '|' . $tx->trans_dt . '|' . (int)$tx->deposit . '|' . (int)$tx->withdraw . '|' . (int)$tx->balance)
|
||||
->values();
|
||||
|
||||
// 오버라이드 데이터 병합 (수정된 적요/내용)
|
||||
if ($transactions->isNotEmpty()) {
|
||||
|
||||
@@ -208,7 +208,7 @@ className="px-3 py-2 border border-gray-300 rounded-lg text-sm"
|
||||
{formatCurrency(report.totalWithdraw)}
|
||||
</td>
|
||||
<td className="px-4 py-3 text-sm text-right text-gray-800 border">
|
||||
{formatCurrency(report.accounts.reduce((sum, a) => sum + a.balance, 0))}
|
||||
{formatCurrency(report.accounts.reduce((sum, a) => sum + Number(a.balance || 0), 0))}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
Reference in New Issue
Block a user