fix: 입금자명 매칭 시 앞 7글자만 비교

은행 SMS는 입금자명을 7글자까지만 표시하므로,
매칭 시 SUBSTR(depositor_name, 1, 7)로 비교하도록 수정

- deposit-agent.ts: 사용자 입력 → bank_notifications 검색
- index.ts: SMS 수신 → deposit_transactions 검색
- CLAUDE.md: 매칭 로직 문서화

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
kappa
2026-01-19 10:46:23 +09:00
parent a1eaae3c04
commit 8a404fe75b
3 changed files with 18 additions and 4 deletions

View File

@@ -898,13 +898,14 @@ async function tryAutoMatch(
notificationId: number,
notification: BankNotification
): Promise<{ transactionId: number; userId: number; amount: number } | null> {
// 매칭 조건: 입금자명 + 금액이 일치하는 pending 거래
// 매칭 조건: 입금자명(앞 7글자) + 금액이 일치하는 pending 거래
// 은행 SMS는 입금자명이 7글자까지만 표시됨
const pendingTx = await db.prepare(
`SELECT dt.id, dt.user_id, dt.amount
FROM deposit_transactions dt
WHERE dt.status = 'pending'
AND dt.type = 'deposit'
AND dt.depositor_name = ?
AND SUBSTR(dt.depositor_name, 1, 7) = ?
AND dt.amount = ?
ORDER BY dt.created_at ASC
LIMIT 1`