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:
@@ -27,7 +27,7 @@ async def scan_and_validate():
|
||||
# Build SKU context from skipped orders and track missing SKUs
|
||||
sku_context = {} # sku -> {order_numbers: [], customers: []}
|
||||
for order, missing_list in skipped:
|
||||
customer = order.billing.company_name or f"{order.billing.firstname} {order.billing.lastname}"
|
||||
customer = order.billing.company_name or f"{order.billing.lastname} {order.billing.firstname}"
|
||||
for sku in missing_list:
|
||||
if sku not in sku_context:
|
||||
sku_context[sku] = {"order_numbers": [], "customers": []}
|
||||
@@ -86,7 +86,7 @@ async def scan_and_validate():
|
||||
"skipped_orders": [
|
||||
{
|
||||
"number": order.number,
|
||||
"customer": order.billing.company_name or f"{order.billing.firstname} {order.billing.lastname}",
|
||||
"customer": order.billing.company_name or f"{order.billing.lastname} {order.billing.firstname}",
|
||||
"items_count": len(order.items),
|
||||
"missing_skus": missing
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user