fix: [계좌내역] 잔액 재계산을 수동입력뿐 아니라 전체 거래에 적용
This commit is contained in:
@@ -1945,14 +1945,19 @@ private function recalcManualBalances(array $logs, ?float $baseBalance = null):
|
||||
|
||||
$prevBalance = $baseBalance;
|
||||
foreach ($logs as &$log) {
|
||||
if (! empty($log['isManual'])) {
|
||||
$deposit = (float) ($log['deposit'] ?? 0);
|
||||
$withdraw = (float) ($log['withdraw'] ?? 0);
|
||||
$newBalance = ($prevBalance !== null ? $prevBalance : 0) + $deposit - $withdraw;
|
||||
$deposit = (float) ($log['deposit'] ?? 0);
|
||||
$withdraw = (float) ($log['withdraw'] ?? 0);
|
||||
|
||||
if ($prevBalance !== null) {
|
||||
// 이전 잔액이 있으면 모든 거래(API/수동 무관)의 잔액을 재계산
|
||||
$newBalance = $prevBalance + $deposit - $withdraw;
|
||||
$log['balance'] = $newBalance;
|
||||
$log['balanceFormatted'] = number_format($newBalance);
|
||||
$prevBalance = $newBalance;
|
||||
} else {
|
||||
// 이전 잔액 없음: 첫 거래의 DB 잔액을 신뢰하여 기준점으로 사용
|
||||
$prevBalance = (float) ($log['balance'] ?? 0);
|
||||
}
|
||||
$prevBalance = (float) ($log['balance'] ?? 0);
|
||||
}
|
||||
unset($log);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user