Files
fund-tracer/backend/app/rules/dedup_rules.py

19 lines
713 B
Python
Raw Normal View History

2026-03-11 16:28:04 +08:00
"""Transaction deduplication rules.
2026-03-12 19:57:30 +08:00
Only marks records as duplicate when there is strong deterministic evidence.
Highly similar records (same amount/time/counterparty) are intentionally kept
for manual review to avoid filtering out potential scam brushing transactions.
2026-03-11 16:28:04 +08:00
"""
from app.models.transaction import TransactionRecord
def is_duplicate_pair(a: TransactionRecord, b: TransactionRecord) -> bool:
2026-03-12 19:57:30 +08:00
# Rule 1: exact order_no match (strong deterministic signal).
2026-03-11 16:28:04 +08:00
if a.order_no and b.order_no and a.order_no == b.order_no:
return True
2026-03-12 19:57:30 +08:00
# Intentionally do NOT deduplicate by amount/time similarity.
# Those records should enter the review stage for human confirmation.
2026-03-11 16:28:04 +08:00
return False