fix:일일자금일보 중복 제거 키에 balance 추가하여 동일 금액 다른 거래 구분
계좌 입출금내역과 동일한 문제: balance 없이 중복 제거하면 같은 출금금액의 서로 다른 거래가 하나로 합쳐지는 문제 수정. BankTransaction 모델의 unique_key 속성(balance 포함)을 재사용. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user