fix(import): 3 production bugs — items cache, CUI lookup, ANAF name
Some checks failed
Tests / fast-tests (push) Has been cancelled
Tests / full-tests (push) Has been cancelled

1. SQLite order_items overwrite on re-import (VELA CAFE #484669620):
   add_order_items, save_orders_batch, mark_order_deleted_in_roa now use
   DELETE + INSERT so GoMag quantity changes propagate to dashboard.

2. PL/SQL strict CUI lookup tolerates whitespace (FG COFFE #485065210):
   cauta_partener_dupa_cod_fiscal regex ^RO\d → ^RO\s*\d; IN-set uses
   canonical v_ro_cui. Platitor/neplatitor business rule preserved.
   Python defensive: re.sub whitespace collapse in determine_partner_data.

3. New PJ partners use ANAF official denumire (denumire_override) instead
   of GoMag company_name. Existing partners (found by CUI) untouched.

Tests: 18 new (5 SQLite unit, 8 Python unit, 5 Oracle PL/SQL). All green
locally: 228 unit + 26 oracle + 33 e2e.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Claude Agent
2026-04-16 14:32:59 +00:00
parent 5397bec35d
commit 3bcb26b0bd
8 changed files with 685 additions and 13 deletions

View File

@@ -14,6 +14,10 @@ CREATE OR REPLACE PACKAGE PACK_IMPORT_PARTENERI AS
-- 07.04.2026 - fix localitate necunoscuta: SOUNDEX fuzzy match (TIER L2) + pastreaza judetul in L3
-- 08.04.2026 - fix parser: inserare virgule in strada inainte de comma-split (sc/ap/et nu se extrageau fara virgula)
-- 15.04.2026 - fix cauta_partener_dupa_denumire: exclude sters=1, prioritizeaza inactiv=0 (bug GoMag #484668145)
-- 16.04.2026 - fix cauta_partener_dupa_cod_fiscal strict mode: regex detectie RO tolereaza spatiu (^RO\s*\d),
-- IN-set foloseste v_ro_cui (canonic) in loc de v_cod_fiscal_curat. Regula business platitor/
-- neplatitor pastrata. Bug anterior: input "RO 34963277" cadea pe branch neplatitor, rata partener
-- existent "RO34963277" → duplicat FG COFFE #485065210.
-- ====================================================================
-- CONSTANTS
@@ -275,13 +279,16 @@ CREATE OR REPLACE PACKAGE BODY PACK_IMPORT_PARTENERI AS
BEGIN
IF p_strict_search = 1 THEN
-- Cautare STRICT: doar forma primita + varianta cu spatiu
IF REGEXP_LIKE(v_cod_fiscal_curat, '^RO\d') THEN
-- Input "RO123" → cauta si "RO 123"
-- Cautare STRICT: regula business ANAF platitor/neplatitor TVA
-- Platitor (prefix RO) → cauta doar RO<bare> si RO <bare> (cu spatiu)
-- Neplatitor (fara RO) → cauta doar <bare>
-- Nu cross-match intre platitor si neplatitor (entitati fiscal distincte).
IF REGEXP_LIKE(v_cod_fiscal_curat, '^RO\s*\d') THEN
-- Input "RO123" sau "RO 123" (platitor TVA) → cauta RO<bare> si RO <bare>
SELECT id_part INTO v_id_part FROM (
SELECT id_part
FROM nom_parteneri
WHERE UPPER(TRIM(cod_fiscal)) IN (v_cod_fiscal_curat, 'RO ' || v_bare_cui)
WHERE UPPER(TRIM(cod_fiscal)) IN (v_ro_cui, 'RO ' || v_bare_cui)
AND NVL(sters, 0) = 0
ORDER BY NVL(inactiv, 0) ASC, id_part DESC
) WHERE ROWNUM = 1;