refactor(anaf): remove dead code in sanitize_cui, fix empty test

Remove unreachable OCR-skip fallback (raw_bare can't be all-digits
if strip_ro_prefix changed it via OCR fix). Add real test for the
checksum result==10→0 branch using CUI 14186770.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Claude Agent
2026-04-02 14:46:10 +00:00
parent 1d871c8215
commit 0992744490
2 changed files with 8 additions and 15 deletions

View File

@@ -43,7 +43,6 @@ def validate_cui_checksum(bare_cui: str) -> bool:
digits = [int(d) for d in bare_cui]
check_digit = digits[-1]
body = digits[:-1]
# Pad left with zeros to 9 positions
padded = [0] * (9 - len(body)) + body
total = sum(d * k for d, k in zip(padded, _CUI_KEY))
result = (total * 10) % 11
@@ -66,11 +65,6 @@ def sanitize_cui(raw_cf: str) -> tuple[str, str | None]:
if validate_cui(bare) and validate_cui_checksum(bare):
return bare, None
# Try without OCR fix (raw, just stripped)
raw_bare = re.sub(r'^RO\s*', '', raw_cf.strip().upper())
if raw_bare != bare and validate_cui(raw_bare) and validate_cui_checksum(raw_bare):
return raw_bare, None
# Sanitized version passes format but not checksum
if validate_cui(bare):
return bare, f"CUI {bare} nu trece verificarea cifrei de control"