feat: 자동인식 분류 학습 — 같은 메모 키워드는 과거 분류로 자동 채움
CI / build (push) Failing after 14m39s

- 알림 자동등록 시 memo(가맹점) 키워드로 과거에 '확정'한 내역의 분류를
  찾아(가장 많이 쓴 분류) pending 내역에 미리 채운다.
- 메모 포함관계 매칭('스타벅스' ↔ '스타벅스 강남점'), 같은 type(수입/지출)만.
- 안전상 '확인 필요' 상태는 유지(분류만 선반영) — 무검토 오확정 방지.
- AccountEntryMapper.findLearnedCategory 추가.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
ByungCheol
2026-06-12 22:22:54 +09:00
parent 120e042971
commit a0fc546ad8
3 changed files with 33 additions and 3 deletions
@@ -66,6 +66,11 @@ public interface AccountEntryMapper {
/** 미확인(확인 필요) 내역 개수 */
int countPending(@Param("memberId") Long memberId);
/** 자동인식 분류 학습: 같은 메모 키워드로 과거에 가장 많이 쓴 분류 1건(없으면 null) */
String findLearnedCategory(@Param("memberId") Long memberId,
@Param("type") String type,
@Param("memo") String memo);
/** 미확인 내역 확정 (pending=0, 분류/계좌 보정) */
int confirm(@Param("id") Long id, @Param("memberId") Long memberId,
@Param("category") String category, @Param("walletId") Long walletId);
@@ -231,13 +231,20 @@ public class AccountService {
String walletType = p.isBankTransfer() ? "BANK" : "CARD";
Long walletId = matchWalletId(p.getIssuer(), memberId, walletType);
// 분류 자동학습: 같은 메모(가맹점) 키워드로 과거에 확정한 분류가 있으면 그대로 채워준다.
String type = p.isIncome() ? "INCOME" : "EXPENSE";
String merchant = p.getMerchant();
String learnedCategory = (merchant != null && !merchant.isBlank())
? mapper.findLearnedCategory(memberId, type, merchant)
: null;
AccountEntry entry = AccountEntry.builder()
.memberId(memberId)
.entryDate(p.getDate() != null ? p.getDate() : java.time.LocalDate.now())
.type(p.isIncome() ? "INCOME" : "EXPENSE")
.category(null)
.type(type)
.category(learnedCategory)
.amount(p.getAmount())
.memo(p.getMerchant())
.memo(merchant)
.walletId(walletId)
.toWalletId(null)
.installmentMonths(null)