fix: [eaccount] 계좌 입출금내역 적요 중복 표시 수정

- BankTransaction::cleanSummary() 메서드 추가: 상대계좌예금주명(cast) 중복 제거
- parseTransactionLogs: 적요 표시 시 remark2 중복 제거 적용
- cacheApiTransactions: DB 저장 시에도 중복 제거 적용
- 기존 DB 데이터 45건 정리 완료
This commit is contained in:
김보곤
2026-03-03 21:11:35 +09:00
parent 9b36052a8f
commit 614cbaef15
2 changed files with 34 additions and 5 deletions

View File

@@ -49,19 +49,40 @@ public function tenant(): BelongsTo
return $this->belongsTo(Tenant::class);
}
/**
* 적요(summary)에서 상대계좌예금주명(cast/remark2) 중복 제거
* 바로빌 API 응답에서 TransRemark1에 TransRemark2가 포함되는 경우 정리
*/
public static function cleanSummary(string $summary, string $remark): string
{
if (empty($remark) || empty($summary) || ! str_contains($summary, $remark)) {
return $summary;
}
$result = rtrim($summary);
while (str_ends_with($result, $remark) && strlen($result) > strlen($remark)) {
$result = rtrim(substr($result, 0, -strlen($remark)));
}
return $result;
}
/**
* 거래 고유 키 생성 (매칭용)
* 숫자는 정수로 변환하여 형식 통일
*/
public function getUniqueKeyAttribute(): string
{
$cleanSummary = self::cleanSummary($this->summary ?? '', $this->cast ?? '');
return implode('|', [
$this->bank_account_num,
$this->trans_dt,
(int) $this->deposit,
(int) $this->withdraw,
(int) $this->balance,
$this->summary ?? '',
$cleanSummary,
]);
}