19 lines
713 B
Python
19 lines
713 B
Python
"""Transaction deduplication rules.
|
|
|
|
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.
|
|
"""
|
|
|
|
from app.models.transaction import TransactionRecord
|
|
|
|
|
|
def is_duplicate_pair(a: TransactionRecord, b: TransactionRecord) -> bool:
|
|
# Rule 1: exact order_no match (strong deterministic signal).
|
|
if a.order_no and b.order_no and a.order_no == b.order_no:
|
|
return True
|
|
|
|
# Intentionally do NOT deduplicate by amount/time similarity.
|
|
# Those records should enter the review stage for human confirmation.
|
|
return False
|