fix(address): smart parser splits numar into bloc/scara/apart/etaj (ORA-12899)

Addresses with commas after street (e.g. "Str.Dacia NR.15 BLOC Z2,SCARA A,AP.7")
caused NUMAR column overflow (max 10 chars). Parser now tokenizes by comma and
routes BL/SC/AP/ET/NR prefixes to proper columns. Also extracts NR/BLOC embedded
in street text. Import service now blocks orders when address creation fails
(returns ERROR instead of silently importing without address).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Claude Agent
2026-04-01 09:19:47 +00:00
parent 115666155b
commit e478c35ecd
3 changed files with 170 additions and 49 deletions

View File

@@ -307,6 +307,16 @@ def import_single_order(order, id_pol: int = None, id_sectie: int = None, app_se
])
addr_livr_id = id_adresa_livr.getvalue()
if addr_livr_id is None:
cur.execute("SELECT PACK_IMPORT_PARTENERI.get_last_error FROM dual")
plsql_err = cur.fetchone()[0]
err_msg = f"Shipping address creation failed for partner {partner_id}"
if plsql_err:
err_msg += f": {plsql_err}"
logger.error(f"Order {order_number}: {err_msg}")
result["error"] = err_msg
return result
# Step 3: Process billing address
if different_person:
# Different person: use shipping address for BOTH billing and shipping in ROA
@@ -325,6 +335,16 @@ def import_single_order(order, id_pol: int = None, id_sectie: int = None, app_se
])
addr_fact_id = id_adresa_fact.getvalue()
if addr_fact_id is None:
cur.execute("SELECT PACK_IMPORT_PARTENERI.get_last_error FROM dual")
plsql_err = cur.fetchone()[0]
err_msg = f"Billing address creation failed for partner {partner_id}"
if plsql_err:
err_msg += f": {plsql_err}"
logger.error(f"Order {order_number}: {err_msg}")
result["error"] = err_msg
return result
if addr_fact_id is not None:
result["id_adresa_facturare"] = int(addr_fact_id)
if addr_livr_id is not None: