From 93af52574d86327e7c744ec8c3198666a94362f3 Mon Sep 17 00:00:00 2001 From: Maciej Pienczyn Date: Thu, 19 Mar 2026 21:19:19 +0100 Subject: [PATCH] fix(fees): stricter partial match to prevent false positives like AMA/ULTRAMARE Co-Authored-By: Claude Opus 4.6 (1M context) --- scripts/import_membership_fees.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/scripts/import_membership_fees.py b/scripts/import_membership_fees.py index a583332..2d05883 100644 --- a/scripts/import_membership_fees.py +++ b/scripts/import_membership_fees.py @@ -252,11 +252,16 @@ def import_fees(excel_path, target_year=None, all_years=False, dry_run=False): else: company = company_map.get(rec['name'].upper()) if not company: - # Try partial match + # Try partial match — but only if Excel name is a prefix/suffix of DB name + # (avoid "AMA" matching "ULTRAMARE") + excel_upper = rec['name'].upper().strip() for key, c in company_map.items(): - if rec['name'].upper() in key or key in rec['name'].upper(): - company = c - break + # Excel name starts with DB name or DB name starts with Excel name + # Minimum 4 chars to avoid false positives + if len(excel_upper) >= 4 and len(key) >= 4: + if key.startswith(excel_upper) or excel_upper.startswith(key): + company = c + break if not company: unmatched.append(f"{rec['name']} ({year})")