fix(partners): prevent duplicate PF partners on firstname/lastname swap
Customers often swap firstname/lastname in GoMag forms, causing duplicate partner creation in Oracle. Fix with two layers: - Python: sort PF name words alphabetically before Oracle lookup - PL/SQL: add Step 2b permutation search (2-3 word names, PF only) - Normalize name order to lastname+firstname across all Python files - Add diagnostic SQL for finding existing reversed-name duplicates - Add Oracle integration test for reverse-name matching Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -244,14 +244,16 @@ def import_single_order(order, id_pol: int = None, id_sectie: int = None, app_se
|
||||
is_pj = 1
|
||||
else:
|
||||
# Use shipping person for partner name (person on shipping label)
|
||||
# Sort words alphabetically to normalize firstname/lastname swap
|
||||
if order.shipping and (order.shipping.lastname or order.shipping.firstname):
|
||||
denumire = clean_web_text(
|
||||
raw_name = clean_web_text(
|
||||
f"{order.shipping.lastname} {order.shipping.firstname}"
|
||||
).upper()
|
||||
else:
|
||||
denumire = clean_web_text(
|
||||
raw_name = clean_web_text(
|
||||
f"{order.billing.lastname} {order.billing.firstname}"
|
||||
).upper()
|
||||
denumire = " ".join(sorted(raw_name.split()))
|
||||
cod_fiscal = None
|
||||
registru = None
|
||||
is_pj = 0
|
||||
|
||||
Reference in New Issue
Block a user